]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5498: Exclude soft deletion events involving Relation records themselves.
authorAron Roberts <aron@socrates.berkeley.edu>
Wed, 12 Dec 2012 03:06:18 +0000 (19:06 -0800)
committerAron Roberts <aron@socrates.berkeley.edu>
Wed, 12 Dec 2012 03:06:18 +0000 (19:06 -0800)
3rdparty/nuxeo/nuxeo-platform-listener/updaterelationsondelete/src/main/java/org/collectionspace/services/listener/UpdateRelationsOnDelete.java

index fbcb55c9d8aef03aeebbd2a542b3e94d384a9801..9656ba139527a77c70b90c3122d6969334c0e8ba 100644 (file)
@@ -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