From: Aron Roberts Date: Wed, 9 Jan 2013 23:39:10 +0000 (-0800) Subject: CSPACE-5728: Initial steps toward supporting list-mode invocation of the batch job... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=7217c927b40f4b35c5d2cbcfcc2ac7e8d99e1605;p=tmp%2Fjakarta-migration.git CSPACE-5728: Initial steps toward supporting list-mode invocation of the batch job to update computedCurrentLocation values. List CSIDs aren't currently appearing in the invocation context; to be investigated. --- diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-list.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-list.xml new file mode 100644 index 000000000..0d36993fe --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-list.xml @@ -0,0 +1,21 @@ + + + list + CollectionObject + + + + ${collectionObject1CSID} + ${collectionObject2CSID} + + + + some key + some value + + + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-single.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-single.xml index a4a1d6af5..755f5917d 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-single.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-single.xml @@ -5,6 +5,9 @@ single CollectionObject ${collectionObjectCSID} + + + 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 84088950e..43747c2cd 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 @@ -7,7 +7,7 @@ - + @@ -103,7 +103,7 @@ - + POST /cspace-services/batch/${createBatchRecord.CSID} batch/batch-invoke-updateobjloc-single.xml @@ -190,5 +190,145 @@ + + + + POST + /cspace-services/batch + batch/updateobjloc.xml + 201 + + + + POST + /cspace-services/collectionobjects + batch/collObj1.xml + 201 + + + + POST + /cspace-services/collectionobjects + batch/collObj1.xml + 201 + + + + POST + /cspace-services/movements + batch/movement.xml + + location-1 + 1900-01-01 + + 201 + + + + POST + /cspace-services/movements + batch/movement.xml + + location-2 + 2000-01-01 + + 201 + + + + POST + /cspace-services/movements + batch/movement.xml + + location-3 + 1800-01-01 + + 201 + + + + POST + /cspace-services/relations + batch/relation.xml + + ${createCollectionObject1.CSID} + CollectionObject + ${createMovement1.CSID} + Movement + + 201 + + + + POST + /cspace-services/relations + batch/relation.xml + + ${createCollectionObject1.CSID} + CollectionObject + ${createMovement2.CSID} + Movement + + 201 + + + + POST + /cspace-services/relations + batch/relation.xml + + ${createCollectionObject2.CSID} + CollectionObject + ${createMovement3.CSID} + Movement + + 201 + + + + POST + /cspace-services/batch/${createBatchRecord.CSID} + batch/batch-invoke-updateobjloc-list.xml + + ${createCollectionObject1.CSID} + ${createCollectionObject2.CSID} + + 200 + + + + + + GET + /cspace-services/collectionobjects/${createCollectionObject1.CSID} + batch/updateobjloc.xml + + + batch/res/collectionobject.res.xml + + ${createMovement2.currentLocation} + + + 200 + + + + + + GET + /cspace-services/collectionobjects/${createCollectionObject2.CSID} + batch/updateobjloc.xml + + + batch/res/collectionobject.res.xml + + ${createMovement3.currentLocation} + + + 200 + + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/updateobjloc.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/updateobjloc.xml index c83b22db1..1129a2a77 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/updateobjloc.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/updateobjloc.xml @@ -8,7 +8,7 @@ CollectionObject true - false + true false org.collectionspace.services.batch.nuxeo.UpdateObjectLocationBatchJob diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/AbstractBatchInvocable.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/AbstractBatchInvocable.java index 1dc9f5001..02c5ddb2a 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/AbstractBatchInvocable.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/AbstractBatchInvocable.java @@ -53,6 +53,38 @@ 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 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 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 getSupportedInvocationModes() { return invocationModes; 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 455f4ffae..cf9cbf427 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 @@ -19,6 +19,7 @@ import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.ResourceBase; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.api.Tools; +import org.collectionspace.services.common.invocable.InvocationContext; import org.collectionspace.services.common.invocable.InvocationResults; import org.collectionspace.services.jaxb.AbstractCommonList; import org.dom4j.DocumentException; @@ -62,10 +63,8 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { setCompletionStatus(STATUS_MIN_PROGRESS); try { - if (logger.isTraceEnabled()) { - logger.trace("Invoking " + CLASSNAME + " ..."); - logger.trace("Invocation context is: " + getInvocationContext().getMode()); - } + + logInvocationContext(); List csids = new ArrayList(); if (requestIsForInvocationModeSingle()) { @@ -74,7 +73,11 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { csids.add(singleCsid); } } else if (requestIsForInvocationModeList()) { - List listCsids = (getInvocationContext().getListCSIDs().getCsid()); + InvocationContext.ListCSIDs invListCsids = getInvocationContext().getListCSIDs(); + if (invListCsids == null) { + throw new Exception(CSID_VALUES_NOT_PROVIDED_IN_INVOCATION_CONTEXT); + } + List listCsids = invListCsids.getCsid(); if (listCsids == null || listCsids.isEmpty()) { throw new Exception(CSID_VALUES_NOT_PROVIDED_IN_INVOCATION_CONTEXT); } @@ -296,4 +299,5 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { getResults().setNumAffected(numAffected); return getResults(); } + }