mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126410 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 121557 jvonka: FileFolder API - experimental support for multi move/copy via post to target folder - please note: API (including uri endpoint) is subject to change RA-683, RA-684 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126756 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1091,8 +1091,18 @@ public class NodesImpl implements Nodes
|
||||
NodeRef parentNodeRef = nodeInfo.getParentId();
|
||||
if (parentNodeRef != null)
|
||||
{
|
||||
// move/rename - with exception mapping
|
||||
move(nodeRef, parentNodeRef, name);
|
||||
NodeRef currentParentNodeRef = getParentNodeRef(nodeRef);
|
||||
if (currentParentNodeRef == null)
|
||||
{
|
||||
// implies root (Company Home) hence return 403 here
|
||||
throw new PermissionDeniedException();
|
||||
}
|
||||
|
||||
if (! currentParentNodeRef.equals(parentNodeRef))
|
||||
{
|
||||
// move/rename - with exception mapping
|
||||
moveOrCopy(nodeRef, parentNodeRef, name, false);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> aspectNames = nodeInfo.getAspectNames();
|
||||
@@ -1178,47 +1188,62 @@ public class NodesImpl implements Nodes
|
||||
return getFolderOrDocument(nodeRef.getId(), parameters);
|
||||
}
|
||||
|
||||
private void move(NodeRef nodeRef, NodeRef parentNodeRef, String name)
|
||||
public Node moveNode(String sourceNodeId, String parentFolderNodeId, String name, Parameters parameters)
|
||||
{
|
||||
NodeRef currentParentNodeRef = getParentNodeRef(nodeRef);
|
||||
if (currentParentNodeRef == null)
|
||||
{
|
||||
// implies root (Company Home) hence return 403 here
|
||||
throw new PermissionDeniedException();
|
||||
}
|
||||
final NodeRef parentNodeRef = validateOrLookupNode(parentFolderNodeId, null);
|
||||
final NodeRef sourceNodeRef = validateOrLookupNode(sourceNodeId, null);
|
||||
|
||||
if (! currentParentNodeRef.equals(parentNodeRef))
|
||||
FileInfo fi = moveOrCopy(sourceNodeRef, parentNodeRef, name, false);
|
||||
return getFolderOrDocument(fi.getNodeRef().getId(), parameters);
|
||||
}
|
||||
|
||||
public Node copyNode(String sourceNodeId, String parentFolderNodeId, String name, Parameters parameters)
|
||||
{
|
||||
final NodeRef parentNodeRef = validateOrLookupNode(parentFolderNodeId, null);
|
||||
final NodeRef sourceNodeRef = validateOrLookupNode(sourceNodeId, null);
|
||||
|
||||
FileInfo fi = moveOrCopy(sourceNodeRef, parentNodeRef, name, true);
|
||||
return getFolderOrDocument(fi.getNodeRef().getId(), parameters);
|
||||
}
|
||||
|
||||
protected FileInfo moveOrCopy(NodeRef nodeRef, NodeRef parentNodeRef, String name, boolean isCopy)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
if (isCopy)
|
||||
{
|
||||
return fileFolderService.copy(nodeRef, parentNodeRef, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// updating "parentId" means moving primary parent !
|
||||
// note: in the future (as and when we support secondary parent/child assocs) we may also
|
||||
// wish to select which parent to "move from" (in case where the node resides in multiple locations)
|
||||
fileFolderService.move(nodeRef, parentNodeRef, name);
|
||||
}
|
||||
catch (InvalidNodeRefException inre)
|
||||
{
|
||||
throw new EntityNotFoundException(inre.getMessage()+" ["+nodeRef+","+parentNodeRef+"]");
|
||||
}
|
||||
catch (FileNotFoundException fnfe)
|
||||
{
|
||||
// convert checked exception
|
||||
throw new EntityNotFoundException(fnfe.getMessage()+" ["+nodeRef+","+parentNodeRef+"]");
|
||||
}
|
||||
catch (FileExistsException fee)
|
||||
{
|
||||
// duplicate - name clash
|
||||
throw new ConstraintViolatedException(fee.getMessage()+" ["+nodeRef+","+parentNodeRef+"]");
|
||||
}
|
||||
catch (FileFolderServiceImpl.InvalidTypeException ite)
|
||||
{
|
||||
throw new InvalidArgumentException(ite.getMessage()+" ["+nodeRef+","+parentNodeRef+"]");
|
||||
}
|
||||
catch (CyclicChildRelationshipException ccre)
|
||||
{
|
||||
throw new InvalidArgumentException(ccre.getMessage()+" ["+nodeRef+","+parentNodeRef+"]");
|
||||
return fileFolderService.move(nodeRef, parentNodeRef, name);
|
||||
}
|
||||
}
|
||||
catch (InvalidNodeRefException inre)
|
||||
{
|
||||
throw new EntityNotFoundException(inre.getMessage()+" ["+nodeRef+","+parentNodeRef+"]");
|
||||
}
|
||||
catch (FileNotFoundException fnfe)
|
||||
{
|
||||
// convert checked exception
|
||||
throw new EntityNotFoundException(fnfe.getMessage()+" ["+nodeRef+","+parentNodeRef+"]");
|
||||
}
|
||||
catch (FileExistsException fee)
|
||||
{
|
||||
// duplicate - name clash
|
||||
throw new ConstraintViolatedException(fee.getMessage()+" ["+nodeRef+","+parentNodeRef+"]");
|
||||
}
|
||||
catch (FileFolderServiceImpl.InvalidTypeException ite)
|
||||
{
|
||||
throw new InvalidArgumentException(ite.getMessage()+" ["+nodeRef+","+parentNodeRef+"]");
|
||||
}
|
||||
catch (CyclicChildRelationshipException ccre)
|
||||
{
|
||||
throw new InvalidArgumentException(ccre.getMessage() + " [" + nodeRef + "," + parentNodeRef + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user