]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
d929813aaac4553892fad761c56ecbb5ba9bd11f
[tmp/jakarta-migration.git] /
1 /**
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:
5
6  *  http://www.collectionspace.org
7  *  http://wiki.collectionspace.org
8
9  *  Copyright 2009 University of California at Berkeley
10
11  *  Licensed under the Educational Community License (ECL), Version 2.0.
12  *  You may not use this file except in compliance with this License.
13
14  *  You may obtain a copy of the ECL 2.0 License at
15
16  *  https://source.collectionspace.org/collection-space/LICENSE.txt
17
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.
23  */
24 package org.collectionspace.services.nuxeo.client.java;
25
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;
34
35 /**
36  * DocumentModelHandler is a base abstract Nuxeo document handler
37  * using Nuxeo Java Remote APIs for CollectionSpace services
38  *
39  * $LastChangedRevision: $
40  * $LastChangedDate: $
41  */
42 public abstract class DocumentModelHandler<T, TL>
43         extends AbstractDocumentHandler<T, TL, DocumentModel, DocumentModelList> {
44
45     private final Logger logger = LoggerFactory.getLogger(DocumentModelHandler.class);
46     private RepositoryInstance repositorySession;
47     //key=schema, value=documentpart
48
49     /**
50      * getRepositorySession returns Nuxeo Repository Session
51      * @return
52      */
53     public RepositoryInstance getRepositorySession() {
54         return repositorySession;
55     }
56
57     /**
58      * setRepositorySession sets repository session
59      * @param repoSession
60      */
61     public void setRepositorySession(RepositoryInstance repoSession) {
62         this.repositorySession = repoSession;
63     }
64
65     @Override
66     public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
67         fillAllParts(wrapDoc);
68     }
69
70     @Override
71     public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
72         fillAllParts(wrapDoc);
73     }
74
75     @Override
76     public void handleGet(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
77         extractAllParts(wrapDoc);
78     }
79
80     @Override
81     public void handleGetAll(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
82         setCommonPartList(extractCommonPartList(wrapDoc));
83     }
84
85     @Override
86     public abstract void completeUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
87
88     @Override
89     public abstract void extractAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
90
91     @Override
92     public abstract T extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
93
94     @Override
95     public abstract void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
96
97     @Override
98     public abstract void fillCommonPart(T obj, DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
99
100     @Override
101     public abstract TL extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception;
102
103     @Override
104     public abstract T getCommonPart();
105
106     @Override
107     public abstract void setCommonPart(T obj);
108
109     @Override
110     public abstract TL getCommonPartList();
111
112     @Override
113     public abstract void setCommonPartList(TL obj);
114
115     /**
116      * Gets the document type.
117      *
118      * @return the document type
119      */
120     public abstract String getDocumentType();
121 }