From: Aron Roberts Date: Wed, 9 Jan 2013 20:20:03 +0000 (-0800) Subject: CSPACE-5728: First successful top-to-bottom run of the single CSID batch job to updat... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=4f8c80db55fad4e5fd01a8c39218e3ad02b95572;p=tmp%2Fjakarta-migration.git CSPACE-5728: First successful top-to-bottom run of the single CSID batch job to update computed current location. Uses JDOM, not dom4j, to get field value. XmlReplay test validation is also now more strict. --- diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-update-object-loc.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-update-object-loc.xml index 3b1fb8eaf..84088950e 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-update-object-loc.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-update-object-loc.xml @@ -37,7 +37,7 @@ - + @@ -122,7 +122,7 @@ /cspace-services/collectionobjects/${createCollectionObject.CSID} batch/updateobjloc.xml - + batch/res/collectionobject.res.xml ${createMovement2.currentLocation} @@ -134,7 +134,7 @@ - + @@ -179,7 +179,7 @@ /cspace-services/collectionobjects/${createCollectionObject.CSID} batch/updateobjloc.xml - + batch/res/collectionobject.res.xml ${createMovement4.currentLocation} diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java index a61f30f63..eed439135 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java @@ -156,9 +156,19 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { try { Document document = builder.build(new StringReader(payload.toXML())); Element root = document.getRootElement(); + // The part element is always expected to have an explicit namespace. Element part = root.getChild(partLabel, partNamespace); + // Try getting the field element both with and without a namespace. + // Even though a field element that lacks a namespace prefix + // may yet inherit its namespace from a parent, JDOM may require that + // the getChild() call be made without a namespace. Element field = part.getChild(fieldPath, partNamespace); - value = field.getText(); + if (field == null) { + field = part.getChild(fieldPath); + } + if (field != null) { + value = field.getText(); + } } catch (Exception e) { logger.error("Error getting value from field path " + fieldPath + " in schema part " + partLabel);