From: Aron Roberts Date: Wed, 12 Dec 2012 03:06:18 +0000 (-0800) Subject: CSPACE-5498: Exclude soft deletion events involving Relation records themselves. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=66dbce4c31f66f16c25257d1ff40ef750f49e2dc;p=tmp%2Fjakarta-migration.git CSPACE-5498: Exclude soft deletion events involving Relation records themselves. --- diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/updaterelationsondelete/src/main/java/org/collectionspace/services/listener/UpdateRelationsOnDelete.java b/3rdparty/nuxeo/nuxeo-platform-listener/updaterelationsondelete/src/main/java/org/collectionspace/services/listener/UpdateRelationsOnDelete.java index fbcb55c9d..9656ba139 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/updaterelationsondelete/src/main/java/org/collectionspace/services/listener/UpdateRelationsOnDelete.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/updaterelationsondelete/src/main/java/org/collectionspace/services/listener/UpdateRelationsOnDelete.java @@ -17,14 +17,15 @@ import org.nuxeo.ecm.core.event.EventListener; import org.nuxeo.ecm.core.event.impl.DocumentEventContext; public class UpdateRelationsOnDelete implements EventListener { - - // FIXME: Get these constant values from external sources rather than redeclaring here - final static String RELATIONS_COMMON_SUBJECT_CSID_FIELD = "relations_common:subjectCsid"; - final static String RELATIONS_COMMON_OBJECT_CSID_FIELD = "relations_common:objectCsid"; // FIXME: We might experiment here with using log4j instead of Apache Commons Logging; // am using the latter to follow Ray's pattern for now final Log logger = LogFactory.getLog(UpdateRelationsOnDelete.class); + + // FIXME: Get these constant values from external sources rather than redeclaring here + final static String RELATION_DOCTYPE = "Relation"; + final static String RELATIONS_COMMON_SUBJECT_CSID_FIELD = "relations_common:subjectCsid"; + final static String RELATIONS_COMMON_OBJECT_CSID_FIELD = "relations_common:objectCsid"; @Override public void handleEvent(Event event) throws ClientException { @@ -39,6 +40,12 @@ public class UpdateRelationsOnDelete implements EventListener { DocumentEventContext docContext = (DocumentEventContext) eventContext; DocumentModel docModel = docContext.getSourceDocument(); + // Exclude soft deletion events involving Relation records themselves + // from handling by this event handler. + if (docModel != null && docModel.getType().startsWith(RELATION_DOCTYPE)) { + return; + } + // Retrieve a list of relation records, where the soft deleted // document provided in the context of the current event is // either the subject or object of any relation