3.3 JavaScript Services API

Document created by resplin Employee on Jun 6, 2015
Version 1Show Document
  • View in full screen mode

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com



3.3Site ServiceDraft PagesJavaScript APIActivities ServiceTagging ServiceThumbnail ServiceTransfer Service

This page describes the JavaScript Services API for Alfresco Enterprise 3.3.X and Alfresco Community 3.3.
See also 3.3 JavaScript API


Table of Contents


Site service


A site is a collaborative area for a unit of work or a project.

This section describes the methods available for the Site Service. The methods are grouped into the following object types:


  • Site service (available as a root object with name siteService)
  • Site

Site service


The following sections describe the available methods.


Create a new site


This method creates a new site.



createSite(sitePreset, shortName, title, description, visibility);













Parameters:
sitePresetThe site preset.
shortNameThe site short name.  The site short name will be used to identify the site, so it must be unique.
titleA title for the site.
descriptionA description for the site.
visibilityThe visibility of the site.  (PUBLIC|PRIVATE|MODIFIED)





Return values:
SiteThe created site.



Deprecated since version 3.2:



createSite(sitePreset, shortName, title, description, isPublic)

List the available sites


This method lists the sites that are available in the repository. The returned list can optionally be filtered by name and site.



listSites(nameFilter, sitePresetFilter)







Parameters:
nameFilterThe name of the filter.
sitePresetFilterThe site preset filter.





Return values:
List<Site>A list of the site filtered, as appropriate. If no filters are specified then all the available sites are returned.

Get a site


This method gets a site for a provided short name.



getSite(shortName)





Parameters:
shortNameThe short name of the site.





Return values:
SiteThe site. This is null if the site does not exist.

List the site roles


This method lists the roles for a site.



listSiteRoles()

Site


The following list shows the properties for site:


shortName:The unique short name identifying the site (read-only).
sitePreset:The name of the site preset used to create the site (read-only).
title:The displayable title of the site.
description:The displayable description of the site.
node:The site node, null if none.




visibility:The visibility of the site. (PUBLIC|MODERATED|PRIVATE)




Save sites


This method saves any outstanding updates to the site details. If properties of the site are changed and the save method is not called, those changes will be lost.



save()

Delete sites


This method deletes the site.



deleteSite()

Get list of site members


This method gets a map of members of the site with their role within the site. This list can be filtered by name and/or role.



listMembers(nameFilter, roleFilter)







Parameters:
nameFilterThe user name filter.
roleFilterThe user role filter.





Return values:
Map<String, String>The list of members of a site with their roles. If no name or role filter is specified, all members of the site are listed.

Get site member's role


This method gets a user's role on this site.



getMembersRole(userName)





Parameters:
userNameThe user's name.





Return values:
StringThe user's role. If the user is not a member of the site then null is returned.

Indicate if user is site member


This method indicates whether a user is a member of the site.



isMember(userName)





Parameters:
userNameThe user's name.





Return values:
boolean valueThis is a boolean value that is true if the user is a member of the site, or false if otherwise.

Set membership details for user


This method sets the membership details for a user. If the user is not already a member of the site, then they are added with the role given. If the user is already a member of the site, then their role is updated to the new role. Only a site manager can modify memberships and there must be at least one site manager at all times.



setMembership(userName, role)







Parameters:
userNameThe user's name.
roleThe role for the user.





Return values:
roleThe site role.

Remove user membership from site


This method removes a user's membership of the site. Only a site manager can remove a user's membership and the last site manager can not be removed.



removeMembership(userName)





Parameters:
userNameThe user's name.

Get container folder for component id


This method gets (or creates) the container folder for the specified component id. NOTE: The container is of type cm:folder.



ScriptNode getContainer(String componentId)





Parameters:
componentIdThe component identifier.





Return values:
nodeThe container folder.

Get container folder for component id


This method gets (or creates) the container folder for the specified component id. NOTE: The type of container is either the one specified by the caller (which must be cm:folder or a sub-type of), or cm:folder, if a type is not specified at all.



public ScriptNode getContainer(String componentId, String folderType)







Parameters:
componentIdThe component identifier.
folderTypeThe type of folder to create. If this is null, it creates a standard folder.





Return values:
nodeThe name of the container folder. This is null if the container cannot be created.

Determine if the container folder exists


This method determines if the container folder for the specified component exists.



hasContainer(String componentId)





Parameters:
componentIdThe component identifier.





