]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5728: Added single- and list-mode batch tests to XmlReplay master, at least...
authorAron Roberts <aron@socrates.berkeley.edu>
Thu, 10 Jan 2013 00:23:26 +0000 (16:23 -0800)
committerAron Roberts <aron@socrates.berkeley.edu>
Thu, 10 Jan 2013 00:23:26 +0000 (16:23 -0800)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-list.xml
services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-single.xml
services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml
services/batch/service/src/main/java/org/collectionspace/services/batch/AbstractBatchInvocable.java
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java

index 0d36993fe4f3d506ebaa3d355e5b1348eee13b76..4ca90476fe77d06e0e669b46205a4be300780370 100644 (file)
@@ -6,10 +6,10 @@
     <docType>CollectionObject</docType>\r
     <singleCSID></singleCSID>\r
     <groupCSID></groupCSID>\r
-    <listCsids>\r
+    <listCSIDs>\r
         <csid>${collectionObject1CSID}</csid>\r
         <csid>${collectionObject2CSID}</csid>\r
-    </listCsids>\r
+    </listCSIDs>\r
     <params>\r
         <param>\r
             <key>some key</key>\r
index 755f5917d4898d1f3ec90e30b3e569a8ab157b9b..beb1ccfa12fb3d1959bc24cf9399612ae9a67fb2 100644 (file)
@@ -6,7 +6,7 @@
     <docType>CollectionObject</docType>\r
     <singleCSID>${collectionObjectCSID}</singleCSID>\r
     <groupCSID></groupCSID>\r
-    <listCsids></listCsids>\r
+    <listCSIDs></listCSIDs>\r
     <params></params>\r
 </ns2:invocationContext>\r
 \r
index 6de5391ce54db01f5256c6fa8e5624814073207c..c0608a741210a58e9a3417eb4af64173f0a808b6 100644 (file)
     <run controlFile="collectionobject/collectionobject-displayname-update.xml" testGroup="DisplayNameChangesReflectedInRefNames" />\r
     \r
     <run controlFile="versioning/versioning.xml" testGroup="VersionedRecordFiltering" />\r
-\r
     \r
+    <run controlFile="batch/batch-update-object-loc.xml" testGroup="testBatchUpdateComputedCurrentLocationInvModeSingle" />\r
+    <run controlFile="batch/batch-update-object-loc.xml" testGroup="testBatchUpdateComputedCurrentLocationInvModeList" />\r
+\r
     <!-- Broken tests -->\r
     \r
     <!-- After most tests above were re-enabled in August 2012, the Batch test -->\r
index 02c5ddb2a869ace7bcae1c6bf43c08d16c537ff1..b2252572a8e790d13cf6f44361e3f51afa9b2672 100644 (file)
@@ -53,38 +53,6 @@ public abstract class AbstractBatchInvocable implements BatchInvocable {
         this.errorInfo = null;
     }
 
