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)
126403 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 121255 jvonka: FileFolder API - add move (with optional rename) - also add +ve/-ve tests RA-683 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126748 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -46,6 +46,7 @@ import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.content.ContentLimitViolationException;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
import org.alfresco.repo.model.filefolder.FileFolderServiceImpl;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.rest.antlr.WhereClauseParser;
|
||||
@@ -81,6 +82,7 @@ import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
@@ -576,7 +578,7 @@ public class NodesImpl implements Nodes
|
||||
catch (FileNotFoundException fnfe)
|
||||
{
|
||||
// convert checked exception
|
||||
throw new InvalidNodeRefException(fnfe.getMessage()+" ["+path+"]", parentNodeRef);
|
||||
throw new EntityNotFoundException(fnfe.getMessage()+" ["+parentNodeRef+","+path+"]");
|
||||
}
|
||||
|
||||
return fileInfo.getNodeRef();
|
||||
@@ -1037,6 +1039,7 @@ public class NodesImpl implements Nodes
|
||||
}
|
||||
catch (DuplicateChildNodeNameException dcne)
|
||||
{
|
||||
// duplicate - name clash
|
||||
throw new ConstraintViolatedException(dcne.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -1083,6 +1086,13 @@ public class NodesImpl implements Nodes
|
||||
}
|
||||
}
|
||||
|
||||
NodeRef parentNodeRef = nodeInfo.getParentId();
|
||||
if (parentNodeRef != null)
|
||||
{
|
||||
// move/rename - with exception mapping
|
||||
move(nodeRef, parentNodeRef, name);
|
||||
}
|
||||
|
||||
List<String> aspectNames = nodeInfo.getAspectNames();
|
||||
if (aspectNames != null)
|
||||
{
|
||||
@@ -1166,6 +1176,39 @@ public class NodesImpl implements Nodes
|
||||
return getFolderOrDocument(nodeRef.getId(), parameters);
|
||||
}
|
||||
|
||||
private void move(NodeRef nodeRef, NodeRef parentNodeRef, String name)
|
||||
{
|
||||
NodeRef currentParentNodeRef = getParentNodeRef(nodeRef);
|
||||
if (! currentParentNodeRef.equals(parentNodeRef))
|
||||
{
|
||||
try
|
||||
{
|
||||
// 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());
|
||||
}
|
||||
catch (FileFolderServiceImpl.InvalidTypeException ite)
|
||||
{
|
||||
throw new InvalidArgumentException("Expect target parentId to be a folder: "+parentNodeRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryResource getContent(String fileNodeId, Parameters parameters)
|
||||
{
|
||||
|
Reference in New Issue
Block a user