]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6115: Apply PAHMA-895 changes to the UpdateObjectLocationBatchJob.
authorAron Roberts <aron@socrates.berkeley.edu>
Wed, 31 Jul 2013 00:57:22 +0000 (17:57 -0700)
committerAron Roberts <aron@socrates.berkeley.edu>
Wed, 31 Jul 2013 00:57:22 +0000 (17:57 -0700)
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java

index 6abcbccabee5be54dd3cf52bfb294cfc4b141048..36ef17097ffcad8c017a08f19ca42d781bcd0aee 100644 (file)
@@ -280,10 +280,10 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
         previousComputedCurrentLocation = getFieldElementValue(collectionObjectPayload,
                 COLLECTIONOBJECTS_COMMON_SCHEMA_NAME, COLLECTIONOBJECTS_COMMON_NAMESPACE,
                 COMPUTED_CURRENT_LOCATION_ELEMENT_NAME);
-        if (Tools.notBlank(previousComputedCurrentLocation)
-                && computedCurrentLocation.equals(previousComputedCurrentLocation)) {
+        if (!shouldUpdateLocation(previousComputedCurrentLocation, computedCurrentLocation)) {
             return numUpdated;
         }
+    
         // Perform the update only if there is a non-blank object number available.
         //
         // In the default CollectionObject validation handler, the object number
@@ -303,6 +303,12 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
             return numUpdated;
         }
 
+        // Update the location.
+        // (Updated location values can legitimately be blank, to 'null out' existing locations.)  
+        if (computedCurrentLocation == null) {
+            computedCurrentLocation = "";
+        }
+
         String collectionObjectUpdatePayload =
                 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                 + "<document name=\"collectionobject\">"
@@ -325,6 +331,16 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
         }
         return numUpdated;
     }
+    
+    protected boolean shouldUpdateLocation(String previousLocation, String currentLocation) {
+        boolean shouldUpdate = true;
+        if (Tools.isBlank(previousLocation) && Tools.isBlank(currentLocation)) {
+            shouldUpdate = false;
+        } else if (Tools.notBlank(previousLocation) && previousLocation.equals(currentLocation)) {
+            shouldUpdate = false;
+        }
+        return shouldUpdate;
+    }
 
     // #################################################################
     // Ray Lee's convenience methods from his AbstractBatchJob class for the