Return values:
boolean valueIf this is true, the container folder exists.

Reset all permissions


This method resets any permissions that have been set on the node. All permissions will be deleted and the node set to inherit permissions.



resetAllPermissions(node)

Allow all members to collaborate


This method allows all members of the site collaboration rights on the node.



allowAllMembersCollaborate(node)

Deny access


This method denies access to all members of the site to the node. Note: site managers will still have appropriate permissions on the node.



denyAllAccess(node)

Invite Moderated


Create new moderated invitation to this web site



ScriptInvitation inviteModerated(String inviteeComments, String inviteeUserName, String inviteeRole)

Invite Nominated (new user)


Create new nominated invitation to this web site for a user who may not already be an alfresco user.



    public ScriptInvitation inviteNominated(String inviteeFirstName, String inviteeLastName, String inviteeEmail, String inviteeRole, String serverPath, String acceptUrl, String rejectUrl)

Invite Nominated (existing user)


Create new nominated invitation to this web site



    public ScriptInvitation inviteNominated(String inviteeUserName, String inviteeRole, String serverPath, String acceptUrl, String rejectUrl)




Get Invitation


Get an invitation to this web site



public ScriptInvitation getInvitation(String invitationId)

List invitations


list the outstanding invitations for this site



    public ScriptInvitation[] listInvitations()

Search invitations


List the open invitations for this web site.
props specifies optional properties to be searched.



public ScriptInvitation[] listInvitations(Scriptable props)

Activities service


Activities refer to the updates to content within a site, including the uploaded files, blogs, discussions, calendars, and the team wiki.

This section describes the methods available for the Activities Service. The methods are grouped into the following object types:


  • Post activity
  • Feed controls

Post activity


Note: siteId is currently required in order to get site members (and to apply feed controls).

Note: appToolId is optional, although recommended (to enable feed controls to applied to a specific type of appTool).

The following sections describe the overloaded methods for post activity.


Post a custom activity type


This method posts a custom activity type.



postActivity(String activityType, String siteId, String appTool, String jsonActivityData)











Parameters:
activityTypeThis is a required parameter.
siteIdThis is a required parameter.
appToolIdThis is an optional parameter. If it is set, then the feed controls can be applied.
jsonActivityDataThis is a required parameter.

Post a predefined activity type


This method posts a predefined activity type. Activity data will be looked-up asynchronously, including:


  • name
  • displayPath
  • typeQName
  • firstName (of posting user)
  • lastName  (of posting user)

postActivity(String activityType, String siteId, String appTool, NodeRef nodeRef)











Parameters:
activityTypeThis is a required parameter.
siteIdThis is a required parameter.
appToolIdThis is an optional parameter. If it is set, then the feed controls can be applied.
nodeRefThis is a required parameter. Do not use this parameter for deleted (or about to be deleted) nodeRef.

Post a predefined activity type with optional name of node


This method posts a predefined activity type, for example, for checked-out nodeRef or renamed nodeRef.



postActivity(String activityType, String siteId, String appTool, NodeRef nodeRef, String beforeName)













Parameters:
activityTypeThis is a required parameter.
siteIdThis is a required parameter.
appToolIdThis is an optional parameter. If it is set, then the feed controls can be applied.
nodeRefThis is a required parameter. Do not use this parameter for a deleted (or about to be deleted) nodeRef.
beforeNameThis is an optional parameter. The name of the node prior to the name change.

Post a predefined activity for deleted nodeRef


This method posts a predefined activity, for example, for the deleted nodeRef.



postActivity(String activityType, String siteId, String appTool, NodeRef nodeRef, String name, QName typeQName,
NodeRef parentNodeRef)

















Parameters:
activityTypeThis is a required parameter.
siteIdThis is a required parameter.
appToolIdThis is an optional parameter. If it is set, then the feed controls can be applied.
nodeRefThis is a required parameter. Do not use this parameter for deleted (or about to be deleted) nodeRef.
nameThis is an optional parameter. The name of name.
typeQNameThis is an optional parameter. The type of node.
parentNodeRefThis is a required parameter. This is used to lookup path/displayPath.

Feed controls


The following sections describe the methods for feed controls.


Set feed control


This method sets the feed control (opt-out) for a site, an appTool, or a site/appTool combination for the current user.



setFeedControl(String siteId, String appToolId)







