]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-176: Added checks to DELETE and UPDATE requests to prevent changes to locked...
authorremillet <remillet@yahoo.com>
Mon, 2 Oct 2017 21:28:07 +0000 (14:28 -0700)
committerremillet <remillet@yahoo.com>
Mon, 2 Oct 2017 21:28:07 +0000 (14:28 -0700)
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java

index 65e2ca771d9b6235aece2213654241af15c95287..8e09b2b2aba4e7360a6f3b9f23c496aaad21406c 100644 (file)
@@ -23,6 +23,7 @@
  */
 package org.collectionspace.services.nuxeo.client.java;
 
+import java.net.HttpURLConnection;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -53,6 +54,7 @@ import org.collectionspace.services.client.RelationClient;
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.NuxeoBasedResource;
+import org.collectionspace.services.common.ServiceException;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.common.config.ServiceConfigUtils;
 import org.collectionspace.services.common.context.JaxRsContext;
@@ -63,6 +65,7 @@ import org.collectionspace.services.common.document.BadRequestException;
 import org.collectionspace.services.common.document.DocumentException;
 import org.collectionspace.services.common.document.DocumentUtils;
 import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.document.DocumentHandler.Action;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.client.IRelationsManager;
 import org.collectionspace.services.common.relation.RelationResource;
@@ -215,6 +218,32 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
         }
     }
        
+    @Override
+    public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+        DocumentModel docModel = wrapDoc.getWrappedObject();
+       String workflowState = WorkflowClient.WORKFLOWSTATE_LOCKED;
+        
+       if (docModel.getCurrentLifeCycleState().contains(workflowState) == true) {
+               throw new ServiceException(HttpURLConnection.HTTP_FORBIDDEN,
+                    "Cannot UPDATE a resource/record if it is in the workflow state: " + workflowState);
+       } else {
+               super.handleUpdate(wrapDoc);
+       }
+    }
+    
+    @Override
+    public boolean handleDelete(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+        DocumentModel docModel = wrapDoc.getWrappedObject();
+       String workflowState = WorkflowClient.WORKFLOWSTATE_LOCKED;
+        
+       if (docModel.getCurrentLifeCycleState().contains(workflowState) == true) {
+               throw new ServiceException(HttpURLConnection.HTTP_FORBIDDEN,
+                    "Cannot DELETE a resource/record if it is in the workflow state: " + workflowState);
+       } else {
+               return super.handleDelete(wrapDoc);
+       }
+    }    
+    
     /* NOTE: The authority item doc handler overrides (after calling) this method.  It performs refName updates.  In this
      * method we just update any and all relationship records that use refNames that have changed.
      * (non-Javadoc)