org.alfresco.repo.avm
Class AVMNodeService

java.lang.Object
  extended by org.alfresco.repo.node.AbstractNodeServiceImpl
      extended by org.alfresco.repo.avm.AVMNodeService
All Implemented Interfaces:
NodeService

public class AVMNodeService
extends AbstractNodeServiceImpl
implements NodeService

NodeService implementing facade over AVMService.


Field Summary
 
Fields inherited from class org.alfresco.repo.node.AbstractNodeServiceImpl
dictionaryService, storesToIgnorePolicies, tenantService, transactionService
 
Constructor Summary
AVMNodeService()
          Default constructor.
 
Method Summary
 void addAspect(NodeRef nodeRef, QName aspectTypeQName, java.util.Map aspectProperties)
          Applies an aspect to the given node.
 java.util.List addChild(java.util.Collection parentRefs, NodeRef childRef, QName assocTypeQName, QName qname)
          Associates a given child node with a given collection of parents.
 ChildAssociationRef addChild(NodeRef parentRef, NodeRef childRef, QName assocTypeQName, QName qname)
          Makes a parent-child association between the given nodes.
 void addProperties(NodeRef nodeRef, java.util.Map properties)
          Add all given properties to the node.
 AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName)
           
 ChildAssociationRef createNode(NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName)
           
 ChildAssociationRef createNode(NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName, java.util.Map properties)
          Creates a new, non-abstract, real node as a primary child of the given parent node.
 StoreRef createStore(java.lang.String protocol, java.lang.String identifier)
          Create a new AVM store.
 void deleteNode(NodeRef nodeRef)
          Deletes the given node.
 void deleteStore(StoreRef storeRef)
          Delete a store and all its contents.
 boolean exists(NodeRef nodeRef)
           
 boolean exists(StoreRef storeRef)
          Does the indicated store exist?
 java.util.Set getAspects(NodeRef nodeRef)
           
 AssociationRef getAssoc(java.lang.Long id)
          Gets an association by ID.
 java.util.List getChildAssocs(NodeRef nodeRef)
          Get all child associations of the given node.
 java.util.List getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern)
          Gets all child associations where the pattern of the association qualified name is a match.
 java.util.List getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern, boolean preload)
          Gets all child associations where the pattern of the association qualified name is a match.
 java.util.List getChildAssocs(NodeRef nodeRef, java.util.Set childNodeTypes)
          Retrieve immediate children of a given node where the child nodes are in the given inclusive list and not in the given exclusive list.
 java.util.Collection 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.
 NodeRef getChildByName(NodeRef nodeRef, QName assocTypeQName, java.lang.String childName)
          Get a child NodeRef by name.
 java.util.List getChildrenByName(NodeRef nodeRef, QName assocTypeQName, java.util.Collection childNames)
          Get the nodes with the given names within the context of the parent node.
 NodeRef.Status getNodeStatus(NodeRef nodeRef)
          Gets the ID of the last transaction that caused the node to change.
 java.util.List getParentAssocs(NodeRef nodeRef)
          Defers to the pattern matching overload
 java.util.List getParentAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern)
          Gets all parent associations where the pattern of the association qualified name is a match
 Path getPath(NodeRef nodeRef)
          The root node has an entry in the path(s) returned.
 java.util.List getPaths(NodeRef nodeRef, boolean primaryOnly)
          The root node has an entry in the path(s) returned.
 ChildAssociationRef getPrimaryParent(NodeRef nodeRef)
          Fetches the primary parent-child relationship.
 java.util.Map getProperties(NodeRef nodeRef)
           
 java.io.Serializable getProperty(NodeRef nodeRef, QName qname)
           
 NodeRef getRootNode(StoreRef storeRef)
           
 java.util.List getSourceAssocs(NodeRef targetRef, QNamePattern qnamePattern)
          Fetches all associations to the given target where the associations' qualified names match the pattern provided.
 NodeRef getStoreArchiveNode(StoreRef storeRef)
          Get the node where archived items will have gone when deleted from the given store.
 java.util.List getStores()
          Gets a list of all available node store references
 java.util.List getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern)
          Fetches all associations from the given source where the associations' qualified names match the pattern provided.
 QName getType(NodeRef nodeRef)
           
 boolean hasAspect(NodeRef nodeRef, QName aspectTypeQName)
          Determines if a given aspect is present on a node.
