]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
91828ea18844f835bec150e38be95ae35b2c666a
[tmp/jakarta-migration.git] /
1 /**
2  *  This document is a part of the source code and related artifacts
3  *  for CollectionSpace, an open source collections management system
4  *  for museums and related institutions:
5
6  *  http://www.collectionspace.org
7  *  http://wiki.collectionspace.org
8
9  *  Copyright 2009 University of California at Berkeley
10
11  *  Licensed under the Educational Community License (ECL), Version 2.0.
12  *  You may not use this file except in compliance with this License.
13
14  *  You may obtain a copy of the ECL 2.0 License at
15
16  *  https://source.collectionspace.org/collection-space/LICENSE.txt
17
18  *  Unless required by applicable law or agreed to in writing, software
19  *  distributed under the License is distributed on an "AS IS" BASIS,
20  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  *  See the License for the specific language governing permissions and
22  *  limitations under the License.
23  */
24 package org.collectionspace.services.nuxeo.client.rest;
25
26 import org.collectionspace.services.common.repository.DocumentHandler;
27 import org.collectionspace.services.common.repository.DocumentWrapper;
28 import org.collectionspace.services.common.repository.DocumentException;
29 import java.io.InputStream;
30 import java.util.ArrayList;
31 import java.util.HashMap;
32 import java.util.List;
33 import java.util.Map;
34 import org.collectionspace.services.nuxeo.client.*;
35 import org.dom4j.Document;
36
37 /**
38  * RepresentationHandler is a base abstract Nuxeo document handler
39  * using Nuxeo RESTful APIs for CollectionSpace services
40  *
41  * $LastChangedRevision: $
42  * $LastChangedDate: $
43  */
44 public abstract class RepresentationHandler<T, TL>
45         implements DocumentHandler<T, TL> {
46
47     private Map<String, Object> properties = new HashMap<String, Object>();
48     private List<String> pathParams = new ArrayList<String>();
49     private Map<String, String> queryParams = new HashMap<String, String>();
50     private Document document;
51     private InputStream inputStream = null;
52
53     @Override
54     public abstract void prepare(Action action) throws Exception;
55
56     @Override
57     public abstract void handle(Action action, DocumentWrapper wrapDoc) throws Exception;
58
59     @Override
60     public abstract T extractCommonObject(DocumentWrapper wrapDoc) throws Exception;
61
62     @Override
63     public abstract void fillCommonObject(T obj, DocumentWrapper wrapDoc) throws Exception;
64
65     @Override
66     public abstract TL extractCommonObjectList(DocumentWrapper wrapDoc) throws Exception;
67
68     @Override
69     public abstract void fillCommonObjectList(TL obj, DocumentWrapper wrapDoc) throws Exception;
70
71     @Override
72     public abstract T getCommonObject();
73
74     @Override
75     public abstract void setCommonObject(T obj);
76
77     @Override
78     public abstract TL getCommonObjectList();
79
80     @Override
81     public abstract void setCommonObjectList(TL obj);
82
83     @Override
84     public Document getDocument(DocumentWrapper wrapDoc) throws DocumentException {
85         throw new UnsupportedOperationException("DocumentHandler.getDocument(wrapDoc)");
86     }
87
88     /**
89      * @return the pathParams
90      */
91     public List<String> getPathParams() {
92         return pathParams;
93     }
94
95     /**
96      * @param pathParams the pathParams to set
97      */
98     public void setPathParams(List<String> pathParams) {
99         this.pathParams = pathParams;
100     }
101
102     /**
103      * @return the queryParams
104      */
105     public Map<String, String> getQueryParams() {
106         return queryParams;
107     }
108
109     /**
110      * @param queryParams the queryParams to set
111      */
112     public void setQueryParams(Map<String, String> queryParams) {
113         this.queryParams = queryParams;
114     }
115
116     /**
117      * getInputStream to retrieve input stream by client for posting a document
118      * @return the inputStream
119      */
120     public InputStream getInputStream() {
121         return inputStream;
122     }
123
124     /**
125      * setInputStream to set input stream to read for posting document
126      * @param inputStream the inputStream to set
127      */
128     public void setInputStream(InputStream inputStream) {
129         this.inputStream = inputStream;
130     }
131
132     /**
133      * @return the document
134      */
135     public Document getDocument() {
136         return document;
137     }
138
139     /**
140      * @param document the document to set
141      */
142     public void setDocument(Document document) {
143         this.document = document;
144     }
145
146     /**
147      * @return the properties
148      */
149     @Override
150     public Map<String, Object> getProperties() {
151         return properties;
152     }
153
154     /**
155      * @param properties the properties to set
156      */
157     @Override
158     public void setProperties(Map<String, Object> properties) {
159         this.properties = properties;
160     }
161 }