cancel
Showing results for 
Search instead for 
Did you mean: 

Finding System Nodes By Path

vamirr
Champ on-the-rise
Champ on-the-rise
I've got a webscript that browses the authorities node  for user groups under workspace://SpacesStore/system/authorities.   To select the folder by its path, I'm using the following:


groupsNode  = search.findNode("path",  ["workspace", "SpacesStore", "system", "authorities"]);

This always returns null.   Any idea why?     If I substitute the call to any folder under Company Home, it works fine.
3 REPLIES 3

jpotts
World-Class Innovator
World-Class Innovator
If you dig into the source, you'll find that that particular method assumes a root path of Company Home:
// TODO: Allow a root path to be specified - for now, hard-code to Company Home
//NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
NodeRef rootNodeRef = getCompanyHome();
if (reference.length == 3)
{
    if (reference[2].equals(nodeService.getPrimaryParent(rootNodeRef).getQName().toPrefixString(namespaceService)))
    {
            nodeRef = rootNodeRef;
    }
    …SNIP…

Try this instead:
groupsNode  = search.luceneSearch("PATH:\"/sys:system/sys:authorities\"");

Jeff

vamirr
Champ on-the-rise
Champ on-the-rise
Thanks Jeff.

To plunge into philosophy for a microsecond,   isn't it the job of the documentation to explain that "Company Home" is assumed, and that substituting another node is of no use?  Should I really have to go to the source for something like that?

Further,   The document shown here here  places "Company Home" in the reference.    Isn't that a little verbose?  Why bother if it's assumed?

var referenceType = "path";
// store type, store id, display path
var reference = ["workspace", "SpacesStore", "Company Home","TEST_FILE_1.TXT"];
var foundNode = search.findNode(referenceType, reference);

jpotts
World-Class Innovator
World-Class Innovator
Should the documentation note that Company Home is assumed? Yes. I've created a Jira for the docs team on that.

I'm not saying this is the case with you, but I do come across many people who are reluctant to dig into the source to figure out stuff like this. A lot of times these are developers coming from the proprietary world who simply aren't used to having the source as a resource. So I agree that the docs could be clearer on this point, but Alfresco's a complex platform–there will always be improvements to be made. Therefore, I encourage everyone to set some breakpoints and step through code. Sometimes it can be tough to tell what's going on. Other times you'll get a quick win as a reward for having looked. Having the source code is extremely valuable, so do not ignore that resource.

Don't mean to preach, but you are the one who wanted to get philosophical. Smiley Happy

Jeff