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 * and ?.
diff --git a/source/java/org/alfresco/service/cmr/repository/AssociationExistsException.java b/source/java/org/alfresco/service/cmr/repository/AssociationExistsException.java
index 9ccd21d69f..003e253a29 100644
--- a/source/java/org/alfresco/service/cmr/repository/AssociationExistsException.java
+++ b/source/java/org/alfresco/service/cmr/repository/AssociationExistsException.java
@@ -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;
diff --git a/source/java/org/alfresco/service/cmr/repository/DuplicateChildNodeNameException.java b/source/java/org/alfresco/service/cmr/repository/DuplicateChildNodeNameException.java
new file mode 100644
index 0000000000..405c42a434
--- /dev/null
+++ b/source/java/org/alfresco/service/cmr/repository/DuplicateChildNodeNameException.java
@@ -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 cm:name property violates the data dictionary
+ * duplicate 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;
+ }
+}
diff --git a/source/java/org/alfresco/service/cmr/repository/NodeService.java b/source/java/org/alfresco/service/cmr/repository/NodeService.java
index 88e178ed64..96b192cf52 100644
--- a/source/java/org/alfresco/service/cmr/repository/NodeService.java
+++ b/source/java/org/alfresco/service/cmr/repository/NodeService.java
@@ -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 container
+ * @param assocTypeQName the type of the association
+ * @param childName the name of the node as per the property cm:name
+ * @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.
*
diff --git a/source/test-resources/filefolder/filefolder-test-import.xml b/source/test-resources/filefolder/filefolder-test-import.xml
index 9d7609596f..90e2430380 100644
--- a/source/test-resources/filefolder/filefolder-test-import.xml
+++ b/source/test-resources/filefolder/filefolder-test-import.xml
@@ -43,15 +43,15 @@
L0- Folder C
-
+
- DUPLICATE
+ CHECK_FILE
contentUrl=classpath:quick/quick.txt|mimetype=text/plain|size=|encoding=
-
-
- DUPLICATE
-
+
+
+ CHECK_FOLDER
+