Parameters:
siteIdThis is a required parameter but is optional if the appToolId is supplied.
appToolIdThis is a required parameter but is optional if the siteId is supplied.

Get feed controls


This method gets the feed control for the current user.



FeedControl[] getFeedControls()

FeedControl returns an array of user feed controls.


Unset feed control


This method unsets the feed control for the current user.


  
unsetFeedControl(String siteId, String appTool)







Parameters:
siteIdThis is a required parameter but is optional if the appToolId is supplied.
appToolIdThis is a required parameter but is optional if the siteId is supplied.

Tagging services


A tag is a non-hierarchical keyword or term assigned to a piece of information.

This section describes the methods available for the Tagging Service. The methods are grouped into the following object types:


  • Tagging service
  • Tag scope
  • Tag details

The following are extensions to the existing JavaScript_API.


  • Extensions to existing Script Node
  • Extensions to existing search API

Tagging service


The following section describes the getTags method for the tagging service.


Get tags



function getTags();

Tag scope


The following properties are available for tag scope:


tags
Read only array containing the tag details in count order.

The following sections describe the methods for tag scope.


Get top tags


This method gets the top N tags ordered by count.



getTopTags(topN);





Parameters:
topNThe number of top tags to return.





Return values:
TagDetails[]The top N tag details ordered by count.

Get count of tag


This method gets the count of a tag.



getCount(tag);





Parameters:
tagThe tag name.





Return values:
intThe tag count. This is zero if the tag is not present.

Refresh the tag scope


This method refreshes the tag scope.



refresh();

TagDetails


The following properties are available for TagDetails:


name
The name of the tag.
count
The tag count.

Extensions To Existing Script Node


The following properties are extensions to the existing Script Node:


isTagScope
Read/write boolean property indicating whether the node is a tag scope or not.
tagScope
Read property that provides the 'nearest' tag scope for the node, is null if no tag scope found.
tags
Read/write string array property of tags applied to this node.  Setting the value of this property resets all the tags on that node.

The following sections describe the additional methods for Script Node.


Clear the node's tags


This method clears the node's tags.



clearTags()

Add tag to a node


This method adds a tag to the node.



addTag(tag)





Parameters:
tagThe tag name.

Add all tags to a node


This method adds all the tags to the node.



addTags(tags)





Parameters:
tagsAn array of tag names.

Remove tag from a node


This method removes a tag from the node.



removeTag(tag)





Parameters:
tagThe tag name.

Remove all tags from a node


This method removes all the tags from the node.



removeTags(tags)





Parameters
tagsAn array of tag names.

Get all children of node


This method gets all the (deep) children of this node that have the tag specified.


    
childrenByTag(tag)





Parameters:
tagThe tag name.





Return values:
ScriptNodeThe nodes that are the deep children of the node with the tag.

Extensions To Existing Search API


The following sections describe the additional methods for the Search API.


Search for node by tag


This method searches the store for all nodes with the given tag applied.



tagSearch(store, tag)





Parameters:
storeThe store reference string. The default is used if null is provided.tagThe tag name.





Return values:
ScriptNodeThe nodes with the tag applied.

Thumbnail Services


A thumbnail is a small image that provides a preview of the file without opening it. This section describes the methods available for the Thumbnail Service.

The methods are grouped into the following object types:


  • Thumbnail service
  • Thumbnail

The following are extensions to the existing JavaScript_API:


  • Extensions To Existing Script Node

Thumbnail Service


The following methods describe the methods for the thumbnail service.


Indicate if thumbnail is registered


This method indicates whether a given thumbnail name has been registered.



isThumbnailNameRegistered(thumbnailName)





Parameters:
thumbnailNameThe thumbnail name.





Return values:
boolean valueThis is true if the thumbnail name is registered, otherwise it is false.

Get place holder resource path


This method gets the resource path for the place holder thumbnail for the given named thumbnail.



getPlaceHolderResourcePath(thumbnailName)





Parameters:
thumbnailNameThe thumbnail name.





Return values:
StringThe place holder thumbnail resource path. This is null if it is not set.

Extensions To Existing Script Node


The following sections describe the additional methods to the existing Script Node.


Create thumbnail


This method creates a thumbnail based on the definition registered for the thumbnail name provided.



createThumbnail(thumbnailName, async)







