Interface INodeService


public interface INodeService
Service for operations on nodes.
  • Method Details

    • getMetadata

      NodeMetadata getMetadata(NodeRef noderef)
      Parameters:
      noderef - The noderef for which the metadata is requested.
      Returns:
      The metadata of the given noderef. In case the node has no transaction id, the transaction id is set to -1. This can be the case for nodes that are stored as an old version.
    • setMetadata

      NodeMetadata setMetadata(NodeRef noderef, MetadataChanges metadata)
      Parameters:
      noderef - The noderef for which the metadata is set.
      metadata - The new metadata for the given noderef.
      Returns:
      Returns the new metadata in a NodeMetadata object (contains node ref, properties, ...).
    • getRootNode

      NodeRef getRootNode(StoreRef storeRef)
      Get the root node of the given store.
      Parameters:
      storeRef - the Store of which the root node is requested.
      Returns:
      the noderef of the root node.
    • getChildAssociations

      List<ChildParentAssociation> getChildAssociations(NodeRef ref)
      Parameters:
      ref - The node for which the child associations are requested.
      Returns:
      The child associations of the given node.
    • getParentAssociations

      List<ChildParentAssociation> getParentAssociations(NodeRef ref)
      Parameters:
      ref - The node for which the parent associations are requested.
      Returns:
      The parent associations of the given node.
    • getTargetAssociations

      List<NodeAssociation> getTargetAssociations(NodeRef ref)
      Fetches all associations for which the given node is the source.
      Parameters:
      ref - The node for which the associations are requested.
      Returns:
      The peer associations of the given node for which it is the source
    • getSourceAssociations

      List<NodeAssociation> getSourceAssociations(NodeRef ref)
      Fetches all associations for which the given node is the target.
      Parameters:
      ref - The node for which the associations are requested.
      Returns:
      The peer associations of the given node for which it is the target
    • getAssociations

      NodeAssociations getAssociations(NodeRef ref)
      Returns all target, parent and child associations of the given node.
      Parameters:
      ref - The node for which the associations are requested.
      Returns:
      all target, parent and child associations of the given node.
    • getAncestors

      List<NodeRef> getAncestors(NodeRef ref, NodeRef rootRef)
      Returns all primary ancestors of the given node.
      Parameters:
      ref - The node for which the ancestors are requested.
      rootRef - The node up to which point the ancestors have to be retrieved. This is optional and uses Company Home as root by default.
      Returns:
      a list of the node references of the primary parents.
    • createAssociation

      void createAssociation(NodeRef source, NodeRef target, QName assocType)
      Creates an association between source and target of a given type.
      Parameters:
      source - The source of the association to create.
      target - The target of the association to create.
      assocType - The type of association to create.
    • removeAssociation

      void removeAssociation(NodeRef source, NodeRef target, QName assocType)
      Removes an association between source and target of a given type.
      Parameters:
      source - The source of the association to remove.
      target - The target of the association to remove.
      assocType - The type of association to remove.
    • copyNode

      NodeRef copyNode(NodeRef source, NodeRef destination, boolean deepCopy)
      Copies a source node to a given destination parent node. Children are copied if deepCopy is true.
      Parameters:
      source - The node to copy.
      destination - The parent which will contain the copied node.
      deepCopy - If true child nodes are also copied.
      Returns:
      The noderef of the new node.
    • moveNode

      NodeRef moveNode(NodeRef source, NodeRef destination)
      Moves a source node to a given destination parent node.
      Parameters:
      source - The node to move.
      destination - The parent which will contain the moved node.
      Returns:
      The new noderef of the moved node.
    • createNode

      NodeRef createNode(NodeRef parent, String name, QName type)
      Create a node with a given parent, name and type.
      Parameters:
      parent - The parent node of the new node.
      name - The name of the new node.
      type - The type of the new node.
      Returns:
      The noderef of the newly created node.
    • createNode

      NodeRef createNode(NodeRef parent, Map<QName,String[]> properties, QName type, ContentData contentData)
      Creation of a node giving the list of properties as well as the type. To be used when using a custom type has required properties.
      Parameters:
      parent - The parent node of the new node.
      properties - list of properties to add to node.
      type - The type of the node.
      contentData - can contain returned result of function createContent (or null).
      Returns:
      The noderef of the new node.
    • createNode

      NodeRef createNode(NodeRef parent, Map<QName,String[]> properties, QName[] aspectsToAdd, QName[] aspectsToRemove, QName type, ContentData contentData)
      Creation of a node giving the list of properties as well as the type. To be used when using a custom type has required properties.
      Parameters:
      parent - The parent node of the new node.
      properties - list of properties to add to node.
      aspectsToAdd - list of aspects to add to node.
      aspectsToRemove - list of aspects to remove from node.
      type - The type of the node.
      contentData - can contain returned result of function createContent (or null).
      Returns:
      The noderef of the new node.
    • createNode

      NodeRef createNode(NodeRef parent, String fileName, String contentType, MetadataChanges metadata, InputStream content)
      Convenience method to create a node giving the type, the list of properties, and requesting metadata extraction from its content. Since Alfresco 7, metadata extraction is done asynchronously. The metadata should be added to the node upon success.
      Parameters:
      parent - The parent node of the new node.
      fileName - Name for the target document.
      contentType - String representation of the target alfresco contenttype.
      metadata - Properties (and optionally, aspects) to set on the new node in MetadataChanges format.
      content - Inputstream for the content for this new node.
      Returns:
      The noderef of the new node.
    • deleteNode

      boolean deleteNode(NodeRef nodeRef, boolean permanently)
      Delete a node.
      Parameters:
      nodeRef - The noderef of the node to delete.
      permanently - If true the node is deleted permanently. If false the node is just moved to the trashcan.
      Returns:
      whether the deletion was successful.
    • deleteNode

      boolean deleteNode(NodeRef nodeRef)
      Delete a node by moving it to the trashcan.
      Parameters:
      nodeRef - The noderef of the node to delete.
      Returns:
      whether the deletion was successful.
    • exists

      boolean exists(NodeRef nodeRef)
      Parameters:
      nodeRef - The noderef of a node that could exist.
      Returns:
      Whether a noderef exists.
    • checkout

      NodeRef checkout(NodeRef original, NodeRef destination)
      Checks out the given node placing a working copy in the destination specified.
      Parameters:
      original - The node to checkout
      destination - The destination in which the working copy is placed.
      Returns:
      null in case the checkout fails.
    • checkin

      NodeRef checkin(NodeRef nodeRef, String comment, boolean majorVersion)
      Checks in the given working copy.
      Parameters:
      nodeRef - the node that will be checked.
      comment - Give a comment while checking in.
      majorVersion - If true this version will have an increased major version number relative to the previous commit. Otherwise an increased minor version number.
      Returns:
      the noderef to the original node, updated with the checked in state.
    • cancelCheckout

      NodeRef cancelCheckout(NodeRef nodeRef)
      Cancels a checkout of a working copy. Returns the noderef of the original node.
      Parameters:
      nodeRef - The working copy of which the checkout will be canceled.
      Returns:
      The noderef of the original node.
    • getWorkingCopySource

      NodeRef getWorkingCopySource(NodeRef nodeRef)
      Parameters:
      nodeRef - The noderef of the working copy.
      Returns:
      The Noderef of the source of the working copy (The original node).
    • setContent

      void setContent(NodeRef node, InputStream inputStream, String originalFilename)
      Sets content of a specific node. Also changes mimetype by guessing it using content and original file name.
      Parameters:
      node - noderef of the node where the content of the inputStream will placed.
      inputStream - The input stream that contains the content. In case the input stream is null the content will be set to empty. The inputstream will be read (in combination with originalFilename) to make a best effort guess about which mimetype the content should have. To enforce a specific mimetype, use setContent(NodeRef, ContentData) with a ContentData object that has the mimetype explicitly set. A ContentData object can be obtained from the method createContent
      originalFilename - The filename of the content. This is only used to guess the mimetype of the node.
    • setContent

      void setContent(NodeRef node, ContentData contentData)
      Set the content of a node.
      Parameters:
      node - The node of which the content is set.
      contentData - The content to set.
    • createContent

      ContentData createContent(InputStream inputStream, String mimeType, String encoding)
      Creates a content without linking it to a specific node yet.
      Parameters:
      inputStream - Can be null: in that case, the content property of the file is removed.
      mimeType - ex: "application/pdf"
      encoding - ex: "UTF-8", ....
      Returns:
      the URL of the content (can be set to the content property of a node).
    • createContentWithMimetypeGuess

      ContentData createContentWithMimetypeGuess(InputStream inputStream, String fileName, String encoding)
      Creates a content without linking it to a specific node yet.
      Parameters:
      inputStream - Can be null: in that case, the content property of the file is removed.
      fileName - Needed for guessing the mimetype. (Does necessary not need to contain the extension as mimeTypeGuessing will also work on content of the inputStream)
      encoding - Encoding of the inputStream. ex: "UTF-8", ....
      Returns:
      the URL of the content (can be set to the content property of a node).
    • getContent

      ContentInputStream getContent(NodeRef node)
      Returns content as inputStream + other related informations (mimeType, size, ...)
      Parameters:
      node - the noderef from which the content will be gathered.
      Returns:
      ContentInputStream.inputStream has to be closed!
    • extractMetadata

      void extractMetadata(NodeRef node)
      Extracts metadata on a node
      Parameters:
      node - the noderef from which metadata will be extracted.