From 9fd3f569c14ace91b0bc727f0a06c44c0f39effe Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Thu, 21 Apr 2016 08:43:19 -0700 Subject: [PATCH] Adding support for marking local items as deprecated. --- .../common/vocabulary/AuthorityServiceUtils.java | 9 +++++---- .../nuxeo/AuthorityItemDocumentModelHandler.java | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityServiceUtils.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityServiceUtils.java index 8b694b8cd..e195c4801 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityServiceUtils.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityServiceUtils.java @@ -83,13 +83,14 @@ public class AuthorityServiceUtils { return result; } - static public boolean setAuthorityItemDeprecated(DocumentModel docModel, String authorityItemCommonSchemaName, Boolean flag) throws Exception { + static public boolean setAuthorityItemDeprecated(ServiceContext ctx, + DocumentModel docModel, String authorityItemCommonSchemaName, Boolean flag) throws Exception { boolean result = false; docModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.DEPRECATED, new Boolean(flag)); - CoreSessionInterface session = (CoreSessionInterface) docModel.getCoreSession(); - session.saveDocument(docModel); + CoreSessionInterface repoSession = (CoreSessionInterface) ctx.getCurrentRepositorySession(); + repoSession.saveDocument(docModel); result = true; return result; @@ -107,7 +108,7 @@ public class AuthorityServiceUtils { try { DocumentModel docModel = NuxeoUtils.getDocFromCsid(ctx, (CoreSessionInterface)ctx.getCurrentRepositorySession(), itemCsid); - result = setAuthorityItemDeprecated(docModel, authorityItemCommonSchemaName, AuthorityServiceUtils.DEPRECATED); + result = setAuthorityItemDeprecated(ctx, docModel, authorityItemCommonSchemaName, AuthorityServiceUtils.DEPRECATED); } catch (Exception e) { logger.warn(String.format("Could not mark item '%s' as deprecated.", itemCsid), e); throw e; diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index fd6d102f3..ee779e6a8 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@ -465,7 +465,7 @@ public abstract class AuthorityItemDocumentModelHandler // // This exception means we tried unsuccessfully to soft-delete (workflow transition 'delete') an item that still has references to it from other records. // - AuthorityServiceUtils.setAuthorityItemDeprecated(itemDocModel, authorityItemCommonSchemaName, AuthorityServiceUtils.DEPRECATED); // Since we can't sof-delete it, we need to mark it as deprecated since it is soft-deleted on the SAS + AuthorityServiceUtils.setAuthorityItemDeprecated(ctx, itemDocModel, authorityItemCommonSchemaName, AuthorityServiceUtils.DEPRECATED); // Since we can't sof-delete it, we need to mark it as deprecated since it is soft-deleted on the SAS logger.warn(String.format("Could not transition item CSID='%s' from workflow state '%s' to '%s'. Check the services log file for details.", localItemCsid, localItemWorkflowState, sasWorkflowState)); } -- 2.47.3