RM-2072 (Concurrency exceptions and deadlocks on Records Management "File to" rule)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2.1.x@102267 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2015-04-21 17:49:48 +00:00
parent 39e2ada34a
commit ecad52e211

View File

@@ -18,10 +18,12 @@ import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileNotFoundException; import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@@ -136,9 +138,23 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr
// first look to see if the destination record folder has been specified // first look to see if the destination record folder has been specified
NodeRef recordFolder = (NodeRef)action.getParameterValue(PARAM_DESTINATION_RECORD_FOLDER); NodeRef recordFolder = (NodeRef)action.getParameterValue(PARAM_DESTINATION_RECORD_FOLDER);
if (recordFolder == null) if (recordFolder == null)
{
final boolean finaltargetIsUnfiledRecords = targetIsUnfiledRecords;
recordFolder = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
{
public NodeRef execute() throws Throwable
{
try
{ {
// get the reference to the record folder based on the relative path // get the reference to the record folder based on the relative path
recordFolder = createOrResolvePath(action, actionedUponNodeRef, targetIsUnfiledRecords); return createOrResolvePath(action, actionedUponNodeRef, finaltargetIsUnfiledRecords);
}
catch (DuplicateChildNodeNameException ex)
{
throw new ConcurrencyFailureException("Cannot create or resolve path.", ex);
}
}
}, false, true);
} }
// now we have the reference to the target folder we can do some final checks to see if the action is valid // now we have the reference to the target folder we can do some final checks to see if the action is valid
@@ -373,24 +389,21 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr
{ {
return AuthenticationUtil.runAsSystem(new RunAsWork<NodeRef>() return AuthenticationUtil.runAsSystem(new RunAsWork<NodeRef>()
{ {
@Override
public NodeRef doWork() public NodeRef doWork()
{
return retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
{
public NodeRef execute() throws Throwable
{ {
NodeRef child = null; NodeRef child = null;
if (targetisUnfiledRecords) if(targetisUnfiledRecords)
{ {
child = fileFolderService.create(parent, childName, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER).getNodeRef(); child = fileFolderService.create(parent, childName, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER).getNodeRef();
} }
else if (lastAsFolder) else if(lastAsFolder)
{ {
child = recordFolderService.createRecordFolder(parent, childName); child = recordFolderService.createRecordFolder(parent, childName);
} }
else else
{ {
if (RecordsManagementModel.TYPE_RECORD_FOLDER.equals(nodeService.getType(parent))) if(RecordsManagementModel.TYPE_RECORD_FOLDER.equals(nodeService.getType(parent)))
{ {
throw new AlfrescoRuntimeException("Unable to execute " + action.getActionDefinitionName() + " action, because the destination path could not be created."); throw new AlfrescoRuntimeException("Unable to execute " + action.getActionDefinitionName() + " action, because the destination path could not be created.");
} }
@@ -400,8 +413,6 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr
} }
}); });
} }
});
}
/** /**
* Return the context. This will be the unfiled records container of the context if targetisUnfiledRecords is true * Return the context. This will be the unfiled records container of the context if targetisUnfiledRecords is true