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.java;
26 import org.collectionspace.services.common.document.DocumentWrapper;
27 import org.collectionspace.services.common.document.AbstractDocumentHandler;
28 import org.collectionspace.services.nuxeo.client.*;
29 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
34 * DocumentModelHandler is a base abstract Nuxeo document handler
35 * using Nuxeo Java Remote APIs for CollectionSpace services
37 * $LastChangedRevision: $
40 public abstract class DocumentModelHandler<T, TL>
41 extends AbstractDocumentHandler<T, TL> {
43 private final Logger logger = LoggerFactory.getLogger(DocumentModelHandler.class);
44 private RepositoryInstance repositorySession;
45 //key=schema, value=documentpart
48 * getRepositorySession returns Nuxeo Repository Session
51 public RepositoryInstance getRepositorySession() {
52 return repositorySession;
56 * setRepositorySession sets repository session
59 public void setRepositorySession(RepositoryInstance repoSession) {
60 this.repositorySession = repoSession;
64 public void handleCreate(DocumentWrapper wrapDoc) throws Exception {
65 fillAllParts(wrapDoc);
69 public void handleUpdate(DocumentWrapper wrapDoc) throws Exception {
70 fillAllParts(wrapDoc);
74 public void handleGet(DocumentWrapper wrapDoc) throws Exception {
75 extractAllParts(wrapDoc);
79 public void handleGetAll(DocumentWrapper wrapDoc) throws Exception {
80 setCommonPartList(extractCommonPartList(wrapDoc));
84 public abstract void completeUpdate(DocumentWrapper wrapDoc) throws Exception;
87 public abstract void extractAllParts(DocumentWrapper wrapDoc) throws Exception;
90 public abstract T extractCommonPart(DocumentWrapper wrapDoc) throws Exception;
93 public abstract void fillAllParts(DocumentWrapper wrapDoc) throws Exception;
96 public abstract void fillCommonPart(T obj, DocumentWrapper wrapDoc) throws Exception;
99 public abstract TL extractCommonPartList(DocumentWrapper wrapDoc) throws Exception;
102 public abstract T getCommonPart();
105 public abstract void setCommonPart(T obj);
108 public abstract TL getCommonPartList();
111 public abstract void setCommonPartList(TL obj);
114 * Gets the document type.
116 * @return the document type
118 public abstract String getDocumentType();