protected  PropertyValue makePropertyValue(PropertyDefinition propertyDef, java.io.Serializable value)
          Helper method to convert the Serializable value into a full, persistable PropertyValue.
protected  java.io.Serializable makeSerializableValue(PropertyDefinition propertyDef, PropertyValue propertyValue)
          Extracts the externally-visible property from the propertyValue.
 ChildAssociationRef moveNode(NodeRef nodeToMoveRef, NodeRef newParentRef, QName assocTypeQName, QName assocQName)
          Moves the primary location of the given node.
 void removeAspect(NodeRef nodeRef, QName aspectTypeQName)
          Remove an aspect and all related properties from a node
 void 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)
          TODO: Check implementation
 void removeProperty(NodeRef nodeRef, QName qname)
          Removes a property value completely.
 boolean removeSeconaryChildAssociation(ChildAssociationRef childAssocRef)
          TODO: Implement
 NodeRef restoreNode(NodeRef archivedNodeRef, NodeRef destinationParentNodeRef, QName assocTypeQName, QName assocQName)
          Restore an individual node (along with its sub-tree nodes) to the target location.
 void setAvmService(AVMService service)
          Set the AVMService.
 void setChildAssociationIndex(ChildAssociationRef childAssocRef, int index)
          Set the ordering index of the child association.
 void setInvokePolicies(boolean invoke)
           
 void setProperties(NodeRef nodeRef, java.util.Map properties)
          Set the values of all properties to be an Serializable instances.
 void setProperty(NodeRef nodeRef, QName qname, java.io.Serializable value)
          Sets the value of a property to be any Serializable instance.
 void setType(NodeRef nodeRef, QName typeQName)
          Re-sets the type of the node.
 
Methods inherited from class org.alfresco.repo.node.AbstractNodeServiceImpl
equals, generateGuid, getDefaultProperties, getDefaultProperties, getTypeAndAspectQNames, hashCode, init, invokeBeforeAddAspect, invokeBeforeCreateChildAssociation, invokeBeforeCreateNode, invokeBeforeCreateNodeAssociation, invokeBeforeCreateStore, invokeBeforeDeleteChildAssociation, invokeBeforeDeleteNode, invokeBeforeRemoveAspect, invokeBeforeUpdateNode, invokeOnAddAspect, invokeOnCreateAssociation, invokeOnCreateChildAssociation, invokeOnCreateNode, invokeOnCreateNodeAssociation, invokeOnCreateStore, invokeOnDeleteAssociation, invokeOnDeleteChildAssociation, invokeOnDeleteNode, invokeOnMoveNode, invokeOnRemoveAspect, invokeOnUpdateNode, invokeOnUpdateProperties, setDictionaryService, setPolicyComponent, setStoresToIgnorePolicies, setTenantService, setTransactionService
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AVMNodeService

public AVMNodeService()
Default constructor.

Method Detail

setAvmService

public void setAvmService(AVMService service)
Set the AVMService. For Spring.

Parameters:
service - The AVMService instance.

setInvokePolicies

public void setInvokePolicies(boolean invoke)

makePropertyValue

protected PropertyValue makePropertyValue(PropertyDefinition propertyDef,
                                          java.io.Serializable value)
Helper method to convert the Serializable value into a full, persistable PropertyValue.

Where the property definition is null, the value will take on the generic ANY value.

Where the property definition specifies a multi-valued property but the value provided is not a collection, the value will be wrapped in a collection.

Parameters:
propertyDef - the property dictionary definition, may be null
value - the value, which will be converted according to the definition - may be null
Returns:
Returns the persistable property value

makeSerializableValue

protected java.io.Serializable makeSerializableValue(PropertyDefinition propertyDef,
                                                     PropertyValue propertyValue)
Extracts the externally-visible property from the propertyValue.

Parameters:
propertyDef - the model property definition - may be null
propertyValue - the persisted property
Returns:
Returns the value of the property in the format dictated by the property definition, or null if the property value is null

getStores

public java.util.List getStores()
Gets a list of all available node store references

Specified by:
getStores in interface NodeService
Returns:
Returns a list of store references

createStore

public StoreRef createStore(java.lang.String protocol,
                            java.lang.String identifier)
                     throws StoreExistsException
