Search code examples
javaalfresco

get noderef from document guid using (bakend) java?


Alfresco Javascript API has a search.findNode("workspace://SpacesStore/" + documentguid) method, that giving a guid of a document (node), one can get the noderef of the document.

How to get this "org.alfresco.service.cmr.repository.NodeRef" using java (backend java), having only the document/node guid?


Solution

  • You can use the NodeRef constructor :

    Construct a Node Reference from a string representation of a Node Reference. NodeRef(String protocol, String identifier, String id)

    Example :

    NodeRef myNoderef = new NodeRef("workspace","SpacesStore",documentguid)
    

    If you want to get more information of your document, or do some modification on it, you can use the NodeService of FileFolderService (it depends of your needs) :

    fileFolderService.getFileInfo(myNoderef)