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 java.util.List;
28 import org.collectionspace.services.common.authorityref.AuthorityRefList;
29 import org.collectionspace.services.common.context.ServiceContext;
30 import org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl;
31 import org.collectionspace.services.common.document.DocumentFilter;
32 import org.collectionspace.services.common.document.DocumentWrapper;
33 import org.collectionspace.services.nuxeo.client.*;
34 import org.nuxeo.ecm.core.api.DocumentModel;
35 import org.nuxeo.ecm.core.api.DocumentModelList;
36 import org.nuxeo.ecm.core.api.model.PropertyException;
37 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
42 * DocumentModelHandler is a base abstract Nuxeo document handler
43 * using Nuxeo Java Remote APIs for CollectionSpace services
45 * $LastChangedRevision: $
48 public abstract class DocumentModelHandler<T, TL>
49 extends AbstractMultipartDocumentHandlerImpl<T, TL, DocumentModel, DocumentModelList> {
51 private final Logger logger = LoggerFactory.getLogger(DocumentModelHandler.class);
52 private RepositoryInstance repositorySession;
53 //key=schema, value=documentpart
56 * getRepositorySession returns Nuxeo Repository Session
59 public RepositoryInstance getRepositorySession() {
60 return repositorySession;
64 * setRepositorySession sets repository session
67 public void setRepositorySession(RepositoryInstance repoSession) {
68 this.repositorySession = repoSession;
72 public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
73 fillAllParts(wrapDoc);
77 public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
78 fillAllParts(wrapDoc);
82 public void handleGet(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
83 extractAllParts(wrapDoc);
87 public void handleGetAll(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
88 setCommonPartList(extractCommonPartList(wrapDoc));
92 public abstract void completeUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
95 public abstract void extractAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
98 public abstract T extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
101 public abstract void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
104 public abstract void fillCommonPart(T obj, DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
107 public abstract TL extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception;
110 public abstract T getCommonPart();
113 public abstract void setCommonPart(T obj);
116 public abstract TL getCommonPartList();
119 public abstract void setCommonPartList(TL obj);
122 public DocumentFilter createDocumentFilter() {
123 DocumentFilter filter = new NuxeoDocumentFilter(this.getServiceContext());
128 * Gets the authority refs.
130 * @param docWrapper the doc wrapper
131 * @param authRefFields the auth ref fields
132 * @return the authority refs
133 * @throws PropertyException the property exception
135 abstract public AuthorityRefList getAuthorityRefs(
136 DocumentWrapper<DocumentModel> docWrapper,
137 List<String> authRefFields) throws PropertyException;