mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-3993 (Exceptions thrown when concurrently creating identical folder structure)
This commit is contained in:
@@ -11,12 +11,12 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
|||||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
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.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;
|
||||||
@@ -103,7 +103,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)
|
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef)
|
protected synchronized void executeImpl(final Action action, final NodeRef actionedUponNodeRef)
|
||||||
{
|
{
|
||||||
String actionName = action.getActionDefinitionName();
|
String actionName = action.getActionDefinitionName();
|
||||||
if (isOkToProceedWithAction(actionedUponNodeRef, actionName))
|
if (isOkToProceedWithAction(actionedUponNodeRef, actionName))
|
||||||
@@ -124,9 +124,16 @@ 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 = getTransactionService().getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
|
||||||
|
{
|
||||||
|
public NodeRef execute() throws Throwable
|
||||||
{
|
{
|
||||||
// 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);
|
||||||
|
}
|
||||||
|
}, 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
|
||||||
@@ -333,19 +340,7 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr
|
|||||||
*/
|
*/
|
||||||
private NodeRef getChild(NodeRef parent, String childName)
|
private NodeRef getChild(NodeRef parent, String childName)
|
||||||
{
|
{
|
||||||
NodeRef child = null;
|
return getNodeService().getChildByName(parent, ContentModel.ASSOC_CONTAINS, childName);
|
||||||
List<ChildAssociationRef> children = getNodeService().getChildAssocs(parent);
|
|
||||||
for (ChildAssociationRef childAssoc : children)
|
|
||||||
{
|
|
||||||
NodeRef childNodeRef = childAssoc.getChildRef();
|
|
||||||
String existingChildName = (String)getNodeService().getProperty(childNodeRef, ContentModel.PROP_NAME);
|
|
||||||
if(existingChildName.equals(childName))
|
|
||||||
{
|
|
||||||
child = childNodeRef;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return child;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -365,8 +360,11 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr
|
|||||||
@Override
|
@Override
|
||||||
public NodeRef doWork()
|
public NodeRef doWork()
|
||||||
{
|
{
|
||||||
NodeRef child = null;
|
// double check that the child hasn't been created by another thread
|
||||||
if(targetisUnfiledRecords)
|
NodeRef child = getChild(parent, childName);
|
||||||
|
if (child == null)
|
||||||
|
{
|
||||||
|
if (targetisUnfiledRecords)
|
||||||
{
|
{
|
||||||
child = fileFolderService.create(parent, childName, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER).getNodeRef();
|
child = fileFolderService.create(parent, childName, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER).getNodeRef();
|
||||||
}
|
}
|
||||||
@@ -382,6 +380,7 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr
|
|||||||
}
|
}
|
||||||
child = filePlanService.createRecordCategory(parent, childName);
|
child = filePlanService.createRecordCategory(parent, childName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user