3.0 JavaScript Services API

cancel
Showing results for 
Search instead for 
Did you mean: 

3.0 JavaScript Services API

resplin
Intermediate
0 0 2,794

Obsolete Pages{{Obsolete}}

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



Labs 3D3.0Design DiscussionsSite ServiceDraft PagesJavaScript APIActivities ServiceTagging ServiceThumbnail Service

This page describes the JavaScript Services API for Alfresco Enterprise 3.0.X and Alfresco Labs 3D. See also JavaScript API 3.0


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
  • 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.


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 sire 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.




isPublic:Indicates whether the site is public or not.

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)

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.



getThumbnailDefintions()





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()