From 90930161814509aa5aef58d55a250de482b1b1c5 Mon Sep 17 00:00:00 2001 From: remillet Date: Thu, 25 Jan 2018 01:01:47 -0800 Subject: [PATCH] DRYD-114: Fixed some compile issues that mistakenly made it into the last commit. --- .../AbstractUpdateObjectLocationValues.java | 26 +++++++++++++++---- .../listener/UpdateRelationsOnDelete.java | 7 ++--- .../services/nuxeo/util/NuxeoUtils.java | 3 ++- 3 files changed, 27 insertions(+), 9 deletions(-) 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 78570530c..83ee45581 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 @@ -12,6 +12,7 @@ import org.collectionspace.services.client.LocationAuthorityClient; import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants; import org.collectionspace.services.common.api.Tools; +import org.collectionspace.services.common.document.DocumentException; import org.collectionspace.services.common.relation.nuxeo.RelationConstants; import org.collectionspace.services.common.api.RefName; import org.collectionspace.services.movement.nuxeo.MovementConstants; @@ -19,7 +20,7 @@ import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.collectionspace.services.nuxeo.client.java.CoreSessionWrapper; import org.collectionspace.services.nuxeo.listener.AbstractCSEventListenerImpl; import org.collectionspace.services.nuxeo.util.NuxeoUtils; - +import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.event.DocumentEventTypes; @@ -299,9 +300,10 @@ public abstract class AbstractUpdateObjectLocationValues extends AbstractCSEvent * @throws ClientException * @return the CSIDs of the CollectionObject records, if any, which are * related to the Movement record. + * @throws DocumentException */ private Set getCollectionObjectCsidsRelatedToMovement(String movementCsid, - CoreSessionInterface coreSession) { + CoreSessionInterface coreSession) throws ClientException { Set csids = new HashSet<>(); @@ -326,7 +328,13 @@ public abstract class AbstractUpdateObjectLocationValues extends AbstractCSEvent + ACTIVE_DOCUMENT_WHERE_CLAUSE_FRAGMENT, RELATION_DOCTYPE, RELATIONS_COMMON_SCHEMA, movementCsid, COLLECTIONOBJECT_DOCTYPE); - DocumentModelList relationDocModels = coreSession.query(query); + DocumentModelList relationDocModels = null; + try { + relationDocModels = coreSession.query(query); + } catch (DocumentException e) { + logger.error(e); + } + if (relationDocModels == null || relationDocModels.isEmpty()) { return csids; } @@ -491,10 +499,11 @@ public abstract class AbstractUpdateObjectLocationValues extends AbstractCSEvent * @throws ClientException * @return the most recent Movement record related to the CollectionObject * identified by the supplied CSID. + * @throws DocumentException */ protected String getMostRecentLocation(Event event, CoreSessionInterface session, String collectionObjectCsid, - boolean isAboutToBeRemovedEvent, String eventMovementCsid) { + boolean isAboutToBeRemovedEvent, String eventMovementCsid) throws ClientException { // // Assume we can determine the most recent location by creating an indeterminate result // @@ -516,7 +525,14 @@ public abstract class AbstractUpdateObjectLocationValues extends AbstractCSEvent RELATION_DOCTYPE, RELATIONS_COMMON_SCHEMA, collectionObjectCsid, MOVEMENT_DOCTYPE); logger.trace("query=" + query); - DocumentModelList relationDocModels = session.query(query); + DocumentModelList relationDocModels; + try { + relationDocModels = session.query(query); + } catch (DocumentException e) { + logger.error(e); + return null; + } + if (isCreatingNewRelationship(event) == true) { DocumentModel newRelation = ((DocumentEventContext)event.getContext()).getSourceDocument(); relationDocModels.add(newRelation); 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 861838cbe..dbf63645e 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 @@ -7,6 +7,7 @@ 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.common.document.DocumentException; import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.collectionspace.services.nuxeo.client.java.CoreSessionWrapper; import org.collectionspace.services.nuxeo.listener.AbstractCSEventListenerImpl; @@ -81,11 +82,11 @@ public class UpdateRelationsOnDelete extends AbstractCSEventListenerImpl { DocumentModelList matchingDocuments; try { matchingDocuments = session.query(queryString.toString(), workflowStateFilter); - } catch (Exception ce) { - logger.warn("Error attempting to retrieve relation records where " + } catch (DocumentException ce) { + logger.error("Error attempting to retrieve relation records where " + "record of type '" + docModel.getType() + "' with CSID " + csid + " is the subject or object of any relation: " + ce.getMessage()); - throw ce; + return; } // Cycle through the list results, soft deleting each matching relation record diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java index 60ceabd8b..51b914d23 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java @@ -64,6 +64,7 @@ import org.nuxeo.ecm.core.NXCore; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.Blob; +import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.DocumentRef; import org.nuxeo.ecm.core.api.IdRef; @@ -920,7 +921,7 @@ public class NuxeoUtils { } public static boolean documentExists(CoreSessionInterface repoSession, - String csid) { + String csid) throws ClientException, DocumentException { boolean result = false; String statement = String.format( -- 2.47.3