Node Service API Design

cancel
Showing results for 
Search instead for 
Did you mean: 

Node Service API Design

resplin
Intermediate
0 0 5,104

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com



Core Repository ServicesNode Service

For up-to-date Node Service documentation, please refer to the NodeServiceImpl API.

Design Considerations


Nodes are Unnamed


  • Nodes are effectively named by path

API Considerations


  • All operations on nodes are specified by reference objects.
  • Nodes and stores are uniquely identified by their Node Handles and Store Protocols
  • A node keeps the same uuid for life
  • Core node types are effectively abstract with the exception of Reference

Basic Node API Methods


Lifecycle Methods


NodeRef createNode(NodeRef parentRef, String name, String nodeType, [Map properties])

Description:

Creates a new, non-abstract node as a primary child of the given parent node.

Parameters:


  • parentRef - the parent node
  • name - the name of the child association between the parent and the new child
  • nodeType - a user defined node type
  • properties - optional map of properties to assign to the node

Result:


  • id of the new node



void deleteNode(NodeRef nodeRef)

Description:

Deletes the given node.

Parameters:


  • nodeRef - reference to a node within a store

Result:





void addChild(NodeRef parentRef, NodeRef childRef, String name)

Description:

Add an existing node as a non-primary child of the given parent.

Parameters:


  • parentRef - the parent node
  • childRef - the child node
  • name - the name of the child association between the parent and the new child

Result:





NodeRef addChildReference(NodeRef parentRef, String refIdOrPath, String name)

Description:

Creates a child reference node.

Parameters:


  • parentRef -
  • refIdOrPath - the reference is soft and must therefore always be a path.  The refId will be resolved to a path but a path may be passed in directly as well.
  • name - the name of the child association between the parent and the new child

Result:


  • reference to the new node



void removeChild(NodeRef parentRef, NodeRef childRef)

Description:

Sever the parent-child relationship.  The removal of the relationship may mandate a deletion of the child node.

Parameters:


  • parentRef -
  • childRef - the ID of the child node to remove

Result:





void removeChildren(NodeRef parentRef, String name)

Description:

Sever the parent-child relationships of the given name and remove any child nodes where the association was primary.

Parameters:


  • parentRef -
  • name - the name of the child relationships to remove

Result:



Metadata Methods


String getType(NodeRef nodeRef)

Description:

Get node type.

Parameters:


  • nodeRef -

Result:


  • The type of the node



Map getProperties(NodeRef nodeRef)

Description:

Get map of all available properties.

Parameters:


  • nodeRef -

Result:


  • Hashmap of all available properties



void setProperties(NodeRef nodeRef, Map properties)

Description:

Set all node properties.  Any properties present on the node but not in the map will be removed.

Parameters:


  • nodeRef -
  • properties - complete list of properties for the node

Result:





Object getProperty(NodeRef nodeRef, String propertyName)

Description:

Get map of all available properties.

Parameters:


  • nodeRef -
  • propertyName -

Result:


  • Raw property value or null if it doesn't exist

Navigation Methods


Collection getParents(NodeRef nodeRef)

Description:

Get list of all parent IDs.

Parameters:


  • nodeRef -

Result:


  • Collection of parent NodeRefs



NodeRef getParent(NodeRef nodeRef, String pathElement)

Description:

Get parent related by specific path element.

Parameters:


  • nodeRef -
  • pathElement - the path element name, i.e. the name by which the child is known to the parent

Result:


  • Reference to the parent node or null if no such relationship exists



NodeRef getPrimaryParent(NodeRef nodeRef)

Description:

Get primary parent.

Parameters:


  • nodeRef -

Result:


  • Reference to the primary parent



String getPath(NodeRef nodeRef)

Description:

Get primary node path to the given node.

Parameters:


  • nodeRef -

Result:


  • full path along the primary node path



List getPaths(NodeRef nodeRef)

Description:

Get all node paths to the given node.

Parameters:


  • nodeRef -

Result:


  • all node paths to the node