cancel
Showing results for 
Search instead for 
Did you mean: 

Get Node uuid

anshul
Champ in-the-making
Champ in-the-making
hi
Can anybody tell me is there any web service to get a node uuid from a path.

thanks
Anshul
7 REPLIES 7

jcustovic
Champ in-the-making
Champ in-the-making

String path = getCompanyHome().getPath() + "/cm:" + ISO9075.encode("someName");
Reference ref = null;
try {
   ref = new Reference(WORKSPACE_STORE, null, path);
   Node[] nodeArray = getRepositoryService().get(new Predicate(new Reference[] { ref }, WORKSPACE_STORE, null));
   ref = nodeArray[0].getReference();
   System.out.println(ref.getUuid()); // Here you can get UUID
} catch (Exception e) {
   System.out.println("Ref with path not found.");
}

anshul
Champ in-the-making
Champ in-the-making
Thanks it worked.
Since i am new to alfresco with one week of experience. Can you please explain me what is going on the code.

Thanks
Anshul

Could you please tell me the whole procedure like how you did it. ? Please I am a noob just started this .

jcustovic
Champ in-the-making
Champ in-the-making
Reference is an object which u don't have. So in order to get that object from alfresco u have to actually "get" it. You need to know path or uuid and space. So basically you set the node path in your case and tell web service to get that object for you (if it exists) if it exist it will return that object with all it's properties (including uuid that you need). You can get node by uuid and get it's path. The only line you need to change is:
space = new Reference(WORKSPACE_STORE, "your-uuid", null);

anshul
Champ in-the-making
Champ in-the-making
ThankYou

kblade
Champ in-the-making
Champ in-the-making
Can Restful API get node UUID ?

abarisone
Star Contributor
Star Contributor
Hi kblade,
you might check this http://wiki.alfresco.com/wiki/4.0_JavaScript_API#ScriptNode_API in order to get some hints about the objects that Alfresco provides you out-of-the-box.
Remember that if some object or property is not directly exposed by the Rhino Javascript Processor, you can always extend the base processor since it's build up on Spring framework.
As well, you can develop a Java-backed webscript in order to perform the operation that you need.

Hope this helps,
Andrea