]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
f910a13a1e52ea050857c95d21bedb60e3b7397c
[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.common.vocabulary.nuxeo;
25
26 import java.util.Map;
27
28 import org.collectionspace.services.common.document.DocumentWrapper;
29 import org.collectionspace.services.common.service.ObjectPartType;
30
31 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
32 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
33 import org.nuxeo.ecm.core.api.DocumentModel;
34
35 /**
36  * AuthorityDocumentModelHandler
37  *
38  * $LastChangedRevision: $
39  * $LastChangedDate: $
40  */
41 public abstract class AuthorityDocumentModelHandler<AuthCommon, AuthCommonList>
42         extends RemoteDocumentModelHandlerImpl<AuthCommon, AuthCommonList> {
43
44         private String authorityCommonSchemaName;
45         
46     /**
47      * authority is used to stash JAXB object to use when handle is called
48      * for Action.CREATE, Action.UPDATE or Action.GET
49      */
50     private AuthCommon authority;
51     /**
52      * authorityList is stashed when handle is called
53      * for ACTION.GET_ALL
54      */
55     private AuthCommonList authorityList;
56
57
58     public AuthorityDocumentModelHandler(String authorityCommonSchemaName) {
59         this.authorityCommonSchemaName = authorityCommonSchemaName;
60     }
61
62     /**
63      * getCommonPart get associated authority
64      * @return
65      */
66     @Override
67     public AuthCommon getCommonPart() {
68         return authority;
69     }
70
71     /**
72      * setCommonPart set associated authority
73      * @param authority
74      */
75     @Override
76     public void setCommonPart(AuthCommon authority) {
77         this.authority = authority;
78     }
79
80     /**
81      * getCommonPartList get associated authority (for index/GET_ALL)
82      * @return
83      */
84     @Override
85     public AuthCommonList getCommonPartList() {
86         return authorityList;
87     }
88
89     /* (non-Javadoc)
90      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
91      */
92     @Override
93     public void setCommonPartList(AuthCommonList authorityList) {
94         this.authorityList = authorityList;
95     }
96
97     /* (non-Javadoc)
98      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
99      */
100     @Override
101     public AuthCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
102             throws Exception {
103         throw new UnsupportedOperationException();
104     }
105
106     /* (non-Javadoc)
107      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper)
108      */
109     @Override
110     public void fillCommonPart(AuthCommon vocabularyObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
111         throw new UnsupportedOperationException();
112     }
113
114     /* (non-Javadoc)
115      * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#extractPart(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, org.collectionspace.services.common.service.ObjectPartType)
116      */
117     @Override
118     protected Map<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)
119             throws Exception {
120         Map<String, Object> unQObjectProperties = super.extractPart(docModel, schema, partMeta);
121         
122         // Add the CSID to the common part
123         if (partMeta.getLabel().equalsIgnoreCase(authorityCommonSchemaName)) {
124                 String csid = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
125                 unQObjectProperties.put("csid", csid);
126         }
127         
128         return unQObjectProperties;
129     }
130     
131 }
132