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:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright 2009 University of California at Berkeley
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
16 * https://source.collectionspace.org/collection-space/LICENSE.txt
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.
24 package org.collectionspace.services.nuxeo.client.rest;
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;
34 import org.collectionspace.services.nuxeo.client.*;
35 import org.dom4j.Document;
38 * RepresentationHandler is a base abstract Nuxeo document handler
39 * using Nuxeo RESTful APIs for CollectionSpace services
41 * $LastChangedRevision: $
44 public abstract class RepresentationHandler<T, TL>
45 implements DocumentHandler<T, TL> {
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;
54 public abstract void prepare(Action action) throws Exception;
57 public abstract void handle(Action action, DocumentWrapper wrapDoc) throws Exception;
60 public abstract T extractCommonObject(DocumentWrapper wrapDoc) throws Exception;
63 public abstract void fillCommonObject(T obj, DocumentWrapper wrapDoc) throws Exception;
66 public abstract TL extractCommonObjectList(DocumentWrapper wrapDoc) throws Exception;
69 public abstract void fillCommonObjectList(TL obj, DocumentWrapper wrapDoc) throws Exception;
72 public abstract T getCommonObject();
75 public abstract void setCommonObject(T obj);
78 public abstract TL getCommonObjectList();
81 public abstract void setCommonObjectList(TL obj);
84 public Document getDocument(DocumentWrapper wrapDoc) throws DocumentException {
85 throw new UnsupportedOperationException("DocumentHandler.getDocument(wrapDoc)");
89 * @return the pathParams
91 public List<String> getPathParams() {
96 * @param pathParams the pathParams to set
98 public void setPathParams(List<String> pathParams) {
99 this.pathParams = pathParams;
103 * @return the queryParams
105 public Map<String, String> getQueryParams() {
110 * @param queryParams the queryParams to set
112 public void setQueryParams(Map<String, String> queryParams) {
113 this.queryParams = queryParams;
117 * getInputStream to retrieve input stream by client for posting a document
118 * @return the inputStream
120 public InputStream getInputStream() {
125 * setInputStream to set input stream to read for posting document
126 * @param inputStream the inputStream to set
128 public void setInputStream(InputStream inputStream) {
129 this.inputStream = inputStream;
133 * @return the document
135 public Document getDocument() {
140 * @param document the document to set
142 public void setDocument(Document document) {
143 this.document = document;
147 * @return the properties
150 public Map<String, Object> getProperties() {
155 * @param properties the properties to set
158 public void setProperties(Map<String, Object> properties) {
159 this.properties = properties;