mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged DEV/CHECK_EXISTS to HEAD
svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/DEV/CHECK_EXISTS@3442 svn://www.alfresco.org:3691/alfresco/BRANCHES/DEV/CHECK_EXISTS@3590 . TODO: Fix bug raising incorrect exception during UI paste of same-named file Note: - Added a new method to NodeService to get child by name - Added a new method to FileFolderService to perform fast, direct lookups based on name git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3591 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -16,29 +16,37 @@
|
||||
*/
|
||||
package org.alfresco.service.cmr.model;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Common, checked exception thrown when an operation fails because
|
||||
* of a name clash.
|
||||
*
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
public class FileExistsException extends Exception
|
||||
public class FileExistsException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = -4133713912784624118L;
|
||||
|
||||
private FileInfo existing;
|
||||
private NodeRef parentNodeRef;
|
||||
private String name;
|
||||
|
||||
public FileExistsException(FileInfo existing)
|
||||
public FileExistsException(NodeRef parentNodeRef, String name)
|
||||
{
|
||||
super("" +
|
||||
(existing.isFolder() ? "Folder " : "File ") +
|
||||
existing.getName() +
|
||||
super("Existing file or folder " +
|
||||
name +
|
||||
" already exists");
|
||||
this.existing = existing;
|
||||
this.parentNodeRef = parentNodeRef;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public FileInfo getExisting()
|
||||
public NodeRef getParentNodeRef()
|
||||
{
|
||||
return existing;
|
||||
return parentNodeRef;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@@ -61,6 +61,16 @@ public interface FileFolderService
|
||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"contextNodeRef"})
|
||||
public List<FileInfo> listFolders(NodeRef contextNodeRef);
|
||||
|
||||
/**
|
||||
* Get a simple list of nodes that have the given name within the parent node
|
||||
*
|
||||
* @param contextNodeRef the parent node
|
||||
* @param name the name of the node to search for
|
||||
* @return Returns the node that has the given name - or null if not found
|
||||
*/
|
||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"contextNodeRef", "name"})
|
||||
public NodeRef searchSimple(NodeRef contextNodeRef, String name);
|
||||
|
||||
/**
|
||||
* Searches for all files and folders with the matching name pattern,
|
||||
* using wildcard characters <b>*</b> and <b>?</b>.
|
||||
|
Reference in New Issue
Block a user