public class ScriptNode extends Object implements Scopeable, org.alfresco.service.namespace.NamespacePrefixResolverProvider
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.
Modifier and Type | Class and Description |
---|---|
class |
ScriptNode.NodeValueConverter
Value converter with knowledge of Node specific value types
|
class |
ScriptNode.ScriptContentData
Inner class wrapping and providing access to a ContentData property
|
Modifier and Type | Field and Description |
---|---|
protected Set<org.alfresco.service.namespace.QName> |
aspects
The aspects applied to this node
|
protected ScriptNode.NodeValueConverter |
converter
Node Value Converter
|
protected String |
id |
protected TemplateImageResolver |
imageResolver |
protected org.alfresco.service.cmr.repository.NodeRef |
nodeRef
Cached values
|
protected ScriptNode |
parent |
protected org.mozilla.javascript.Scriptable |
scope
Root scope for this object
|
protected ServiceRegistry |
services |
protected String |
siteName |
protected boolean |
siteNameResolved |
Constructor and 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
|
Modifier and Type | Method and Description |
---|---|
boolean |
addAspect(String type)
Add an aspect to the Node.
|
boolean |
addAspect(String type,
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(String tag)
Adds a tag to the node
|
void |
addTags(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(String history)
Check-in a working copy document.
|
ScriptNode |
checkin(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(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,
Object ignoreTypes) |
ScriptPagingNodes |
childFileFolders(boolean files,
boolean folders,
Object ignoreTypes,
int maxItems)
Deprecated.
API for review (subject to change prior to release)
author janv |
ScriptPagingNodes |
childFileFolders(boolean files,
boolean folders,
Object ignoreTypes,
int skipOffset,
int maxItems,
int requestTotalCountMax,
String sortProp,
Boolean sortAsc,
String queryExecutionId) |
ScriptNode[] |
childrenByTags(String tag)
Gets all (deep) children of this node that have the tag specified.
|
org.mozilla.javascript.Scriptable |
childrenByXPath(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,
String assocType)
Create an association between this node and the specified target node.
|
ScriptNode |
createFile(String name)
Create a new File (cm:content) node as a child of this node.
|
ScriptNode |
createFile(String name,
String type)
Create a new File (cm:content) node as a child of this node.
|
ScriptNode |
createFolder(String name)
Create a new folder (cm:folder) node as a child of this node.
|
ScriptNode |
createFolder(String name,
String type)
Create a new folder (cm:folder) node as a child of this node.
|
ScriptNode |
createFolderPath(String path)
Create a path of folder (cm:folder) nodes as a child of this node.
|
ScriptNode |
createNode(String name,
String type)
Create a new Node of the specified type as a child of this node.
|
ScriptNode |
createNode(String name,
String type,
Object properties)
Create a new Node of the specified type as a child of this node.
|
ScriptNode |
createNode(String name,
String type,
Object properties,
String assocType)
Create a new Node of the specified type as a child of this node.
|
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.
|
ScriptNode |
createNode(String name,
String type,
String assocType)
Create a new Node of the specified type as a child of this node.
|
protected org.alfresco.service.namespace.QName |
createQName(String s)
Helper to create a QName from either a fully qualified or short-name QName string
|
ScriptThumbnail |
createThumbnail(String thumbnailName)
Creates a thumbnail for the content property of the node.
|
ScriptThumbnail |
createThumbnail(String thumbnailName,
boolean async)
Creates a thumbnail for the content property of the node.
|
ScriptThumbnail |
createThumbnail(String thumbnailName,
boolean async,
boolean force)
Creates a thumbnail for the content property of the node.
|
protected ScriptNode.NodeValueConverter |
createValueConverter()
Constructs the node value converter
|
ScriptVersion |
createVersion(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(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() |
Set<org.alfresco.service.namespace.QName> |
getAspectsSet() |
org.mozilla.javascript.Scriptable |
getAspectsShort() |
Map<String,Object> |
getAssociations() |
Map<String,Object> |
getAssocs()
Return the target associations from this Node.
|
ScriptNode |
getCheckedOut()
Gets the check-out of a working copy document
|
Map<String,Object> |
getChildAssociations() |
Map<String,Object> |
getChildAssocs()
Return the child associations from this Node.
|
org.mozilla.javascript.Scriptable |
getChildAssocsByType(String type)
Return an Array of the associations from this Node that match a specific object type.
|
org.mozilla.javascript.Scriptable |
getChildren() |
String |
getContent() |
org.mozilla.javascript.Scriptable |
getDirectPermissions() |
String |
getDisplayPath() |
String |
getDownloadUrl() |
org.mozilla.javascript.Scriptable |
getFullPermissions() |
boolean |
getHasChildren() |
String |
getIcon16() |
String |
getIcon32() |
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
|
String |
getMimetype() |
String |
getName() |
org.alfresco.service.namespace.NamespacePrefixResolver |
getNamespacePrefixResolver()
NamespacePrefixResolverProvider getter implementation
|
org.alfresco.service.cmr.repository.NodeRef |
getNodeRef() |
String |
getOwner()
Get the owner of the node.
|
ScriptNode |
getParent() |
Map<String,Object> |
getParentAssociations() |
Map<String,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() |
Map<String,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.
|
String |
getQnamePath() |
org.alfresco.service.namespace.QName |
getQNameType() |
org.mozilla.javascript.Scriptable |
getSettablePermissions() |
protected 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.
|
String |
getSiteShortName()
Returns the short name of the site this node is located within.
|
long |
getSize() |
static List<org.alfresco.service.cmr.security.AccessPermission> |
getSortedACLs(Set<org.alfresco.service.cmr.security.AccessPermission> acls) |
Map<String,Object> |
getSourceAssociations() |
Map<String,Object> |
getSourceAssocs()
Return the source associations to this Node.
|
String |
getStoreId() |
String |
getStoreType() |
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(String thumbnailName)
Get the given thumbnail for the content property
|
String[] |
getThumbnailDefinitions()
Returns the names of the thumbnail defintions that can be applied to the content property of
this node.
|
String[] |
getThumbnailDefintions()
Deprecated.
|
ScriptThumbnail[] |
getThumbnails()
Get the all the thumbnails for a given node's content property.
|
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.
|
String |
getTypeShort() |
String |
getUrl() |
protected ScriptNode.NodeValueConverter |
getValueConverter()
Gets the node value converter
|
ScriptVersion |
getVersion(String versionLabel)
Gets the version of this node specified by version label
|
org.mozilla.javascript.Scriptable |
getVersionHistory()
Gets the version history
|
String |
getWebdavUrl() |
boolean |
hasAspect(String aspect) |
int |
hashCode() |
boolean |
hasPermission(String permission)
Return true if the user has the specified permission on the node.
|
boolean |
inheritsPermissions() |
boolean |
isScriptContent(Object o)
Helper to return true if the supplied property value is a ScriptContentData object
|
boolean |
isSubType(String type) |
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
|
String |
processTemplate(ScriptNode template)
Process a FreeMarker Template against the current node.
|
String |
processTemplate(ScriptNode template,
Object args)
Process a FreeMarker Template against the current node.
|
String |
processTemplate(String template)
Process a FreeMarker Template against the current node.
|
String |
processTemplate(String template,
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(String type)
Remove aspect from the node.
|
void |
removeAssociation(ScriptNode target,
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(String permission)
Remove a permission for ALL user from the node.
|
void |
removePermission(String permission,
String authority)
Remove a permission for the specified authority (e.g.
|
void |
removeTag(String tag)
Removes a tag from the node
|
void |
removeTags(String[] tags)
Removes all the tags from the node
|
void |
reset()
Reset the Node cached state
|
protected Object[] |
retrieveAllSetPermissions(boolean direct,
boolean full)
Helper to construct the response object for the various getPermissions() calls.
|
ScriptNode |
revert(String history,
boolean majorVersion,
String versionLabel)
Revert this Node to the specified version.
|
ScriptNode |
revert(String history,
boolean majorVersion,
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(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(String mimetype)
Set the mimetype encoding for the content attached to the node from the default content property
(@see ContentModel.PROP_CONTENT)
|
void |
setName(String name)
Helper to set the 'name' property for the node.
|
void |
setOwner(String userId)
Set the owner of the node
|
void |
setPermission(String permission)
Apply a permission for ALL users to the node.
|
void |
setPermission(String permission,
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(String[] tags)
Set the tags applied to this node.
|
boolean |
specializeType(String type)
Re-sets the type of the node.
|
void |
takeOwnership()
Take ownership of the node.
|
String |
toJSON()
Returns the JSON representation of this node.
|
String |
toJSON(boolean useShortQNames)
Returns the JSON representation of this node.
|
String |
toString()
Override Object.toString() to provide useful debug output
|
ScriptNode |
transformDocument(String mimetype)
Transform a document to a new document mimetype format.
|
ScriptNode |
transformDocument(String mimetype,
ScriptNode destination)
Transform a document to a new document mimetype format.
|
ScriptNode |
transformImage(String mimetype)
Transform an image to a new image format.
|
ScriptNode |
transformImage(String mimetype,
ScriptNode destination)
Transform an image to a new image mimetype format.
|
ScriptNode |
transformImage(String mimetype,
String options)
Transform an image to a new image format.
|
ScriptNode |
transformImage(String mimetype,
String options,
ScriptNode destination)
Transform an image to a new image mimetype format.
|
void |
unlock()
Removes the lock on a node.
|
protected org.mozilla.javascript.Scriptable scope
protected ScriptNode.NodeValueConverter converter
protected org.alfresco.service.cmr.repository.NodeRef nodeRef
protected String id
protected String siteName
protected boolean siteNameResolved
protected Set<org.alfresco.service.namespace.QName> aspects
protected ServiceRegistry services
protected TemplateImageResolver imageResolver
protected ScriptNode parent
public ScriptNode(org.alfresco.service.cmr.repository.NodeRef nodeRef, ServiceRegistry services)
nodeRef
- The NodeRef this Node wrapper representsservices
- The ServiceRegistry the Node can use to access servicespublic ScriptNode(FileInfo nodeInfo, ServiceRegistry services, org.mozilla.javascript.Scriptable scope)
nodeInfo
- The FileInfo this Node wrapper representsservices
- The ServiceRegistry the Node can use to access servicesscope
- Root scope for this Nodepublic ScriptNode(org.alfresco.service.cmr.repository.NodeRef nodeRef, ServiceRegistry services, org.mozilla.javascript.Scriptable scope)
nodeRef
- The NodeRef this Node wrapper representsservices
- The ServiceRegistry the Node can use to access servicesscope
- Root scope for this Nodepublic ScriptNode newInstance(org.alfresco.service.cmr.repository.NodeRef nodeRef, ServiceRegistry services, org.mozilla.javascript.Scriptable scope)
public ScriptNode newInstance(FileInfo nodeInfo, ServiceRegistry services, org.mozilla.javascript.Scriptable scope)
public void setScope(org.mozilla.javascript.Scriptable scope)
Scopeable
setScope
in interface Scopeable
scope
- relative global scopeScopeable.setScope(org.mozilla.javascript.Scriptable)
public String getId()
public String getStoreType()
public String getStoreId()
public org.alfresco.service.cmr.repository.NodeRef getNodeRef()
public org.alfresco.service.namespace.QName getQNameType()
public String getType()
public String getTypeShort()
public String getName()
public void setName(String name)
name
- Name to setpublic org.mozilla.javascript.Scriptable getChildren()
public boolean getHasChildren()
public ScriptNode childByNamePath(String path)
mynode.childByNamePath("/QA/Testing/Docs");
path
- the relative path of the descendant node to find e.g. "/QA/Testing/Docs"
null
if the node is not found.
null
if the specified path is ""
.NullPointerException
- if the provided path is null
.public org.mozilla.javascript.Scriptable childrenByXPath(String xpath)
mynode.childrenByXPath("*[@cm:name='Testing']/*");
public org.mozilla.javascript.Scriptable childFileFolders()
public org.mozilla.javascript.Scriptable childFileFolders(boolean files, boolean folders)
files
- Return files extending from cm:contentfolders
- Return folders extending from cm:folder - ignoring sub-types of cm:systemfolderpublic org.mozilla.javascript.Scriptable childFileFolders(boolean files, boolean folders, Object ignoreTypes)
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".public ScriptPagingNodes childFileFolders(boolean files, boolean folders, Object ignoreTypes, int maxItems)
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 itemspublic ScriptPagingNodes childFileFolders(boolean files, boolean folders, Object ignoreTypes, int skipOffset, int maxItems, int requestTotalCountMax, String sortProp, Boolean sortAsc, String queryExecutionId)
public Map<String,Object> getAssocs()
node.assocs["translations"][0]
public Map<String,Object> getSourceAssocs()
node.sourceAssocs["translations"][0]
public Map<String,Object> getChildAssocs()
node.childAssocs["contains"][0]
public org.mozilla.javascript.Scriptable getChildAssocsByType(String type)
node.getChildAssocsByType("cm:folder")[0]
public Map<String,Object> getParentAssocs()
node.parentAssocs["contains"][0]
public boolean exists()
ScriptNode
exists in the repository.public Map<String,Object> getProperties()
node.properties["name"]
public org.mozilla.javascript.Scriptable getTypePropertyNames()
public org.mozilla.javascript.Scriptable getTypePropertyNames(boolean useShortQNames)
useShortQNames
- if true short-form qnames will be returned, else long-form.public org.mozilla.javascript.Scriptable getPropertyNames(boolean useShortQNames)
useShortQNames
- if true short-form qnames will be returned, else long-form.public boolean getIsContainer()
public boolean getIsDocument()
public boolean getIsLinkToContainer()
public boolean getIsLinkToDocument()
public boolean getIsCategory()
public Set<org.alfresco.service.namespace.QName> getAspectsSet()
public org.mozilla.javascript.Scriptable getAspects()
public org.mozilla.javascript.Scriptable getAspectsShort()
public boolean hasAspect(String aspect)
aspect
- The aspect name to test for (fully qualified or short-name form)public boolean isSubType(String type)
type
- The qname type to test this object against (fully qualified or short-name form)public String getQnamePath()
public String getDisplayPath()
public String getIcon16()
public String getIcon32()
public boolean getIsLocked()
public ScriptNode getParent()
public org.mozilla.javascript.Scriptable getParents()
public org.alfresco.service.cmr.repository.ChildAssociationRef getPrimaryParentAssoc()
public String getContent()
public void setContent(String content)
content
- Content string to setpublic String getUrl()
For a container node, this method return the URL to browse to the folder in the web-client
public String getDownloadUrl()
For a container node, this method returns an empty string
public String jsGet_downloadUrl()
public String getWebdavUrl()
public String getMimetype()
public void setMimetype(String mimetype)
mimetype
- Mimetype to setpublic long getSize()
public boolean hasPermission(String permission)
The default permissions are found in org.alfresco.service.cmr.security.PermissionService
.
Most commonly used are "Write", "Delete" and "AddChildren".
permission
- as found in org.alfresco.service.cmr.security.PermissionService
public org.mozilla.javascript.Scriptable getPermissions()
public org.mozilla.javascript.Scriptable getDirectPermissions()
public org.mozilla.javascript.Scriptable getFullPermissions()
public static List<org.alfresco.service.cmr.security.AccessPermission> getSortedACLs(Set<org.alfresco.service.cmr.security.AccessPermission> acls)
AccessPermission
based on CMISConnector.AccessPermissionComparator
and AccessStatus
of the permission for an authority.protected Object[] retrieveAllSetPermissions(boolean direct, boolean full)
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.public org.mozilla.javascript.Scriptable getSettablePermissions()
public boolean inheritsPermissions()
public void setInheritsPermissions(boolean inherit)
inherit
- True to inherit parent permissions, false otherwise.public void setInheritsPermissions(boolean inherit, boolean asyncCall)
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.public void setPermission(String permission)
permission
- Permission to applyPermissionService
public void setPermission(String permission, String authority)
permission
- Permission to apply @see org.alfresco.service.cmr.security.PermissionServiceauthority
- Authority (generally a username or group name) to apply the permission forpublic void removePermission(String permission)
permission
- Permission to remove @see org.alfresco.service.cmr.security.PermissionServicepublic void removePermission(String permission, String authority)
permission
- Permission to remove @see org.alfresco.service.cmr.security.PermissionServiceauthority
- Authority (generally a username or group name) to apply the permission forpublic void setOwner(String userId)
public void takeOwnership()
public String getOwner()
public void save()
public boolean specializeType(String type)
type
- Type to specialize the nodepublic ScriptNode createFile(String name)
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.
name
- Name of the file to createpublic ScriptNode createFile(String name, String type)
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.
name
- Name of the file to createtype
- Type of the file to create (if null, defaults to ContentModel.TYPE_CONTENT)public ScriptNode createFolder(String name)
save()
first.name
- Name of the folder to createpublic ScriptNode createFolder(String name, String type)
save()
first.name
- Name of the folder to createtype
- Type of the folder to create (if null, defaults to ContentModel.TYPE_FOLDER)public ScriptNode createFolderPath(String path)
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.
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.public ScriptNode createNode(String name, String type)
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')public ScriptNode createNode(String name, String type, String assocType)
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')public ScriptNode createNode(String name, String type, Object properties)
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.public ScriptNode createNode(String name, String type, Object properties, String assocType)
save()
first.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')public ScriptNode createNode(String name, String type, Object properties, String assocType, String assocName)
save()
first.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')public void addNode(ScriptNode node)
save()
first.node
- node to add as a child of this nodepublic void removeNode(ScriptNode node)
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.
node
- child node to removepublic Association createAssociation(ScriptNode target, String assocType)
save()
first.target
- Destination node for the associationassocType
- Association type qname (short form or fully qualified)public void removeAssociation(ScriptNode target, String assocType)
save()
first.target
- Destination node on the end of the associationassocType
- Association type qname (short form or fully qualified)public boolean remove()
save()
first.public boolean remove(boolean newTransaction)
save()
first.public ScriptNode copy(ScriptNode destination)
destination
- Nodepublic ScriptNode copy(ScriptNode destination, boolean deepCopy)
destination
- NodedeepCopy
- True for a deep copy, false otherwise.public ScriptNode revert(String history, boolean majorVersion, String versionLabel)
versionLabel
- to revert fromnull
otherwise
(if the version does not exist).public ScriptNode revert(String history, boolean majorVersion, String versionLabel, boolean deep)
save()
first.history
- Version history notemajorVersion
- True to save as a major version increment, false for minor version.versionLabel
- to revert fromdeep
- true
for a deep revert, false
otherwise.null
otherwise
(if the version does not exist).public boolean move(ScriptNode destination)
save()
first.destination
- Nodepublic boolean move(ScriptNode source, ScriptNode destination)
save()
first.source
- Nodedestination
- Nodepublic boolean addAspect(String type)
save()
first.type
- Type name of the aspect to addpublic boolean addAspect(String type, Object props)
save()
first.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!public boolean removeAspect(String type)
save()
first.type
- the aspect typepublic void ensureVersioningEnabled(boolean autoVersion, boolean autoVersionProps)
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?public void ensureVersioningEnabled()
public ScriptVersion createVersion(String history, boolean majorVersion)
history
- Version history notemajorVersion
- True to save as a major version increment, false for minor version.public boolean getIsVersioned()
public org.mozilla.javascript.Scriptable getVersionHistory()
public ScriptVersion getVersion(String versionLabel)
versionLabel
- version labelpublic ScriptNode checkout()
public ScriptNode checkoutForUpload()
public ScriptNode checkout(ScriptNode destination)
destination
- Destination for the checked out document working copy Node.public ScriptNode checkin()
public ScriptNode checkin(String history)
history
- Version history notepublic ScriptNode checkin(String history, boolean majorVersion)
history
- Version history notemajorVersion
- True to save as a major version increment, false for minor version.public void unlock()
public ScriptNode getCheckedOut()
public ScriptNode cancelCheckout()
public ScriptNode transformDocument(String mimetype)
mimetype
- Mimetype destination for the transformationpublic ScriptNode transformDocument(String mimetype, ScriptNode destination)
mimetype
- Mimetype destination for the transformationdestination
- Destination folder locationpublic ScriptNode transformImage(String mimetype)
mimetype
- Mimetype destination for the transformationpublic ScriptNode transformImage(String mimetype, String options)
mimetype
- Mimetype destination for the transformationoptions
- Image convert command optionspublic ScriptNode transformImage(String mimetype, ScriptNode destination)
mimetype
- Mimetype destination for the transformationdestination
- Destination folder locationpublic ScriptNode transformImage(String mimetype, String options, ScriptNode destination)
mimetype
- Mimetype destination for the transformationoptions
- Image convert command optionsdestination
- Destination folder locationpublic String processTemplate(ScriptNode template)
template
- Node of the template to executepublic String processTemplate(ScriptNode template, Object args)
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 templatepublic String processTemplate(String template)
template
- The template to executepublic String processTemplate(String template, Object args)
template
- The template to executeargs
- Scriptable object (generally an associative array) containing the name/value pairs of
arguments to be passed to the templatepublic ScriptThumbnail createThumbnail(String thumbnailName)
thumbnailName
- the name of the thumbnailpublic ScriptThumbnail createThumbnail(String thumbnailName, boolean async)
thumbnailName
- the name of the thumbnailasync
- indicates whether the thumbnail is create asynchronously or notpublic ScriptThumbnail createThumbnail(String thumbnailName, boolean async, boolean force)
thumbnailName
- the name of the thumbnailasync
- indicates whether the thumbnail is create asynchronously or notforce
- ignore system.thumbnail.generate=falsepublic ScriptThumbnail getThumbnail(String thumbnailName)
thumbnailName
- the thumbnail namepublic ScriptThumbnail[] getThumbnails()
public String[] getThumbnailDefinitions()
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.
@Deprecated public String[] getThumbnailDefintions()
getThumbnailDefinitions()
public void clearTags()
public void addTag(String tag)
tag
- tag namepublic void addTags(String[] tags)
tags
- array of tag namespublic void removeTag(String tag)
tag
- tag namepublic void removeTags(String[] tags)
tags
- array of tag namespublic String[] getTags()
public void setTags(String[] tags)
tags
- array of tagspublic void setIsTagScope(boolean value)
value
- true if this node is a tag scope, false otherwisepublic boolean getIsTagScope()
public TagScope getTagScope()
If none is found, null is returned.
public ScriptNode[] childrenByTags(String tag)
tag
- tag namepublic org.mozilla.javascript.Scriptable getActiveWorkflows()
public String getSiteShortName()
public String toString()
public String toJSON(boolean useShortQNames)
useShortQNames
- if true short-form qnames will be returned, else long-form.public String toJSON()
protected String getShortQName(org.alfresco.service.namespace.QName longQName)
longQName
- QNameprotected org.alfresco.service.namespace.QName createQName(String s)
s
- Fully qualified or short-name QName stringpublic void reset()
public boolean isScriptContent(Object o)
o
- Object to testprotected ScriptNode.NodeValueConverter getValueConverter()
protected ScriptNode.NodeValueConverter createValueConverter()
public org.alfresco.service.namespace.NamespacePrefixResolver getNamespacePrefixResolver()
getNamespacePrefixResolver
in interface org.alfresco.service.namespace.NamespacePrefixResolverProvider
Copyright © 2005–2017 Alfresco Software. All rights reserved.