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.common.vocabulary.nuxeo;
28 import org.collectionspace.services.common.document.DocumentWrapper;
29 import org.collectionspace.services.common.service.ObjectPartType;
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;
36 * AuthorityDocumentModelHandler
38 * $LastChangedRevision: $
41 public abstract class AuthorityDocumentModelHandler<AuthCommon, AuthCommonList>
42 extends RemoteDocumentModelHandlerImpl<AuthCommon, AuthCommonList> {
44 private String authorityCommonSchemaName;
47 * authority is used to stash JAXB object to use when handle is called
48 * for Action.CREATE, Action.UPDATE or Action.GET
50 private AuthCommon authority;
52 * authorityList is stashed when handle is called
55 private AuthCommonList authorityList;
58 public AuthorityDocumentModelHandler(String authorityCommonSchemaName) {
59 this.authorityCommonSchemaName = authorityCommonSchemaName;
63 * getCommonPart get associated authority
67 public AuthCommon getCommonPart() {
72 * setCommonPart set associated authority
76 public void setCommonPart(AuthCommon authority) {
77 this.authority = authority;
81 * getCommonPartList get associated authority (for index/GET_ALL)
85 public AuthCommonList getCommonPartList() {
90 * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
93 public void setCommonPartList(AuthCommonList authorityList) {
94 this.authorityList = authorityList;
98 * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
101 public AuthCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
103 throw new UnsupportedOperationException();
107 * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper)
110 public void fillCommonPart(AuthCommon vocabularyObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
111 throw new UnsupportedOperationException();
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)
118 protected Map<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)
120 Map<String, Object> unQObjectProperties = super.extractPart(docModel, schema, partMeta);
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);
128 return unQObjectProperties;