Class ScriptNode

  • All Implemented Interfaces:
    java.io.Serializable, Scopeable, org.alfresco.service.namespace.NamespacePrefixResolverProvider
    Direct Known Subclasses:
    ActivitiScriptNode, CategoryNode, ScriptThumbnail

    public class ScriptNode
    extends java.lang.Object
    implements Scopeable, org.alfresco.service.namespace.NamespacePrefixResolverProvider
    Script Node class implementation, specific for use by ScriptService as part of the object model.

    The class exposes Node properties, children and assocs as dynamically populated maps and lists. The various collection classes are mirrored as JavaScript properties. So can be accessed using standard JavaScript property syntax, such as node.children[0].properties.name.

    Various helper methods are provided to access common and useful node variables such as the content url and type information.

    Author:
    Kevin Roast
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ScriptNode​(FileInfo nodeInfo, ServiceRegistry services, org.mozilla.javascript.Scriptable scope)
      Constructor
      ScriptNode​(org.alfresco.service.cmr.repository.NodeRef nodeRef, ServiceRegistry services)
      Constructor
      ScriptNode​(org.alfresco.service.cmr.repository.NodeRef nodeRef, ServiceRegistry services, org.mozilla.javascript.Scriptable scope)
      Constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean addAspect​(java.lang.String type)
      Add an aspect to the Node.
      boolean addAspect​(java.lang.String type, java.lang.Object props)
      Add an aspect to the Node.
      void addNode​(ScriptNode node)
      Creates a new secondary association between the current node and the specified child node.
      void addTag​(java.lang.String tag)
      Adds a tag to the node
      void addTags​(java.lang.String[] tags)
      Adds all the tags to the node
      ScriptNode cancelCheckout()
      Cancel the check-out of a working copy document.
      ScriptNode checkin()
      Check-in a working copy document.
      ScriptNode checkin​(java.lang.String history)
      Check-in a working copy document.
      ScriptNode checkin​(java.lang.String history, boolean majorVersion)
      Check-in a working copy document.
      ScriptNode checkout()
      Perform a check-out of this document into the current parent space.
      ScriptNode checkout​(ScriptNode destination)
      Perform a check-out of this document into the specified destination space.
      ScriptNode checkoutForUpload()
      Performs a check-out of this document for the purposes of an upload
      ScriptNode childByNamePath​(java.lang.String path)
      childByNamePath returns the Node at the specified 'cm:name' based Path walking the children of this Node.
      org.mozilla.javascript.Scriptable childFileFolders()  
      org.mozilla.javascript.Scriptable childFileFolders​(boolean files, boolean folders)  
      org.mozilla.javascript.Scriptable childFileFolders​(boolean files, boolean folders, java.lang.Object ignoreTypes)  
      ScriptPagingNodes childFileFolders​(boolean files, boolean folders, java.lang.Object ignoreTypes, int maxItems)
      Deprecated.
      API for review (subject to change prior to release)
      author janv
      ScriptPagingNodes childFileFolders​(boolean files, boolean folders, java.lang.Object ignoreTypes, int skipOffset, int maxItems, int requestTotalCountMax, java.lang.String sortProp, java.lang.Boolean sortAsc, java.lang.String queryExecutionId)  
      ScriptNode[] childrenByTags​(java.lang.String tag)
      Gets all (deep) children of this node that have the tag specified.
      org.mozilla.javascript.Scriptable childrenByXPath​(java.lang.String xpath)  
      void clearTags()
      Clear the node's tags
      ScriptNode copy​(ScriptNode destination)
      Copy this Node to a new parent destination.
      ScriptNode copy​(ScriptNode destination, boolean deepCopy)
      Copy this Node and potentially all child nodes to a new parent destination.
      Association createAssociation​(ScriptNode target, java.lang.String assocType)
      Create an association between this node and the specified target node.
      ScriptNode createFile​(java.lang.String name)
      Create a new File (cm:content) node as a child of this node.
      ScriptNode createFile​(java.lang.String name, java.lang.String type)
      Create a new File (cm:content) node as a child of this node.
      ScriptNode createFolder​(java.lang.String name)
      Create a new folder (cm:folder) node as a child of this node.
      ScriptNode createFolder​(java.lang.String name, java.lang.String type)
      Create a new folder (cm:folder) node as a child of this node.
      ScriptNode createFolderPath​(java.lang.String path)
      Create a path of folder (cm:folder) nodes as a child of this node.
      ScriptNode createNode​(java.lang.String name, java.lang.String type)
      Create a new Node of the specified type as a child of this node.
      ScriptNode createNode​(java.lang.String name, java.lang.String type, java.lang.Object properties)
      Create a new Node of the specified type as a child of this node.
      ScriptNode createNode​(java.lang.String name, java.lang.String type, java.lang.Object properties, java.lang.String assocType)
      Create a new Node of the specified type as a child of this node.
      ScriptNode createNode​(java.lang.String name, java.lang.String type, java.lang.Object properties, java.lang.String assocType, java.lang.String assocName)
      Create a new Node of the specified type as a child of this node.
      ScriptNode createNode​(java.lang.String name, java.lang.String type, java.lang.String assocType)
      Create a new Node of the specified type as a child of this node.
      protected org.alfresco.service.namespace.QName createQName​(java.lang.String s)
      Helper to create a QName from either a fully qualified or short-name QName string
      ScriptThumbnail createThumbnail​(java.lang.String thumbnailName)
      Creates a thumbnail for the content property of the node.
      ScriptThumbnail createThumbnail​(java.lang.String thumbnailName, boolean async)
      Deprecated.
      The async flag in the method signature will not be applicable as all of the future transformations will be asynchronous
      ScriptThumbnail createThumbnail​(java.lang.String thumbnailName, boolean async, boolean force)
      Deprecated.
      The async flag in the method signature will not be applicable as all of the future transformations will be asynchronous
      protected ScriptNode.NodeValueConverter createValueConverter()
      Constructs the node value converter
      ScriptVersion createVersion​(java.lang.String history, boolean majorVersion)
      Create a version of this document.
      void ensureVersioningEnabled()
      Ensures that this document has the cm:versionable aspect applied to it, and that it has the initial version in the version store.
      void ensureVersioningEnabled​(boolean autoVersion, boolean autoVersionProps)
      Ensures that this document has the cm:versionable aspect applied to it, and that it has the initial version in the version store.
      boolean equals​(java.lang.Object obj)  
      boolean exists()
      Checks whether the ScriptNode exists in the repository.
      org.mozilla.javascript.Scriptable getActiveWorkflows()
      Get active workflow instances this node belongs to
      org.mozilla.javascript.Scriptable getAspects()  
      java.util.Set<org.alfresco.service.namespace.QName> getAspectsSet()  
      org.mozilla.javascript.Scriptable getAspectsShort()  
      java.util.Map<java.lang.String,​java.lang.Object> getAssociations()  
      java.util.Map<java.lang.String,​java.lang.Object> getAssocs()
      Return the target associations from this Node.
      ScriptNode getCheckedOut()
      Gets the check-out of a working copy document
      java.util.Map<java.lang.String,​java.lang.Object> getChildAssociations()  
      java.util.Map<java.lang.String,​java.lang.Object> getChildAssocs()
      Return the child associations from this Node.
      org.mozilla.javascript.Scriptable getChildAssocsByType​(java.lang.String type)
      Return an Array of the associations from this Node that match a specific object type.
      org.mozilla.javascript.Scriptable getChildren()  
      java.lang.String getContent()  
      org.mozilla.javascript.Scriptable getDirectPermissions()  
      java.lang.String getDisplayPath()  
      java.lang.String getDownloadUrl()  
      org.mozilla.javascript.Scriptable getFullPermissions()  
      boolean getHasChildren()  
      java.lang.String getIcon16()  
      java.lang.String getIcon32()  
      java.lang.String getId()  
      boolean getIsCategory()  
      boolean getIsContainer()  
      boolean getIsDocument()  
      boolean getIsLinkToContainer()  
      boolean getIsLinkToDocument()  
      boolean getIsLocked()  
      boolean getIsTagScope()
      Gets whether this node is a tag scope
      boolean getIsVersioned()
      Determines if this node is versioned
      java.lang.String getMimetype()  
      java.lang.String getName()  
      org.alfresco.service.namespace.NamespacePrefixResolver getNamespacePrefixResolver()
      NamespacePrefixResolverProvider getter implementation
      org.alfresco.service.cmr.repository.NodeRef getNodeRef()  
      java.lang.String getOwner()
      Get the owner of the node.
      ScriptNode getParent()  
      java.util.Map<java.lang.String,​java.lang.Object> getParentAssociations()  
      java.util.Map<java.lang.String,​java.lang.Object> getParentAssocs()
      Return the parent associations to this Node.
      org.mozilla.javascript.Scriptable getParents()  
      org.mozilla.javascript.Scriptable getPermissions()  
      org.alfresco.service.cmr.repository.ChildAssociationRef getPrimaryParentAssoc()  
      java.util.Map<java.lang.String,​java.lang.Object> getProperties()
      Return all the properties known about this node.
      org.mozilla.javascript.Scriptable getPropertyNames​(boolean useShortQNames)
      Return all the property names defined for this node as an array.
      java.lang.String getQnamePath()  
      org.alfresco.service.namespace.QName getQNameType()  
      org.mozilla.javascript.Scriptable getSettablePermissions()  
      protected java.lang.String getShortQName​(org.alfresco.service.namespace.QName longQName)
      Given a long-form QName, this method uses the namespace service to create a short-form QName string.
      java.lang.String getSiteShortName()
      Returns the short name of the site this node is located within.
      long getSize()  
      static java.util.List<org.alfresco.service.cmr.security.AccessPermission> getSortedACLs​(java.util.Set<org.alfresco.service.cmr.security.AccessPermission> acls)  
      java.util.Map<java.lang.String,​java.lang.Object> getSourceAssociations()  
      java.util.Map<java.lang.String,​java.lang.Object> getSourceAssocs()
      Return the source associations to this Node.
      java.lang.String getStoreId()  
      java.lang.String getStoreType()  
      java.lang.String[] getTags()
      Get all the tags applied to this node
      TagScope getTagScope()
      Gets the 'nearest' tag scope to this node by travesing up the parent hierarchy untill one is found.
      ScriptThumbnail getThumbnail​(java.lang.String thumbnailName)
      Get the given thumbnail for the content property
      java.lang.String[] getThumbnailDefinitions()
      Returns the names of the thumbnail defintions that can be applied to the content property of this node.
      java.lang.String[] getThumbnailDefintions()
      Deprecated.
      ScriptThumbnail[] getThumbnails()
      Get the all the thumbnails for a given node's content property.
      java.lang.String getType()  
      org.mozilla.javascript.Scriptable getTypePropertyNames()
      Return all the property names defined for this node's type as an array of short QNames.
      org.mozilla.javascript.Scriptable getTypePropertyNames​(boolean useShortQNames)
      Return all the property names defined for this node's type as an array.
      java.lang.String getTypeShort()  
      java.lang.String getUrl()  
      protected ScriptNode.NodeValueConverter getValueConverter()
      Gets the node value converter
      ScriptVersion getVersion​(java.lang.String versionLabel)
      Gets the version of this node specified by version label
      org.mozilla.javascript.Scriptable getVersionHistory()
      Gets the version history
      java.lang.String getWebdavUrl()  
      boolean hasAspect​(java.lang.String aspect)  
      int hashCode()  
      boolean hasPermission​(java.lang.String permission)
      Return true if the user has the specified permission on the node.
      boolean inheritsPermissions()  
      boolean isScriptContent​(java.lang.Object o)
      Helper to return true if the supplied property value is a ScriptContentData object
      boolean isSubType​(java.lang.String type)  
      java.lang.String jsGet_downloadUrl()  
      boolean move​(ScriptNode destination)
      Move this Node to a new parent destination.
      boolean move​(ScriptNode source, ScriptNode destination)
      Move this Node from specified parent to a new parent destination.
      ScriptNode newInstance​(FileInfo nodeInfo, ServiceRegistry services, org.mozilla.javascript.Scriptable scope)  
      ScriptNode newInstance​(org.alfresco.service.cmr.repository.NodeRef nodeRef, ServiceRegistry services, org.mozilla.javascript.Scriptable scope)
      Factory method
      java.lang.String processTemplate​(java.lang.String template)
      Process a FreeMarker Template against the current node.
      java.lang.String processTemplate​(java.lang.String template, java.lang.Object args)
      Process a FreeMarker Template against the current node.
      java.lang.String processTemplate​(ScriptNode template)
      Process a FreeMarker Template against the current node.
      java.lang.String processTemplate​(ScriptNode template, java.lang.Object args)
      Process a FreeMarker Template against the current node.
      boolean remove()
      Remove this node.
      boolean remove​(boolean newTransaction)
      Remove this node in a new transaction or not as specified.
      boolean removeAspect​(java.lang.String type)
      Remove aspect from the node.
      void removeAssociation​(ScriptNode target, java.lang.String assocType)
      Remove an association between this node and the specified target node.
      void removeNode​(ScriptNode node)
      Remove an existing child node of this node.
      void removePermission​(java.lang.String permission)
      Remove a permission for ALL user from the node.
      void removePermission​(java.lang.String permission, java.lang.String authority)
      Remove a permission for the specified authority (e.g.
      void removeTag​(java.lang.String tag)
      Removes a tag from the node
      void removeTags​(java.lang.String[] tags)
      Removes all the tags from the node
      void reset()
      Reset the Node cached state
      protected java.lang.Object[] retrieveAllSetPermissions​(boolean direct, boolean full)
      Helper to construct the response object for the various getPermissions() calls.
      ScriptNode revert​(java.lang.String history, boolean majorVersion, java.lang.String versionLabel)
      Revert this Node to the specified version.
      ScriptNode revert​(java.lang.String history, boolean majorVersion, java.lang.String versionLabel, boolean deep)
      Revert this Node to the specified version and potentially all child nodes.
      void save()
      Persist the modified properties of this Node.
      void setContent​(java.lang.String content)
      Set the content for this node
      void setInheritsPermissions​(boolean inherit)
      Set whether this node should inherit permissions from the parent node.
      void setInheritsPermissions​(boolean inherit, boolean asyncCall)
      Set whether this node should inherit permissions from the parent node.
      void setIsTagScope​(boolean value)
      Sets whether this node is a tag scope or not
      void setMimetype​(java.lang.String mimetype)
      Set the mimetype encoding for the content attached to the node from the default content property (@see ContentModel.PROP_CONTENT)
      void setName​(java.lang.String name)
      Helper to set the 'name' property for the node.
      void setOwner​(java.lang.String userId)
      Set the owner of the node
      void setPermission​(java.lang.String permission)
      Apply a permission for ALL users to the node.
      void setPermission​(java.lang.String permission, java.lang.String authority)
      Apply a permission for the specified authority (e.g.
      void setScope​(org.mozilla.javascript.Scriptable scope)
      Set the Scriptable global scope
      void setTags​(java.lang.String[] tags)
      Set the tags applied to this node.
      boolean specializeType​(java.lang.String type)
      Re-sets the type of the node.
      void takeOwnership()
      Take ownership of the node.
      java.lang.String toJSON()
      Returns the JSON representation of this node.
      java.lang.String toJSON​(boolean useShortQNames)
      Returns the JSON representation of this node.
      java.lang.String toString()
      Override Object.toString() to provide useful debug output
      ScriptNode transformDocument​(java.lang.String mimetype)
      Transform a document to a new document mimetype format.
      ScriptNode transformDocument​(java.lang.String mimetype, ScriptNode destination)
      Transform a document to a new document mimetype format.
      ScriptNode transformImage​(java.lang.String mimetype)
      Transform an image to a new image format.
      ScriptNode transformImage​(java.lang.String mimetype, java.lang.String options)
      Transform an image to a new image format.
      ScriptNode transformImage​(java.lang.String mimetype, java.lang.String options, ScriptNode destination)
      Transform an image to a new image mimetype format.
      ScriptNode transformImage​(java.lang.String mimetype, ScriptNode destination)
      Transform an image to a new image mimetype format.
      void unlock()
      Removes the lock on a node.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • scope

        protected org.mozilla.javascript.Scriptable scope
        Root scope for this object
      • nodeRef

        protected org.alfresco.service.cmr.repository.NodeRef nodeRef
        Cached values
      • id

        protected java.lang.String id
      • siteName

        protected java.lang.String siteName
      • siteNameResolved

        protected boolean siteNameResolved
      • aspects

        protected java.util.Set<org.alfresco.service.namespace.QName> aspects
        The aspects applied to this node
    • Constructor Detail

      • ScriptNode

        public ScriptNode​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                          ServiceRegistry services)
        Constructor
        Parameters:
        nodeRef - The NodeRef this Node wrapper represents
        services - The ServiceRegistry the Node can use to access services
      • ScriptNode

        public ScriptNode​(FileInfo nodeInfo,
                          ServiceRegistry services,
                          org.mozilla.javascript.Scriptable scope)
        Constructor
        Parameters:
        nodeInfo - The FileInfo this Node wrapper represents
        services - The ServiceRegistry the Node can use to access services
        scope - Root scope for this Node
      • ScriptNode

        public ScriptNode​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                          ServiceRegistry services,
                          org.mozilla.javascript.Scriptable scope)
        Constructor
        Parameters:
        nodeRef - The NodeRef this Node wrapper represents
        services - The ServiceRegistry the Node can use to access services
        scope - Root scope for this Node
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • newInstance

        public ScriptNode newInstance​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                      ServiceRegistry services,
                                      org.mozilla.javascript.Scriptable scope)
        Factory method
      • getId

        public java.lang.String getId()
        Returns:
        The GUID for the node
      • getStoreType

        public java.lang.String getStoreType()
        Returns:
        the store type for the node
      • getStoreId

        public java.lang.String getStoreId()
        Returns:
        the store id for the node
      • getNodeRef

        public org.alfresco.service.cmr.repository.NodeRef getNodeRef()
        Returns:
        Returns the NodeRef this Node object represents
      • getQNameType

        public org.alfresco.service.namespace.QName getQNameType()
        Returns:
        Returns the QName type.
      • getType

        public java.lang.String getType()
        Returns:
        Returns the type.
      • getTypeShort

        public java.lang.String getTypeShort()
        Returns:
        Returns the type in short format.
      • getName

        public java.lang.String getName()
        Returns:
        Helper to return the 'name' property for the node
      • setName

        public void setName​(java.lang.String name)
        Helper to set the 'name' property for the node.
        Parameters:
        name - Name to set
      • getChildren

        public org.mozilla.javascript.Scriptable getChildren()
        Returns:
        The children of this Node as JavaScript array of Node object wrappers
      • getHasChildren

        public boolean getHasChildren()
        Returns:
        true if the Node has children
      • childByNamePath

        public ScriptNode childByNamePath​(java.lang.String path)
        childByNamePath returns the Node at the specified 'cm:name' based Path walking the children of this Node. So a valid call might be: mynode.childByNamePath("/QA/Testing/Docs");
        Parameters:
        path - the relative path of the descendant node to find e.g. "/QA/Testing/Docs"
        Returns:
        The ScriptNode or null if the node is not found. null if the specified path is "".
        Throws:
        java.lang.NullPointerException - if the provided path is null.
      • childrenByXPath

        public org.mozilla.javascript.Scriptable childrenByXPath​(java.lang.String xpath)
        Returns:
        Returns a JavaScript array of Nodes at the specified XPath starting at this Node. So a valid call might be mynode.childrenByXPath("*[@cm:name='Testing']/*");
      • childFileFolders

        public org.mozilla.javascript.Scriptable childFileFolders()
        Returns:
        Returns a JavaScript array of child file/folder nodes for this nodes. Automatically retrieves all sub-types of cm:content and cm:folder, also removes system folder types from the results. This is equivalent to @see FileFolderService.list()
      • childFileFolders

        public org.mozilla.javascript.Scriptable childFileFolders​(boolean files,
                                                                  boolean folders)
        Parameters:
        files - Return files extending from cm:content
        folders - Return folders extending from cm:folder - ignoring sub-types of cm:systemfolder
        Returns:
        Returns a JavaScript array of child file/folder nodes for this nodes. Automatically retrieves all sub-types of cm:content and cm:folder, also removes system folder types from the results. This is equivalent to @see FileFolderService.listFiles() and @see FileFolderService.listFolders()
      • childFileFolders

        public org.mozilla.javascript.Scriptable childFileFolders​(boolean files,
                                                                  boolean folders,
                                                                  java.lang.Object ignoreTypes)
        Parameters:
        files - Return files extending from cm:content
        folders - Return folders extending from cm:folder - ignoring sub-types of cm:systemfolder
        ignoreTypes - Also optionally removes additional type qnames. The additional type can be specified in short or long qname string form as a single string or an Array e.g. "fm:forum".
        Returns:
        Returns a JavaScript array of child file/folder nodes for this nodes. Automatically retrieves all sub-types of cm:content and cm:folder, also removes system folder types from the results. This is equivalent to @see FileFolderService.listFiles() and @see FileFolderService.listFolders()
      • childFileFolders

        public ScriptPagingNodes childFileFolders​(boolean files,
                                                  boolean folders,
                                                  java.lang.Object ignoreTypes,
                                                  int maxItems)
        Deprecated.
        API for review (subject to change prior to release)
        author janv
        Parameters:
        files - Return files extending from cm:content
        folders - Return folders extending from cm:folder - ignoring sub-types of cm:systemfolder
        ignoreTypes - Also optionally removes additional type qnames. The additional type can be specified in short or long qname string form as a single string or an Array e.g. "fm:forum".
        maxItems - Max number of items
        Returns:
        Returns ScriptPagingNodes which includes a JavaScript array of child file/folder nodes for this nodes. Automatically retrieves all sub-types of cm:content and cm:folder, also removes system folder types from the results. This is equivalent to @see FileFolderService.listFiles() and @see FileFolderService.listFolders()
        Since:
        4.0
      • childFileFolders

        public ScriptPagingNodes childFileFolders​(boolean files,
                                                  boolean folders,
                                                  java.lang.Object ignoreTypes,
                                                  int skipOffset,
                                                  int maxItems,
                                                  int requestTotalCountMax,
                                                  java.lang.String sortProp,
                                                  java.lang.Boolean sortAsc,
                                                  java.lang.String queryExecutionId)
      • getAssocs

        public java.util.Map<java.lang.String,​java.lang.Object> getAssocs()
        Return the target associations from this Node. As a Map of assoc type to a JavaScript array of Nodes. The Map returned implements the Scriptable interface to allow access to the assoc arrays via JavaScript associative array access. This means associations of this node can be access thus: node.assocs["translations"][0]
        Returns:
        target associations as a Map of assoc name to a JavaScript array of Nodes.
      • getAssociations

        public java.util.Map<java.lang.String,​java.lang.Object> getAssociations()
      • getSourceAssocs

        public java.util.Map<java.lang.String,​java.lang.Object> getSourceAssocs()
        Return the source associations to this Node. As a Map of assoc name to a JavaScript array of Nodes. The Map returned implements the Scriptable interface to allow access to the assoc arrays via JavaScript associative array access. This means source associations to this node can be access thus: node.sourceAssocs["translations"][0]
        Returns:
        source associations as a Map of assoc name to a JavaScript array of Nodes.
      • getSourceAssociations

        public java.util.Map<java.lang.String,​java.lang.Object> getSourceAssociations()
      • getChildAssocs

        public java.util.Map<java.lang.String,​java.lang.Object> getChildAssocs()
        Return the child associations from this Node. As a Map of assoc name to a JavaScript array of Nodes. The Map returned implements the Scriptable interface to allow access to the assoc arrays via JavaScript associative array access. This means associations of this node can be access thus: node.childAssocs["contains"][0]
        Returns:
        child associations as a Map of assoc name to a JavaScript array of Nodes.
      • getChildAssociations

        public java.util.Map<java.lang.String,​java.lang.Object> getChildAssociations()
      • getChildAssocsByType

        public org.mozilla.javascript.Scriptable getChildAssocsByType​(java.lang.String type)
        Return an Array of the associations from this Node that match a specific object type. node.getChildAssocsByType("cm:folder")[0]
        Returns:
        Array of child associations from this Node that match a specific object type.
      • getParentAssocs

        public java.util.Map<java.lang.String,​java.lang.Object> getParentAssocs()
        Return the parent associations to this Node. As a Map of assoc name to a JavaScript array of Nodes. The Map returned implements the Scriptable interface to allow access to the assoc arrays via JavaScript associative array access. This means associations of this node can be access thus: node.parentAssocs["contains"][0]
        Returns:
        parent associations as a Map of assoc name to a JavaScript array of Nodes.
      • getParentAssociations

        public java.util.Map<java.lang.String,​java.lang.Object> getParentAssociations()
      • exists

        public boolean exists()
        Checks whether the ScriptNode exists in the repository.
        Returns:
        boolean
      • getProperties

        public java.util.Map<java.lang.String,​java.lang.Object> getProperties()
        Return all the properties known about this node. The Map returned implements the Scriptable interface to allow access to the properties via JavaScript associative array access. This means properties of a node can be access thus: node.properties["name"]
        Returns:
        Map of properties for this Node.
      • getTypePropertyNames

        public org.mozilla.javascript.Scriptable getTypePropertyNames()
        Return all the property names defined for this node's type as an array of short QNames.
        Returns:
        Array of property names for this node's type.
      • getTypePropertyNames

        public org.mozilla.javascript.Scriptable getTypePropertyNames​(boolean useShortQNames)
        Return all the property names defined for this node's type as an array.
        Parameters:
        useShortQNames - if true short-form qnames will be returned, else long-form.
        Returns:
        Array of property names for this node's type.
      • getPropertyNames

        public org.mozilla.javascript.Scriptable getPropertyNames​(boolean useShortQNames)
        Return all the property names defined for this node as an array.
        Parameters:
        useShortQNames - if true short-form qnames will be returned, else long-form.
        Returns:
        Array of property names for this node type and optionally parent properties.
      • getIsContainer

        public boolean getIsContainer()
        Returns:
        true if this Node is a container (i.e. a folder)
      • getIsDocument

        public boolean getIsDocument()
        Returns:
        true if this Node is a Document (i.e. with content)
      • getIsLinkToContainer

        public boolean getIsLinkToContainer()
        Returns:
        true if this Node is a Link to a Container (i.e. a folderlink)
      • getIsLinkToDocument

        public boolean getIsLinkToDocument()
        Returns:
        true if this Node is a Link to a Document (i.e. a filelink)
      • getIsCategory

        public boolean getIsCategory()
        Returns:
        true if the Node is a Category
      • getAspectsSet

        public java.util.Set<org.alfresco.service.namespace.QName> getAspectsSet()
        Returns:
        The list of aspects applied to this node
      • getAspects

        public org.mozilla.javascript.Scriptable getAspects()
        Returns:
        The array of aspects applied to this node as fully qualified qname strings
      • getAspectsShort

        public org.mozilla.javascript.Scriptable getAspectsShort()
        Returns:
        The array of aspects applied to this node as short prefix qname strings
      • hasAspect

        public boolean hasAspect​(java.lang.String aspect)
        Parameters:
        aspect - The aspect name to test for (fully qualified or short-name form)
        Returns:
        true if the node has the aspect false otherwise
      • isSubType

        public boolean isSubType​(java.lang.String type)
        Parameters:
        type - The qname type to test this object against (fully qualified or short-name form)
        Returns:
        true if this Node is a sub-type of the specified class (or itself of that class)
      • getQnamePath

        public java.lang.String getQnamePath()
        Returns:
        QName path to this node. This can be used for Lucene PATH: style queries
      • getDisplayPath

        public java.lang.String getDisplayPath()
        Returns:
        Display path to this node
      • getIcon16

        public java.lang.String getIcon16()
        Returns:
        the small icon image for this node
      • getIcon32

        public java.lang.String getIcon32()
        Returns:
        the large icon image for this node
      • getIsLocked

        public boolean getIsLocked()
        Returns:
        true if the node is currently locked
      • getParent

        public ScriptNode getParent()
        Returns:
        the primary parent node
      • getParents

        public org.mozilla.javascript.Scriptable getParents()
        Returns:
        all parent nodes
      • getPrimaryParentAssoc

        public org.alfresco.service.cmr.repository.ChildAssociationRef getPrimaryParentAssoc()
        Returns:
        the primary parent association so we can get at the association QName and the association type QName.
      • getContent

        public java.lang.String getContent()
        Returns:
        the content String for this node from the default content property (@see ContentModel.PROP_CONTENT)
      • setContent

        public void setContent​(java.lang.String content)
        Set the content for this node
        Parameters:
        content - Content string to set
      • getUrl

        public java.lang.String getUrl()
        Returns:
        For a content document, this method returns the URL to the content stream for the default content property (@see ContentModel.PROP_CONTENT)

        For a container node, this method return the URL to browse to the folder in the web-client

      • getDownloadUrl

        public java.lang.String getDownloadUrl()
        Returns:
        For a content document, this method returns the download URL to the content for the default content property (@see ContentModel.PROP_CONTENT)

        For a container node, this method returns an empty string

      • jsGet_downloadUrl

        public java.lang.String jsGet_downloadUrl()
      • getWebdavUrl

        public java.lang.String getWebdavUrl()
        Returns:
        The WebDav cm:name based path to the content for the default content property (@see ContentModel.PROP_CONTENT)
      • getMimetype

        public java.lang.String getMimetype()
        Returns:
        The mimetype encoding for content attached to the node from the default content property (@see ContentModel.PROP_CONTENT)
      • setMimetype

        public void setMimetype​(java.lang.String mimetype)
        Set the mimetype encoding for the content attached to the node from the default content property (@see ContentModel.PROP_CONTENT)
        Parameters:
        mimetype - Mimetype to set
      • getSize

        public long getSize()
        Returns:
        The size in bytes of the content attached to the node from the default content property (@see ContentModel.PROP_CONTENT)
      • hasPermission

        public boolean hasPermission​(java.lang.String permission)
        Return true if the user has the specified permission on the node.

        The default permissions are found in org.alfresco.service.cmr.security.PermissionService. Most commonly used are "Write", "Delete" and "AddChildren".

        Parameters:
        permission - as found in org.alfresco.service.cmr.security.PermissionService
        Returns:
        true if the user has the specified permission on the node.
      • getPermissions

        public org.mozilla.javascript.Scriptable getPermissions()
        Returns:
        Array of permissions applied to this Node, including inherited. Strings returned are of the format [ALLOWED|DENIED];[USERNAME|GROUPNAME];PERMISSION for example ALLOWED;kevinr;Consumer so can be easily tokenized on the ';' character.
      • getDirectPermissions

        public org.mozilla.javascript.Scriptable getDirectPermissions()
        Returns:
        Array of permissions applied directly to this Node (does not include inherited). Strings returned are of the format [ALLOWED|DENIED];[USERNAME|GROUPNAME];PERMISSION for example ALLOWED;kevinr;Consumer so can be easily tokenized on the ';' character.
      • getFullPermissions

        public org.mozilla.javascript.Scriptable getFullPermissions()
        Returns:
        Array of all permissions applied to this Node, including inherited. Strings returned are of the format [ALLOWED|DENIED];[USERNAME|GROUPNAME];PERMISSION;[INHERITED|DIRECT] for example: ALLOWED;kevinr;Consumer;DIRECT so can be easily tokenized on the ';' character.
      • getSortedACLs

        public static java.util.List<org.alfresco.service.cmr.security.AccessPermission> getSortedACLs​(java.util.Set<org.alfresco.service.cmr.security.AccessPermission> acls)
        Returns:
        Sorted list of AccessPermission based on CMISConnector.AccessPermissionComparator and AccessStatus of the permission for an authority.
      • retrieveAllSetPermissions

        protected java.lang.Object[] retrieveAllSetPermissions​(boolean direct,
                                                               boolean full)
        Helper to construct the response object for the various getPermissions() calls.
        Parameters:
        direct - True to only retrieve direct permissions, false to get inherited also
        full - True to retrieve full data string with [INHERITED|DIRECT] element This exists to maintain backward compatibility with existing permission APIs.
        Returns:
        Object[] of packed permission strings.
      • getSettablePermissions

        public org.mozilla.javascript.Scriptable getSettablePermissions()
        Returns:
        Array of settable permissions for this Node
      • inheritsPermissions

        public boolean inheritsPermissions()
        Returns:
        true if the node inherits permissions from the parent node, false otherwise
      • setInheritsPermissions

        public void setInheritsPermissions​(boolean inherit)
        Set whether this node should inherit permissions from the parent node.
        Parameters:
        inherit - True to inherit parent permissions, false otherwise.
      • setInheritsPermissions

        public void setInheritsPermissions​(boolean inherit,
                                           boolean asyncCall)
        Set whether this node should inherit permissions from the parent node. If the operation takes too long and asyncCall parameter set accordingly, fixed ACLs method will be asynchronously called.
        Parameters:
        inherit - True to inherit parent permissions, false otherwise.
        asyncCall - True if fixed ACLs should be asynchronously set when operation execution takes too long, false otherwise.
      • setPermission

        public void setPermission​(java.lang.String permission)
        Apply a permission for ALL users to the node.
        Parameters:
        permission - Permission to apply
        See Also:
        PermissionService
      • setPermission

        public void setPermission​(java.lang.String permission,
                                  java.lang.String authority)
        Apply a permission for the specified authority (e.g. username or group) to the node.
        Parameters:
        permission - Permission to apply @see org.alfresco.service.cmr.security.PermissionService
        authority - Authority (generally a username or group name) to apply the permission for
      • removePermission

        public void removePermission​(java.lang.String permission)
        Remove a permission for ALL user from the node.
        Parameters:
        permission - Permission to remove @see org.alfresco.service.cmr.security.PermissionService
      • removePermission

        public void removePermission​(java.lang.String permission,
                                     java.lang.String authority)
        Remove a permission for the specified authority (e.g. username or group) from the node.
        Parameters:
        permission - Permission to remove @see org.alfresco.service.cmr.security.PermissionService
        authority - Authority (generally a username or group name) to apply the permission for
      • setOwner

        public void setOwner​(java.lang.String userId)
        Set the owner of the node
      • takeOwnership

        public void takeOwnership()
        Take ownership of the node.
      • getOwner

        public java.lang.String getOwner()
        Get the owner of the node.
        Returns:
        String
      • save

        public void save()
        Persist the modified properties of this Node.
      • specializeType

        public boolean specializeType​(java.lang.String type)
        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 responsibility of the caller to ensure that the node is in a approriate state after changing the type.
        Parameters:
        type - Type to specialize the node
        Returns:
        true if successful, false otherwise
      • createFile

        public ScriptNode createFile​(java.lang.String name)
        Create a new File (cm:content) node as a child of this node.

        Once created the file should have content set using the content property. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.

        Parameters:
        name - Name of the file to create
        Returns:
        Newly created Node or null if failed to create.
      • createFile

        public ScriptNode createFile​(java.lang.String name,
                                     java.lang.String type)
        Create a new File (cm:content) node as a child of this node.

        Once created the file should have content set using the content property. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.

        Parameters:
        name - Name of the file to create
        type - Type of the file to create (if null, defaults to ContentModel.TYPE_CONTENT)
        Returns:
        Newly created Node or null if failed to create.
      • createFolder

        public ScriptNode createFolder​(java.lang.String name)
        Create a new folder (cm:folder) node as a child of this node. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        name - Name of the folder to create
        Returns:
        Newly created Node or null if failed to create.
      • createFolder

        public ScriptNode createFolder​(java.lang.String name,
                                       java.lang.String type)
        Create a new folder (cm:folder) node as a child of this node. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        name - Name of the folder to create
        type - Type of the folder to create (if null, defaults to ContentModel.TYPE_FOLDER)
        Returns:
        Newly created Node or null if failed to create.
      • createFolderPath

        public ScriptNode createFolderPath​(java.lang.String path)
        Create a path of folder (cm:folder) nodes as a child of this node.

        This method operates like a unix 'mkdir -p' no error if existing, make parent directories as needed.

        Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.

        Parameters:
        path - Folder path to create - of the form "One/Two/Three". Leading and trailing slashes are not expected to be present in the supplied path.
        Returns:
        reference to the last child of the newly created folder node(s) or null if failed to create.
      • createNode

        public ScriptNode createNode​(java.lang.String name,
                                     java.lang.String type)
        Create a new Node of the specified type as a child of this node.
        Parameters:
        name - Name of the node to create (can be null for a node without a 'cm:name' property)
        type - QName type (fully qualified or short form such as 'cm:content')
        Returns:
        Newly created Node or null if failed to create.
      • createNode

        public ScriptNode createNode​(java.lang.String name,
                                     java.lang.String type,
                                     java.lang.String assocType)
        Create a new Node of the specified type as a child of this node.
        Parameters:
        name - Name of the node to create (can be null for a node without a 'cm:name' property)
        type - QName type (fully qualified or short form such as 'cm:content')
        assocType - QName of the child association type (fully qualified or short form e.g. 'cm:contains')
        Returns:
        Newly created Node or null if failed to create.
      • createNode

        public ScriptNode createNode​(java.lang.String name,
                                     java.lang.String type,
                                     java.lang.Object properties)
        Create a new Node of the specified type as a child of this node.
        Parameters:
        name - Name of the node to create (can be null for a node without a 'cm:name' property)
        type - QName type (fully qualified or short form such as 'cm:content')
        properties - Associative array of the default properties for the node.
        Returns:
        Newly created Node or null if failed to create.
      • createNode

        public ScriptNode createNode​(java.lang.String name,
                                     java.lang.String type,
                                     java.lang.Object properties,
                                     java.lang.String assocType)
        Create a new Node of the specified type as a child of this node. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        name - Name of the node to create (can be null for a node without a 'cm:name' property)
        type - QName type (fully qualified or short form such as 'cm:content')
        properties - Associative array of the default properties for the node.
        assocType - QName of the child association type (fully qualified or short form e.g. 'cm:contains')
        Returns:
        Newly created Node or null if failed to create.
      • createNode

        public ScriptNode createNode​(java.lang.String name,
                                     java.lang.String type,
                                     java.lang.Object properties,
                                     java.lang.String assocType,
                                     java.lang.String assocName)
        Create a new Node of the specified type as a child of this node. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        name - Name of the node to create (can be null for a node without a 'cm:name' property)
        type - QName type (fully qualified or short form such as 'cm:content')
        properties - Associative array of the default properties for the node.
        assocType - QName of the child association type (fully qualified or short form e.g. 'cm:contains')
        assocName - QName of the child association name (fully qualified or short form e.g. 'fm:discussion')
        Returns:
        Newly created Node or null if failed to create.
      • addNode

        public void addNode​(ScriptNode node)
        Creates a new secondary association between the current node and the specified child node. The association is given the same name as the child node's primary association. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        node - node to add as a child of this node
      • removeNode

        public void removeNode​(ScriptNode node)
        Remove an existing child node of this node. 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. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.

        Parameters:
        node - child node to remove
      • createAssociation

        public Association createAssociation​(ScriptNode target,
                                             java.lang.String assocType)
        Create an association between this node and the specified target node. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        target - Destination node for the association
        assocType - Association type qname (short form or fully qualified)
      • removeAssociation

        public void removeAssociation​(ScriptNode target,
                                      java.lang.String assocType)
        Remove an association between this node and the specified target node. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        target - Destination node on the end of the association
        assocType - Association type qname (short form or fully qualified)
      • remove

        public boolean remove()
        Remove this node. Any references to this Node or its NodeRef should be discarded! Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
      • remove

        public boolean remove​(boolean newTransaction)
        Remove this node in a new transaction or not as specified. Any references to this Node or its NodeRef should be discarded! Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
      • copy

        public ScriptNode copy​(ScriptNode destination)
        Copy this Node to a new parent destination. Note that children of the source Node are not copied.
        Parameters:
        destination - Node
        Returns:
        The newly copied Node instance or null if failed to copy.
      • copy

        public ScriptNode copy​(ScriptNode destination,
                               boolean deepCopy)
        Copy this Node and potentially all child nodes to a new parent destination.
        Parameters:
        destination - Node
        deepCopy - True for a deep copy, false otherwise.
        Returns:
        The newly copied Node instance or null if failed to copy.
      • revert

        public ScriptNode revert​(java.lang.String history,
                                 boolean majorVersion,
                                 java.lang.String versionLabel)
        Revert this Node to the specified version. Note this is not a deep revert of associations. This node must have the cm:versionable aspect. It will be checked out if required but will be checked in after the call.
        Parameters:
        versionLabel - to revert from
        Returns:
        the original Node that was checked out if reverted, null otherwise (if the version does not exist).
      • revert

        public ScriptNode revert​(java.lang.String history,
                                 boolean majorVersion,
                                 java.lang.String versionLabel,
                                 boolean deep)
        Revert this Node to the specified version and potentially all child nodes. This node must have the cm:versionable aspect. It will be checked out if required but will be checked in after the call. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        history - Version history note
        majorVersion - True to save as a major version increment, false for minor version.
        versionLabel - to revert from
        deep - true for a deep revert, false otherwise.
        Returns:
        the original Node that was checked out if reverted, null otherwise (if the version does not exist).
      • move

        public boolean move​(ScriptNode destination)
        Move this Node to a new parent destination. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        destination - Node
        Returns:
        true on successful move, false on failure to move.
      • move

        public boolean move​(ScriptNode source,
                            ScriptNode destination)
        Move this Node from specified parent to a new parent destination. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        source - Node
        destination - Node
        Returns:
        true on successful move, false on failure to move.
      • addAspect

        public boolean addAspect​(java.lang.String type)
        Add an aspect to the Node. As no properties are provided in this call, it can only be used to add aspects that do not require any mandatory properties. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        type - Type name of the aspect to add
        Returns:
        true if the aspect was added successfully, false if an error occured.
      • addAspect

        public boolean addAspect​(java.lang.String type,
                                 java.lang.Object props)
        Add an aspect to the Node. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        type - Type name of the aspect to add
        props - ScriptableObject (generally an assocative array) providing the named properties for the aspect - any mandatory properties for the aspect must be provided!
        Returns:
        true if the aspect was added successfully, false if an error occured.
      • removeAspect

        public boolean removeAspect​(java.lang.String type)
        Remove aspect from the node. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call save() first.
        Parameters:
        type - the aspect type
        Returns:
        true if successful, false otherwise
      • ensureVersioningEnabled

        public void ensureVersioningEnabled​(boolean autoVersion,
                                            boolean autoVersionProps)
        Ensures that this document has the cm:versionable aspect applied to it, and that it has the initial version in the version store. Calling this on a versioned node with a version store entry will have no effect. Calling this on a newly uploaded share node will have versioning enabled for it (Share currently does lazy versioning to improve performance of documents that are uploaded but never edited, and multi upload performance).
        Parameters:
        autoVersion - If the cm:versionable aspect is applied, should auto versioning be requested?
        autoVersionProps - If the cm:versionable aspect is applied, should auto versioning of properties be requested?
      • ensureVersioningEnabled

        public void ensureVersioningEnabled()
        Ensures that this document has the cm:versionable aspect applied to it, and that it has the initial version in the version store. Calling this on a versioned node with a version store entry will have no effect. Calling this on a newly uploaded share node will have versioning enabled for it (Share currently does lazy versioning to improve performance of documents that are uploaded but never edited, and multi upload performance).
      • createVersion

        public ScriptVersion createVersion​(java.lang.String history,
                                           boolean majorVersion)
        Create a version of this document. Note: this will add the cm:versionable aspect.
        Parameters:
        history - Version history note
        majorVersion - True to save as a major version increment, false for minor version.
        Returns:
        ScriptVersion object representing the newly added version node
      • getIsVersioned

        public boolean getIsVersioned()
        Determines if this node is versioned
        Returns:
        true => is versioned
      • getVersionHistory

        public org.mozilla.javascript.Scriptable getVersionHistory()
        Gets the version history
        Returns:
        version history
      • getVersion

        public ScriptVersion getVersion​(java.lang.String versionLabel)
        Gets the version of this node specified by version label
        Parameters:
        versionLabel - version label
        Returns:
        version of node, or null if node is not versioned, or label does not exist
      • checkout

        public ScriptNode checkout()
        Perform a check-out of this document into the current parent space.
        Returns:
        the working copy Node for the checked out document
      • checkoutForUpload

        public ScriptNode checkoutForUpload()
        Performs a check-out of this document for the purposes of an upload
        Returns:
        ScriptNode
      • checkout

        public ScriptNode checkout​(ScriptNode destination)
        Perform a check-out of this document into the specified destination space.
        Parameters:
        destination - Destination for the checked out document working copy Node.
        Returns:
        the working copy Node for the checked out document
      • checkin

        public ScriptNode checkin()
        Check-in a working copy document. The current state of the working copy is copied to the original node, this will include any content updated in the working node. Note that this method can only be called on a working copy Node.
        Returns:
        the original Node that was checked out.
      • checkin

        public ScriptNode checkin​(java.lang.String history)
        Check-in a working copy document. The current state of the working copy is copied to the original node, this will include any content updated in the working node. Note that this method can only be called on a working copy Node.
        Parameters:
        history - Version history note
        Returns:
        the original Node that was checked out.
      • checkin

        public ScriptNode checkin​(java.lang.String history,
                                  boolean majorVersion)
        Check-in a working copy document. The current state of the working copy is copied to the original node, this will include any content updated in the working node. Note that this method can only be called on a working copy Node.
        Parameters:
        history - Version history note
        majorVersion - True to save as a major version increment, false for minor version.
        Returns:
        the original Node that was checked out.
      • unlock

        public void unlock()
        Removes the lock on a node.
      • getCheckedOut

        public ScriptNode getCheckedOut()
        Gets the check-out of a working copy document
        Returns:
        the original Node that was checked out or null if it's not a working copy
      • cancelCheckout

        public ScriptNode cancelCheckout()
        Cancel the check-out of a working copy document. The working copy will be deleted and any changes made to it are lost. Note that this method can only be called on a working copy Node. The reference to this working copy Node should be discarded.
        Returns:
        the original Node that was checked out.
      • transformDocument

        public ScriptNode transformDocument​(java.lang.String mimetype)
        Transform a document to a new document mimetype format. A copy of the document is made and the extension changed to match the new mimetype, then the transformation isapplied.
        Parameters:
        mimetype - Mimetype destination for the transformation
        Returns:
        Node representing the newly transformed document.
      • transformDocument

        public ScriptNode transformDocument​(java.lang.String mimetype,
                                            ScriptNode destination)
        Transform a document to a new document mimetype format. A copy of the document is made in the specified destination folder and the extension changed to match the new mimetype, then then transformation is applied.
        Parameters:
        mimetype - Mimetype destination for the transformation
        destination - Destination folder location
        Returns:
        Node representing the newly transformed document.
      • transformImage

        public ScriptNode transformImage​(java.lang.String mimetype)
        Transform an image to a new image format. A copy of the image document is made and the extension changed to match the new mimetype, then the transformation is applied.
        Parameters:
        mimetype - Mimetype destination for the transformation
        Returns:
        Node representing the newly transformed image.
      • transformImage

        public ScriptNode transformImage​(java.lang.String mimetype,
                                         java.lang.String options)
        Transform an image to a new image format. A copy of the image document is made and the extension changed to match the new mimetype, then the transformation is applied.
        Parameters:
        mimetype - Mimetype destination for the transformation
        options - Image convert command options
        Returns:
        Node representing the newly transformed image.
      • transformImage

        public ScriptNode transformImage​(java.lang.String mimetype,
                                         ScriptNode destination)
        Transform an image to a new image mimetype format. A copy of the image document is made in the specified destination folder and the extension changed to match the newmimetype, then then transformation is applied.
        Parameters:
        mimetype - Mimetype destination for the transformation
        destination - Destination folder location
        Returns:
        Node representing the newly transformed image.
      • transformImage

        public ScriptNode transformImage​(java.lang.String mimetype,
                                         java.lang.String options,
                                         ScriptNode destination)
        Transform an image to a new image mimetype format. A copy of the image document is made in the specified destination folder and the extension changed to match the new mimetype, then then transformation is applied.
        Parameters:
        mimetype - Mimetype destination for the transformation
        options - Image convert command options
        destination - Destination folder location
        Returns:
        Node representing the newly transformed image.
      • processTemplate

        public java.lang.String processTemplate​(ScriptNode template)
        Process a FreeMarker Template against the current node.
        Parameters:
        template - Node of the template to execute
        Returns:
        output of the template execution
      • processTemplate

        public java.lang.String processTemplate​(ScriptNode template,
                                                java.lang.Object args)
        Process a FreeMarker Template against the current node.
        Parameters:
        template - Node of the template to execute
        args - Scriptable object (generally an associative array) containing the name/value pairs of arguments to be passed to the template
        Returns:
        output of the template execution
      • processTemplate

        public java.lang.String processTemplate​(java.lang.String template)
        Process a FreeMarker Template against the current node.
        Parameters:
        template - The template to execute
        Returns:
        output of the template execution
      • processTemplate

        public java.lang.String processTemplate​(java.lang.String template,
                                                java.lang.Object args)
        Process a FreeMarker Template against the current node.
        Parameters:
        template - The template to execute
        args - Scriptable object (generally an associative array) containing the name/value pairs of arguments to be passed to the template
        Returns:
        output of the template execution
      • createThumbnail

        public ScriptThumbnail createThumbnail​(java.lang.String thumbnailName)
        Creates a thumbnail for the content property of the node. The thumbnail name correspionds to pre-set thumbnail details stored in the repository.
        Parameters:
        thumbnailName - the name of the thumbnail
        Returns:
        ScriptThumbnail the newly create thumbnail node
      • createThumbnail

        @Deprecated
        public ScriptThumbnail createThumbnail​(java.lang.String thumbnailName,
                                               boolean async)
        Deprecated.
        The async flag in the method signature will not be applicable as all of the future transformations will be asynchronous
        Creates a thumbnail for the content property of the node. The thumbnail name corresponds to pre-set thumbnail details stored in the repository. If the thumbnail is created asynchronously then the result will be null and creation of the thumbnail will occure at some point in the background.
        Parameters:
        thumbnailName - the name of the thumbnail
        async - indicates whether the thumbnail is create asynchronously or not
        Returns:
        ScriptThumbnail the newly create thumbnail node or null if async creation occures
      • createThumbnail

        @Deprecated
        public ScriptThumbnail createThumbnail​(java.lang.String thumbnailName,
                                               boolean async,
                                               boolean force)
        Deprecated.
        The async flag in the method signature will not be applicable as all of the future transformations will be asynchronous
        Creates a thumbnail for the content property of the node. The thumbnail name corresponds to pre-set thumbnail details stored in the repository. If the thumbnail is created asynchronously then the result will be null and creation of the thumbnail will occure at some point in the background. If foce param specified system.thumbnail.generate is ignoring. Could be used for preview creation
        Parameters:
        thumbnailName - the name of the thumbnail
        async - indicates whether the thumbnail is create asynchronously or not
        force - ignore system.thumbnail.generate=false
        Returns:
        ScriptThumbnail the newly create thumbnail node or null if async creation occures
      • getThumbnail

        public ScriptThumbnail getThumbnail​(java.lang.String thumbnailName)
        Get the given thumbnail for the content property
        Parameters:
        thumbnailName - the thumbnail name
        Returns:
        ScriptThumbnail the thumbnail
      • getThumbnails

        public ScriptThumbnail[] getThumbnails()
        Get the all the thumbnails for a given node's content property.
        Returns:
        Scriptable list of thumbnails, empty if none available
      • getThumbnailDefinitions

        public java.lang.String[] getThumbnailDefinitions()
        Returns the names of the thumbnail defintions that can be applied to the content property of this node.

        Thumbanil defintions only appear in this list if they can produce a thumbnail for the content found in the content property. This will be determined by looking at the mimetype of the content and the destinatino mimetype of the thumbnail.

        Returns:
        String[] array of thumbnail names that are valid for the current content type
      • getThumbnailDefintions

        @Deprecated
        public java.lang.String[] getThumbnailDefintions()
        Deprecated.
        This version of the method name spelling is retained (for now) for backwards compatibility
        See Also:
        getThumbnailDefinitions()
      • clearTags

        public void clearTags()
        Clear the node's tags
      • addTag

        public void addTag​(java.lang.String tag)
        Adds a tag to the node
        Parameters:
        tag - tag name
      • addTags

        public void addTags​(java.lang.String[] tags)
        Adds all the tags to the node
        Parameters:
        tags - array of tag names
      • removeTag

        public void removeTag​(java.lang.String tag)
        Removes a tag from the node
        Parameters:
        tag - tag name
      • removeTags

        public void removeTags​(java.lang.String[] tags)
        Removes all the tags from the node
        Parameters:
        tags - array of tag names
      • getTags

        public java.lang.String[] getTags()
        Get all the tags applied to this node
        Returns:
        String[] array containing all the tag applied to this node
      • setTags

        public void setTags​(java.lang.String[] tags)
        Set the tags applied to this node. This overwirtes the list of tags currently applied to the node.
        Parameters:
        tags - array of tags
      • setIsTagScope

        public void setIsTagScope​(boolean value)
        Sets whether this node is a tag scope or not
        Parameters:
        value - true if this node is a tag scope, false otherwise
      • getIsTagScope

        public boolean getIsTagScope()
        Gets whether this node is a tag scope
        Returns:
        boolean true if this node is a tag scope, false otherwise
      • getTagScope

        public TagScope getTagScope()
        Gets the 'nearest' tag scope to this node by travesing up the parent hierarchy untill one is found.

        If none is found, null is returned.

        Returns:
        TagScope the 'nearest' tag scope
      • childrenByTags

        public ScriptNode[] childrenByTags​(java.lang.String tag)
        Gets all (deep) children of this node that have the tag specified.
        Parameters:
        tag - tag name
        Returns:
        ScriptNode[] nodes that are deep children of the node with the tag
      • getActiveWorkflows

        public org.mozilla.javascript.Scriptable getActiveWorkflows()
        Get active workflow instances this node belongs to
        Returns:
        the active workflow instances this node belongs to
      • getSiteShortName

        public java.lang.String getSiteShortName()
        Returns the short name of the site this node is located within. If the node is not located within a site null is returned.
        Returns:
        The short name of the site this node is located within, null if the node is not located within a site.
      • toString

        public java.lang.String toString()
        Override Object.toString() to provide useful debug output
        Overrides:
        toString in class java.lang.Object
      • toJSON

        public java.lang.String toJSON​(boolean useShortQNames)
        Returns the JSON representation of this node.
        Parameters:
        useShortQNames - if true short-form qnames will be returned, else long-form.
        Returns:
        The JSON representation of this node
      • toJSON

        public java.lang.String toJSON()
        Returns the JSON representation of this node. Long-form QNames are used in the result.
        Returns:
        The JSON representation of this node
      • getShortQName

        protected java.lang.String getShortQName​(org.alfresco.service.namespace.QName longQName)
        Given a long-form QName, this method uses the namespace service to create a short-form QName string.
        Parameters:
        longQName - QName
        Returns:
        the short form of the QName string, e.g. "cm:content"
      • createQName

        protected org.alfresco.service.namespace.QName createQName​(java.lang.String s)
        Helper to create a QName from either a fully qualified or short-name QName string
        Parameters:
        s - Fully qualified or short-name QName string
        Returns:
        QName
      • reset

        public void reset()
        Reset the Node cached state
      • isScriptContent

        public boolean isScriptContent​(java.lang.Object o)
        Helper to return true if the supplied property value is a ScriptContentData object
        Parameters:
        o - Object to test
        Returns:
        true if instanceof ScriptContentData, false otherwise
      • getValueConverter

        protected ScriptNode.NodeValueConverter getValueConverter()
        Gets the node value converter
        Returns:
        the node value converter
      • createValueConverter

        protected ScriptNode.NodeValueConverter createValueConverter()
        Constructs the node value converter
        Returns:
        the node value converter
      • getNamespacePrefixResolver

        public org.alfresco.service.namespace.NamespacePrefixResolver getNamespacePrefixResolver()
        NamespacePrefixResolverProvider getter implementation
        Specified by:
        getNamespacePrefixResolver in interface org.alfresco.service.namespace.NamespacePrefixResolverProvider