]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6937: Fixed what appears to have been a bug in how we handle soft-deletes...
authorremillet <remillet@yahoo.com>
Sat, 16 Apr 2016 01:24:42 +0000 (18:24 -0700)
committerremillet <remillet@yahoo.com>
Sat, 16 Apr 2016 01:24:42 +0000 (18:24 -0700)
services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java
services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java

index 7c2247f40c1567a8a0176a55c3e9a39a37f5abc8..6f5ccd4c2befcbb9a80a17e0b9023387bbb49e91 100644 (file)
@@ -134,9 +134,33 @@ public class RelationServiceTest extends AbstractPoxServiceTestImpl<RelationsCom
     
     @AfterSuite
     private void deletePersonRefs() {
-       //
-       // Delete all the persons we created for the tests
-       //
+        PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
+        for (String csid:personIdsCreated) {
+               Response res = personAuthClient.deleteItem(personAuthCSID, csid);
+               try {
+                       int statusCode = res.getStatus();
+               
+                       Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                               invalidStatusCodeMessage(testRequestType, statusCode));
+                       Assert.assertEquals(statusCode, this.STATUS_OK);
+               } finally {
+                       res.close();
+               }
+        }
+        //
+        // Now delete the container (the parent)
+        //
+        Response res = personAuthClient.delete(personAuthCSID);
+        try {
+               int statusCode = res.getStatus();
+       
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, this.STATUS_OK);
+        } finally {
+               res.close();
+        }
+        
     }
 
     private String createPerson(String firstName, String surName, String shortId, String authRefName) {
index b76e574b0843fd1b994aa59ace178e5ef602927f..98d94e5c6fa85818307f83391c9e5d62d1735470 100644 (file)
@@ -116,11 +116,10 @@ public class RelationDocumentModelHandler
         * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#handleWorkflowTransition(org.collectionspace.services.common.document.DocumentWrapper, org.collectionspace.services.lifecycle.TransitionDef)
         */
        public void handleWorkflowTransition(DocumentWrapper<DocumentModel> wrapDoc, TransitionDef transitionDef)
-                       throws Exception {
-               String workflowState = transitionDef.getDestinationState();
-               if (subjectOrObjectInWorkflowState(wrapDoc, workflowState) == true) {
+                       throws Exception {              
+               if (subjectOrObjectInWorkflowState(wrapDoc, WorkflowClient.WORKFLOWSTATE_LOCKED) == true) {
                throw new ServiceException(HttpURLConnection.HTTP_FORBIDDEN,
-                    "Cannot change a relationship if either end of it is in the workflow state: " + workflowState);
+                    "Cannot change a relationship if either end of it is in the workflow state: " + WorkflowClient.WORKFLOWSTATE_LOCKED);
                }
        }
 
@@ -132,7 +131,7 @@ public class RelationDocumentModelHandler
         // And take care of ensuring all the values for the relation info are correct 
         populateSubjectAndObjectValues(wrapDoc);
        
-        // both subject and object cannot be locked
+        // Neither the subject nor the object can be locked
        String workflowState = WorkflowClient.WORKFLOWSTATE_LOCKED;
        if (subjectOrObjectInWorkflowState(wrapDoc, workflowState) == true) {
                throw new ServiceException(HttpURLConnection.HTTP_FORBIDDEN,
@@ -152,7 +151,7 @@ public class RelationDocumentModelHandler
     @Override
     public void handleDelete(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
        String workflowState = WorkflowClient.WORKFLOWSTATE_LOCKED;
-       // both subject and object cannot be locked
+       // Neither the subject nor the object can be locked
        if (subjectOrObjectInWorkflowState(wrapDoc, workflowState) == false) {
                super.handleDelete(wrapDoc);
        } else {