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.workflow.service.nuxeo;
26 import java.util.HashMap;
29 import javax.ws.rs.core.MediaType;
31 import org.collectionspace.services.common.document.DocumentWrapper;
32 import org.collectionspace.services.common.service.ObjectPartType;
33 import org.collectionspace.services.common.workflow.client.WorkflowClient;
34 import org.collectionspace.services.common.workflow.jaxb.WorkflowJAXBSchema;
35 import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
36 import org.collectionspace.services.workflow.WorkflowsCommon;
37 import org.nuxeo.ecm.core.api.DocumentModel;
39 public class WorkflowDocumentModelHandler
40 extends DocHandlerBase<WorkflowsCommon> {
43 protected Map<String, Object> extractPart(DocumentModel docModel,
45 ObjectPartType partMeta,
46 Map<String, Object> addToMap)
48 Map<String, Object> result = null;
50 MediaType mt = MediaType.valueOf(partMeta.getContent().getContentType()); //FIXME: REM - This is no longer needed. Everything is POX
51 if (mt.equals(MediaType.APPLICATION_XML_TYPE)) {
52 Map<String, Object> unQObjectProperties =
53 (addToMap != null) ? addToMap : (new HashMap<String, Object>());
54 unQObjectProperties.put(WorkflowJAXBSchema.WORKFLOW_LIFECYCLEPOLICY, docModel.getLifeCyclePolicy());
55 unQObjectProperties.put(WorkflowJAXBSchema.WORKFLOW_CURRENTLIFECYCLESTATE, docModel.getCurrentLifeCycleState());
56 result = unQObjectProperties;
57 } //TODO: handle other media types
63 public void extractAllParts(DocumentWrapper<DocumentModel> wrapDoc)
66 DocumentModel docModel = wrapDoc.getWrappedObject();
67 String[] schemas = {WorkflowClient.SERVICE_COMMONPART_NAME};
68 Map<String, ObjectPartType> partsMetaMap = getServiceContext().getPartsMetadata();
69 for (String schema : schemas) {
70 ObjectPartType partMeta = partsMetaMap.get(schema);
71 if (partMeta == null) {
72 continue; // unknown part, ignore
74 Map<String, Object> unQObjectProperties = extractPart(docModel, schema, partMeta);
75 addOutputPart(unQObjectProperties, schema, partMeta);