1586

Recursively get all content file names under a folder in Alfresco 5.0 (by WebScripts)

Question:

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:

<ul><li>

Show ALL nodes recursively ??

And less important:

</li> <li>

Filter only content objects for the answer (folders looped but not returned)?

</li> <li>

Filter all the metadata but the name, the only important thing to me?

</li> </ul>

Answer1:

Here is an example of webscript which may help you. Create this webscript in alfresco.

<strong>getChildren.get.desc.xml</strong>

<webscript> <shortname>Get Documents</shortname> <description>Display all Documents within Folder</description> <url>/getChildren</url> <format default="json">argument</format> <authentication>user</authentication> </webscript>

<strong>getChildren.get.js</strong>

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

<strong>getChildren.get.json.ftl</strong>

{ "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:

<strong><a href="http://localhost:8080/alfresco/service/getChildren?foldername=Test_Folder" rel="nofollow">http://localhost:8080/alfresco/service/getChildren?foldername=Test_Folder</a></strong>

<strong>Note:</strong> This will fetch child details of folders in company home only. Change lucene query in javascript file according to your requirement.

Answer2:

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.

<a href="https://wiki.alfresco.com/wiki/Web_Scripts" rel="nofollow">https://wiki.alfresco.com/wiki/Web_Scripts</a>

Recommend

  • Microdata and multiple opening in a day
  • select only 1st level of nested elements
  • Unable to get a dynamically generated content from a webpage
  • Python subprocess communicate kills my process
  • Wait for a SLOT to finish the execution with Qt
  • PowerShell: Start a process with unquoted arguments
  • Is there a way to synchronize ajax calls
  • how can I make a server communicate with more than 1 client at the same time?
  • Stopping the upload process if the upload limit I chose is exceeded
  • How to prevent multiple fires for scroll event?
  • No OpenID endpoint found - Relying Party Timeout Option
  • Determine if Finder can be safely killed
  • PID feedback & Position Controller with DC motor/encoder
  • Best way to avoid out of memory exception in application
  • Structured data not being picked up on telephone number
  • Rails UJS: Preventing the event from propagating using “'ajax:before'”
  • Wait for Swing to finish updating JProgressBar before continuing
  • Regex takes a long time to complete
  • How do I access SQL from XPages
  • How can I embed schema.org markup in SVG?
  • How to set the id of a foreign key id #sf2 #doctrine2
  • Thread Synchronization - Synchronizing three threads to print 012012012012… not working
  • Dart HTTP server and Futures
  • How can I set the buffer size for the underneath Socket UDP?
  • Task.IsCancelled doesn't work
  • Reaping zombie process - child
  • dm-script catch error with “Analyze Particles”
  • Unity registration fails after iisreset
  • Paramiko SSHException Channel Closed
  • Parallel sieve of Eratosthenes - Java Multithreading
  • Multiple producers single consumer locking schema
  • Code in Job's Script Block after Start-Process Does not Execute
  • why overloaded new operator is calling constructor even I am using malloc inside overloading functio
  • Adding a button at the bottom of a table view
  • Getting last autonumber in access
  • Fetching methods from BroadcastReceiver to update UI
  • Symfony2: How to get request parameter
  • Delete MySQLi record without showing the id in the URL
  • GridView Sorting works once only
  • WPF Applying a trigger on binding failure