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.context.ServiceContext;
27 import org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl;
28 import org.collectionspace.services.common.document.DocumentFilter;
29 import org.collectionspace.services.common.document.DocumentWrapper;
30 import org.collectionspace.services.nuxeo.client.*;
31 import org.nuxeo.ecm.core.api.DocumentModel;
32 import org.nuxeo.ecm.core.api.DocumentModelList;
33 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
38 * DocumentModelHandler is a base abstract Nuxeo document handler
39 * using Nuxeo Java Remote APIs for CollectionSpace services
41 * $LastChangedRevision: $
44 public abstract class DocumentModelHandler<T, TL>
45 extends AbstractMultipartDocumentHandlerImpl<T, TL, DocumentModel, DocumentModelList> {
47 private final Logger logger = LoggerFactory.getLogger(DocumentModelHandler.class);
48 private RepositoryInstance repositorySession;
49 //key=schema, value=documentpart
52 * getRepositorySession returns Nuxeo Repository Session
55 public RepositoryInstance getRepositorySession() {
56 return repositorySession;
60 * setRepositorySession sets repository session
63 public void setRepositorySession(RepositoryInstance repoSession) {
64 this.repositorySession = repoSession;
68 public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
69 fillAllParts(wrapDoc);
73 public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
74 fillAllParts(wrapDoc);
78 public void handleGet(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
79 extractAllParts(wrapDoc);
83 public void handleGetAll(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
84 setCommonPartList(extractCommonPartList(wrapDoc));
88 public abstract void completeUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
91 public abstract void extractAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
94 public abstract T extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
97 public abstract void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
100 public abstract void fillCommonPart(T obj, DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
103 public abstract TL extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception;
106 public abstract T getCommonPart();
109 public abstract void setCommonPart(T obj);
112 public abstract TL getCommonPartList();
115 public abstract void setCommonPartList(TL obj);
118 public DocumentFilter createDocumentFilter() {
119 DocumentFilter filter = new NuxeoDocumentFilter(this.getServiceContext());