. 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:
Kevin Roast
2011-08-16 11:05:57 +00:00
parent 12575caa53
commit eb623f44c1
6 changed files with 77 additions and 0 deletions

View File

@@ -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>

View File

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

View File

@@ -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>

View File

@@ -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>

View File

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