mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Name duplicate detection is not done at the end of the transaction, so late setting of
cm:name has to be avoided. This fix makes the CopyService use the auto-assigned cm:name before doing the copy. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3621 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
||||||
import org.alfresco.repo.policy.JavaBehaviour;
|
import org.alfresco.repo.policy.JavaBehaviour;
|
||||||
@@ -31,6 +32,7 @@ import org.alfresco.repo.policy.PolicyComponent;
|
|||||||
import org.alfresco.repo.policy.PolicyScope;
|
import org.alfresco.repo.policy.PolicyScope;
|
||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
@@ -401,6 +403,23 @@ public class CopyServiceImpl implements CopyService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the parent node is the same, then remove the name property - it will have to
|
||||||
|
// be changed by the client code
|
||||||
|
AssociationDefinition assocDef = dictionaryService.getAssociation(destinationAssocTypeQName);
|
||||||
|
if (!assocDef.isChild())
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Association is not a child association: " + destinationAssocTypeQName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ChildAssociationDefinition childAssocDef = (ChildAssociationDefinition) assocDef;
|
||||||
|
if (!childAssocDef.getDuplicateChildNamesAllowed())
|
||||||
|
{
|
||||||
|
// duplicate children are not allowed.
|
||||||
|
properties.remove(ContentModel.PROP_NAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create the new node
|
// Create the new node
|
||||||
ChildAssociationRef destinationChildAssocRef = this.nodeService.createNode(
|
ChildAssociationRef destinationChildAssocRef = this.nodeService.createNode(
|
||||||
destinationParent,
|
destinationParent,
|
||||||
|
@@ -586,13 +586,20 @@ public class FileFolderServiceImpl implements FileFolderService
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// copy the node
|
try
|
||||||
targetNodeRef = copyService.copy(
|
{
|
||||||
sourceNodeRef,
|
// copy the node
|
||||||
targetParentRef,
|
targetNodeRef = copyService.copy(
|
||||||
assocRef.getTypeQName(),
|
sourceNodeRef,
|
||||||
qname,
|
targetParentRef,
|
||||||
true);
|
assocRef.getTypeQName(),
|
||||||
|
qname,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
catch (DuplicateChildNodeNameException e)
|
||||||
|
{
|
||||||
|
throw new FileExistsException(targetParentRef, newName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only update the name if it has changed
|
// Only update the name if it has changed
|
||||||
|
Reference in New Issue
Block a user