From: Aron Roberts Date: Wed, 5 Dec 2012 04:08:47 +0000 (-0800) Subject: CSPACE-5727: Filter out all but active Movement records when responding to create... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=3d776d9dc20bc455dc09c7abcca80db93003efab;p=tmp%2Fjakarta-migration.git CSPACE-5727: Filter out all but active Movement records when responding to create or update events. --- diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/pom.xml b/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/pom.xml index 2fed52dab..3c28ba123 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/pom.xml +++ b/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/pom.xml @@ -27,6 +27,11 @@ org.collectionspace.services.movement.service ${project.version} + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/UpdateObjectLocationOnMove.java b/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/UpdateObjectLocationOnMove.java index 14f160c49..39078782e 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/UpdateObjectLocationOnMove.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/UpdateObjectLocationOnMove.java @@ -1,15 +1,11 @@ package org.collectionspace.services.listener; -import java.util.ArrayList; -import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.movement.nuxeo.MovementConstants; import org.nuxeo.ecm.core.api.ClientException; -import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.nuxeo.ecm.core.api.impl.LifeCycleFilter; import org.nuxeo.ecm.core.event.Event; import org.nuxeo.ecm.core.event.EventContext; import org.nuxeo.ecm.core.event.EventListener; @@ -23,7 +19,7 @@ public class UpdateObjectLocationOnMove implements EventListener { @Override public void handleEvent(Event event) throws ClientException { - + logger.info("In handleEvent in UpdateObjectLocationOnMove ..."); EventContext eventContext = event.getContext(); @@ -33,8 +29,37 @@ public class UpdateObjectLocationOnMove implements EventListener { DocumentEventContext docEventContext = (DocumentEventContext) eventContext; DocumentModel docModel = docEventContext.getSourceDocument(); logger.debug("docType=" + docModel.getType()); - if (docModel.getType().startsWith(MovementConstants.NUXEO_DOCTYPE)) { - logger.info("A create or update event for a Movement document was received by UpdateObjectLocationOnMove ..."); + if (docModel.getType().startsWith(MovementConstants.NUXEO_DOCTYPE) + && isActiveDocument(docModel)) { + logger.info("A create or update event for an active Movement document was received by UpdateObjectLocationOnMove ..."); + } + + } + + /** + * Identifies whether a document is an active document; that is, if + * it is not a versioned record; not a proxy (symbolic link to an + * actual record); and not in the 'deleted' workflow state. + * + * (A note relating the latter: Nuxeo appears to send 'documentModified' events + * even on workflow transitions, such when records are 'soft deleted' by being + * transitioned to the 'deleted' workflow state.) + * + * @param docModel + * @return true if the document is an active document; false if it + * is not. + */ + private boolean isActiveDocument(DocumentModel docModel) { + boolean isActiveDocument = false; + try { + if (!docModel.isVersion() + && !docModel.isProxy() + && !docModel.getCurrentLifeCycleState().equals(WorkflowClient.WORKFLOWSTATE_DELETED)) { + isActiveDocument = true; + } + } catch (ClientException ce) { + logger.warn("Error while identifying whether document is an active document: ", ce); } + return isActiveDocument; } }