Parameters:
thumbnailNameThe thumbnail name. If the thumbnail name has not been registered, there will be an error.
asyncThis is an optional parameter and is false by default. This parameter is true if the thumbnail was created asynchronously. Otherwise, it is false. When it is set to false, the method blocks until the thumbnail is created and the newly created thumbnail is returned. If it is set to true, the method queues the creation of the thumbnail asynchronously and immediately returns to the calling client with null.

The return value for createThumbnail is the thumbnail script node if the async is false. Otherwise it is null.


Get thumbnail


This method gets the given thumbnail for the content property.



getThumbnail(thumbnailName)





Parameters:
thumbnailNameThe thumbnail name.





Return values:
ScriptThumbnailThe thumbnail.

Get thumbnails


This method gets all the thumbnails for a given node's content property.



getThumbnails()





Return values:
ScriptThumbnailA list of thumbnails. This is empty if none are available.

Get thumbnail definitions


This method returns the names of the thumbnail definitions that can be applied to the content property of this node.  Thumbnail definitions 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 destination mimetype of the thumbnail.



getThumbnailDefinitions()





Return values:
StringAn array of thumbnail names that are valid for the current content type.

Thumbnail


The thumbnail object extends the standard ScriptNode and represents a thumbnail object.



updateThumbnail()




Rendition Services


A rendition is an alternative representation of a content node. Renditions are derived from their source nodes and are usually updated automatically when their source node is updated. Thumbnails are a special case of renditions which are still available through the Thumbnail Service (see above). Other examples include content that has been transformed into other formats (MIME types), images that have been processed in some way or content which incorporates property values from the source node. This section describes the methods available for the Rendition Service.

The methods are grouped into the following object types:


  • Rendition Service
  • Rendition Definition

Rendition Service


The following methods describe the methods for the rendition service.


Create a new Rendition Definition


This method creates a new Rendition Definition with the specified rendition name and will use the specified rendering engine.



createRenditionDefinition(renditionName, renderingEngineName)







Parameters:
renditionNameThe rendition definition name.
renderingEngineNameThe rendering engine name.





Return values:
RenditionDefinition valueThe newly created RenditionDefinition object.

Produce a rendition for a content node


This method will use a rendition definition to produce a rendition from a given node.



render(sourceNode, renditionDefQName)







Parameters:
sourceNodeThe node for which a rendition should be created.
renditionDefQNameThe qname of the rendition definition to use.





Return values:
ScriptNode valueThe new rendition object.

Get existing renditions for a content node


These methods will retrieve existing renditions for a node.



getRenditions(node)





Parameters:
nodeThe node whose renditions are requested.





Return values:
ScriptNode[] valueAny and all existing rendition objects for the specified node.


getRenditions(node, mimeTypePrefix)







Parameters:
nodeThe node whose renditions are requested.
mimeTypePrefixA filter to restrict the renditions returned to those whose MIME-type starts with the prefix.





Return values:
ScriptNode[] valueAny existing rendition objects for the specified node whose MIME-type starts with the given filter string.


getRenditionsByName(node, renditionName)







Parameters:
nodeThe node whose renditions are requested.
renditionNameA filter to restrict the renditions returned to those with the given name.





Return values:
ScriptNode[] valueAny existing rendition objects for the specified node whose name matches renditionName.




Rendition Definition


The ScriptRenditionDefinition extends from ScriptAction.
The following are extensions to the existing JavaScript_API for Script Actions:


Get a Rendition Definition name


This method returns the rendition definition name for the current rendition definition.



getRenditionName()





Return values:
String valueThe name of this rendition definition object.

Get a Rendering Engine name


This method returns the rendering engine name used by the current rendition definition.



getRenderingEngineName()





Return values:
String valueThe name of the rendering engine used by the current rendition definition object.

Groups (Authority Service)


Script object representing the authority service.    groups


Get the root groups


Get the root groups, those without a parent group.





Parameters:





Return values:
Array<ScriptGroup>The root groups. (empty if there are no root groups)

  
ScriptGroup[] getAllRootGroups()

Searches for root groups in the specified zone.






Parameters:
zoneThe zone to search in.





Return values:
Array<ScriptGroup>The root groups. (empty if there are no root groups)

  
ScriptGroup[] getAllRootGroupsInZone(String zone)

Get Group


Get a group given its short name






Parameters:
shortNameThe short name of the group.





Return values:
ScriptGroupThe authority or null if it can't be found.




  
ScriptGroup getGroup(String shortName)

Create Root Group


Create a new root group






Parameters:
shortNameThe short name of the group.





