© 2005 BEA Systems, Inc.

com.bea.content.spi
Interface NodeOps

All Superinterfaces:
Serializable
All Known Implementing Classes:
NodeOpsImpl

public interface NodeOps
extends Serializable

NodeOps is a service for Node CRUD operations. It is used to manage nodes, including their Properties, in a content repository.

NodeOps rules are defined below.

All nodes are uniquely identified through:

  • 1) their ID, which contains the uid that uniquely identifies it within the repository. This uid may be the path, a database id, etc.
  • 2) their path that uniquely identifies it within a repository. The path should be in unix-like format such as /a/b/c where / is the root and a is the root's child. The path must always begin with / and never end with it. So neither of the following are valid: a/b/c/d or /a/b/d/d/.

    All Properties are identified through their ID, which includes the uid that uniquely identifies the Property in the repository.

    A Node may either be a Content Node or a Hierarchy Node as defined by its type. A Hierarchy Node may contain both Hierarchy and Content Nodes, but a Conent Node may only contain other Content Nodes.

    Node names must not contain either forward, or backslashes.

    If a node contains an ObjectClass, it will also contain a Property for each PropertyDefinition of its ObjectClass and each Property will be in the shape as defined by its corresponding PropertyDefinition.

    Most operations use ID objects as parameters. Whenever an ID is used, it must not be null. The uid may be null when dealing with root. For example a call to getNodeChildren(ID id) with a correct repository name and a null uid will return all Nodes at root for that repository. It may also be null on create operations, in which the uid has not been created yet, but will be created and returned by the repository.

    The repository implementation may have more specific validation rules than that defined above. If a repository considers an attempted operation invalid, it will throw a RepositoryException.

    If a Node has an ObjectClass associated with it, whenever it is retrieved it must contain the ObjectClass. However, the Node Properties need not be present as they may be lazy loaded by the call to getProperties() on the Node. For the getNode implementations, it is best to initially set the Properties on the return.


    Method Summary
     Node addNodeContent(ID nodeId, ID objectClassId, Property[] properties)
              Updates the node with the given id to contain the given objectClass and properties (content and meta-content).
     Node copyNode(ID sourceId, ID destinationId)
              This method copies a Node to a new location in the hierarchy along with all its descendants.
     Node createNode(ID parentId, String newNodeName, int type)
              This method creates a new Node underneath the parent.
     Node createNode(ID parentId, String newNodeName, int type, ID objectClassId, Property[] properties)
              This method creates a new Node underneath the parent.
     void deleteNode(ID nodeId)
              This method performs a full cascade delete on a Node.
     Node getNode(ID nodeId)
              This method gets a particular Node based on its id.
     Node getNode(String path)
              This method gets a particular Node based on its path.
     Node[] getNodeChildren(ID parentId, int type)
              This method returns an array of all children Nodes for the parent Node.
     Node[] getNodes(ID[] nodeIds)
              This method gets the Node for each node ID passed in.
     Property[] getProperties(ID nodeId)
              Gets all Properties for a Node.
     InputStream getPropertyBytes(ID propertyId)
              Gets the Binary data for the given Property Id.
     Node moveNode(ID sourceId, ID destinationId)
              This method moves a Node to a new location in the hierarchy along with all its descendants.
     Node removeNodeContent(ID nodeId)
              Removes the ObjectClass reference from the given Node and deletes the Node's properties.
     Node renameNode(ID nodeId, String newName)
              This method renames a node and implicitly all of its descendants paths.
     Node updateProperties(ID nodeId, Property[] properties)
              Updates the node with the given id with the given properties.
     

    Method Detail

    addNodeContent

    public Node addNodeContent(ID nodeId,
                               ID objectClassId,
                               Property[] properties)
                        throws AuthorizationException,
                               NoSuchObjectClassException,
                               NoSuchNodeException,
                               RepositoryException
    Updates the node with the given id to contain the given objectClass and properties (content and meta-content). If the node already has an ObjectClass and properties, they will be replaced. If there is a PropertyDefintion in the given ObjectClass with no corresponding Property in the properties array a Property will be created with a null value, unless the Property is required, in which case a validation exception will be thrown.

    Parameters:
    nodeId - - the ID for the node to update.
    Returns:
    Node - the updated Node.
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NoSuchObjectClassException - thrown if the ObjectClass to set on the Node does not exist.
    NoSuchNodeException - - if the Node to update does not exist.
    RepositoryException - - if validation error occurs.

    copyNode

    public Node copyNode(ID sourceId,
                         ID destinationId)
                  throws AuthorizationException,
                         NoSuchNodeException,
                         RepositoryException
    This method copies a Node to a new location in the hierarchy along with all its descendants.

    A Hierarchy Node may only be copied to another Hierarchy Node. Each Node will get a new Id, parent id and new Properties.

    If the uid is null for the destinationId, the desination will be the repository root.

    Parameters:
    sourceId - - the id of the Node to be copied
    destinationId - - the id of the Node under which the sourceId Node is copied
    Returns:
    Node - the copied Node, with a new path
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NoSuchNodeException - - if the source or destination node can't be found.
    RepositoryException - - if validation error occurs.

    createNode

    public Node createNode(ID parentId,
                           String newNodeName,
                           int type)
                    throws AuthorizationException,
                           NodeExistsException,
                           RepositoryException
    This method creates a new Node underneath the parent. If the parentId's uid is null then the new Node is created under root.

    Parameters:
    parentId - - the id for the parent of the node. The uid is null if the parent is root.
    newNodeName - - the name of Node to create.
    type - - the type of node - either com.bea.content.Node.HIERARCHY or com.bea.content.Node.CONTENT.
    Returns:
    Node - the newly created node.
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NodeExistsException - - if the name for the node already exists as a child of the parent.
    RepositoryException - - if validation error occurs.

    createNode

    public Node createNode(ID parentId,
                           String newNodeName,
                           int type,
                           ID objectClassId,
                           Property[] properties)
                    throws AuthorizationException,
                           NodeExistsException,
                           NoSuchObjectClassException,
                           RepositoryException
    This method creates a new Node underneath the parent. If the parent uid is null then the new Node is created under root. It associates the ObjectClass with the given id to the new Node and adds the given properties (content and meta-content) to the Node. If there is a PropertyDefintion in the given ObjectClass with no corresponding Property in the properties array a Property will be created with a null value, unless the Property is required, in which case a validation exception will be thrown.

    Parameters:
    parentId - - the id for the parent of the node. The parentId's uid is null if the parent is root.
    newNodeName - - the name of Node to create.
    type - - the type of node - either com.bea.content.Node.HIERARCHY or com.bea.content.Node.CONTENT.
    objectClassId - - the ID for the ObjectClass to associate the new Node to.
    properties - - the properties to add to the new Node.
    Returns:
    Node - the newly created Node.
    Throws:
    AuthorizationException
    NodeExistsException - - if the parent Node already has a child with the same name.
    NoSuchObjectClassException - - if the ObjectClass doesn't exist.
    RepositoryException - - if a validation error occurs.

    deleteNode

    public void deleteNode(ID nodeId)
                    throws AuthorizationException,
                           NoSuchNodeException,
                           RepositoryException
    This method performs a full cascade delete on a Node. As such, the node - all its descendant Nodes and each Nodes Properties are removed in the process.

    Parameters:
    nodeId - - the id of the Node to be deleted
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NoSuchNodeException - - if the node to delete can't be found.
    RepositoryException - - if validation error occurs.

    getNode

    public Node getNode(ID nodeId)
                 throws AuthorizationException,
                        NoSuchNodeException
    This method gets a particular Node based on its id. If there is an ObjectClass associated with it then it along with the Node Properties should be contained in the Node.

    Parameters:
    nodeId - - the id for the node to get.
    Returns:
    Node - the retrieved Node.
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NoSuchNodeException - - if the node to get can't be found.

    getNode

    public Node getNode(String path)
                 throws AuthorizationException,
                        NoSuchNodeException
    This method gets a particular Node based on its path. If there is an ObjectClass associated with it then it along with the Node Properties should be contained in the Node.

    Parameters:
    path - - the path for the node to get.
    Returns:
    Node - the retrieved Node.
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NoSuchNodeException - - if the node to get can't be found.

    getNodeChildren

    public Node[] getNodeChildren(ID parentId,
                                  int type)
                           throws AuthorizationException,
                                  NoSuchNodeException
    This method returns an array of all children Nodes for the parent Node.

    Parameters:
    parentId - - the Node which may have children
    type - - the type of children to return, either com.bea.content.Node.HIERARCHY, com.bea.content.Node.CONTENT or or com.bea.content.Node.NODE. If the type is com.bea.content.Node.NODE then all children (both HIERARCHY and CONTENT) will be returned.
    Returns:
    array - one Node per child of the parent, or empty array if the Node has no children.
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NoSuchNodeException - - if the parent node can't be found.

    getNodes

    public Node[] getNodes(ID[] nodeIds)
                    throws AuthorizationException,
                           NoSuchNodeException
    This method gets the Node for each node ID passed in. If the current credential is not allowed access to a particular node, then there may be a null in the returned array at that nodes place.

    Parameters:
    nodeIds - - the Node IDs to retrieve the Nodes for.
    Returns:
    Node[] - the retrieved Nodes.
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NoSuchNodeException - - if a node to get can't be found.

    getProperties

    public Property[] getProperties(ID nodeId)
                             throws AuthorizationException,
                                    NoSuchNodeException
    Gets all Properties for a Node. If a Property is Binary, then the bytes will not be contained in the BinaryValue. In order to get the bytes a call to (@link #getPropertyBytes} is necessary.

    Parameters:
    nodeId - - the id for the node.
    Returns:
    Property[] - array of Node Properties.
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NoSuchNodeException - - if the node can't be found.

    getPropertyBytes

    public InputStream getPropertyBytes(ID propertyId)
                                 throws AuthorizationException,
                                        NoSuchPropertyException
    Gets the Binary data for the given Property Id.

    Parameters:
    propertyId - - the id for the Property that contains the binary data.
    Returns:
    InputStream - the bytes.
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NoSuchPropertyException - - if the Property does not exist.

    moveNode

    public Node moveNode(ID sourceId,
                         ID destinationId)
                  throws AuthorizationException,
                         NodeExistsException,
                         NoSuchNodeException,
                         RepositoryException
    This method moves a Node to a new location in the hierarchy along with all its descendants.

    A Hierarchy Node may only be moved under another Hierarchy Node. The parent id for the source node will be changed, but all descendants of the source node will keep their parent relationships intact.

    If the uid is null for the destinationId, the desination will be the repository root.

    Parameters:
    sourceId - - the id of the Node to be moved
    destinationId - - the id of the Node under which the sourceId Node is moved
    Returns:
    Node - the moved Node, with a new path
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NodeExistsException - - if attempting to move a Node to a path that already exists.
    NoSuchNodeException - - if the source or destination node can't be found.
    RepositoryException - - if validation error occurs.

    removeNodeContent

    public Node removeNodeContent(ID nodeId)
                           throws AuthorizationException,
                                  NoSuchNodeException,
                                  RepositoryException
    Removes the ObjectClass reference from the given Node and deletes the Node's properties.

    Parameters:
    nodeId - - the id for the Node to remove the ObjectClass from.
    Returns:
    Node - the updated Node.
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NoSuchNodeException - if the node does not exist.
    RepositoryException - - if validation error occurs.

    renameNode

    public Node renameNode(ID nodeId,
                           String newName)
                    throws AuthorizationException,
                           NoSuchNodeException,
                           NodeExistsException,
                           RepositoryException
    This method renames a node and implicitly all of its descendants paths. A Node may not be renamed to a Node name that exists at the same level in the hierarchy.

    Parameters:
    nodeId - - the id for the node to rename
    newName - - a String for the new node name
    Returns:
    Node - the renamed Node
    Throws:
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NoSuchNodeException - - if the node to rename can't be found.
    NodeExistsException - - if the newName already exists as a sibling.
    RepositoryException - - if validation error occurs.

    updateProperties

    public Node updateProperties(ID nodeId,
                                 Property[] properties)
                          throws AuthenticationException,
                                 AuthorizationException,
                                 NoSuchNodeException,
                                 NoSuchPropertyException,
                                 RepositoryException
    Updates the node with the given id with the given properties. The node must already have a ObjectClass and valid properties associated with it. All Properties are validated against their respective PropertyDefinition.

    Parameters:
    nodeId - - the ID of the node to update. The ID must include the repositoryName.
    properties - - the properties to update on the Node.
    Returns:
    Node - the updated Node.
    Throws:
    AuthenticationException - - if the user attempting the operation isn't authenticated against the repository.
    AuthorizationException - - if the user attempting the operation is not authorized to perform it.
    NoSuchNodeException - - if the Node to update does not exist.
    NoSuchPropertyException - - if a Property does not exist on the Node.
    RepositoryException - - if system or validation error occurs.

    © 2005 BEA Systems, Inc.

    Copyright © 2005 BEA Systems, Inc. All Rights Reserved