Class ScriptNode
- All Implemented Interfaces:
Serializable,Scopeable,NamespacePrefixResolverProvider
- Direct Known Subclasses:
ActivitiScriptNode,CategoryNode,ScriptThumbnail
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassValue converter with knowledge of Node specific value typesclassInner class wrapping and providing access to a ContentData property -
Field Summary
FieldsModifier and TypeFieldDescriptionThe aspects applied to this nodeprotected ScriptNode.NodeValueConverterNode Value Converterprotected Stringprotected TemplateImageResolverprotected NodeRefCached valuesprotected ScriptNodeprotected org.mozilla.javascript.ScriptableRoot scope for this objectprotected ServiceRegistryprotected Stringprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionScriptNode(FileInfo nodeInfo, ServiceRegistry services, org.mozilla.javascript.Scriptable scope) ConstructorScriptNode(NodeRef nodeRef, ServiceRegistry services) ConstructorScriptNode(NodeRef nodeRef, ServiceRegistry services, org.mozilla.javascript.Scriptable scope) Constructor -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd an aspect to the Node.booleanAdd an aspect to the Node.voidaddNode(ScriptNode node) Creates a new secondary association between the current node and the specified child node.voidAdds a tag to the nodevoidAdds all the tags to the nodeCancel the check-out of a working copy document.checkin()Check-in a working copy document.Check-in a working copy document.Check-in a working copy document.checkout()Perform a check-out of this document into the current parent space.checkout(ScriptNode destination) Perform a check-out of this document into the specified destination space.Performs a check-out of this document for the purposes of an uploadchildByNamePath(String path) childByNamePath returns the Node at the specified 'cm:name' based Path walking the children of this Node.org.mozilla.javascript.Scriptableorg.mozilla.javascript.ScriptablechildFileFolders(boolean files, boolean folders) org.mozilla.javascript.ScriptablechildFileFolders(boolean files, boolean folders, Object ignoreTypes) childFileFolders(boolean files, boolean folders, Object ignoreTypes, int maxItems) Deprecated.childFileFolders(boolean files, boolean folders, Object ignoreTypes, int skipOffset, int maxItems, int requestTotalCountMax, String sortProp, Boolean sortAsc, String queryExecutionId) childrenByTags(String tag) Gets all (deep) children of this node that have the tag specified.org.mozilla.javascript.ScriptablechildrenByXPath(String xpath) voidClear the node's tagscopy(ScriptNode destination) Copy this Node to a new parent destination.copy(ScriptNode destination, boolean deepCopy) Copy this Node and potentially all child nodes to a new parent destination.createAssociation(ScriptNode target, String assocType) Create an association between this node and the specified target node.createFile(String name) Create a new File (cm:content) node as a child of this node.createFile(String name, String type) Create a new File (cm:content) node as a child of this node.createFolder(String name) Create a new folder (cm:folder) node as a child of this node.createFolder(String name, String type) Create a new folder (cm:folder) node as a child of this node.createFolderPath(String path) Create a path of folder (cm:folder) nodes as a child of this node.createNode(String name, String type) Create a new Node of the specified type as a child of this node.createNode(String name, String type, Object properties) Create a new Node of the specified type as a child of this node.createNode(String name, String type, Object properties, String assocType) Create a new Node of the specified type as a child of this node.Create a new Node of the specified type as a child of this node.createNode(String name, String type, String assocType) Create a new Node of the specified type as a child of this node.protected QNameHelper to create a QName from either a fully qualified or short-name QName stringcreateThumbnail(String thumbnailName) Creates a thumbnail for the content property of the node.createThumbnail(String thumbnailName, boolean async) Deprecated.The async flag in the method signature will not be applicable as all of the future transformations will be asynchronouscreateThumbnail(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 asynchronousprotected ScriptNode.NodeValueConverterConstructs the node value convertercreateVersion(String history, boolean majorVersion) Create a version of this document.voidEnsures that this document has the cm:versionable aspect applied to it, and that it has the initial version in the version store.voidensureVersioningEnabled(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.booleanbooleanexists()Checks whether theScriptNodeexists in the repository.org.mozilla.javascript.ScriptableGet active workflow instances this node belongs toorg.mozilla.javascript.Scriptableorg.mozilla.javascript.ScriptableReturn the target associations from this Node.Gets the check-out of a working copy documentReturn the child associations from this Node.org.mozilla.javascript.ScriptablegetChildAssocsByType(String type) Return an Array of the associations from this Node that match a specific object type.org.mozilla.javascript.Scriptableorg.mozilla.javascript.Scriptableorg.mozilla.javascript.ScriptablebooleangetId()booleanbooleanbooleanbooleanbooleanbooleanbooleanGets whether this node is a tag scopebooleanDetermines if this node is versionedgetName()NamespacePrefixResolverProvider getter implementationgetOwner()Get the owner of the node.Return the parent associations to this Node.org.mozilla.javascript.Scriptableorg.mozilla.javascript.ScriptableReturn all the properties known about this node.org.mozilla.javascript.ScriptablegetPropertyNames(boolean useShortQNames) Return all the property names defined for this node as an array.org.mozilla.javascript.Scriptableprotected StringgetShortQName(QName longQName) Given a long-form QName, this method uses the namespace service to create a short-form QName string.Returns the short name of the site this node is located within.longgetSize()static List<AccessPermission>getSortedACLs(Set<AccessPermission> acls) Return the source associations to this Node.String[]getTags()Get all the tags applied to this nodeGets the 'nearest' tag scope to this node by travesing up the parent hierarchy untill one is found.getThumbnail(String thumbnailName) Get the given thumbnail for the content propertyString[]Returns the names of the thumbnail defintions that can be applied to the content property of this node.String[]Deprecated.Get the all the thumbnails for a given node's content property.getType()org.mozilla.javascript.ScriptableReturn all the property names defined for this node's type as an array of short QNames.org.mozilla.javascript.ScriptablegetTypePropertyNames(boolean useShortQNames) Return all the property names defined for this node's type as an array.getUrl()protected ScriptNode.NodeValueConverterGets the node value convertergetVersion(String versionLabel) Gets the version of this node specified by version labelorg.mozilla.javascript.ScriptableGets the version historybooleaninthashCode()booleanhasPermission(String permission) Return true if the user has the specified permission on the node.booleanbooleanHelper to return true if the supplied property value is a ScriptContentData objectbooleanbooleanmove(ScriptNode destination) Move this Node to a new parent destination.booleanmove(ScriptNode source, ScriptNode destination) Move this Node from specified parent to a new parent destination.newInstance(FileInfo nodeInfo, ServiceRegistry services, org.mozilla.javascript.Scriptable scope) newInstance(NodeRef nodeRef, ServiceRegistry services, org.mozilla.javascript.Scriptable scope) Factory methodprocessTemplate(String template) Process a FreeMarker Template against the current node.processTemplate(String template, Object args) Process a FreeMarker Template against the current node.processTemplate(ScriptNode template) Process a FreeMarker Template against the current node.processTemplate(ScriptNode template, Object args) Process a FreeMarker Template against the current node.booleanremove()Remove this node.booleanremove(boolean newTransaction) Remove this node in a new transaction or not as specified.booleanremoveAspect(String type) Remove aspect from the node.voidremoveAssociation(ScriptNode target, String assocType) Remove an association between this node and the specified target node.voidremoveNode(ScriptNode node) Remove an existing child node of this node.voidremovePermission(String permission) Remove a permission for ALL user from the node.voidremovePermission(String permission, String authority) Remove a permission for the specified authority (e.g. username or group) from the node.voidRemoves a tag from the nodevoidremoveTags(String[] tags) Removes all the tags from the nodevoidreset()Reset the Node cached stateprotected Object[]retrieveAllSetPermissions(boolean direct, boolean full) Helper to construct the response object for the various getPermissions() calls.Revert this Node to the specified version.Revert this Node to the specified version and potentially all child nodes.voidsave()Persist the modified properties of this Node.voidsetContent(String content) Set the content for this nodevoidsetInheritsPermissions(boolean inherit) Set whether this node should inherit permissions from the parent node.voidsetInheritsPermissions(boolean inherit, boolean asyncCall) Set whether this node should inherit permissions from the parent node.voidsetIsTagScope(boolean value) Sets whether this node is a tag scope or notvoidsetMimetype(String mimetype) Set the mimetype encoding for the content attached to the node from the default content property (@see ContentModel.PROP_CONTENT)voidHelper to set the 'name' property for the node.voidSet the owner of the nodevoidsetPermission(String permission) Apply a permission for ALL users to the node.voidsetPermission(String permission, String authority) Apply a permission for the specified authority (e.g. username or group) to the node.voidsetScope(org.mozilla.javascript.Scriptable scope) Set the Scriptable global scopevoidSet the tags applied to this node.booleanspecializeType(String type) Re-sets the type of the node.voidTake ownership of the node.toJSON()Returns the JSON representation of this node.toJSON(boolean useShortQNames) Returns the JSON representation of this node.toString()Override Object.toString() to provide useful debug outputtransformDocument(String mimetype) Transform a document to a new document mimetype format.transformDocument(String mimetype, ScriptNode destination) Transform a document to a new document mimetype format.transformImage(String mimetype) Transform an image to a new image format.transformImage(String mimetype, String options) Transform an image to a new image format.transformImage(String mimetype, String options, ScriptNode destination) Transform an image to a new image mimetype format.transformImage(String mimetype, ScriptNode destination) Transform an image to a new image mimetype format.voidunlock()Removes the lock on a node.
-
Field Details
-
scope
protected org.mozilla.javascript.Scriptable scopeRoot scope for this object -
converter
Node Value Converter -
nodeRef
Cached values -
id
-
siteName
-
siteNameResolved
protected boolean siteNameResolved -
aspects
The aspects applied to this node -
services
-
imageResolver
-
parent
-
-
Constructor Details
-
ScriptNode
Constructor- Parameters:
nodeRef- The NodeRef this Node wrapper representsservices- 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 representsservices- The ServiceRegistry the Node can use to access servicesscope- Root scope for this Node
-
ScriptNode
public ScriptNode(NodeRef nodeRef, ServiceRegistry services, org.mozilla.javascript.Scriptable scope) Constructor- Parameters:
nodeRef- The NodeRef this Node wrapper representsservices- The ServiceRegistry the Node can use to access servicesscope- Root scope for this Node
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
newInstance
public ScriptNode newInstance(NodeRef nodeRef, ServiceRegistry services, org.mozilla.javascript.Scriptable scope) Factory method -
newInstance
public ScriptNode newInstance(FileInfo nodeInfo, ServiceRegistry services, org.mozilla.javascript.Scriptable scope) -
setScope
public void setScope(org.mozilla.javascript.Scriptable scope) Description copied from interface:ScopeableSet the Scriptable global scope -
getId
- Returns:
- The GUID for the node
-
getStoreType
- Returns:
- the store type for the node
-
getStoreId
- Returns:
- the store id for the node
-
getNodeRef
- Returns:
- Returns the NodeRef this Node object represents
-
getQNameType
- Returns:
- Returns the QName type.
-
getType
- Returns:
- Returns the type.
-
getTypeShort
- Returns:
- Returns the type in short format.
-
getName
- Returns:
- Helper to return the 'name' property for the node
-
setName
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
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
nullif the node is not found.nullif the specified path is"". - Throws:
NullPointerException- if the provided path isnull.
-
childrenByXPath
- 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:contentfolders- 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, Object ignoreTypes) - Parameters:
files- Return files extending from cm:contentfolders- Return folders extending from cm:folder - ignoring sub-types of cm:systemfolderignoreTypes- 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, Object ignoreTypes, int maxItems) Deprecated.API for review (subject to change prior to release)
author janv- Parameters:
files- Return files extending from cm:contentfolders- Return folders extending from cm:folder - ignoring sub-types of cm:systemfolderignoreTypes- 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, Object ignoreTypes, int skipOffset, int maxItems, int requestTotalCountMax, String sortProp, Boolean sortAsc, String queryExecutionId) -
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
-
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
-
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
-
getChildAssocsByType
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
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
-
exists
public boolean exists()Checks whether theScriptNodeexists in the repository.- Returns:
- boolean
-
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
- 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
- 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
- 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
- Returns:
- QName path to this node. This can be used for Lucene PATH: style queries
-
getDisplayPath
- Returns:
- Display path to this node
-
getIcon16
- Returns:
- the small icon image for this node
-
getIcon32
- Returns:
- the large icon image for this node
-
getIsLocked
public boolean getIsLocked()- Returns:
- true if the node is currently locked
-
getParent
- Returns:
- the primary parent node
-
getParents
public org.mozilla.javascript.Scriptable getParents()- Returns:
- all parent nodes
-
getPrimaryParentAssoc
- Returns:
- the primary parent association so we can get at the association QName and the association type QName.
-
getContent
- Returns:
- the content String for this node from the default content property (@see ContentModel.PROP_CONTENT)
-
setContent
Set the content for this node- Parameters:
content- Content string to set
-
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
- 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
-
getWebdavUrl
- Returns:
- The WebDav cm:name based path to the content for the default content property (@see ContentModel.PROP_CONTENT)
-
getMimetype
- Returns:
- The mimetype encoding for content attached to the node from the default content property (@see ContentModel.PROP_CONTENT)
-
setMimetype
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
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 inorg.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
- Returns:
- Sorted list of
AccessPermissionbased onCMISConnector.AccessPermissionComparatorandAccessStatusof the permission for an authority.
-
retrieveAllSetPermissions
Helper to construct the response object for the various getPermissions() calls.- Parameters:
direct- True to only retrieve direct permissions, false to get inherited alsofull- 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
Apply a permission for ALL users to the node.- Parameters:
permission- Permission to apply- See Also:
-
setPermission
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.PermissionServiceauthority- Authority (generally a username or group name) to apply the permission for
-
removePermission
Remove a permission for ALL user from the node.- Parameters:
permission- Permission to remove @see org.alfresco.service.cmr.security.PermissionService
-
removePermission
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.PermissionServiceauthority- Authority (generally a username or group name) to apply the permission for
-
setOwner
Set the owner of the node -
takeOwnership
public void takeOwnership()Take ownership of the node. -
getOwner
Get the owner of the node.- Returns:
- String
-
save
public void save()Persist the modified properties of this Node. -
specializeType
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
Create a new File (cm:content) node as a child of this node.Once created the file should have content set using the
contentproperty. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes callsave()first.- Parameters:
name- Name of the file to create- Returns:
- Newly created Node or null if failed to create.
-
createFile
Create a new File (cm:content) node as a child of this node.Once created the file should have content set using the
contentproperty. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes callsave()first.- Parameters:
name- Name of the file to createtype- Type of the file to create (if null, defaults to ContentModel.TYPE_CONTENT)- Returns:
- Newly created Node or null if failed to create.
-
createFolder
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 callsave()first.- Parameters:
name- Name of the folder to create- Returns:
- Newly created Node or null if failed to create.
-
createFolder
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 callsave()first.- Parameters:
name- Name of the folder to createtype- Type of the folder to create (if null, defaults to ContentModel.TYPE_FOLDER)- Returns:
- Newly created Node or null if failed to create.
-
createFolderPath
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
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
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
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
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 callsave()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(String name, String type, Object properties, String assocType, 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 callsave()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
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 callsave()first.- Parameters:
node- node to add as a child of this node
-
removeNode
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
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 callsave()first.- Parameters:
target- Destination node for the associationassocType- Association type qname (short form or fully qualified)
-
removeAssociation
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 callsave()first.- Parameters:
target- Destination node on the end of the associationassocType- 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 callsave()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 callsave()first. -
copy
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
Copy this Node and potentially all child nodes to a new parent destination.- Parameters:
destination- NodedeepCopy- True for a deep copy, false otherwise.- Returns:
- The newly copied Node instance or null if failed to copy.
-
revert
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,
nullotherwise (if the version does not exist).
-
revert
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 callsave()first.- Parameters:
history- Version history notemajorVersion- True to save as a major version increment, false for minor version.versionLabel- to revert fromdeep-truefor a deep revert,falseotherwise.- Returns:
- the original Node that was checked out if reverted,
nullotherwise (if the version does not exist).
-
move
Move this Node to a new parent destination. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes callsave()first.- Parameters:
destination- Node- Returns:
- true on successful move, false on failure to move.
-
move
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 callsave()first.- Parameters:
source- Nodedestination- Node- Returns:
- true on successful move, false on failure to move.
-
addAspect
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 callsave()first.- Parameters:
type- Type name of the aspect to add- Returns:
- true if the aspect was added successfully, false if an error occured.
-
addAspect
Add an aspect to the Node. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes callsave()first.- Parameters:
type- Type name of the aspect to addprops- 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
Remove aspect from the node. Beware: Any unsaved property changes will be lost when this is called. To preserve property changes callsave()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
Create a version of this document. Note: this will add the cm:versionable aspect.- Parameters:
history- Version history notemajorVersion- 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
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
Perform a check-out of this document into the current parent space.- Returns:
- the working copy Node for the checked out document
-
checkoutForUpload
Performs a check-out of this document for the purposes of an upload- Returns:
- ScriptNode
-
checkout
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
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
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
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 notemajorVersion- 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
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
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
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
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 transformationdestination- Destination folder location- Returns:
- Node representing the newly transformed document.
-
transformImage
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
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 transformationoptions- Image convert command options- Returns:
- Node representing the newly transformed image.
-
transformImage
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 transformationdestination- Destination folder location- Returns:
- Node representing the newly transformed image.
-
transformImage
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 transformationoptions- Image convert command optionsdestination- Destination folder location- Returns:
- Node representing the newly transformed image.
-
processTemplate
Process a FreeMarker Template against the current node.- Parameters:
template- Node of the template to execute- Returns:
- output of the template execution
-
processTemplate
Process a FreeMarker Template against the current node.- Parameters:
template- Node of the template to executeargs- 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
Process a FreeMarker Template against the current node.- Parameters:
template- The template to execute- Returns:
- output of the template execution
-
processTemplate
Process a FreeMarker Template against the current node.- Parameters:
template- The template to executeargs- 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
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.The async flag in the method signature will not be applicable as all of the future transformations will be asynchronousCreates 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 thumbnailasync- 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(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 asynchronousCreates 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 thumbnailasync- indicates whether the thumbnail is create asynchronously or notforce- ignore system.thumbnail.generate=false- Returns:
- ScriptThumbnail the newly create thumbnail node or null if async creation occures
-
getThumbnail
Get the given thumbnail for the content property- Parameters:
thumbnailName- the thumbnail name- Returns:
- ScriptThumbnail the thumbnail
-
getThumbnails
Get the all the thumbnails for a given node's content property.- Returns:
- Scriptable list of thumbnails, empty if none available
-
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.This version of the method name spelling is retained (for now) for backwards compatibility- See Also:
-
clearTags
public void clearTags()Clear the node's tags -
addTag
Adds a tag to the node- Parameters:
tag- tag name
-
addTags
Adds all the tags to the node- Parameters:
tags- array of tag names
-
removeTag
Removes a tag from the node- Parameters:
tag- tag name
-
removeTags
Removes all the tags from the node- Parameters:
tags- array of tag names
-
getTags
Get all the tags applied to this node- Returns:
- String[] array containing all the tag applied to this node
-
setTags
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
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
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
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
Override Object.toString() to provide useful debug output -
toJSON
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
Returns the JSON representation of this node. Long-form QNames are used in the result.- Returns:
- The JSON representation of this node
-
getShortQName
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
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
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
Gets the node value converter- Returns:
- the node value converter
-
createValueConverter
Constructs the node value converter- Returns:
- the node value converter
-
getNamespacePrefixResolver
NamespacePrefixResolverProvider getter implementation- Specified by:
getNamespacePrefixResolverin interfaceNamespacePrefixResolverProvider
-
author janv