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.blob.nuxeo;
26 import java.util.Iterator;
27 import java.util.List;
29 import org.collectionspace.services.BlobJAXBSchema;
30 import org.collectionspace.services.common.document.DocumentWrapper;
31 import org.collectionspace.services.blob.BlobCommon;
32 import org.collectionspace.services.blob.BlobCommonList;
33 import org.collectionspace.services.blob.BlobCommonList.BlobListItem;
34 import org.collectionspace.services.jaxb.AbstractCommonList;
35 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
36 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
37 import org.nuxeo.ecm.core.api.DocumentModel;
38 import org.nuxeo.ecm.core.api.DocumentModelList;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
43 * The Class BlobDocumentModelHandler.
45 public class BlobDocumentModelHandler
46 extends RemoteDocumentModelHandlerImpl<BlobCommon, BlobCommonList> {
49 private final Logger logger = LoggerFactory.getLogger(BlobDocumentModelHandler.class);
52 private BlobCommon blob;
55 private BlobCommonList blobList;
59 * Gets the common part.
61 * @return the common part
64 public BlobCommon getCommonPart() {
69 * Sets the common part.
71 * @param blob the new common part
74 public void setCommonPart(BlobCommon blob) {
79 * Gets the common part list.
81 * @return the common part list
84 public BlobCommonList getCommonPartList() {
89 * Sets the common part list.
91 * @param blobList the new common part list
94 public void setCommonPartList(BlobCommonList blobList) {
95 this.blobList = blobList;
99 * Extract common part.
101 * @param wrapDoc the wrap doc
102 * @return the blob common
103 * @throws Exception the exception
106 public BlobCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
108 throw new UnsupportedOperationException();
114 * @param blobObject the blob object
115 * @param wrapDoc the wrap doc
116 * @throws Exception the exception
119 public void fillCommonPart(BlobCommon blobObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
120 throw new UnsupportedOperationException();
124 * Extract common part list.
126 * @param wrapDoc the wrap doc
127 * @return the blob common list
128 * @throws Exception the exception
131 public BlobCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
132 BlobCommonList coList = extractPagingInfo(new BlobCommonList(), wrapDoc);
133 AbstractCommonList commonList = (AbstractCommonList) coList;
134 //CSPACE-3209 don't use all fields. commonList.setFieldsReturned("currentOwner|depositor|exitDate|exitMethod|exitNote|exitNumber|exitReason|packingNote|uri|csid");
135 commonList.setFieldsReturned("exitNumber|currentOwner|uri|csid"); //CSPACE-3209 now do this
136 List<BlobCommonList.BlobListItem> list = coList.getBlobListItem();
137 Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
138 while(iter.hasNext()){
139 DocumentModel docModel = iter.next();
140 BlobListItem ilistItem = new BlobListItem();
142 String label = getServiceContext().getCommonPartLabel();
143 ilistItem.setExitNumber((String) docModel.getProperty(label, BlobJAXBSchema.OBJECT_EXIT_NUMBER));
144 //CSPACE-3209 ilistItem.setExitDate((String) docModel.getProperty(label, BlobJAXBSchema.OBJECT_EXIT_DATE));
145 ilistItem.setCurrentOwner((String) docModel.getProperty(label, BlobJAXBSchema.OBJECT_EXIT_CURRENT_OWNER)); //CSPACE-3209
146 String id = NuxeoUtils.extractId(docModel.getPathAsString());
147 ilistItem.setUri(getServiceContextPath() + id);
148 ilistItem.setCsid(id);
156 * Gets the q property.
158 * @param prop the prop
159 * @return the q property
162 public String getQProperty(String prop) {
163 return BlobConstants.NUXEO_SCHEMA_NAME + ":" + prop;