From 66dbce4c31f66f16c25257d1ff40ef750f49e2dc Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Tue, 11 Dec 2012 19:06:18 -0800 Subject: [PATCH] CSPACE-5498: Exclude soft deletion events involving Relation records themselves. --- .../listener/UpdateRelationsOnDelete.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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 -- 2.47.3