cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot find documentLibrary using NodeService

juliay
Champ in-the-making
Champ in-the-making
I am trying to create a directory structure in a site's document library but I'm having trouble with navigating to the documentLibrary.

//java code
SiteInfo site = siteService.getSite("shortname");
String name = "documentLibrary";
List<ChildAssociationRef> children = nodeService.getChildAssocs(site.getNodeRef());
if (log.isTraceEnabled()) {
    log.trace("Found: " + children.size() + " children of " + parent.toString());
}
for (ChildAssociationRef child : children) {
    NodeRef temp = child.getChildRef();
    Map<QName, Serializable> properties = nodeService.getProperties(temp);
    String nameProp = (String) properties.get(ContentModel.PROP_NAME);
    if (log.isTraceEnabled()) {
        log.trace("Checking node [" + temp + "] with name [" + nameProp + "]");
        log.trace(nameProp + " == " + name + "(" + (nameProp.equals(name)) + ")");
    }
    if (nameProp.equals(name)) {
        return temp;
    }
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


#alfresco.log
11:32:42,382 TRACE Found: 1 children of workspace://SpacesStore/e673ec52-de3b-4bc8-9e10-1b19cc2d9632
11:32:42,385 TRACE Checking node [workspace://SpacesStore/7aac6e26-d6fa-4405-9ac2-d76155fa0488] with name [surf-config]
11:32:42,386 TRACE surf-config == documentLibrary(false)
‍‍‍‍‍‍

But in the repository I have the following

#node browser
surf-config   workspace://SpacesStore/7aac6e26-d6fa-4405-9ac2-d76155fa0488
documentLibrary   workspace://SpacesStore/b09a3e14-981b-4a27-80cc-66bf407e4ee0
‍‍‍‍‍
both have the same permissions including: "ReadPermissions   GROUP_EVERYONE   ALLOWED"

Why isn't the node service returning both folders under the site?
And, is there another way I could approach getting the node ref of the document library?
1 REPLY 1

arnoldschrijve1
Champ on-the-rise
Champ on-the-rise
You can use the following:


        // Get the documentLibrary of the site.
        NodeRef docLib = siteService().getContainer(siteInfo.getShortName(), "documentlibrary");
‍‍‍‍