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.DocumentModel;
30 import org.nuxeo.ecm.core.api.DocumentModelList;
31 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
36 * DocumentModelHandler is a base abstract Nuxeo document handler
37 * using Nuxeo Java Remote APIs for CollectionSpace services
39 * $LastChangedRevision: $
42 public abstract class DocumentModelHandler<T, TL>
43 extends AbstractDocumentHandler<T, TL, DocumentModel, DocumentModelList> {
45 private final Logger logger = LoggerFactory.getLogger(DocumentModelHandler.class);
46 private RepositoryInstance repositorySession;
47 //key=schema, value=documentpart
50 * getRepositorySession returns Nuxeo Repository Session
53 public RepositoryInstance getRepositorySession() {
54 return repositorySession;
58 * setRepositorySession sets repository session
61 public void setRepositorySession(RepositoryInstance repoSession) {
62 this.repositorySession = repoSession;
66 public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
67 fillAllParts(wrapDoc);
71 public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
72 fillAllParts(wrapDoc);
76 public void handleGet(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
77 extractAllParts(wrapDoc);
81 public void handleGetAll(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
82 setCommonPartList(extractCommonPartList(wrapDoc));
86 public abstract void completeUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
89 public abstract void extractAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
92 public abstract T extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
95 public abstract void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
98 public abstract void fillCommonPart(T obj, DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
101 public abstract TL extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception;
104 public abstract T getCommonPart();
107 public abstract void setCommonPart(T obj);
110 public abstract TL getCommonPartList();
113 public abstract void setCommonPartList(TL obj);
116 * Gets the document type.
118 * @return the document type
120 public abstract String getDocumentType();