From: Aron Roberts Date: Sat, 15 Feb 2014 01:23:21 +0000 (-0800) Subject: CSPACE-6307: Use updatedAt, rather than createdAt, as tiebreaker when identifying... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=e056633bc434222808e5deb93cbe4005cfa338dc;p=tmp%2Fjakarta-migration.git CSPACE-6307: Use updatedAt, rather than createdAt, as tiebreaker when identifying the latest L/M/I record for maintaining the computed current location value in Cataloging records. --- diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/AbstractUpdateObjectLocationValues.java b/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/AbstractUpdateObjectLocationValues.java index 859722621..af5e86c4f 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/AbstractUpdateObjectLocationValues.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/AbstractUpdateObjectLocationValues.java @@ -42,6 +42,7 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene protected final static String CURRENT_LOCATION_PROPERTY = "currentLocation"; // FIXME: Get from external constant protected final static String COLLECTIONSPACE_CORE_SCHEMA = "collectionspace_core"; // FIXME: Get from external constant protected final static String CREATED_AT_PROPERTY = "createdAt"; // FIXME: Get from external constant + protected final static String UPDATED_AT_PROPERTY = "updatedAt"; // FIXME: Get from external constant private final static String NONVERSIONED_NONPROXY_DOCUMENT_WHERE_CLAUSE_FRAGMENT = "AND ecm:isCheckedInVersion = 0" + "AND ecm:isProxy = 0 "; @@ -101,9 +102,9 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene if (logger.isTraceEnabled()) { logger.trace("An event involving a Movement document was received by UpdateObjectLocationOnMove ..."); } - // FIXME: exclude creation events for Movement records here, if we can - // identify that we'l still be properly handling creation events - // that include a relations list as part of the creation payload, + // FIXME: exclude update events for Movement records here, if we can + // identify that we'l still be properly handling update events + // that include a relations list as part of the update payload, // perhaps because that may trigger a separate event notification. movementCsid = NuxeoUtils.getCsid(docModel); if (Tools.isBlank(movementCsid)) { @@ -400,7 +401,7 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene // Note: the following value is used to compare any two records, rather // than to identify the most recent value so far encountered. Thus, it may // occasionally be set backward or forward in time, within the loop below. - GregorianCalendar comparisonCreationDate = EARLIEST_COMPARISON_DATE; + GregorianCalendar comparisonUpdatedDate = EARLIEST_COMPARISON_DATE; DocumentModel movementDocModel; Set alreadyProcessedMovementCsids = new HashSet<>(); String relatedMovementCsid; @@ -450,22 +451,22 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene if (locationDate == null) { continue; } - GregorianCalendar creationDate = - (GregorianCalendar) movementDocModel.getProperty(COLLECTIONSPACE_CORE_SCHEMA, CREATED_AT_PROPERTY); + GregorianCalendar updatedDate = + (GregorianCalendar) movementDocModel.getProperty(COLLECTIONSPACE_CORE_SCHEMA, UPDATED_AT_PROPERTY); if (locationDate.after(mostRecentLocationDate)) { mostRecentLocationDate = locationDate; - if (creationDate != null) { - comparisonCreationDate = creationDate; + if (updatedDate != null) { + comparisonUpdatedDate = updatedDate; } mostRecentMovementDocModel = movementDocModel; // If the current Movement record's location date is identical // to that of the (at this time) most recent Movement record, then - // instead compare the two records using their creation date values + // instead compare the two records using their update date values } else if (locationDate.compareTo(mostRecentLocationDate) == 0) { - if (creationDate != null && creationDate.after(comparisonCreationDate)) { + if (updatedDate != null && updatedDate.after(comparisonUpdatedDate)) { // The most recent location date value doesn't need to be // updated here, as the two records' values are identical - comparisonCreationDate = creationDate; + comparisonUpdatedDate = updatedDate; mostRecentMovementDocModel = movementDocModel; } } diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/listener/listener-update-object-loc.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/listener/listener-update-object-loc.xml index 752390a51..52147be04 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/listener/listener-update-object-loc.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/listener/listener-update-object-loc.xml @@ -390,9 +390,9 @@ 200 - + - + POST @@ -457,6 +457,30 @@ 200 + + PUT + /cspace-services/movements/${createMovement3.CSID} + listener/movement.xml + + ${createMovement3.currentLocation} + ${updateMovement3WithNonBlankCurrentLocation.locationDate} + + 200 + + + + GET + /cspace-services/collectionobjects/${createCollectionObject1.CSID} + + + listener/res/collectionobject.res.xml + + ${createMovement3.currentLocation} + + + 200 + +