org.alfresco.repo.node
Class AbstractNodeServiceImpl

java.lang.Object
  extended by org.alfresco.repo.node.AbstractNodeServiceImpl
All Implemented Interfaces:
NodeService
Direct Known Subclasses:
AVMNodeService, DbNodeServiceImpl

public abstract class AbstractNodeServiceImpl
extends java.lang.Object
implements NodeService

Provides common functionality for NodeService implementations.

Some of the overloaded simpler versions of methods are implemented by passing through the defaults as required.

The callback handling is also provided as a convenience for implementations.


Field Summary
protected  DictionaryService dictionaryService
           
 
Constructor Summary
protected AbstractNodeServiceImpl()
           
 
Method Summary
protected  void addDefaultPropertyValues(ClassDefinition classDefinition, java.util.Map properties)
          Sets the default property values
 boolean equals(java.lang.Object obj)
          Checks equality by type and uuid
protected  java.lang.String generateGuid(java.util.Map preCreationProperties)
          Generates a GUID for the node using either the creation properties or just by generating a value randomly.
 java.util.List getChildAssocs(NodeRef nodeRef)
          Defers to the pattern matching overload
 java.util.List getParentAssocs(NodeRef nodeRef)
          Defers to the pattern matching overload
protected  java.util.Set getTypeAndAspectQNames(NodeRef nodeRef)
          Get all aspect and node type qualified names
 int hashCode()
           
 void init()
          Registers the node policies as well as node indexing behaviour if the indexer is present.
protected  void invokeBeforeAddAspect(NodeRef nodeRef, QName aspectTypeQName)
           
protected  void invokeBeforeCreateChildAssociation(NodeRef parentNodeRef, NodeRef childNodeRef, QName assocTypeQName, QName assocQName, boolean isNewNode)
           
protected  void invokeBeforeCreateNode(NodeRef parentNodeRef, QName assocTypeQName, QName assocQName, QName childNodeTypeQName)
           
protected  void invokeBeforeCreateNodeAssociation(NodeRef parentNodeRef, QName assocTypeQName, QName assocQName)
           
protected  void invokeBeforeCreateStore(QName nodeTypeQName, StoreRef storeRef)
           
protected  void invokeBeforeDeleteChildAssociation(ChildAssociationRef childAssocRef)
           
protected  void invokeBeforeDeleteNode(NodeRef nodeRef)
           
protected  void invokeBeforeRemoveAspect(NodeRef nodeRef, QName aspectTypeQName)
           
protected  void invokeBeforeUpdateNode(NodeRef nodeRef)
           
protected  void invokeOnAddAspect(NodeRef nodeRef, QName aspectTypeQName)
           
protected  void invokeOnCreateAssociation(AssociationRef nodeAssocRef)
           
protected  void invokeOnCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
           
protected  void invokeOnCreateNode(ChildAssociationRef childAssocRef)
           
protected  void invokeOnCreateNodeAssociation(ChildAssociationRef childAssocRef)
           
protected  void invokeOnCreateStore(NodeRef rootNodeRef)
           
protected  void invokeOnDeleteAssociation(AssociationRef nodeAssocRef)
           
protected  void invokeOnDeleteChildAssociation(ChildAssociationRef childAssocRef)
           
protected  void invokeOnDeleteNode(ChildAssociationRef childAssocRef, QName childNodeTypeQName, java.util.Set childAspectQnames, boolean isArchivedNode)
           
protected  void invokeOnMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
           
protected  void invokeOnRemoveAspect(NodeRef nodeRef, QName aspectTypeQName)
           
protected  void invokeOnUpdateNode(NodeRef nodeRef)
           
protected  void invokeOnUpdateProperties(NodeRef nodeRef, java.util.Map before, java.util.Map after)
           
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.
 void setDictionaryService(DictionaryService dictionaryService)
           
 void setPolicyComponent(PolicyComponent policyComponent)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.alfresco.service.cmr.repository.NodeService