-    protected void logInvocationContext() {
-        if (logger.isInfoEnabled()) {
-            logger.info("Invocation mode=" + this.getInvocationContext().getMode());
-            logger.info("Invocation doc type=" + this.getInvocationContext().getDocType());
-            logger.info("Invocation single CSID=" + this.getInvocationContext().getSingleCSID());
-            logger.info("Invocation group CSID=" + this.getInvocationContext().getGroupCSID());
-            InvocationContext.ListCSIDs lcsids = this.getInvocationContext().getListCSIDs();
-            if (lcsids == null) {
-                logger.info("Invocation list CSIDs are null.");
-            } else {
-                List<String> csidsList = lcsids.getCsid();
-                if (csidsList != null) {
-                    for (String listcsid : csidsList) {
-                        logger.info("List CSID=" + listcsid);
-                    }
-                }
-            }
-            InvocationContext.Params params = this.getInvocationContext().getParams();
-            if (params == null) {
-                logger.info("Invocation list Params are null.");
-            } else {
-                List<InvocationContext.Params.Param> paramsList = params.getParam();
-                if (paramsList != null) {
-                    for (InvocationContext.Params.Param param : paramsList) {
-                        logger.info("Param key=" + param.getKey());
-                        logger.info("Param value=" + param.getValue());
-                    }
-                }
-            }
-        }
-    }
-
     @Override
     public List<String> getSupportedInvocationModes() {
         return invocationModes;
@@ -155,6 +123,36 @@ public abstract class AbstractBatchInvocable implements BatchInvocable {
         return (INVOCATION_MODE_NO_CONTEXT.equalsIgnoreCase(getInvocationContext().getMode()) ? true : false);
     }
 
+    protected List<String> getListCsids() {
+        List<String> emptyCsidsList = Collections.emptyList();
+        InvocationContext.ListCSIDs lcsids = getInvocationContext().getListCSIDs();
+        if (lcsids == null) {
+            return emptyCsidsList;
+        } else {
+            List<String> csidsList = lcsids.getCsid();
+            if (csidsList == null) {
+                return emptyCsidsList;
+            } else {
+                return csidsList;
+            }
+        }
+    }
+
+    protected List<InvocationContext.Params.Param> getParams() {
+        List<InvocationContext.Params.Param> emptyParamsList = Collections.emptyList();
+        InvocationContext.Params params = this.getInvocationContext().getParams();
+        if (params == null) {
+            return emptyParamsList;
+        } else {
+            List<InvocationContext.Params.Param> paramsList = params.getParam();
+            if (paramsList == null) {
+                return emptyParamsList;
+            } else {
+                return paramsList;
+            }
+        }
+    }
+
     protected void setErrorResult(String message) {
         setErrorResult(message, INT_ERROR_STATUS);
     }
index cf9cbf42764878fb77f13f158c3eea5a96e6da2b..737efe6be34ba21047ffb8b0f4ce49036a547c19 100644 (file)
@@ -64,32 +64,28 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
 
         try {
 
-            logInvocationContext();
-
             List<String> csids = new ArrayList<String>();
             if (requestIsForInvocationModeSingle()) {
                 String singleCsid = getInvocationContext().getSingleCSID();
-                if (Tools.notBlank(singleCsid)) {
+                if (Tools.isBlank(singleCsid)) {
+                    throw new Exception(CSID_VALUES_NOT_PROVIDED_IN_INVOCATION_CONTEXT);
+                } else {
                     csids.add(singleCsid);
                 }
             } else if (requestIsForInvocationModeList()) {
-                InvocationContext.ListCSIDs invListCsids = getInvocationContext().getListCSIDs();
-                if (invListCsids == null) {
-                    throw new Exception(CSID_VALUES_NOT_PROVIDED_IN_INVOCATION_CONTEXT);
-                }
-                List<String> listCsids = invListCsids.getCsid();
-                if (listCsids == null || listCsids.isEmpty()) {
+                List<String> listCsids = getListCsids();
+                if (listCsids.isEmpty()) {
                     throw new Exception(CSID_VALUES_NOT_PROVIDED_IN_INVOCATION_CONTEXT);
                 }
                 csids.addAll(listCsids);
             } else if (requestIsForInvocationModeGroup()) {
-                String groupCsid = getInvocationContext().getGroupCSID();
-                // FIXME: Get individual CSIDs from the group
-                // and add them to the list
-            }
-
-            if (csids.isEmpty()) {
-                throw new Exception(CSID_VALUES_NOT_PROVIDED_IN_INVOCATION_CONTEXT);
+                // Currently not supported
+                // FIXME: Get individual CSIDs, if any, from the group
+                // String groupCsid = getInvocationContext().getGroupCSID();
+                // ...
+            } else if (requestIsForInvocationModeNoContext()) {
+                // Currently not supported
+                // FIXME: Add code to invoke batch job on every active CollectionObject
             }
 
             // Update the computed current location field for each CollectionObject
@@ -299,5 +295,4 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
         getResults().setNumAffected(numAffected);
         return getResults();
     }
-
 }