4

I'm trying to improve performance of one of our implementation,

We currently retrieve the node using Alfresco nodeService.getChildAssocs from the rootNode and running some kind of loop to compare the path.

This is not very efficient when you have a huge amount of files. I've debug the locate file webscript from Share and seen that they run a Lucene query based on the path.

That's also what is described here: http://wiki.alfresco.com/wiki/NodeRef_cookbook#Getting_a_NodeRef_from_its_path

Is this the most efficient way to retrieve the NodeRef ? Is there another API available to run this simple task from the repo side (in Java)?

many thanks

plus-
  • 45,453
  • 15
  • 60
  • 73

2 Answers2

5

Within the foundation API, you can call:

FileFolderService.resolveNamePath(NodeRef rootNode, List pathElements)
FileFolderService.resolveNamePath(NodeRef rootNode, List pathElements, Boolean mustExist)

Internally, it uses a search loop pattern, probably similar to what you mentioned you're already doing. Then, if you want to just go through searches, you could use this other API:

SearchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, "/app:company_home/cm:path/cm:to/cm:content")

An OOTB remote API is the org/alfresco/cmis/item.get web script which offer, among others, the following URL templates:

/cmis/s/{store}/arg/p?path={path}&filter={filter?}&returnVersion={returnVersion?}&includeAllowableActions={includeAllowableActions?}&includeRelationships={includeRelationships?}&includeACL={includeACL?}&renditionFilter={renditionFilter?}
/api/path/{store_type}/{store_id}/{nodepath}?filter={filter?}&returnVersion={returnVersion?}&includeAllowableActions={includeAllowableActions?}&includeRelationships={includeRelationships?}&includeACL={includeACL?}&renditionFilter={renditionFilter?}

I wouldn't recommend it for a performance critical path, though, as CMIS is quite chatty. I'd probably develop a custom web script that leverages the above foundation APIs.

skuro
  • 13,414
  • 1
  • 48
  • 67
0

Here are examples for using CMIS RESTful API, assuming you have a repo file "/Sites/test/test.pdf":

Return metadata in Atom XML:

http//localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom/path?path=/Sites/test/test.pdf

Download the content (the actual PDF file):

http//localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/Sites/test/test.pdf

Return the metadata in JSON:

http//localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/Sites/test/test.pdf?cmisselector=object

Return folder children in JSON:

http//localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/Sites/test?cmisselector=children
Michael Chen
  • 631
  • 5
  • 12