PSContentMgr Class and finding items by Path

In Java, I am trying to list all the content items in a folder.

I’ve gotten as far as:

PSContentMgrLocator.getContentMgr().findItemsByPath(null,
                            Collections.singletonList(path), null );

But the documentation doesn’t state if this returns the folder or the content items in the folder or all the descendants of the folder…

Has anyone used this before?

Is there a better or easier way?

Have you tried #findFolderChildren from IPSContentWs?

It looks like there are several different ways… this is probably what I’m going to go with (I’ll be adding error checking, of course):


PSServerFolderProcessor folderProcessor = new PSServerFolderProcessor(PSRequest.getContextForRequest(), null);
IPSContentMgr contentMgr = PSContentMgrLocator.getContentMgr();
int folderId = folderProcessor.getIdByPath( folderPath );
List<IPSGuid> guids = new ArrayList<IPSGuid>();
for (PSComponentSummary s : folderProcessor.getChildSummaries(new PSLocator(folderId))) {
    if (s.getPublicRevision() > 0) { // ignore items that have never been made public.
        guids.add(new PSLegacyGuid(s.getContentId(),s.getPublicRevision()));
    }
}
List<Node> folderContents = guids.size() > 0 ? contentMgr.findItemsByGUID( guids, null )
    : Collections.<Node>emptyList();