addAspect, addChild, createAssociation, createNode, createNode, createStore, deleteNode, exists, exists, getAspects, getChildAssocs, getChildByName, getNodeStatus, getParentAssocs, getPath, getPaths, getPrimaryParent, getProperties, getProperty, getRootNode, getSourceAssocs, getStoreArchiveNode, getStores, getTargetAssocs, getType, hasAspect, moveNode, removeAspect, removeAssociation, removeChild, removeChildAssociation, removeProperty, removeSeconaryChildAssociation, restoreNode, setChildAssociationIndex, setProperties, setProperty, setType
 

Field Detail

dictionaryService

protected DictionaryService dictionaryService
Constructor Detail

AbstractNodeServiceImpl

protected AbstractNodeServiceImpl()
Method Detail

setPolicyComponent

public void setPolicyComponent(PolicyComponent policyComponent)

setDictionaryService

public void setDictionaryService(DictionaryService dictionaryService)

equals

public boolean equals(java.lang.Object obj)
Checks equality by type and uuid

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
AbstractNodeServiceImpl.uuid

init

public void init()
Registers the node policies as well as node indexing behaviour if the indexer is present.


invokeBeforeCreateStore

protected void invokeBeforeCreateStore(QName nodeTypeQName,
                                       StoreRef storeRef)
See Also:
NodeServicePolicies.BeforeCreateStorePolicy.beforeCreateStore(QName, StoreRef)

invokeOnCreateStore

protected void invokeOnCreateStore(NodeRef rootNodeRef)
See Also:
NodeServicePolicies.OnCreateStorePolicy.onCreateStore(NodeRef)

invokeBeforeCreateNode

protected void invokeBeforeCreateNode(NodeRef parentNodeRef,
                                      QName assocTypeQName,
                                      QName assocQName,
                                      QName childNodeTypeQName)
See Also:
NodeServicePolicies.BeforeCreateNodePolicy.beforeCreateNode(NodeRef, QName, QName, QName)

invokeOnCreateNode

protected void invokeOnCreateNode(ChildAssociationRef childAssocRef)
See Also:
NodeServicePolicies.OnCreateNodePolicy.onCreateNode(ChildAssociationRef)

invokeOnMoveNode

protected void invokeOnMoveNode(ChildAssociationRef oldChildAssocRef,
                                ChildAssociationRef newChildAssocRef)
See Also:
NodeServicePolicies.OnMoveNodePolicy.onMoveNode(ChildAssociationRef, ChildAssociationRef)

invokeBeforeUpdateNode

protected void invokeBeforeUpdateNode(NodeRef nodeRef)
See Also:
NodeServicePolicies.BeforeUpdateNodePolicy.beforeUpdateNode(NodeRef)

invokeOnUpdateNode

protected void invokeOnUpdateNode(NodeRef nodeRef)
See Also:
NodeServicePolicies.OnUpdateNodePolicy.onUpdateNode(NodeRef)

invokeOnUpdateProperties

protected void invokeOnUpdateProperties(NodeRef nodeRef,
                                        java.util.Map before,
                                        java.util.Map after)
See Also:
NodeServicePolicies.OnUpdateProperties#onUpdatePropertiesPolicy(NodeRef, Map, Map)

invokeBeforeDeleteNode

protected void invokeBeforeDeleteNode(NodeRef nodeRef)
See Also:
NodeServicePolicies.BeforeDeleteNodePolicy.beforeDeleteNode(NodeRef)

invokeOnDeleteNode

protected void invokeOnDeleteNode(ChildAssociationRef childAssocRef,
                                  QName childNodeTypeQName,
                                  java.util.Set childAspectQnames,
                                  boolean isArchivedNode)
See Also:
NodeServicePolicies.OnDeleteNodePolicy#onDeleteNode(ChildAssociationRef)

invokeBeforeAddAspect

protected void invokeBeforeAddAspect(NodeRef nodeRef,
                                     QName aspectTypeQName)
See Also:
NodeServicePolicies.BeforeAddAspectPolicy.beforeAddAspect(NodeRef, QName)

invokeOnAddAspect

protected void invokeOnAddAspect(NodeRef nodeRef,
                                 QName aspectTypeQName)
See Also:
NodeServicePolicies.OnAddAspectPolicy.onAddAspect(NodeRef, QName)

invokeBeforeRemoveAspect

protected void invokeBeforeRemoveAspect(NodeRef nodeRef,
                                        QName aspectTypeQName)
