Interface NodeService
Amongst other things, this service must enforce the unique name check as mandated by the duplicate entity in the model.
<type name="cm:folder"> ... <associations> <child-association name="cm:contains"> ... <duplicate>false</duplicate> </child-association> </associations> </type>When duplicates are not allowed, and the cm:name property of a node changes, then the
org.alfresco.service.cmr.repository.DuplicateChildNodeNameException
exception must be thrown. Client code can catch this exception and deal with it
appropriately.- Author:
- Derek Hulley
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
General node-find parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Applies an aspect to the given node.Associates a given child node with a given collection of parents.Makes a parent-child association between the given nodes.void
addProperties
(NodeRef nodeRef, Map<QName, Serializable> properties) Add all given properties to the node.int
countChildAssocs
(NodeRef nodeRef, boolean isPrimary) Counts the number of child associations of nodeRef.createAssociation
(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) Create a peer association between two nodes.createNode
(NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName) createNode
(NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName, Map<QName, Serializable> properties) Creates a new, non-abstract, real node as a primary child of the given parent node.createStore
(String protocol, String identifier) Create a new store for the given protocol and identifier.void
deleteNode
(NodeRef nodeRef) Deletes the given node.void
deleteStore
(StoreRef storeRef) Delete a store and all its contents.boolean
boolean
getAllRootNodes
(StoreRef storeRef) getAspects
(NodeRef nodeRef) Gets an association by ID.getChildAssocs
(NodeRef nodeRef) Get all child associations of the given node.getChildAssocs
(NodeRef nodeRef, Set<QName> childNodeTypeQNames) Retrieve immediate children of a given node where the child nodes are in the given inclusive list.getChildAssocs
(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) Gets all child associations where the pattern of the association qualified name is a match.getChildAssocs
(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern, boolean preload) Gets all child associations where the pattern of the association qualified names match the patterns provided.getChildAssocs
(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern, int maxResults, boolean preload) Gets all child associations where the pattern of the association qualified name is an exact match.getChildAssocsByPropertyValue
(NodeRef nodeRef, QName propertyQName, Serializable value) Retrieve the immediate children of a given node based on the value of a property of those children.getChildAssocsWithoutParentAssocsOfType
(NodeRef parent, QName assocTypeQName) Gets the set of child associations of a certain parent node without parent associations of a certain type to other nodes with the same parent! In effect the 'orphans' with respect to a certain association type.getChildByName
(NodeRef nodeRef, QName assocTypeQName, String childName) Get the node with the given name within the context of the parent node.getChildrenByName
(NodeRef nodeRef, QName assocTypeQName, Collection<String> childNames) Get the nodes with the given names within the context of the parent node.getNodeAclId
(NodeRef nodeRef) getNodeRef
(Long nodeId) Get the node reference for a given node DB IDgetNodeStatus
(NodeRef nodeRef) Gets the ID of the last transaction that caused the node to change.getParentAssocs
(NodeRef nodeRef) getParentAssocs
(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) Gets all parent associations where the pattern of the association qualified name is a matchThe root node has an entry in the path(s) returned.The root node has an entry in the path(s) returned.getPrimaryParent
(NodeRef nodeRef) Fetches the primary parent-child relationship.getProperties
(NodeRef nodeRef) getProperty
(NodeRef nodeRef, QName qname) getRootNode
(StoreRef storeRef) getSourceAssocs
(NodeRef targetRef, QNamePattern qnamePattern) Fetches all associations to the given target where the associations' qualified names match the pattern provided.getStoreArchiveNode
(StoreRef storeRef) Get the node where archived items will have gone when deleted from the given store.Gets a list of all available node store referencesgetTargetAssocs
(NodeRef sourceRef, QNamePattern qnamePattern) Fetches all associations from the given source where the associations' qualified names match the pattern provided.getTargetAssocsByPropertyValue
(NodeRef sourceRef, QNamePattern qnamePattern, QName propertyQName, Serializable propertyValue) Fetches all associations from the given source where the associations' qualified names match the pattern provided.boolean
Determines if a given aspect is present on a node.Moves the primary location of the given node.void
removeAspect
(NodeRef nodeRef, QName aspectTypeQName) Remove an aspect and all related properties from a nodevoid
removeAssociation
(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) void
removeChild
(NodeRef parentRef, NodeRef childRef) Severs all parent-child relationships between two nodes.boolean
removeChildAssociation
(ChildAssociationRef childAssocRef) Remove a specific child association.void
removeProperty
(NodeRef nodeRef, QName qname) Removes a property value completely.boolean
removeSeconaryChildAssociation
(ChildAssociationRef childAssocRef) Deprecated.boolean
removeSecondaryChildAssociation
(ChildAssociationRef childAssocRef) Remove a specific secondary child association.restoreNode
(NodeRef archivedNodeRef, NodeRef destinationParentNodeRef, QName assocTypeQName, QName assocQName) Restore an individual node (along with its sub-tree nodes) to the target location.void
setAssociations
(NodeRef sourceRef, QName assocTypeQName, List<NodeRef> targetRefs) Re-assign all typed target associations for a given node.void
setChildAssociationIndex
(ChildAssociationRef childAssocRef, int index) Set the ordering index of the child association.void
setProperties
(NodeRef nodeRef, Map<QName, Serializable> properties) Replace all current properties on the node with the given properties.void
setProperty
(NodeRef nodeRef, QName qname, Serializable value) Sets the value of a property to be anySerializable
instance.void
Re-sets the type of the node.
-
Method Details
-
getStores
Gets a list of all available node store references- Returns:
- Returns a list of store references
-
createStore
@Auditable(parameters={"protocol","identifier"}) StoreRef createStore(String protocol, String identifier) throws StoreExistsException Create a new store for the given protocol and identifier. The implementation may create the store in any number of locations, including a database or Subversion.- Parameters:
protocol
- implementation protocolidentifier
- the protocol-specific identifier- Returns:
- Returns a reference to the store
- Throws:
StoreExistsException
-
deleteStore
Delete a store and all its contents.- Parameters:
storeRef
- the store to delete- Throws:
InvalidStoreRefException
- if the store reference is invalid
-
exists
- Parameters:
storeRef
- a reference to the store to look for- Returns:
- Returns true if the store exists, otherwise false
-
exists
- Parameters:
nodeRef
- a reference to the node to look for- Returns:
- Returns true if the node exists, otherwise false
-
getNodeStatus
Gets the ID of the last transaction that caused the node to change. This includes deletions, so it is possible that the node being referenced no longer exists. If the node never existed, then null is returned.- Parameters:
nodeRef
- a reference to a current or previously existing node- Returns:
- Returns the status of the node, or null if the node never existed
-
getNodeRef
Get the node reference for a given node DB ID- Parameters:
nodeId
- the node's DB ID- Returns:
- the corresponding node reference or null if not found
-
getRootNode
@Auditable(parameters="storeRef") NodeRef getRootNode(StoreRef storeRef) throws InvalidStoreRefException - Parameters:
storeRef
- a reference to an existing store- Returns:
- Returns a reference to the root node of the store
- Throws:
InvalidStoreRefException
- if the store could not be found
-
getAllRootNodes
- Parameters:
storeRef
- a reference to an existing store- Returns:
- Returns a set of references to all nodes in the store tagged with the root aspect
- Throws:
InvalidStoreRefException
- if the store could not be found
-
createNode
@Auditable(parameters={"parentRef","assocTypeQName","assocQName","nodeTypeQName"}) ChildAssociationRef createNode(NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName) throws InvalidNodeRefException, InvalidTypeException -
createNode
@Auditable(parameters={"parentRef","assocTypeQName","assocQName","nodeTypeQName","properties"}) ChildAssociationRef createNode(NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName, Map<QName, Serializable> properties) throws InvalidNodeRefException, InvalidTypeExceptionCreates a new, non-abstract, real node as a primary child of the given parent node.- Parameters:
parentRef
- the parent nodeassocTypeQName
- the type of the association to create. This is used for verification against the data dictionary.assocQName
- the qualified name of the associationnodeTypeQName
- a reference to the node typeproperties
- optional map of properties to keyed by their qualified names- Returns:
- Returns a reference to the newly created child association
- Throws:
InvalidNodeRefException
- if the parent reference is invalidInvalidTypeException
- if the node type reference is not recognised- See Also:
-
moveNode
@Auditable(parameters={"nodeToMoveRef","newParentRef","assocTypeQName","assocQName"}) ChildAssociationRef moveNode(NodeRef nodeToMoveRef, NodeRef newParentRef, QName assocTypeQName, QName assocQName) throws InvalidNodeRefException Moves the primary location of the given node.This involves changing the node's primary parent and possibly the name of the association referencing it.
If the new parent is in a different store from the original, then the entire node hierarchy is moved to the new store. Inter-store associations are not affected.
- Parameters:
nodeToMoveRef
- the node to movenewParentRef
- the new parent of the moved nodeassocTypeQName
- the type of the association to create. This is used for verification against the data dictionary.assocQName
- the qualified name of the new child association- Returns:
- Returns a reference to the newly created child association
- Throws:
InvalidNodeRefException
- if either the parent node or move node reference is invalidorg.alfresco.service.cmr.repository.CyclicChildRelationshipException
- if the child partakes in a cyclic relationship after the add- See Also:
-
setChildAssociationIndex
@Auditable(parameters={"childAssocRef","index"}) void setChildAssociationIndex(ChildAssociationRef childAssocRef, int index) throws InvalidChildAssociationRefException Set the ordering index of the child association. This affects the ordering of of the return values of methods that return a set of children or child associations.- Parameters:
childAssocRef
- the child association that must be moved in the orderindex
- an arbitrary index that will affect the return order- Throws:
InvalidChildAssociationRefException
- See Also:
-
getType
- Parameters:
nodeRef
- NodeRef- Returns:
- Returns the type name
- Throws:
InvalidNodeRefException
- if the node could not be found- See Also:
-
setType
@Auditable(parameters={"nodeRef","typeQName"}) void setType(NodeRef nodeRef, QName typeQName) throws InvalidNodeRefException Re-sets the type of the node. Can be called in order specialise a node to a sub-type. This should be used with caution since calling it changes the type of the node and thus implies a different set of aspects, properties and associations. It is the calling codes responsibility to ensure that the node is in a approriate state after changing the type.- Parameters:
nodeRef
- the node referencetypeQName
- the type QName- Throws:
InvalidNodeRefException
- Since:
- 1.1
-
addAspect
@Auditable(parameters={"nodeRef","aspectTypeQName","aspectProperties"}) void addAspect(NodeRef nodeRef, QName aspectTypeQName, Map<QName, Serializable> aspectProperties) throws InvalidNodeRefException, InvalidAspectExceptionApplies an aspect to the given node. After this method has been called, the node with have all the aspect-related properties present- Parameters:
nodeRef
- NodeRefaspectTypeQName
- the aspect to apply to the nodeaspectProperties
- a minimum of the mandatory properties required for the aspect- Throws:
InvalidNodeRefException
InvalidAspectException
- if the class reference is not to a valid aspect- See Also:
-
removeAspect
@Auditable(parameters={"nodeRef","aspectTypeQName"}) void removeAspect(NodeRef nodeRef, QName aspectTypeQName) throws InvalidNodeRefException, InvalidAspectException Remove an aspect and all related properties from a node- Parameters:
nodeRef
- NodeRefaspectTypeQName
- the type of aspect to remove- Throws:
InvalidNodeRefException
- if the node could not be foundInvalidAspectException
- if the the aspect is unknown or if the aspect is mandatory for the class of the node
-
hasAspect
@Auditable(parameters={"nodeRef","aspectTypeQName"}) boolean hasAspect(NodeRef nodeRef, QName aspectTypeQName) throws InvalidNodeRefException, InvalidAspectException Determines if a given aspect is present on a node. Aspects may only be removed if they are NOT mandatory.- Parameters:
nodeRef
- NodeRefaspectTypeQName
- QName- Returns:
- Returns true if the aspect has been applied to the given node, otherwise false
- Throws:
InvalidNodeRefException
- if the node could not be foundInvalidAspectException
- if the aspect reference is invalid
-
getAspects
@Auditable(parameters="nodeRef") Set<QName> getAspects(NodeRef nodeRef) throws InvalidNodeRefException - Parameters:
nodeRef
- NodeRef- Returns:
- Returns a set of all aspects applied to the node, including mandatory aspects
- Throws:
InvalidNodeRefException
- if the node could not be found
-
deleteNode
Deletes the given node.All associations (both children and regular node associations) will be deleted, and where the given node is the primary parent, the children will also be cascade deleted.
Node stores may be mapped to an associated archive node store. For example, Alfresco ships with the mapping
workspace://SpacesStore
.. maps to ..archive://SpacesStore
.
When a node is deleted:- If there *is a mapping* from the node's current store to an archive store, the node is first copied to the archive store
- If there *is no mapping* from the node's current store, then the node is permanently deleted
restore
feature to return a node back to its original store.- Parameters:
nodeRef
- reference to a node within a store- Throws:
InvalidNodeRefException
- if the reference given is invalid
-
addChild
@Auditable(parameters={"parentRef","childRef","assocTypeQName","qname"}) ChildAssociationRef addChild(NodeRef parentRef, NodeRef childRef, QName assocTypeQName, QName qname) throws InvalidNodeRefException Makes a parent-child association between the given nodes. Both nodes must belong to the same store.- Parameters:
parentRef
- the parent nodechildRef
- the child nodeassocTypeQName
- the qualified name of the association type as defined in the datadictionaryqname
- the qualified name of the association- Returns:
- Returns a reference to the newly created child association
- Throws:
InvalidNodeRefException
- if the parent or child nodes could not be foundorg.alfresco.service.cmr.repository.CyclicChildRelationshipException
- if the child partakes in a cyclic relationship after the add
-
addChild
@Auditable(parameters={"parentRefs","childRef","assocTypeQName","qname"}) List<ChildAssociationRef> addChild(Collection<NodeRef> parentRefs, NodeRef childRef, QName assocTypeQName, QName qname) throws InvalidNodeRefException Associates a given child node with a given collection of parents. All nodes must belong to the same store.- Parameters:
parentRefs
- the parent nodes (there will be this many associations created).childRef
- the child nodeassocTypeQName
- the qualified name of the association type as defined in the datadictionaryqname
- the qualified name of the association- Returns:
- Returns a reference to the newly created child association
- Throws:
InvalidNodeRefException
- if the parent or child nodes could not be foundorg.alfresco.service.cmr.repository.CyclicChildRelationshipException
- if the child partakes in a cyclic relationship after the add
-
removeChild
@Auditable(parameters={"parentRef","childRef"}) void removeChild(NodeRef parentRef, NodeRef childRef) throws InvalidNodeRefException Severs all parent-child relationships between two nodes.The child node will be cascade deleted if one of the associations was the primary association, i.e. the one with which the child node was created.
- Parameters:
parentRef
- the parent end of the associationchildRef
- the child end of the association- Throws:
InvalidNodeRefException
- if the parent or child nodes could not be found
-
removeChildAssociation
@Auditable(parameters="childAssocRef") boolean removeChildAssociation(ChildAssociationRef childAssocRef) Remove a specific child association.The child node will be cascade deleted if the association was the primary association, i.e. the one with which the child node was created.
- Parameters:
childAssocRef
- the association to remove- Returns:
- Returns true if the association existed, otherwise false.
-
removeSeconaryChildAssociation
@Auditable(parameters="childAssocRef") boolean removeSeconaryChildAssociation(ChildAssociationRef childAssocRef) Deprecated. -
removeSecondaryChildAssociation
@Auditable(parameters="childAssocRef") boolean removeSecondaryChildAssociation(ChildAssociationRef childAssocRef) Remove a specific secondary child association.- Parameters:
childAssocRef
- the association to remove- Returns:
- Returns true if the association existed, otherwise false.
- Throws:
IllegalArgumentException
- if the association is primary- Since:
- 4.0
-
getProperties
@Auditable(parameters="nodeRef") Map<QName,Serializable> getProperties(NodeRef nodeRef) throws InvalidNodeRefException - Parameters:
nodeRef
- NodeRef- Returns:
- Returns all properties keyed by their qualified name
- Throws:
InvalidNodeRefException
- if the node could not be found
-
getNodeAclId
- Parameters:
nodeRef
- NodeRef- Returns:
- Returns the acl id of the node
- Throws:
InvalidNodeRefException
- if the node could not be found
-
getProperty
@Auditable(parameters={"nodeRef","qname"}) Serializable getProperty(NodeRef nodeRef, QName qname) throws InvalidNodeRefException - Parameters:
nodeRef
- NodeRefqname
- the qualified name of the property- Returns:
- Returns the value of the property, or null if not yet set
- Throws:
InvalidNodeRefException
- if the node could not be found
-
setProperties
@Auditable(parameters={"nodeRef","properties"}) void setProperties(NodeRef nodeRef, Map<QName, Serializable> properties) throws InvalidNodeRefExceptionReplace all current properties on the node with the given properties. The properties given must still fulfill the requirements of the class and aspects relevant to the node.NOTE: Null values are allowed.
- Parameters:
nodeRef
- the node to chanceproperties
- all the properties of the node keyed by their qualified names- Throws:
InvalidNodeRefException
- if the node could not be found
-
addProperties
@Auditable(parameters={"nodeRef","properties"}) void addProperties(NodeRef nodeRef, Map<QName, Serializable> properties) throws InvalidNodeRefExceptionAdd all given properties to the node.NOTE: Null values are allowed and will replace the existing value.
- Parameters:
nodeRef
- the node to changeproperties
- the properties to change, keyed by their qualified names- Throws:
InvalidNodeRefException
- if the node could not be found
-
setProperty
@Auditable(parameters={"nodeRef","qname","value"}) void setProperty(NodeRef nodeRef, QName qname, Serializable value) throws InvalidNodeRefException Sets the value of a property to be anySerializable
instance.NOTE: Null values are allowed.
- Parameters:
nodeRef
- a reference to an existing nodeqname
- the fully qualified name of the propertyvalue
- the value of the property - never null- Throws:
InvalidNodeRefException
- if the node could not be found
-
removeProperty
@Auditable(parameters={"nodeRef","qname"}) void removeProperty(NodeRef nodeRef, QName qname) throws InvalidNodeRefException Removes a property value completely.- Parameters:
nodeRef
- a reference to an existing nodeqname
- the fully qualified name of the property- Throws:
InvalidNodeRefException
- if the node could not be found
-
getParentAssocs
@Auditable(parameters="nodeRef") List<ChildAssociationRef> getParentAssocs(NodeRef nodeRef) throws InvalidNodeRefException - Parameters:
nodeRef
- the child node- Returns:
- Returns a list of all parent-child associations that exist where the given node is the child
- Throws:
InvalidNodeRefException
- if the node could not be found- See Also:
-
getParentAssocs
@Auditable(parameters={"nodeRef","typeQNamePattern","qnamePattern"}) List<ChildAssociationRef> getParentAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) throws InvalidNodeRefException Gets all parent associations where the pattern of the association qualified name is a matchThe resultant list is ordered by (a) explicit index and (b) association creation time.
- Parameters:
nodeRef
- the child nodetypeQNamePattern
- the pattern that the type qualified name of the association must matchqnamePattern
- the pattern that the qnames of the assocs must match- Returns:
- Returns a list of all parent-child associations that exist where the given node is the child
- Throws:
InvalidNodeRefException
- if the node could not be found- See Also:
-
getChildAssocs
@Auditable(parameters="nodeRef") List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef) throws InvalidNodeRefException Get all child associations of the given node.The resultant list is ordered by (a) explicit index and (b) association creation time.
- Parameters:
nodeRef
- the parent node - usually a container- Returns:
- Returns a collection of
ChildAssocRef
instances. If the node is not a container then the result will be empty. - Throws:
InvalidNodeRefException
- if the node could not be found- See Also:
-
getChildAssocs
@Auditable(parameters={"nodeRef","typeQNamePattern","qnamePattern"}) List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) throws InvalidNodeRefException Gets all child associations where the pattern of the association qualified name is a match. Using awildcard
for the type and a specificqualified name
for the association is akin to using the XPath browse expression ./{url}localname in the context of the parent node. Note that all child associations are fetched and preloading is done for all results.- Parameters:
nodeRef
- the parent node - usually a containertypeQNamePattern
- the pattern that the type qualified name of the association must matchqnamePattern
- the pattern that the qnames of the assocs must match- Returns:
- Returns a list of
ChildAssociationRef
instances. If the node is not a container then the result will be empty. - Throws:
InvalidNodeRefException
- if the node could not be found- See Also:
-
getChildAssocs
@Auditable(parameters={"nodeRef","typeQNamePattern","qnamePattern","maxResults","preload"}) List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern, int maxResults, boolean preload) throws InvalidNodeRefException Gets all child associations where the pattern of the association qualified name is an exact match.- Parameters:
nodeRef
- the parent node - usually a containertypeQNamePattern
- the qualified name of the association (null to ignore)qnamePattern
- the path qualified name (null to ignore)maxResults
- the number of results to getpreload
- true if the nodes must be preloaded into the cache- Returns:
- Returns a list of
ChildAssociationRef
instances - Throws:
InvalidNodeRefException
- if the node could not be found- See Also:
-
getChildAssocs
@Auditable(parameters={"nodeRef","typeQNamePattern","qnamePattern"}) List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern, boolean preload) throws InvalidNodeRefException Gets all child associations where the pattern of the association qualified names match the patterns provided. Note that all results are retrieved but preloading is optional.- Parameters:
nodeRef
- the parent node - usually a containertypeQNamePattern
- the qualified name pattern of the associationqnamePattern
- the path qualified name patternpreload
- true if the nodes must be preloaded into the cache- Returns:
- Returns a list of
ChildAssociationRef
instances - Throws:
InvalidNodeRefException
- if the node could not be found- See Also:
-
getChildAssocs
@Auditable(parameters={"nodeRef","childNodeTypes"}) List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, Set<QName> childNodeTypeQNames) Retrieve immediate children of a given node where the child nodes are in the given inclusive list.- Parameters:
nodeRef
- the parent node - usually a containerchildNodeTypeQNames
- the types that the children may be. Subtypes are not automatically calculated and the list must therefore be exhaustive.- Returns:
- Returns a list of
ChildAssociationRef
instances. - Throws:
InvalidNodeRefException
- if the node could not be found
-
getChildAssocsByPropertyValue
@Auditable(parameters={"nodeRef","propertyQName","value"}) List<ChildAssociationRef> getChildAssocsByPropertyValue(NodeRef nodeRef, QName propertyQName, Serializable value) Retrieve the immediate children of a given node based on the value of a property of those children.If the property to be searched is multi-valued then will match on any one values.
Please note, the following system maintained properties that cannot be used with this method.
- cm:name - use getChildByName instead
- cm:created
- cm:creator
- cm:modified
- cm:modifier
- sys:node-uuid
- sys:node-dbid
- sys:store-identifier
- sys:store-protocol
- Parameters:
nodeRef
- the parent node - usually a containerpropertyQName
- the fully qualified name of the propertyvalue
- the value to search for. Must be a simple type such as String, Number, Date or Boolean, it cannot be a collection, a content property, MLText or a float.- Returns:
- Returns a list of
ChildAssociationRef
instances.
-
getChildByName
@Auditable(parameters={"nodeRef","assocTypeQName","childName"}) NodeRef getChildByName(NodeRef nodeRef, QName assocTypeQName, String childName) 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.That API method getChildByName only works for associations that don't allow duplicate child names. See cm:folder and the duplicate tag. Child associations without this allow duplicate child names and therefore it is possible to have multiple children with the same name stored against the given association type.
- Parameters:
nodeRef
- the parent node - usuall a containerassocTypeQName
- the type of the associationchildName
- the name of the node as per the property cm:name- Returns:
- Returns the child node or null if not found
-
getChildrenByName
@Auditable(parameters={"nodeRef","assocTypeQName","childName"}) List<ChildAssociationRef> getChildrenByName(NodeRef nodeRef, QName assocTypeQName, Collection<String> childNames) Get the nodes with the given names within the context of the parent node.- Parameters:
childNames
- a collection of up to 1000 child names to match on- See Also:
-
getPrimaryParent
@Auditable(parameters="nodeRef") ChildAssociationRef getPrimaryParent(NodeRef nodeRef) throws InvalidNodeRefException Fetches the primary parent-child relationship.For a root node, the parent node reference will be null.
- Parameters:
nodeRef
- NodeRef- Returns:
- Returns the primary parent-child association of the node
- Throws:
InvalidNodeRefException
- if the node could not be found
-
getChildAssocsWithoutParentAssocsOfType
@Auditable(parameters={"parent","assocTypeQName"}) Collection<ChildAssociationRef> getChildAssocsWithoutParentAssocsOfType(NodeRef parent, QName assocTypeQName) Gets the set of child associations of a certain parent node without parent associations of a certain type to other nodes with the same parent! In effect the 'orphans' with respect to a certain association type.- Parameters:
parent
- the parent node referenceassocTypeQName
- the association type QName- Returns:
- a set of child associations
-
createAssociation
@Auditable(parameters={"sourceRef","targetRef","assocTypeQName"}) AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) throws InvalidNodeRefException, AssociationExistsException Create a peer association between two nodes. The ordering will be natural. To change association ordering, usesetAssociations
.- Parameters:
sourceRef
- a reference to a real nodetargetRef
- a reference to a nodeassocTypeQName
- the qualified name of the association type- Returns:
- Returns a reference to the new association
- Throws:
InvalidNodeRefException
- if either of the nodes could not be foundAssociationExistsException
- if an association of the same type exists between the nodes- See Also:
-
removeAssociation
@Auditable(parameters={"sourceRef","targetRef","assocTypeQName"}) void removeAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) throws InvalidNodeRefException - Parameters:
sourceRef
- the associaton source nodetargetRef
- the association target nodeassocTypeQName
- the qualified name of the association type- Throws:
InvalidNodeRefException
- if either of the nodes could not be found
-
setAssociations
@Auditable(parameters={"sourceRef","assocTypeQName","targetRefs"}) void setAssociations(NodeRef sourceRef, QName assocTypeQName, List<NodeRef> targetRefs) Re-assign all typed target associations for a given node.- Parameters:
sourceRef
- the source nodeassocTypeQName
- the specific type of the associationtargetRefs
- the target nodes (not null but empty list is accepted).
-
getAssoc
Gets an association by ID.- Parameters:
id
- the association id- Returns:
- the association, or
null
if it does not exist
-
getTargetAssocs
@Auditable(parameters={"sourceRef","qnamePattern"}) List<AssociationRef> getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern) throws InvalidNodeRefException Fetches all associations from the given source where the associations' qualified names match the pattern provided. The results are ordered if a specific type of association is requested- Parameters:
sourceRef
- the association sourceqnamePattern
- the association qname pattern to match against- Returns:
- a list of
NodeAssocRef
instances for which the given node is a source - Throws:
InvalidNodeRefException
- if the source node could not be found- See Also:
-
getTargetAssocsByPropertyValue
@Auditable(parameters={"sourceRef","qnamePattern","propertyQName","propertyValue"}) List<AssociationRef> getTargetAssocsByPropertyValue(NodeRef sourceRef, QNamePattern qnamePattern, QName propertyQName, Serializable propertyValue) Fetches all associations from the given source where the associations' qualified names match the pattern provided. The results are ordered if a specific type of association is requested- Parameters:
sourceRef
- the association sourceqnamePattern
- the association qname pattern to match againstpropertyQName
- the fully qualified name of the property of the association target. Optional parameter - can be null.propertyValue
- association target property value to search for. Must be a simple type such as String, Number, Date or Boolean, it cannot be a collection, a content property, MLText or a float. If propertyQName is null the value is ignored.- Returns:
- a list of
AssociationRef
instances for which the given node is a source - Throws:
InvalidNodeRefException
- if the source node could not beIllegalArgumentException
- if propertyQName is a system maintained property- See Also:
-
getSourceAssocs
@Auditable(parameters={"targetRef","qnamePattern"}) List<AssociationRef> getSourceAssocs(NodeRef targetRef, QNamePattern qnamePattern) throws InvalidNodeRefException Fetches all associations to the given target where the associations' qualified names match the pattern provided.- Parameters:
targetRef
- the association targetqnamePattern
- the association qname pattern to match against- Returns:
- Returns a list of
NodeAssocRef
instances for which the given node is a target - Throws:
InvalidNodeRefException
- See Also:
-
getPath
The root node has an entry in the path(s) returned. For this reason, there will always be at least one path element in the returned path(s). The first element will have a null parent reference and qname.- Parameters:
nodeRef
- NodeRef- Returns:
- Returns the path to the node along the primary node path
- Throws:
InvalidNodeRefException
- if the node could not be found- See Also:
-
getPaths
@Auditable(parameters={"nodeRef","primaryOnly"}) List<Path> getPaths(NodeRef nodeRef, boolean primaryOnly) throws InvalidNodeRefException The root node has an entry in the path(s) returned. For this reason, there will always be at least one path element in the returned path(s). The first element will have a null parent reference and qname.- Parameters:
nodeRef
- NodeRefprimaryOnly
- true if only the primary path must be retrieved. If true, the result will have exactly one entry.- Returns:
- Returns a List of all possible paths to the given node
- Throws:
InvalidNodeRefException
- if the node could not be found
-
getStoreArchiveNode
Get the node where archived items will have gone when deleted from the given store.- Parameters:
storeRef
- the store that items were deleted from- Returns:
- Returns the archive node parent
-
restoreNode
@Auditable(parameters={"archivedNodeRef","destinationParentNodeRef","assocTypeQName","assocQName"}) NodeRef restoreNode(NodeRef archivedNodeRef, NodeRef destinationParentNodeRef, QName assocTypeQName, QName assocQName) Restore an individual node (along with its sub-tree nodes) to the target location. The archived node must have thearchived aspect
set against it. This would have been applied when a node was originallydeleted
.- Parameters:
archivedNodeRef
- the archived nodedestinationParentNodeRef
- the parent to move the node into or null to use the originalassocTypeQName
- the primary association type name to use in the new location or null to use the originalassocQName
- the primary association name to use in the new location or null to use the original- Returns:
- Returns the reference to the newly created node
-
findNodes
-
countChildAssocs
@Auditable(parameters={"nodeRef","isPrimary"}) int countChildAssocs(NodeRef nodeRef, boolean isPrimary) throws InvalidNodeRefException Counts the number of child associations of nodeRef.- Parameters:
nodeRef
- the parent node idisPrimary
- count just primary associations?- Returns:
- Returns the number of child associations
- Throws:
InvalidNodeRefException
-
removeSecondaryChildAssociation(ChildAssociationRef)