Alfresco JavaScript API
A collection of sublime text snippets useful for coding Alfresco webscripts, and scripts
Main Controller Script !
Trigger: main
Output:
/*
description: archivo.js
author: Oscar Daniel Torres Hdez : odtorres@uci.cu
organization: CIGED-UCI
published: 2015
version: v0.1.0
*/
try{
model.result=" ";
}catch(e){
model.error = e.message;
}
Trigger: main path type
Output:
/*
description: archivo.js
author: Oscar Daniel Torres Hdez : odtorres@uci.cu
organization: CIGED-UCI
published: 2015
version: v0.1.0
*/
try{
var path = 'PATH:"/app:company_home//*" AND TYPE:"pref:name"';
model.result = search.luceneSearch('workspace://SpacesStore', path);
}catch(e){
model.error = e.message;
}
Trigger: main findNode
Output:
/*
description: archivo.js
author: Oscar Daniel Torres Hdez : odtorres@uci.cu
organization: CIGED-UCI
published: 2015
version: v0.1.0
*/
try{
model.result search.findNode('workspace://SpacesStore/' + uuid);
}catch(e){
model.error = e.message;
}
Trigger: validate args
Output:
if (args.to == null)
{
status.code = 400;
status.message = "Some argumments are missing";
status.redirect = true;
}
else
{
model.to = args.to;
}
Root Objects !
Trigger: actions
Output:
actions
Trigger: args
Output:
args
Trigger: argsM
Output:
argsM.var
Trigger: avm
Output:
avm
Trigger: classification
Output:
classification
Trigger: companyhome
Output:
companyhome
Trigger: config
Output:
var c = new XML(config.script);
c.propertyValue;
Trigger: crossRepoCopy
Output:
crossRepoCopy
Trigger: document
Output:
document
Trigger: groups
Output:
groups
Trigger: invitations
Output:
invitations
Trigger: logger
Output:
logger
Trigger: msg
Output:
msg("value")
Trigger: people
Output:
people
Trigger: person
Output:
person
Trigger: script
Output:
script
Trigger: search
Output:
search
Trigger: search text
Output:
search.luceneSearch("TEXT:alfresco");
Trigger: search workspace text
Output:
search.luceneSearch("workspace://SpacesStore", "TEXT:site");
Trigger: search text sortcolumn asc
Output:
search.luceneSearch("TEXT:alfresco", "@cm:modified", false);
Trigger:search workspace text sortcolumn asc
Output:
search.luceneSearch("workspace://SpacesStore","TEXT:alfresco", "@cm:modified", false);
Trigger:search xpath
Output:
search.xpathSearch(string xpath);
Trigger:search workspace xpath
Output:
search.xpathSearch("workspace://SpacesStore", string xpath);
Trigger:search noderef
Output:
search.findNode('workspace://SpacesStore/'+uuid);
Trigger:search type
Output:
search.luceneSearch('workspace://SpacesStore', 'PATH:"/app:company_home//*" AND TYPE:"p:name"');
Trigger: sites
Output:
sites
Trigger: space
Output:
space
Trigger: transfer
Output:
transfer
Trigger: userhome
Output:
userhome
Trigger: utils
Output:
utils
Trigger: webprojects
Output:
webprojects
ScriptNode API !
Trigger: activeWorkflows
Output:
activeWorkflows
Trigger: aspects
Output:
aspects[0];
Trigger: assocs
Output:
assocs["cm:translations"][0];
Trigger: childAssocs
Output:
childAssocs["fm:discussion"][0];
Trigger: childByNamePath
Output:
childByNamePath("QA/Performance/Testing");
Trigger: children
Output:
children[0];
Trigger: childrenByXPath
Output:
childrenByXPath("*[@cm:name='Finance Documents']/*");
Trigger: content
Output:
content
Trigger: getSiteShortName
Output:
getSiteShortName();
Trigger: isContainer
Output:
isContainer
Trigger: isDocument
Output:
isDocument
Trigger: name
Output:
name
Trigger: nodeRef
Output:
nodeRef
Trigger: parent
Output:
parent
Trigger: parentAssocs
Output:
parentAssocs["cm:contains"][0];
Trigger: properties
Output:
properties["name"];
Trigger: qnamePath
Output:
qnamePath
Trigger: save
Output:
save();
Trigger: size
Output:
size
Trigger: sourceAssocs
Output:
sourceAssocs["cm:translations"][0];
Trigger: createFile
Output:
createFile(string name);
Trigger: createFolder
Output:
createFolder(string name);
Trigger: createNode
Output:
createNode("myfolder", "cm:folder");
Trigger: createNode2
Output:
createNode(string name, string type, Array properties);
Trigger: createNode3
Output:
createNode(string name, string type, string assocType);
Trigger: createNode4
Output:
createNode(string name, string type, Array properties, string assocType);
Trigger: createNode5
Output:
createNode(string name, string type, Array properties, string assocType, string assocName);
Trigger: addNode
Output:
addNode(ScriptNode node);
Trigger: removeNode
Output:
removeNode(ScriptNode node);
Trigger: createAssociation
Output:
createAssociation(ScriptNode target, string assocType);
Trigger: removeAssociation
Output:
removeAssociation(ScriptNode target, string assocType);
Trigger: remove
Output:
remove();
Trigger: copy
Output:
copy(ScriptNode destination);
Trigger: copy2
Output:
copy(ScriptNode destination, boolean deepCopy);
Trigger: move
Output:
move(ScriptNode destination);
Trigger: addAspect
Output:
addAspect(string aspect);
Trigger: addAspect2
Output:
addAspect(string aspect, Object properties);
Trigger: removeAspect
Output:
removeAspect(string aspect);
Workflow API !
Trigger: createPackage
Output:
workflow.createPackage();
Trigger: getActiveInstances
Output:
workflow.getActiveInstances();
Trigger: getAllDefinitions
Output:
workflow.getAllDefinitions();
Trigger: getAssignedTasks
Output:
workflow.getAssignedTasks();
Trigger: getCompletedTasks
Output:
workflow.getCompletedTasks();
Trigger: getDefinition
Output:
workflow.getDefinition("A workflow definition id");
Trigger: getDefinitionByName
Output:
workflow.getDefinitionByName("The name of the workflow");
Trigger: getDescription
Output:
workflow.getDescription();
Trigger: getId
Output:
workflow.getId();
Importing Scripts !
Trigger: import
Output:
<import resource="/Company Home/Data Dictionary/Scripts/library.js">
<import resource="workspace://SpacesStore/6f73de1b-d3b4-11db-80cb-112e6c2ea048">
<import resource="classpath:alfresco/extension/myutils.js">
Tools !
Trigger: System.out.println
Output:
java.lang.System.out.println("");
Trigger: jsonUtils.encodeJSONString
Output:
jsonUtils.encodeJSONString(value);
Trigger: jsonUtils.toJSONObject
Output:
jsonUtils.toJSONObject(object);
Trigger: jsonUtils.toJSONString
Output:
jsonUtils.toJSONString(object);
Trigger: jsonUtils.toObject
Output:
jsonUtils.toObject(jsonString);
Trigger: jsonUtils.toObject
Output:
jsonUtils.toObject(jsonObject);
Work in progress...
Author
GitHub: odtorres