]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-3711, CSPACE-3706, CSPACE-3708, CSPACE-3496, CSPACE-3483: Workflow (soft-delet...
authorRichard Millet <richard.millet@berkeley.edu>
Mon, 28 Mar 2011 23:23:35 +0000 (23:23 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Mon, 28 Mar 2011 23:23:35 +0000 (23:23 +0000)
services/common/src/main/java/org/collectionspace/services/common/workflow/jaxb/WorkflowJAXBSchema.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/common/workflow/service/nuxeo/WorkflowDocumentModelHandler.java [new file with mode: 0644]

diff --git a/services/common/src/main/java/org/collectionspace/services/common/workflow/jaxb/WorkflowJAXBSchema.java b/services/common/src/main/java/org/collectionspace/services/common/workflow/jaxb/WorkflowJAXBSchema.java
new file mode 100644 (file)
index 0000000..6949a5e
--- /dev/null
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package org.collectionspace.services.common.workflow.jaxb;
+
+public interface WorkflowJAXBSchema {
+    final static String WORKFLOW_LIFECYCLEPOLICY = "lifeCyclePolicy";
+    final static String WORKFLOW_CURRENTLIFECYCLESTATE = "currentLifeCycleState";
+    final static String WORKFLOW_ALLOWEDSTATETRANSITIONS = "allowedStateTransitionList";
+}
diff --git a/services/common/src/main/java/org/collectionspace/services/common/workflow/service/nuxeo/WorkflowDocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/common/workflow/service/nuxeo/WorkflowDocumentModelHandler.java
new file mode 100644 (file)
index 0000000..dc622c4
--- /dev/null
@@ -0,0 +1,80 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.collectionspace.services.common.workflow.service.nuxeo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.core.MediaType;
+
+import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.service.ObjectPartType;
+import org.collectionspace.services.common.workflow.client.WorkflowClient;
+import org.collectionspace.services.common.workflow.jaxb.WorkflowJAXBSchema;
+import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
+import org.collectionspace.services.workflow.WorkflowsCommon;
+import org.nuxeo.ecm.core.api.DocumentModel;
+
+public class WorkflowDocumentModelHandler 
+       extends DocHandlerBase<WorkflowsCommon> {
+       
+       @Override
+    protected Map<String, Object> extractPart(DocumentModel docModel, 
+            String schema,
+            ObjectPartType partMeta,
+            Map<String, Object> addToMap)
+               throws Exception {
+        Map<String, Object> result = null;
+
+        MediaType mt = MediaType.valueOf(partMeta.getContent().getContentType()); //FIXME: REM - This is no longer needed.  Everything is POX
+        if (mt.equals(MediaType.APPLICATION_XML_TYPE)) {
+            Map<String, Object> unQObjectProperties =
+                    (addToMap != null) ? addToMap : (new HashMap<String, Object>());
+            unQObjectProperties.put(WorkflowJAXBSchema.WORKFLOW_LIFECYCLEPOLICY, docModel.getLifeCyclePolicy());
+            unQObjectProperties.put(WorkflowJAXBSchema.WORKFLOW_CURRENTLIFECYCLESTATE, docModel.getCurrentLifeCycleState());
+            result = unQObjectProperties;
+        } //TODO: handle other media types
+
+        return result;
+    }
+       
+    @Override
+    public void extractAllParts(DocumentWrapper<DocumentModel> wrapDoc)
+            throws Exception {
+
+        DocumentModel docModel = wrapDoc.getWrappedObject();
+        String[] schemas = {WorkflowClient.SERVICE_COMMONPART_NAME};
+        Map<String, ObjectPartType> partsMetaMap = getServiceContext().getPartsMetadata();
+        for (String schema : schemas) {
+            ObjectPartType partMeta = partsMetaMap.get(schema);
+            if (partMeta == null) {
+                continue; // unknown part, ignore
+            }
+            Map<String, Object> unQObjectProperties = extractPart(docModel, schema, partMeta);
+            addOutputPart(unQObjectProperties, schema, partMeta);
+        }
+    }
+       
+}
+