mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
. Create node from source (i.e. a templated document) WebScripts to support ALF-9710
. Added selectNodes(xpath) to JavaScript Search API (not sure why I never added it before...!) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29789 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<webscript>
|
||||
<shortname>Create Node Templates</shortname>
|
||||
<description>Document List Component - Create Node Templates GET data webscript</description>
|
||||
<url>/slingshot/doclib/node-templates</url>
|
||||
<format default="json">argument</format>
|
||||
<authentication>user</authentication>
|
||||
<transaction allow="readonly">required</transaction>
|
||||
<lifecycle>internal</lifecycle>
|
||||
</webscript>
|
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Document List Component: Create New Node - get list of available node templates in the Data Dictionary
|
||||
*/
|
||||
function main()
|
||||
{
|
||||
var nodes = search.selectNodes('/app:company_home/app:dictionary/app:node_templates/*[subtypeOf("cm:content")]');
|
||||
return nodes;
|
||||
}
|
||||
|
||||
model.nodes = main();
|
@@ -0,0 +1,15 @@
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
"data":
|
||||
[
|
||||
<#list nodes as node>
|
||||
{
|
||||
"nodeRef": "${node.nodeRef}",
|
||||
"name": "${node.name}",
|
||||
"title": "${node.properties.title!""}",
|
||||
"description": "${node.properties.description!""}"
|
||||
}<#if node_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
||||
}
|
||||
</#escape>
|
@@ -0,0 +1,9 @@
|
||||
<webscript>
|
||||
<shortname>Create Node Templates</shortname>
|
||||
<description>Document List Component - Create Node Templates POST data webscript</description>
|
||||
<url>/slingshot/doclib/node-templates</url>
|
||||
<format default="json">argument</format>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
<lifecycle>internal</lifecycle>
|
||||
</webscript>
|
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"success": true
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Document List Component: Create New Node - create copy of node template in the Data Dictionary
|
||||
*/
|
||||
function main()
|
||||
{
|
||||
// get the arguments - expecting the "sourceNodeRef" and "parentNodeRef" of the source node to copy
|
||||
// and the parent node to contain the new copy of the source.
|
||||
var sourceNodeRef = json.get("sourceNodeRef");
|
||||
if (sourceNodeRef == null || sourceNodeRef.length === 0)
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "Mandatory 'sourceNodeRef' parameter missing.");
|
||||
return;
|
||||
}
|
||||
var parentNodeRef = json.get("parentNodeRef");
|
||||
if (parentNodeRef == null || parentNodeRef.length === 0)
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "Mandatory 'parentNodeRef' parameter missing.");
|
||||
return;
|
||||
}
|
||||
|
||||
// get the nodes and perform the copy - permission failures etc. will produce a status code response
|
||||
var sourceNode = search.findNode(sourceNodeRef),
|
||||
parentNode = search.findNode(parentNodeRef);
|
||||
if (sourceNode == null || parentNode == null)
|
||||
{
|
||||
status.setCode(status.STATUS_NOT_FOUND, "Source or destination node is missing for copy operation.");
|
||||
}
|
||||
sourceNode.copy(parentNode);
|
||||
}
|
||||
|
||||
main();
|
Reference in New Issue
Block a user