use of com.day.cq.workflow.collection.ResourceCollection in project acs-aem-commons by Adobe-Consulting-Services.
the class WorkflowPackageManagerImpl method getPaths.
/**
* {@inheritDoc}
*/
public final List<String> getPaths(final ResourceResolver resourceResolver, final String path, final String[] nodeTypes) throws RepositoryException {
final List<String> collectionPaths = new ArrayList<String>();
final Resource resource = resourceResolver.getResource(path);
if (resource == null) {
log.warn("Requesting paths for a non-existent Resource [ {} ]; returning empty results.", path);
return Collections.EMPTY_LIST;
} else if (!isWorkflowPackage(resourceResolver, path)) {
log.debug("Requesting paths for a non-Resource Collection [ {} ]; returning provided path.", path);
return Arrays.asList(new String[] { path });
} else {
final PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
final Page page = pageManager.getContainingPage(path);
if (page != null && page.getContentResource() != null) {
final Node node = page.getContentResource().adaptTo(Node.class);
final ResourceCollection resourceCollection = ResourceCollectionUtil.getResourceCollection(node, resourceCollectionManager);
if (resourceCollection != null) {
final List<Node> members = resourceCollection.list(nodeTypes);
for (final Node member : members) {
collectionPaths.add(member.getPath());
}
return collectionPaths;
}
}
return Arrays.asList(new String[] { path });
}
}
Aggregations