-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Alfresco Developer Guide

As you learned in examples throughout the book, JavaScript is used in several different places across the Alfresco platform, particularly as one option for controller logic in web scripts. This section starts with a listing of the out of the box root JavaScript objects available to all scripts (except where noted), and then provides details for the rest of the JavaScript API.
The root objects available to your scripts are either utility objects or entry points into different areas of the JavaScript API. This section lists the root objects available and notes where further APIs exist. API details are provided in the next section, "JavaScript API".
Root Object |
Description |
---|---|
|
Entry point into the Actions API. Used to retrieve the list of actions configured in the repository or as a factory to retrieve an instance of an action. |
|
Available when the script is run as a web script controller. Contains the arguments passed to the script. |
|
Entry point into the AVM API. Used to retrieve a list of all AVM stores, to search for a store based on ID, or to search for a specific node. |
|
Available when the script is run as a web script controller. The cache object is used to dynamically modify the cache settings for a web script. |
|
Entry point into the Classification API. Used to get and create root categories, or to get all category nodes for a classification. |
|
|
|
Utility object for copying nodes between the DM and AVM store (and vice-versa). |
|
|
|
Utility object for logging messages to the console. |
|
Available when the script is run as a web script controller. The associative array used to pass data to the view. |
|
Entry point into the People API, which is used to work with people and groups. |
|
|
|
|
|
Entry point into the Search API, which can be used to execute Lucene searches, XPath searches, saved searches, and searches based on node reference. |
|
Used to retrieve the ticket for the current user executing the script. |
|
|
|
Available when the script is run as a web script controller. Used to set the response code, error message, and redirect flag. |
|
|
|
A generic utility object with commonly used functions. |
|
Available in Labs only, this is the entry point into the Workflow API. It is used to get tasks, workflow definitions, and workflow instances. It can also be used to create workflow packages. |
The classes that implement the JavaScript root objects are in org.alfresco.repo.jscript
. Much of the information in the tables within this section has been taken directly from the Alfresco Javadoc comments for the classes in that package.
In this section, method names are listed as they appear in the underlying Java class. For getters and setters, this means the "get" or "set" is shown even though it is typically dropped in JavaScript. For example, document.tags
and document.getTags()
are equivalent.
This section lists general utility classes or classes that are used across multiple APIs, such as ScriptNode
.
Function |
Description |
Return value |
---|---|---|
|
Gets the |
|
|
Gets the source |
|
|
Gets the target |
|
|
Gets the type of the association. |
String containing the |
Function |
Description |
Return value |
---|---|---|
|
Gets the child node on the target end of this association. |
|
|
Gets the |
|
|
Gets the name of the association. |
String containing the |
|
Gets the parent node. |
|
|
Gets the type of the association. |
String containing the |
|
Determines whether or not this is the primary association for this node. |
True if this is the primary association, otherwise false. |
Function |
Description |
Return value |
---|---|---|
|
Adds an aspect to the node. |
True if the aspect was added successfully, false if an error occurred. |
|
Adds an existing node as a child of this node. |
Void |
|
Adds the specified tag to the node. |
Void |
|
Gets the aspects applied to the node. |
|
|
Gets the aspects applied to the node. |
Set of |
|
Gets the target associations for a node. |
Associative array of target associations. |
|
Gets the target associations for a node. |
Associative array of target associations. |
|
Cancels the check-out of a working copy document. |
|
|
Checks in a working copy document. |
|
|
Performs a check-out of this document into the current parent space or, alternatively, the specified destination folder. |
|
|
Gets the child associations for a node. |
Associative array of child associations. |
|
Gets the child associations for a node. |
Associative array of child associations. |
|
Returns the node at the specified |
|
|
Gets the child nodes for a node. |
|
|
Searches the children of this node with the supplied XPath expression. |
Array of matching nodes. |
|
Gets the content property of this node as a string. |
String containing the node content. |
|
Brings in use the cross repository copy object to copy nodes between the DM and AVM repositories. |
|
|
Copies this node to a new parent destination. Note that children of the source node are not copied unless the |
|
|
Creates an association between this node and the specified target node. |
Void |
|
Creates a new File ( |
|
|
Creates a new folder ( |
|
|
Creates a new Node of the specified type as a child of this node. |
|
|
Creates a thumbnail for the content property of the node. |
|
|
Gets the human-readable path to the node. |
String containing the path. |
|
For a content document, this method returns the download URL to the content for the default content property. |
String containing the URL. |
|
Checks for the presence of the specified aspect. |
True if the aspect has been applied, otherwise returns false. |
|
Checks to see if the current user has the specified permission on this node. |
True if the user has permission, otherwise returns false. |
|
Returns the small or large icon for the node. |
String containing the URL for the image. |
|
Returns the UUID for the node. |
String containing the ID. |
|
Checks to see whether or not this node inherits its permissions from a parent. |
True if the inherit permission flag is turned on, otherwise returns false. |
|
Checks whether or not the node is a category. |
True if the node is a category, otherwise it returns false. |
|
Checks whether or not the node is a folder. |
True if the node is a folder, otherwise it returns false. |
|
Checks whether or not this node is of type |
True for |
|
Checks whether or not this node is a link to a folder. |
True if the node is a folder link, otherwise returns false. |
|
Checks whether or not this node is a link to a document. |
True if the node is a document link, otherwise returns false. |
|
Checks whether or not this node is locked. |
True if the node is locked, otherwise returns false. |
|
Checks whether or not this node is a tag scope. |
True if it is, false if it is not. |
|
Gets the mimetype for the node. |
String containing the mimetype. |
|
Moves this Node to a new parent destination. |
True if the move succeeds, and false if it fails. |
|
Gets the |
String containing the value of the |
|
Gets the node reference for the node. |
String containing the node's node reference. |
|
Gets the owner of the node. |
String containing the owner of the node. |
|
Gets the node reference for the node's parent. |
|
|
Retrieves the permissions for the node. |
Array of permissions applied to this Node. Strings returned are of the format [ALLOWED|DENIED];[USERNAME|GROUPNAME];PERMISSION for example: ALLOWED;kevinr;Consumer so can be easily tokenized on the ";" character. |
|
Gets the primary parent association for this node. |
|
|
Processes the specified FreeMarker template against this node. |
String containing the output of the FreeMarker template. |
|
Gets all properties for the node. |
An Associative Array of |
|
Gets the |
A String representing the path. |
|
Gets the |
A String representing the |
|
Gets the source associations for this node. |
Map of source associations. |
|
Gets the source associations for this node. |
Map of source associations. |
|
Gets the store ID for this node. |
String representing the store ID. |
|
Gets the store type for this node. |
String representing the store type. |
|
Gets the list of tags applied to this node. |
String array containing the tags. |
|
Gets the thumbnail for this node given a thumbnail name. |
|
|
Gets all thumbnails for this node. |
Array of |
|
Deletes the node. |
Returns true if the deletion was successful, false if it wasn't. |
|
Removes the specified aspect from the node. |
Returns true if the removal was successful, false if it wasn't. |
|
Removes an association between this node and the specified target node. |
Void |
|
Removes an existing child node of this node. |
Void |
|
Removes permission for ALL users from this node or from the specified authority. |
Void |
|
Removes the specified tag from this node. |
Void |
|
Saves the property changes to this node. |
Void |
|
Sets the content of this node to the value of the provided String. |
Void |
|
Sets whether this node should inherit permissions from the parent node. |
Void |
|
Sets whether or not this node is a tag scope. |
Void |
|
Sets the mimetype for the content attached to this node. |
Void |
|
Sets the |
Void |
|
Sets the owner of the node. |
Void |
|
Sets the permission for all users of this node or for the specified authority. |
Void |
|
Specializes the type of the node. |
True if successful, otherwise false. |
|
Gets the size of the content that is attached to the node. |
The size, in bytes, of the content. |
|
Takes ownership of the node. |
Void |
|
Transforms 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 is applied. |
|
|
Transforms 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. |
|
|
Gets the content type of this node. |
String containing the content type. |
|
Gets either the content stream URL or, for folders, the browse details URL for this node. |
String containing the URL. |
|
Gets the WebDAV URL for this node. |
String containing the URL. |
Function |
Description |
Return value |
---|---|---|
|
Retrieves a |
|
|
Pads a string with zeros ("0") to the desired length. |
Padded String. |
|
Converts a String to a boolean. |
Boolean value. |
Function |
Description |
Return value |
---|---|---|
|
Determines if the web script can have its response placed in a public cache. |
True if the content is public, false if it is not. |
|
Determines whether or not the cache should re-validate to make sure it is picking up the latest version of the web script response. |
True if cache should revalidate, false if it does not have to revalidate. |
|
Determines if the web script response should never be cached. |
True if the response should never be cached, false if it is OK to cache. |
|
Sets the |
Void |
|
Sets the |
Void |
|
Sets the |
Void |
Function |
Description |
Return value |
---|---|---|
|
Performs a copy of a source node to the specified parent destination node. The name will be applied to the destination node copy. Inter-store copy operations between Workspace and AVM and visa-versa are supported. |
|
Function |
Description |
Return value |
---|---|---|
|
Determines whether or not logging is enabled. |
True if logging is enabled, false if it is not. |
|
Writes a message to the log. |
Void |
Function |
Description |
Return value |
---|---|---|
|
Gets the status code for the web script's response. |
Code as an |
|
Sets the status code for the web script's response. |
Void |
|
Gets the description of the status code. |
String representing the status code description. |
|
Gets the short name of the status code. |
String representing the short name of the status code. |
|
Gets the exception that's been set on this status object. |
Throwable representing the exception. |
|
Gets the location. |
String representing the location. |
|
Sets the location. |
Void |
|
Gets the web script status message. |
String representing the status message. |
|
Sets the web script status message. |
Void |
|
Gets the redirect flag. |
Boolean representing the redirect flag. |
|
Sets the redirect flag. |
Void |
|
Sets the exception. |
Void |
Function |
Description |
Return value |
---|---|---|
|
Creates a reference to an Action |
|
|
Gets the registered list of actions. |
An Array of registered actions. |
Function |
Description |
Return value |
---|---|---|
|
Executes the script. |
Void |
|
Gets the name of the action. |
String representing the name of the action. |
|
Gets the parameters for the action. |
|
The AVM API is used for working with objects in the AVM store, which is currently only used by Alfresco's WCM functionality:
Function |
Description |
Return value |
---|---|---|
|
Gets the preview URL for the given |
String containing the URL. |
|
Gets the list of modified items for the specified user sandbox for a specific webapp as compared against the staging store in the store specified by the store ID. |
List of AVMNodes. |
|
Return an AVM Node for the fully qualified path. |
AVMNode of the matching node. |
|
Returns an AVM store object for the specified store name |
|
|
Returns an AVM Node representing the public store root folder. |
AVMNode of the root folder. |
|
Gets the staging store name for the given store ID. |
String containing the name. |
|
Gets a list of AVM stores in the repository. |
|
|
Gets the Sandbox Store name for the given store ID and username. |
String containing the name. |
|
Gets the folder path to the webapps folder. |
String containing the path. |
|
Gets the preview URL for the web site managed in the store represented by the store ID. |
String containing the URL. |
|
Gets the preview URL for the user sandbox for the store and username specified. |
String containing the URL. |
Function |
Description |
Return value |
---|---|---|
|
Copies this node into a new parent destination. |
ScriptNode representing the copy of this node |
| Gets the list of aspects applied to this node. | List of QNames. |
| Gets the name property of the node. | String representing the name. |
| Determines whether or not the current user can make a change to the node either because the node is not locked or the node is locked and the user is the lock owner or a Content Manager. | True if the user can make a change, false if they cannot. |
| Determines whether or not this node is a directory. | True if it is a directory, false if it is not. |
| Determines whether or not this node is a file. | True if it is a file, false if it is not. |
| Determines whether or not this node is locked. | True if it is locked, false if it is not. |
| Determines if this node is locked and the current user is the lock owner. | True if the node is locked and the user is the lock owner, otherwise false. |
| Determines if this node is locked and the current user is the lock owner. | True if the node is locked and the user is the lock owner, otherwise false. |
| Moves this node to the specified destination. | True if the move is successful, false if it is not. |
| Gets the path to this node's parent. | String representing the path. |
| Gets the full AVM path to this node. | String representing the path. |
| Renames this node to the new name specified. | True if the rename is successful, false if it is not. |
| Gets the Qname type of the node. | String representing the type. |
| Gets the version of the node. | Version number of the node as an integer. |
Function |
Description |
Return value |
---|---|---|
|
Gets the store's creation date. |
Date the store was created. |
|
Gets the user who created the store. |
String representing the store creator. |
|
Gets the store's ID. |
String representing the store ID. |
|
Looks up a node in the store; the path is assumed to be related to the webapps folder root. Therefore a valid path would be |ROOT/WEB-INF|lib|web.xml. |
|
|
Gets the store's name. |
String representing the name of the store. |
|
Gets the store's root node. |
AVMNode representing the root node. |
|
Executes a Lucene query against this store and returns the results. |
|
The Classification API is used for working with categories.
Function |
Description |
Return value |
---|---|---|
|
Gets all the aspects that define this classification. |
String array containing a list of aspect names. |
|
Creates a root category for this classification. |
Void |
|
Gets all category nodes for this classification. |
|
|
Gets categories with the most number of objects. The number of categories returned is specified in |
|
|
Gets all root categories for this classification. |
|
Function |
Description |
Return value |
---|---|---|
|
Gets all of the members of a category. |
An array of |
|
Creates a new subcategory. |
|
|
Gets the immediate members of a category. |
Array of |
|
Gets the immediate members and subcategories. |
Array of |
|
Gets the immediate subcategories. |
Array of |
|
Gets the members and subcategories for this category. |
Array of |
|
Removes this category. |
Void |
|
Gets the subcategories for this category. |
Array of |
The People API is for working with people and groups:
Function |
Description |
Return value |
---|---|---|
|
Adds an authority (a user or group) to a group container as a new child. |
Void |
|
Creates a new root-level group (or a subgroup if a parent is specified) with the specified unique name (do not use the "GROUP_" prefix). |
|
|
Creates a person with a generated username. |
|
|
Deletes the specified group. |
Void |
|
Deletes the specified person object. |
Void |
|
Enables the specified user account. |
Void |
|
Gets the authorities this authority contains, optionally recursing into subauthorities. |
Array of Objects representing the contained authorities. |
|
Gets the groups that contain the specified authority. |
|
|
Gets the group specified. |
|
|
Gets the people that belong to the specified group and, optionally, any sub-groups of the specified group. |
|
|
Gets all the people in the repository, optionally filtered by a query string. |
|
|
Gets the person given the specified username. |
|
|
Removes a person or group from the specified group. |
Void |
The Presence API can be used to determine whether or not someone is online according to their preferred presence provider:
Function |
Description |
Return value |
---|---|---|
|
Gets the presence provider and presence user name of the person specified. |
String of the format [presence provider]|[presence username]. |
|
Determines whether or not the person specified is configured with a presence provider. |
True if the person is configured for presence, otherwise false. |
The Search API is for executing queries, including saved searches:
Function |
Description |
Return value |
---|---|---|
|
Finds a single Node by the Node reference. 3.0 version adds the ability to pass in a reference type and string as follows:
|
|
|
Executes a Lucene search. |
JavaScript array of Node results from the search— can be empty, but not null. |
|
Executes a saved Lucene search. |
JavaScript array of Node results from the search—can be empty, but not null. |
|
Executes an XPath search. |
JavaScript array of Node results from the search— can be empty, but not null. |
Change the font size
Change margin width
Change background colour