Return values:
ScriptGroupThe authority or null if it can't be found.

 
ScriptGroup createRootGroup(String shortName, String displayName)

Search Groups


Search for groups






Parameters:
shortNameFilterpartial match on shortName (* and ?) work.  If empty then matches everything.





Return values:
ScriptGroup[]The groups matching the query

  
ScriptGroup[] searchGroups(String shortNameFilter)







Parameters:
shortNameFilterpartial match on shortName (* and ?) work.  If empty then matches everything.
zonesearch in the specified zone?





Return values:
ScriptGroup[]The groups matching the query

  
ScriptGroup[] searchGroupsInZone(String shortNameFilter, string zone)

Group Authority


public class ScriptGroup implements Authority, Serializable


Delete this group


Delete this group


  
deleteGroup()

getAuthorityType



ScriptAuthorityType getAuthorityType()

getShortName



String getShortName()

getFullName


 
String getFullName()

setDisplayName


Change the display name for this group.    Need administrator permission to call this method to change a display name.
  @param displayName


  
setDisplayName(String displayName)

getDisplayName


public String getDisplayName()


Get All Users


Get the users contained within this group.






Return values:
ScriptUser[]The users contained within this group and its sub groups.


ScriptUser[] getAllUsers()

Get All Sub Groups


Get all sub groups (all decendants)






Return values:
ScriptGroup[]The descenants of this group


ScriptGroup[] getAllGroups()

Get Child Users


Get child users of this group



ScriptUser[] getChildUsers()

Get Child Groups


Get child groups of this group



ScriptGroup[] getChildGroups()

Get Parent Groups


Get the immediate parents of this group






Return values:
ScriptGroup[]The immediate parents of this group


ScriptGroup[] getParentGroups()

Get All Parent Groups


Get all the parents of this group






Return values:
ScriptGroup[]All the parents of this group


ScriptGroup[] getAllParentGroups()

Get Child Authorities


Get all the children of this group, regardless of type






Return values:
Authority[]All the children of this group


Authority[] getChildAuthorities()

isRootGroup


Is this a root group?



boolean isRootGroup()

isAdminGroup


Is this an admin group?
Not yet implemented



boolean isAdminGroup()




getUserCount


Get the number of users contained within this group.






Return values:
intThe number of users contained within this group.


int getUserCount()

getGroupCount


Get the number of child groups contained within this group.






Return values:
intThe number of child groups contained within this group.


int getGroupCount()

Create Sub Group


Create a new group as a child of this group.








Parameters:
shortNameThe short name of the group.
displayNameThe display name of the group.





Return values:
ScriptGroupThe new group.


ScriptGroup createGroup(String shortName, String displayName)

Remove Sub Group


Remove sub group from this group






Parameters:
shortNameThe short name of the group.





removeGroup(String shortName)

Remove User


Remove child user from this group






Parameters:
shortNameThe shortName of the user to remove from this group.


removeUser(String shortName)

Add Authority


Add authority as a child of this group






Parameters:
fullAuthorityNamethe full name of the authority to add to this group.


addAuthority(String fullAuthorityName)

Remove Authority


Remove child Authority from this group






Parameters:
fullAuthorityNamethe full name of the authority to remove from this group.


void removeAuthority(String fullAuthorityName)

User Authority


The Script user is a USER authority exposed to the scripting API


Get Authority Type



ScriptAuthorityType getAuthorityType()




Get Short Name



String getShortName()




Get Full Name



String getFullName()




Get Display Name



String getDisplayName()

Transfer service


The transfer service transfers nodes from one repository to another.


ScriptTransferTarget


The following list shows the properties for a script transfer target:

   ;name:the unique name of the transfer target (read-only)
   ;description: the description (read-only)
   ;endpointHost: hostname (read-only)
   ;endpointProtocol: protocol http/https (read-only)
   ;endpointPort: port number (read-only)

Methods


getAllTransferTargets






Return values:
ScriptTransferTargetthe targets



ScriptTransferTarget[] getAllTransferTargets(groupName);


getTransferTargetsForGroup






Parameters:
groupNameThe name of the transfer group.





Return values:
ScriptTransferTargetthe targets


ScriptTransferTarget[] getTransferTargetsForGroup(groupName);

transfer


Transfers the set of nodes to the transfer target



Returns the transfer report node.


ScriptNode transfer(targetName, nodesToTransfer)

Attachments

    Outcomes