Create a new AVM store.

Specified by:
createStore in interface NodeService
Parameters:
protocol - the implementation protocol
identifier - the protocol-specific identifier
Returns:
Returns a reference to the store
Throws:
StoreExistsException

deleteStore

public void deleteStore(StoreRef storeRef)
                 throws InvalidStoreRefException
Description copied from interface: NodeService
Delete a store and all its contents.

Specified by:
deleteStore in interface NodeService
Parameters:
storeRef - the store to delete
Throws:
java.lang.UnsupportedOperationException - Always
InvalidStoreRefException - if the store reference is invalid

exists

public boolean exists(StoreRef storeRef)
Does the indicated store exist?

Specified by:
exists in interface NodeService
Parameters:
storeRef - a reference to the store to look for
Returns:
Returns true if the store exists, otherwise false

exists

public boolean exists(NodeRef nodeRef)
Specified by:
exists in interface NodeService
Parameters:
nodeRef - a reference to the node to look for
Returns:
Returns true if the node exists, otherwise false

getNodeStatus

public NodeRef.Status getNodeStatus(NodeRef nodeRef)
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.

Specified by:
getNodeStatus in interface NodeService
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

getRootNode

public NodeRef getRootNode(StoreRef storeRef)
                    throws InvalidStoreRefException
Specified by:
getRootNode in interface NodeService
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

createNode

public ChildAssociationRef createNode(NodeRef parentRef,
                                      QName assocTypeQName,
                                      QName assocQName,
                                      QName nodeTypeQName)
                               throws InvalidNodeRefException,
                                      InvalidTypeException
Specified by:
createNode in interface NodeService
Throws:
InvalidNodeRefException
InvalidTypeException
See Also:
AVMNodeService.createNode(NodeRef, QName, QName, QName, Map)

createNode

public ChildAssociationRef createNode(NodeRef parentRef,
                                      QName assocTypeQName,
                                      QName assocQName,
                                      QName nodeTypeQName,
                                      java.util.Map properties)
                               throws InvalidNodeRefException,
                                      InvalidTypeException
Creates a new, non-abstract, real node as a primary child of the given parent node.

Specified by:
createNode in interface NodeService
Parameters:
parentRef - the parent node
assocTypeQName - the type of the association to create. This is used for verification against the data dictionary.
assocQName - the qualified name of the association
nodeTypeQName - a reference to the node type
properties - 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 invalid
InvalidTypeException - if the node type reference is not recognised
See Also:
DictionaryService

moveNode

public 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.

Specified by:
moveNode in interface NodeService
Parameters:
nodeToMoveRef - the node to move
newParentRef - the new parent of the moved node
assocTypeQName - 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 invalid
CyclicChildRelationshipException - if the child partakes in a cyclic relationship after the add
See Also:
AVMNodeService.getPrimaryParent(NodeRef)

setChildAssociationIndex

public 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.

Specified by:
setChildAssociationIndex in interface NodeService
Parameters:
childAssocRef - the child association that must be moved in the order
index - an arbitrary index that will affect the return order
Throws:
InvalidChildAssociationRefException
See Also:
AVMNodeService.getChildAssocs(NodeRef), AVMNodeService.getChildAssocs(NodeRef, QNamePattern, QNamePattern), ChildAssociationRef.getNthSibling()

getType

public QName getType(NodeRef nodeRef)
              throws InvalidNodeRefException
Specified by:
getType in interface NodeService
Parameters:
nodeRef -
Returns:
Returns the type name
Throws:
InvalidNodeRefException - if the node could not be found
See Also:
DictionaryService

setType

public 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.

Specified by:
setType in interface NodeService
Parameters:
nodeRef - the node reference
typeQName - the type QName
Throws:
InvalidNodeRefException
Since:
1.1

addAspect

public void addAspect(NodeRef nodeRef,
                      QName aspectTypeQName,
                      java.util.Map aspectProperties)
               throws InvalidNodeRefException,
                      InvalidAspectException
Applies an aspect to the given node. After this method has been called, the node with have all the aspect-related properties present

Specified by:
addAspect in interface NodeService
Parameters:
nodeRef -
aspectTypeQName - the aspect to apply to the node
aspectProperties - 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:
DictionaryService.getAspect(QName), ClassDefinition.getProperties()

removeAspect

