cancel
Showing results for 
Search instead for 
Did you mean: 

Searching for PATH children

marcus
Champ in-the-making
Champ in-the-making
I'm wanting to get all the children of a specific node, which after reading the docs seemed like it should be achievable by doing something like the following


Node node = new Node(someNodeRef);
String query = "PATH:\""+node.getPath()+"/*\"";
[code]

However, for some reason it only seems to work if I replace the full namespace URIs (eg "{http://www.alfresco.org/model/application/1.0}") with the shortened versions ("app:") in the path.

This is with 1.4p.
5 REPLIES 5

andy
Champ on-the-rise
Champ on-the-rise
Hi

That is correct. It uses the XPATH prefix style.


Node node = new Node(someNodeRef);
String query = "PATH:\""+node.getPath().toPrefixString(resolver)+"/*\"";

Will give the correct path (prefixes and encoding of non allowed characters in PATH/XPATH)

Regards

Andy

marcus
Champ in-the-making
Champ in-the-making
That makes sense, however node.getPath() returns a String value. Am I missing something here?

kevinr
Star Contributor
Star Contributor
The issue is the Node class you are using (the web-client Node wrapper) returns the String version of the Path. You want the underlying repository Path object. This code should work in the web-client:


NodeService nodeService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
Node node = new Node(nodeRef);
String query = "PATH:\"" + nodeService.getPath(nodeRef).toPrefixString(resolver) + "/*\"";

Thanks,

Kevin

marcus
Champ in-the-making
Champ in-the-making
Funny, I stumbled on this just before I got a notify email Smiley Wink. However, I can't figure out what Namespace resolver I should be using; not just for this instance, but in other cases too. Are there rules about what resolver to use where?

kevinr
Star Contributor
Star Contributor
use the ServiceRegistry to get the NamespaceService as that supports the resolver interface for Alfresco and custom models.

Thanks,

Kevin