]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
ec5cec310ce14507613771a2423882eb87c714d7
[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.repository.RepositoryInstance;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32
33 /**
34  * DocumentModelHandler is a base abstract Nuxeo document handler
35  * using Nuxeo Java Remote APIs for CollectionSpace services
36  *
37  * $LastChangedRevision: $
38  * $LastChangedDate: $
39  */
40 public abstract class DocumentModelHandler<T, TL>
41         extends AbstractDocumentHandler<T, TL> {
42
43     private final Logger logger = LoggerFactory.getLogger(DocumentModelHandler.class);
44     private RepositoryInstance repositorySession;
45     //key=schema, value=documentpart
46
47     /**
48      * getRepositorySession returns Nuxeo Repository Session
49      * @return
50      */
51     public RepositoryInstance getRepositorySession() {
52         return repositorySession;
53     }
54
55     /**
56      * setRepositorySession sets repository session
57      * @param repoSession
58      */
59     public void setRepositorySession(RepositoryInstance repoSession) {
60         this.repositorySession = repoSession;
61     }
62
63     @Override
64     public void handleCreate(DocumentWrapper wrapDoc) throws Exception {
65         fillAllParts(wrapDoc);
66     }
67
68     @Override
69     public void handleUpdate(DocumentWrapper wrapDoc) throws Exception {
70         fillAllParts(wrapDoc);
71     }
72
73     @Override
74     public void handleGet(DocumentWrapper wrapDoc) throws Exception {
75         extractAllParts(wrapDoc);
76     }
77
78     @Override
79     public void handleGetAll(DocumentWrapper wrapDoc) throws Exception {
80         setCommonPartList(extractCommonPartList(wrapDoc));
81     }
82
83     @Override
84     public abstract void completeUpdate(DocumentWrapper wrapDoc) throws Exception;
85
86     @Override
87     public abstract void extractAllParts(DocumentWrapper wrapDoc) throws Exception;
88
89     @Override
90     public abstract T extractCommonPart(DocumentWrapper wrapDoc) throws Exception;
91
92     @Override
93     public abstract void fillAllParts(DocumentWrapper wrapDoc) throws Exception;
94
95     @Override
96     public abstract void fillCommonPart(T obj, DocumentWrapper wrapDoc) throws Exception;
97
98     @Override
99     public abstract TL extractCommonPartList(DocumentWrapper wrapDoc) throws Exception;
100
101     @Override
102     public abstract T getCommonPart();
103
104     @Override
105     public abstract void setCommonPart(T obj);
106
107     @Override
108     public abstract TL getCommonPartList();
109
110     @Override
111     public abstract void setCommonPartList(TL obj);
112
113     /**
114      * Gets the document type.
115      *
116      * @return the document type
117      */
118     public abstract String getDocumentType();
119 }