cancel
Showing results for 
Search instead for 
Did you mean: 

Get NodeRef by path

robertmarkbram
Champ in-the-making
Champ in-the-making
Hi All,

Can I create a NodeRef purely from the path?

It seems like NodeRef doesn't allow it, and looking at the various methods in the SearchService and FileFolderService they all require a NodeRef or something similar to search.

Let's say I already know this information about  a node (from Node Browser):

Node Identifier
Primary Path:    /{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/content/1....
Reference:   workspace://SpacesStore/1960748f-cf69-4784-89a0-a4cbd6f03b49
Type:   {http://www.alfresco.org/model/content/1.0}folder
Parent:   workspace://SpacesStore/410438c0-095e-49ac-bfd3-e167b3be863c

How could I do something like this:
NodeRef bnr = new NodeRef("/{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/content/1....");

Thanks for any advice!

Rob
Smiley Happy
4 REPLIES 4

openpj
Elite Collaborator
Elite Collaborator
The NodeRef is created by the repository itself, you can't create your own NodeRef in that way.
You need to invoke the createNode method using the NodeService that returns you the new NodeRef.

robertmarkbram
Champ in-the-making
Champ in-the-making
Hi Piergiorgio,

Do you mean to say that, in order to reference an existing node purely from the path (which is what I meant by "create a NodeRef purely from the path") I need to call createNode? As in:
getNodeService().createNode()

But createNode() also wants nodeRefs and QNames.. so I still don't see how I can reference an existing node if all I know is the path.

Rob
Smiley Happy

gyro_gearless
Champ in-the-making
Champ in-the-making
You might want to use e.g. FilefolderService#resolveNamePath. Here is a code snippet i use to resolve the NodeRef of a template file:


            
            NodeRef companyHome = getCompanyHome();
            List<String> pathElements = Arrays.asList(StringUtils.split(this.template, '/'));

            NodeRef templateRef = fileFolderService.resolveNamePath(companyHome, pathElements).getNodeRef();

where this.template is set to e.g. "Data Dictionary/Email Templates/ACME/Initial Publish.ftl".

HTH
Gyro

arunvallamkondu
Champ in-the-making
Champ in-the-making
is there any webservice api to get noderef by path