public void removeAspect(NodeRef nodeRef,
                         QName aspectTypeQName)
                  throws InvalidNodeRefException,
                         InvalidAspectException
Remove an aspect and all related properties from a node

Specified by:
removeAspect in interface NodeService
Parameters:
nodeRef -
aspectTypeQName - the type of aspect to remove
Throws:
InvalidNodeRefException - if the node could not be found
InvalidAspectException - if the the aspect is unknown or if the aspect is mandatory for the class of the node

hasAspect

public 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.

Specified by:
hasAspect in interface NodeService
Parameters:
nodeRef -
aspectTypeQName -
Returns:
Returns true if the aspect has been applied to the given node, otherwise false
Throws:
InvalidNodeRefException - if the node could not be found
InvalidAspectException - if the aspect reference is invalid

getAspects

public java.util.Set getAspects(NodeRef nodeRef)
                         throws InvalidNodeRefException
Specified by:
getAspects in interface NodeService
Parameters:
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

public void deleteNode(NodeRef nodeRef)
                throws InvalidNodeRefException
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.

Specified by:
deleteNode in interface NodeService
Parameters:
nodeRef - reference to a node within a store
Throws:
InvalidNodeRefException - if the reference given is invalid

addChild

public 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.

Specified by:
addChild in interface NodeService
Parameters:
parentRef -
childRef -
assocTypeQName - the qualified name of the association type as defined in the datadictionary
qname - 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 found
CyclicChildRelationshipException - if the child partakes in a cyclic relationship after the add

addChild

