From: Richard Millet Date: Fri, 15 Apr 2016 04:59:51 +0000 (-0700) Subject: CSPACE-6937: Verified that new cs_sas lifecycle seems to be working on Person authority. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=92aa80c516e957e799b1894ba92e1ca0df282490;p=tmp%2Fjakarta-migration.git CSPACE-6937: Verified that new cs_sas lifecycle seems to be working on Person authority. --- diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index f8dcd8215..c6bb8652e 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -754,16 +754,18 @@ public abstract class AuthorityResource if (existingContext != null && existingContext.getCurrentRepositorySession() != null) { ctx.setCurrentRepositorySession(existingContext.getCurrentRepositorySession()); // If a repo session is already open, we need to use it and not create a new one } - + // // Create a service context and document handler for the target resource -not the workflow resource itself. + // ServiceContext targetCtx = createServiceContext(getItemServiceName()); - AuthorityItemDocumentModelHandler parentDocHandler = (AuthorityItemDocumentModelHandler) this.createDocumentHandler(targetCtx); - parentDocHandler.setShouldUpdateRevNumber(updateRevNumber); - ctx.setProperty(WorkflowClient.TARGET_DOCHANDLER, parentDocHandler); //added as a context param for the workflow document handler -it will call the parent's dochandler "prepareForWorkflowTranstion" method - - // When looking for the document, we need to use the parent resource's workspace name -not the "workflow" workspace name - String parentWorkspaceName = targetCtx.getRepositoryWorkspaceName(); - ctx.setRespositoryWorkspaceName(parentWorkspaceName); //find the document in the parent's workspace + AuthorityItemDocumentModelHandler targetDocHandler = (AuthorityItemDocumentModelHandler) this.createDocumentHandler(targetCtx); + targetDocHandler.setShouldUpdateRevNumber(updateRevNumber); + ctx.setProperty(WorkflowClient.TARGET_DOCHANDLER, targetDocHandler); //added as a context param for the workflow document handler -it will call the parent's dochandler "prepareForWorkflowTranstion" method + // + // When looking for the document, we need to use the parent/target resource's workspace name -not the "workflow" workspace name + // + String targetWorkspaceName = targetCtx.getRepositoryWorkspaceName(); + ctx.setRespositoryWorkspaceName(targetWorkspaceName); //find the document in the parent's workspace // Get the type of transition we're being asked to make and store it as a context parameter -used by the workflow document handler TransitionDef transitionDef = getTransitionDef(targetCtx, transition); 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 5fdd5dcdc..a6cf7781b 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 @@ -426,12 +426,27 @@ public abstract class AuthorityItemDocumentModelHandler ResourceMap resourceMap = ctx.getResourceMap(); String resourceName = this.getAuthorityServicePath(); AuthorityResource authorityResource = (AuthorityResource) resourceMap.get(resourceName); - authorityResource.updateItemWorkflowWithTransition(ctx, localParentCsid, localItemCsid, transition, AuthorityServiceUtils.DONT_UPDATE_REV) + // + // We need to move the local item to the SAS workflow state. This might involve multiple transitions. + // + List transitionList = getTransitionList(sasWorkflowState, localItemWorkflowState); + for (String transition:transitionList) { + authorityResource.updateItemWorkflowWithTransition(ctx, localParentCsid, localItemCsid, transition, AuthorityServiceUtils.DONT_UPDATE_REV); + } } return result; } + /** + * We need to move the local item to the SAS workflow state. This might involve multiple transitions. + */ + private List getTransitionList(String sasWorkflowState, String localItemWorkflowState) { + List result = new ArrayList(); + // TO BE COMPLETELED + return result; + } + /* (non-Javadoc) * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper) */ @@ -534,7 +549,8 @@ public abstract class AuthorityItemDocumentModelHandler // // Next, update the inAuthority (the parent's) rev number // - DocumentModel inAuthorityDocModel = NuxeoUtils.getDocFromCsid(getServiceContext(), getRepositorySession(), getInAuthority()); + String inAuthority = (String)documentModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.IN_AUTHORITY); + DocumentModel inAuthorityDocModel = NuxeoUtils.getDocFromCsid(getServiceContext(), getRepositorySession(), inAuthority); Long parentRev = (Long)inAuthorityDocModel.getProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV); if (parentRev == null) { parentRev = new Long(0);