From cfc9c6988f56c12e1e010f90e024452aa072d6ac Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Thu, 25 Feb 2016 19:37:14 +0200 Subject: [PATCH] RM-2994 : fixed issue - issue title: Copy/Move/Link actions don't take place and errors are thrown when running rules that perform them. - regression caused by RM-2072 merged forward from v2.2 - the retrying transaction helper was missing from copyTo, moveTo and linkTo beans and was causing NullPointerException - createOrResolvePath method calls getContext on a node created in the current transaction which is not visible in the new transaction and it throws a FileNotFoundException - solution: I moved the creation of the new transaction after the context was retrieved as the concurrency exception reported in RM-2072 was being caused by property updates --- .../rm-action-context.xml | 3 ++ .../impl/CopyMoveLinkFileToBaseAction.java | 47 +++++++++---------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml index 342e5dff92..0c2510f0a8 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml @@ -791,6 +791,7 @@ + @@ -819,6 +820,7 @@ + @@ -847,6 +849,7 @@ + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java index abc881889f..8ba3b055b1 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java @@ -116,7 +116,7 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) */ @Override - protected synchronized void executeImpl(final Action action, final NodeRef actionedUponNodeRef) + protected synchronized void executeImpl(Action action, final NodeRef actionedUponNodeRef) { String actionName = action.getActionDefinitionName(); if (isOkToProceedWithAction(actionedUponNodeRef, actionName)) @@ -139,24 +139,7 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr if (recordFolder == null) { final boolean finaltargetIsUnfiledRecords = targetIsUnfiledRecords; - recordFolder = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - NodeRef result = null; - try - { - // get the reference to the record folder based on the relative path - result = createOrResolvePath(action, actionedUponNodeRef, finaltargetIsUnfiledRecords); - } - catch (DuplicateChildNodeNameException ex) - { - throw new ConcurrencyFailureException("Cannot create or resolve path.", ex); - } - - return result; - } - }, false, true); + recordFolder = createOrResolvePath(action, actionedUponNodeRef, finaltargetIsUnfiledRecords); } // now we have the reference to the target folder we can do some final checks to see if the action is valid @@ -282,23 +265,39 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr * @param targetisUnfiledRecords true is the target is in unfiled records * @return */ - private NodeRef createOrResolvePath(Action action, NodeRef actionedUponNodeRef, boolean targetisUnfiledRecords) + private NodeRef createOrResolvePath(final Action action, final NodeRef actionedUponNodeRef, final boolean targetisUnfiledRecords) { // get the starting context - NodeRef context = getContext(action, actionedUponNodeRef, targetisUnfiledRecords); + final NodeRef context = getContext(action, actionedUponNodeRef, targetisUnfiledRecords); NodeRef path = context; // get the path we wish to resolve String pathParameter = (String)action.getParameterValue(PARAM_PATH); - String[] pathElementsArray = StringUtils.tokenizeToStringArray(pathParameter, "/", false, true); + final String[] pathElementsArray = StringUtils.tokenizeToStringArray(pathParameter, "/", false, true); if((pathElementsArray != null) && (pathElementsArray.length > 0)) { // get the create parameter Boolean createValue = (Boolean)action.getParameterValue(PARAM_CREATE_RECORD_PATH); - boolean create = createValue == null ? false : createValue.booleanValue(); + final boolean create = createValue == null ? false : createValue.booleanValue(); // create or resolve the specified path - path = createOrResolvePath(action, context, actionedUponNodeRef, Arrays.asList(pathElementsArray), targetisUnfiledRecords, create, false); + path = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public NodeRef execute() throws Throwable + { + NodeRef path = null; + try + { + path = createOrResolvePath(action, context, actionedUponNodeRef, Arrays.asList(pathElementsArray), targetisUnfiledRecords, + create, false); + } + catch (DuplicateChildNodeNameException ex) + { + throw new ConcurrencyFailureException("Cannot create or resolve path.", ex); + } + return path; + } + }, false, true); } return path; }