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;
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;
* @throws ClientException
* @return the CSIDs of the CollectionObject records, if any, which are
* related to the Movement record.
+ * @throws DocumentException
*/
private Set<String> getCollectionObjectCsidsRelatedToMovement(String movementCsid,
- CoreSessionInterface coreSession) {
+ CoreSessionInterface coreSession) throws ClientException {
Set<String> csids = new HashSet<>();
+ 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;
}
* @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
//
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);
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;
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