public java.util.List addChild(java.util.Collection 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.

Specified by:
addChild in interface NodeService
Parameters:
parentRefs -
childRef -
assocTypeQName - the qualified name of the association type as defined in the datadictionary
qname - 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 found
CyclicChildRelationshipException - if the child partakes in a cyclic relationship after the add

removeChild

public 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.

Specified by:
removeChild in interface NodeService
Parameters:
parentRef - the parent end of the association
childRef - the child end of the association
Throws:
InvalidNodeRefException - if the parent or child nodes could not be found

removeChildAssociation

public boolean removeChildAssociation(ChildAssociationRef childAssocRef)
TODO: Check implementation

Specified by:
removeChildAssociation in interface NodeService
Parameters:
childAssocRef - the association to remove
Returns:
Returns true if the association existed, otherwise false.

removeSeconaryChildAssociation

public boolean removeSeconaryChildAssociation(ChildAssociationRef childAssocRef)
TODO: Implement

Specified by:
removeSeconaryChildAssociation in interface NodeService
Parameters:
childAssocRef - the association to remove
Returns:
Returns true if the association existed, otherwise false.

getProperties

public java.util.Map getProperties(NodeRef nodeRef)
                            throws InvalidNodeRefException
Specified by:
getProperties in interface NodeService
Parameters:
nodeRef -
Returns:
Returns all properties keyed by their qualified name
Throws:
InvalidNodeRefException - if the node could not be found

getProperty

public java.io.Serializable getProperty(NodeRef nodeRef,
                                        QName qname)
                                 throws InvalidNodeRefException
Specified by:
getProperty in interface NodeService
Parameters:
nodeRef -
qname - 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

removeProperty

public void removeProperty(NodeRef nodeRef,
                           QName qname)
                    throws InvalidNodeRefException
Removes a property value completely.

Specified by:
removeProperty in interface NodeService
Parameters:
nodeRef - a reference to an existing node
qname - the fully qualified name of the property
Throws:
InvalidNodeRefException - if the node could not be found

setProperties

public void setProperties(NodeRef nodeRef,
                          java.util.Map properties)
                   throws InvalidNodeRefException
Set the values of all properties to be an Serializable instances. The properties given must still fulfill the requirements of the class and aspects relevant to the node.

NOTE: Null values are allowed.

Specified by:
setProperties in interface NodeService
Parameters:
nodeRef -
properties - all the properties of the node keyed by their qualified names
Throws:
InvalidNodeRefException - if the node could not be found

addProperties

public void addProperties(NodeRef nodeRef,
                          java.util.Map properties)
Description copied from interface: NodeService
Add all given properties to the node.

NOTE: Null values are allowed and will replace the existing value.

Specified by:
addProperties in interface NodeService
Parameters:
nodeRef - the node to change
properties - the properties to change, keyed by their qualified names

setProperty

public void setProperty(NodeRef nodeRef,
                        QName qname,
                        java.io.Serializable value)
                 throws InvalidNodeRefException
Sets the value of a property to be any Serializable instance. To remove a property value, use AVMNodeService.getProperties(NodeRef), remove the value and call AVMNodeService.setProperties(NodeRef, Map).

NOTE: Null values are allowed.

Specified by:
setProperty in interface NodeService
Parameters:
nodeRef -
qname - the fully qualified name of the property
propertyValue - the value of the property - never null
Throws:
InvalidNodeRefException - if the node could not be found

getParentAssocs

public java.util.List getParentAssocs(NodeRef nodeRef)
                               throws InvalidNodeRefException
Description copied from class: AbstractNodeServiceImpl
Defers to the pattern matching overload

Specified by:
getParentAssocs in interface NodeService
Overrides:
getParentAssocs in class AbstractNodeServiceImpl
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:
AVMNodeService.getParentAssocs(NodeRef, QNamePattern, QNamePattern)

getParentAssocs

public java.util.List getParentAssocs(NodeRef nodeRef,
                                      QNamePattern typeQNamePattern,
                                      QNamePattern qnamePattern)
                               throws InvalidNodeRefException
Gets all parent associations where the pattern of the association qualified name is a match

The resultant list is ordered by (a) explicit index and (b) association creation time.

Specified by:
getParentAssocs in interface NodeService
Parameters:
nodeRef - the child node
typeQNamePattern - the pattern that the type qualified name of the association must match
qnamePattern - 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:
ChildAssociationRef.getNthSibling(), AVMNodeService.setChildAssociationIndex(ChildAssociationRef, int), QName, RegexQNamePattern.MATCH_ALL

getChildAssocs

public java.util.List 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.

Specified by:
getChildAssocs in interface NodeService
Overrides:
getChildAssocs in class AbstractNodeServiceImpl
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:
AVMNodeService.getChildAssocs(NodeRef, QNamePattern, QNamePattern), AVMNodeService.setChildAssociationIndex(ChildAssociationRef, int), ChildAssociationRef.getNthSibling()

getChildAssocs

public java.util.List getChildAssocs(NodeRef nodeRef,
                                     QNamePattern typeQNamePattern,
                                     QNamePattern qnamePattern)
                              throws InvalidNodeRefException
Gets all child associations where the pattern of the association qualified name is a match.

Specified by:
getChildAssocs in interface NodeService
Parameters:
nodeRef - the parent node - usually a container
typeQNamePattern - the pattern that the type qualified name of the association must match
qnamePattern - the pattern that the qnames of the assocs must match
Returns:
Returns a list 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:
QName, RegexQNamePattern.MATCH_ALL

getChildAssocs

public java.util.List getChildAssocs(NodeRef nodeRef,
                                     QNamePattern typeQNamePattern,
                                     QNamePattern qnamePattern,
                                     boolean preload)
                              throws InvalidNodeRefException
Description copied from interface: NodeService
Gets all child associations where the pattern of the association qualified name is a match. Using a wildcard for the type and a specific qualified name for the association is akin to using the XPath browse expression ./{url}localname in the context of the parent node.

Specified by:
getChildAssocs in interface NodeService
Parameters:
nodeRef - the parent node - usually a container
typeQNamePattern - the pattern that the type qualified name of the association must match
qnamePattern - the pattern that the qnames of the assocs must match
preload - should the nodes be preloaded into the cache?
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:
QName, RegexQNamePattern.MATCH_ALL

getChildAssocs

public java.util.List getChildAssocs(NodeRef nodeRef,
                                     java.util.Set childNodeTypes)
Description copied from interface: NodeService
Retrieve immediate children of a given node where the child nodes are in the given inclusive list and not in the given exclusive list.

Specified by:
getChildAssocs in interface NodeService
Parameters:
nodeRef - the parent node - usually a container
Returns:
Returns a list of ChildAssociationRef instances.

getChildrenByName

public java.util.List getChildrenByName(NodeRef nodeRef,
                                        QName assocTypeQName,
                                        java.util.Collection childNames)
Description copied from interface: NodeService
Get the nodes with the given names within the context of the parent node.

Specified by:
getChildrenByName in interface NodeService
childNames - a collection of up to 1000 child names to match on
See Also:
#getChildByName(NodeRef, QName, String)}

getChildByName

public NodeRef getChildByName(NodeRef nodeRef,
                              QName assocTypeQName,
                              java.lang.String childName)
Get a child NodeRef by name.

Specified by:
getChildByName in interface NodeService
Parameters:
nodeRef - The parent node.
assocTypeQName - The type of the Child Association.
childName - The name of the child to get.
Returns:
Returns the child node or null if not found

getPrimaryParent

public ChildAssociationRef getPrimaryParent(NodeRef nodeRef)
                                     throws InvalidNodeRefException
Fetches the primary parent-child relationship.

For a root node, the parent node reference will be null.

Specified by:
getPrimaryParent in interface NodeService
Parameters:
nodeRef -
Returns:
Returns the primary parent-child association of the node
Throws:
InvalidNodeRefException - if the node could not be found

createAssociation

public AssociationRef createAssociation(NodeRef sourceRef,
                                        NodeRef targetRef,
                                        QName assocTypeQName)
                                 throws InvalidNodeRefException,
                                        AssociationExistsException
Specified by:
createAssociation in interface NodeService
Parameters:
sourceRef - a reference to a real node
targetRef - a reference to a node
assocTypeQName - 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 found
AssociationExistsException

removeAssociation

public void removeAssociation(NodeRef sourceRef,
                              NodeRef targetRef,
                              QName assocTypeQName)
                       throws InvalidNodeRefException
Specified by:
removeAssociation in interface NodeService
Parameters:
sourceRef - the associaton source node
targetRef - the association target node
assocTypeQName - the qualified name of the association type
Throws:
InvalidNodeRefException - if either of the nodes could not be found

getAssoc

public AssociationRef getAssoc(java.lang.Long id)
Gets an association by ID.

Specified by:
getAssoc in interface NodeService
Parameters:
assocId - the association id
Returns:
the association, or null if it does not exist

getTargetAssocs

public java.util.List getTargetAssocs(NodeRef sourceRef,
                                      QNamePattern qnamePattern)
                               throws InvalidNodeRefException
Fetches all associations from the given source where the associations' qualified names match the pattern provided.

Specified by:
getTargetAssocs in interface NodeService
Parameters:
sourceRef - the association source
qnamePattern - the association qname pattern to match against
Returns:
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:
QName, RegexQNamePattern.MATCH_ALL

getSourceAssocs

public java.util.List getSourceAssocs(NodeRef targetRef,
                                      QNamePattern qnamePattern)
                               throws InvalidNodeRefException
Fetches all associations to the given target where the associations' qualified names match the pattern provided.

Specified by:
getSourceAssocs in interface NodeService
Parameters:
targetRef - the association target
qnamePattern - 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:
QName, RegexQNamePattern.MATCH_ALL

getPath

public Path getPath(NodeRef nodeRef)
             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.

Specified by:
getPath in interface NodeService
Parameters:
nodeRef -
Returns:
Returns the path to the node along the primary node path
Throws:
InvalidNodeRefException - if the node could not be found
See Also:
AVMNodeService.getPaths(NodeRef, boolean)

getPaths

public java.util.List 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.

Specified by:
getPaths in interface NodeService
Parameters:
nodeRef -
primaryOnly - 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

public NodeRef getStoreArchiveNode(StoreRef storeRef)
Get the node where archived items will have gone when deleted from the given store.

Specified by:
getStoreArchiveNode in interface NodeService
Parameters:
storeRef - the store that items were deleted from
Returns:
Returns the archive node parent

restoreNode

public 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 the archived aspect set against it.

Specified by:
restoreNode in interface NodeService
Parameters:
archivedNodeRef - the archived node
destinationParentNodeRef - the parent to move the node into or null to use the original
assocTypeQName - the primary association type name to use in the new location or null to use the original
assocQName - 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

getChildAssocsWithoutParentAssocsOfType

public java.util.Collection getChildAssocsWithoutParentAssocsOfType(NodeRef parent,
                                                                    QName assocTypeQName)
Description copied from interface: NodeService
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.

Specified by:
getChildAssocsWithoutParentAssocsOfType in interface NodeService
Parameters:
parent - the parent node reference
assocTypeQName - the association type QName
Returns:
a set of child associations


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.