mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.0 to HEAD
12140: Merged V2.2 to V3.0 11732: Fixed ETWOTWO-804: Node and Transaction Cleanup Job 11747: Missed config for Node and Txn purging 11826: WCM - fix ETWOTWO-817 11951: Fixed ETWOTWO-901: NodeService cleanup must be pluggable 11961: Merged V2.1 to V2.2 11561: ETWOONE-224: when renaming duplicates during copy association names where not renamed 11583: (ALREADY PRESENT) Updated NTLM config example in web.xml - adding missing servlet mappings 11584: Fix for ETWOONE-209 - JavaScript People.createGroup() API now correctly checks for actual group name when testing for existence 11585: Fix for ETWOONE-214 - View In CIFS link now works even when users des not have view permissions on the parent folder 11612: Fix for ETWOONE-91: the description textarea in the modify space properties web form eats one leading newline each time it is submitted 11613: Fix 2.1 build and adjust implementation of ETWOONE-224 fix 11621: Fix for ETWOONE-343 11669: Improved debug from index tracking when exceptions occur 12141: Avoid annoying Spring WARN messages for ClientAbortException 12143: File that should have been deleted in CHK-5460 (rev 12140) 12177: Fix failing FS Deployment Tests since introduction of transaction check advice. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12507 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -54,7 +54,6 @@ import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.CopyService;
|
||||
import org.alfresco.service.cmr.repository.CopyServiceException;
|
||||
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
@@ -71,9 +70,6 @@ import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.tools.ant.taskdefs.War;
|
||||
|
||||
import freemarker.log.Logger;
|
||||
|
||||
/**
|
||||
* Node operations service implmentation.
|
||||
@@ -224,6 +220,9 @@ public class CopyServiceImpl implements CopyService
|
||||
new JavaBehaviour(this, "onCopyComplete"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.repository.CopyService#copy(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName, boolean)
|
||||
*/
|
||||
public NodeRef copy(
|
||||
NodeRef sourceNodeRef,
|
||||
NodeRef destinationParentRef,
|
||||
@@ -267,29 +266,36 @@ public class CopyServiceImpl implements CopyService
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.repository.CopyService#copyAndRename(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName, boolean)
|
||||
*/
|
||||
public NodeRef copyAndRename(NodeRef sourceNodeRef, NodeRef destinationParent, QName destinationAssocTypeQName, QName destinationQName, boolean copyChildren)
|
||||
{
|
||||
// Make a note of the source name and do the copy
|
||||
// To fix ETWOONE-224 issue it is necessary to change a QName of the new node accordingly to its name.
|
||||
NodeRef result = null;
|
||||
String sourceName = (String)this.internalNodeService.getProperty(sourceNodeRef, ContentModel.PROP_NAME);
|
||||
NodeRef copy = copy(sourceNodeRef, destinationParent, destinationAssocTypeQName, destinationQName, copyChildren);
|
||||
|
||||
// Do the rename, iterating until a non-duplicate name is found
|
||||
boolean bDone = false;
|
||||
while (bDone == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.internalNodeService.setProperty(copy, ContentModel.PROP_NAME, sourceName);
|
||||
bDone = true;
|
||||
}
|
||||
catch(DuplicateChildNodeNameException exception)
|
||||
{
|
||||
sourceName = I18NUtil.getMessage(COPY_OF_LABEL, sourceName);
|
||||
}
|
||||
}
|
||||
|
||||
// Return the copy
|
||||
return copy;
|
||||
|
||||
// Find a non-duplicate name
|
||||
String newName = sourceName;
|
||||
while (this.internalNodeService.getChildByName(destinationParent, destinationAssocTypeQName, newName) != null)
|
||||
{
|
||||
newName = I18NUtil.getMessage(COPY_OF_LABEL, newName);
|
||||
}
|
||||
|
||||
if (destinationQName == null)
|
||||
{
|
||||
// Change a QName of the new node accordingly to its name
|
||||
destinationQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(newName));
|
||||
}
|
||||
|
||||
// Make a copy
|
||||
result = copy(sourceNodeRef, destinationParent, destinationAssocTypeQName, destinationQName, copyChildren);
|
||||
|
||||
// Set name property
|
||||
this.internalNodeService.setProperty(result, ContentModel.PROP_NAME, newName);
|
||||
|
||||
// Return new NodeRef
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -660,6 +660,35 @@ public class CopyServiceImplTest extends BaseSpringTest
|
||||
assertFalse(TEST_NAME.equals(this.nodeService.getProperty(contentCopy, ContentModel.PROP_NAME)));
|
||||
}
|
||||
|
||||
/**
|
||||
* https://issues.alfresco.com/jira/browse/ETWOONE-224
|
||||
*/
|
||||
public void testETWOONE_244()
|
||||
{
|
||||
// Create a folder and content node
|
||||
Map<QName, Serializable> propsFolder = new HashMap<QName, Serializable>(1);
|
||||
propsFolder.put(ContentModel.PROP_NAME, "tempFolder");
|
||||
NodeRef folderNode = this.nodeService.createNode(this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "tempFolder"), ContentModel.TYPE_FOLDER, propsFolder).getChildRef();
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
||||
props.put(ContentModel.PROP_NAME, "myDoc.txt");
|
||||
NodeRef contentNode = this.nodeService.createNode(folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myDoc.txt"), ContentModel.TYPE_CONTENT, props).getChildRef();
|
||||
|
||||
NodeRef copy = this.copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
|
||||
assertEquals("Copy of myDoc.txt", this.nodeService.getProperty(copy, ContentModel.PROP_NAME));
|
||||
QName copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of myDoc.txt");
|
||||
assertEquals(copyQName, this.nodeService.getPrimaryParent(copy).getQName());
|
||||
|
||||
copy = this.copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
|
||||
assertEquals("Copy of Copy of myDoc.txt", this.nodeService.getProperty(copy, ContentModel.PROP_NAME));
|
||||
copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of Copy of myDoc.txt");
|
||||
assertEquals(copyQName, this.nodeService.getPrimaryParent(copy).getQName());
|
||||
|
||||
copy = this.copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
|
||||
assertEquals("Copy of Copy of Copy of myDoc.txt", this.nodeService.getProperty(copy, ContentModel.PROP_NAME));
|
||||
copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of Copy of Copy of myDoc.txt");
|
||||
assertEquals(copyQName, this.nodeService.getPrimaryParent(copy).getQName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the copied node contains the state we are expecting
|
||||
*
|
||||
|
Reference in New Issue
Block a user