Reputation: 6629
So far I found the script to show the children:
http://localhost:8080/alfresco/service/slingshot/datalists/lists/site/MyFakeSite/documentLibrary
It returns me something like:
{
"container": "workspace:\/\/SpacesStore\/8ef98a58-18f0-4f27-9fee-709f81ca0a65",
"permissions":
{
"create": true
},
"datalists":
[
{
"name": "MyPicture.jpg",
"title": "My Awesome Picture File",
"description": "Legen - wait for it - dary!!!",
"nodeRef": "workspace://SpacesStore/54acabf9-bf6b-42f0-8b68-bbe9732b29b8",
"itemType": "",
"permissions":
{
"edit": true,
"delete": true
}
}
,
{
"name": "MyFirstLevelFolder",
"title": "FirstLevel",
"description": "",
"nodeRef": "workspace://SpacesStore/181a36df-2892-4669-aac0-d13ff90457bb",
"itemType": "",
"permissions":
{
"edit": true,
"delete": true
}
}
which is the list of the child nodes of a level down.
Is there any way to:
Show ALL nodes recursively ??
And less important:
Filter only content objects for the answer (folders looped but not returned)?
Filter all the metadata but the name, the only important thing to me?
Upvotes: 0
Views: 2931
Reputation: 2203
Here is an example of webscript which may help you. Create this webscript in alfresco.
getChildren.get.desc.xml
<webscript>
<shortname>Get Documents</shortname>
<description>Display all Documents within Folder</description>
<url>/getChildren</url>
<format default="json">argument</format>
<authentication>user</authentication>
</webscript>
getChildren.get.js
function main()
{
var node = [];
var folderName = args["foldername"];
node = search.luceneSearch("PATH:\"/app:company_home/cm:"+folderName+"/*\"");
model.totalItems = node.length;
model.results = node;
} main();
getChildren.get.json.ftl
{
"totalItems": "${totalItems}",
"nodes":
[<#list results as node>
{
"name" : "${node.properties["cm:name"]?trim}"
}<#if (node_index + 1 < results?size)>,</#if>
</#list>
]
}
After creating fire this query in browser:
http://localhost:8080/alfresco/service/getChildren?foldername=Test_Folder
Note: This will fetch child details of folders in company home only. Change lucene query in javascript file according to your requirement.
Upvotes: 1
Reputation: 3175
you can create your custom webscript instead of above which you have specified.Customize the webscript as per your requirement.
Below link is use full for creating webscript in alfresco.
https://wiki.alfresco.com/wiki/Web_Scripts
Upvotes: 1