See Also:
NodeServicePolicies.BeforeRemoveAspectPolicy#BeforeRemoveAspect(NodeRef, QName)

invokeOnRemoveAspect

protected void invokeOnRemoveAspect(NodeRef nodeRef,
                                    QName aspectTypeQName)
See Also:
NodeServicePolicies.OnRemoveAspectPolicy.onRemoveAspect(NodeRef, QName)

invokeBeforeCreateNodeAssociation

protected void invokeBeforeCreateNodeAssociation(NodeRef parentNodeRef,
                                                 QName assocTypeQName,
                                                 QName assocQName)
See Also:
NodeServicePolicies.BeforeCreateNodeAssociationPolicy#beforeCreateChildAssociation(NodeRef, NodeRef, QName, QName)

invokeOnCreateNodeAssociation

protected void invokeOnCreateNodeAssociation(ChildAssociationRef childAssocRef)
See Also:
NodeServicePolicies.OnCreateNodeAssociationPolicy#onCreateChildAssociation(ChildAssociationRef)

invokeBeforeCreateChildAssociation

protected void invokeBeforeCreateChildAssociation(NodeRef parentNodeRef,
                                                  NodeRef childNodeRef,
                                                  QName assocTypeQName,
                                                  QName assocQName,
                                                  boolean isNewNode)
See Also:
NodeServicePolicies.BeforeCreateChildAssociationPolicy#beforeCreateChildAssociation(NodeRef, NodeRef, QName, QName)

invokeOnCreateChildAssociation

protected void invokeOnCreateChildAssociation(ChildAssociationRef childAssocRef,
                                              boolean isNewNode)
See Also:
NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(ChildAssociationRef)

invokeBeforeDeleteChildAssociation

protected void invokeBeforeDeleteChildAssociation(ChildAssociationRef childAssocRef)
See Also:
NodeServicePolicies.BeforeDeleteChildAssociationPolicy.beforeDeleteChildAssociation(ChildAssociationRef)

invokeOnDeleteChildAssociation

protected void invokeOnDeleteChildAssociation(ChildAssociationRef childAssocRef)
See Also:
NodeServicePolicies.OnDeleteChildAssociationPolicy.onDeleteChildAssociation(ChildAssociationRef)

invokeOnCreateAssociation

protected void invokeOnCreateAssociation(AssociationRef nodeAssocRef)
See Also:
NodeServicePolicies.OnCreateAssociationPolicy#onCreateAssociation(NodeRef, NodeRef, QName)

invokeOnDeleteAssociation

protected void invokeOnDeleteAssociation(AssociationRef nodeAssocRef)
See Also:
NodeServicePolicies.OnDeleteAssociationPolicy.onDeleteAssociation(AssociationRef)

getTypeAndAspectQNames

protected java.util.Set getTypeAndAspectQNames(NodeRef nodeRef)
Get all aspect and node type qualified names

Parameters:
nodeRef - the node we are interested in
Returns:
Returns a set of qualified names containing the node type and all the node aspects, or null if the node no longer exists

generateGuid

protected java.lang.String generateGuid(java.util.Map preCreationProperties)
Generates a GUID for the node using either the creation properties or just by generating a value randomly.

Parameters:
preCreationProperties - the properties that will be applied to the node
Returns:
Returns the ID to create the node with

getParentAssocs

public java.util.List getParentAssocs(NodeRef nodeRef)
                               throws InvalidNodeRefException
Defers to the pattern matching overload

Specified by:
getParentAssocs in interface NodeService
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:
RegexQNamePattern.MATCH_ALL, NodeService.getParentAssocs(NodeRef, QNamePattern, QNamePattern)

getChildAssocs

public java.util.List getChildAssocs(NodeRef nodeRef)
                              throws InvalidNodeRefException
Defers to the pattern matching overload

Specified by:
getChildAssocs in interface NodeService
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:
RegexQNamePattern.MATCH_ALL, NodeService.getChildAssocs(NodeRef, QNamePattern, QNamePattern)

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

addDefaultPropertyValues

protected void addDefaultPropertyValues(ClassDefinition classDefinition,
                                        java.util.Map properties)
Sets the default property values

Parameters:
classDefinition - the model type definition for which to get defaults
properties - the properties of the node


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