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>.
|
||||
|
@@ -33,9 +33,7 @@ public class AssociationExistsException extends RuntimeException
|
||||
private QName qname;
|
||||
|
||||
/**
|
||||
* @param sourceRef the source of the association
|
||||
* @param targetRef the target of the association
|
||||
* @param qname the qualified name of the association
|
||||
* @see #AssociationExistsException(NodeRef, NodeRef, QName, Throwable)
|
||||
*/
|
||||
public AssociationExistsException(NodeRef sourceRef, NodeRef targetRef, QName qname)
|
||||
{
|
||||
@@ -45,6 +43,20 @@ public class AssociationExistsException extends RuntimeException
|
||||
this.qname = qname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sourceRef the source of the association
|
||||
* @param targetRef the target of the association
|
||||
* @param qname the qualified name of the association
|
||||
* @param cause a causal exception
|
||||
*/
|
||||
public AssociationExistsException(NodeRef sourceRef, NodeRef targetRef, QName qname, Throwable cause)
|
||||
{
|
||||
super(cause);
|
||||
this.sourceRef = sourceRef;
|
||||
this.targetRef = targetRef;
|
||||
this.qname = qname;
|
||||
}
|
||||
|
||||
public NodeRef getSourceRef()
|
||||
{
|
||||
return sourceRef;
|
||||
|
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.service.cmr.repository;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* Thrown when a child node <b>cm:name</b> property violates the data dictionary
|
||||
* <b>duplicate</b> child association constraint.
|
||||
*
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
public class DuplicateChildNodeNameException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 5143099335847200453L;
|
||||
|
||||
private static final String ERR_DUPLICATE_NAME = "system.err.duplicate_name";
|
||||
|
||||
private NodeRef parentNodeRef;
|
||||
private QName assocTypeQName;
|
||||
private String name;
|
||||
|
||||
public DuplicateChildNodeNameException(NodeRef parentNodeRef, QName assocTypeQName, String name)
|
||||
{
|
||||
super(I18NUtil.getMessage(ERR_DUPLICATE_NAME, name));
|
||||
this.parentNodeRef = parentNodeRef;
|
||||
this.assocTypeQName = assocTypeQName;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public NodeRef getParentNodeRef()
|
||||
{
|
||||
return parentNodeRef;
|
||||
}
|
||||
|
||||
public QName getAssocTypeQName()
|
||||
{
|
||||
return assocTypeQName;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
@@ -417,6 +417,21 @@ public interface NodeService
|
||||
QNamePattern qnamePattern)
|
||||
throws InvalidNodeRefException;
|
||||
|
||||
/**
|
||||
* Get the node with the given name within the context of the parent node. The name
|
||||
* is case-insensitive as Alfresco has to support case-insensitive clients as standard.
|
||||
*
|
||||
* @param nodeRef the parent node - usuall a <b>container</b>
|
||||
* @param assocTypeQName the type of the association
|
||||
* @param childName the name of the node as per the property <b>cm:name</b>
|
||||
* @return Returns the child node or null if not found
|
||||
*/
|
||||
@Auditable(key = Auditable.Key.ARG_0 ,parameters = {"nodeRef", "assocTypeQName", "childName"})
|
||||
public NodeRef getChildByName(
|
||||
NodeRef nodeRef,
|
||||
QName assocTypeQName,
|
||||
String childName);
|
||||
|
||||
/**
|
||||
* Fetches the primary parent-child relationship.
|
||||
* <p>
|
||||
|
Reference in New Issue
Block a user