in src/main/java/org/apache/sling/distribution/resources/impl/common/AbstractReadableResourceProvider.java [123:171]
public Iterator<Resource> listChildren(Resource parent) {
String path = parent.getPath();
ResourceResolver resourceResolver = parent.getResourceResolver();
SimplePathInfo pathInfo = extractPathInfo(path);
if (pathInfo == null) {
return null;
}
if (pathInfo.getResourcePathInfo() != null && pathInfo.getResourcePathInfo().length() > 0) {
return null;
}
if (!hasPermission(resourceResolver, pathInfo.getResourcePath(), Session.ACTION_READ)) {
return null;
}
List<Resource> resourceList = new ArrayList<Resource>();
Iterable<String> childrenList = getResourceChildren(resourceResolver, pathInfo);
Iterator<Map<String,Object>> childrenProperties = null;
if (childrenList == null) {
Map<String, Object> properties = getResourceProperties(resourceResolver, pathInfo);
if (properties != null && properties.containsKey(ITEMS)
&& properties.get(ITEMS) instanceof String[]) {
String[] itemsArray = (String[]) properties.get(ITEMS);
childrenList = Arrays.asList(itemsArray);
}
if (properties != null && properties.containsKey(INTERNAL_ITEMS_ITERATOR)) {
childrenProperties = (Iterator<Map<String,Object>>) properties.get(INTERNAL_ITEMS_ITERATOR);
}
}
if (childrenProperties != null) {
return new SimpleReadableResourceIterator(childrenProperties, resourceResolver, path);
} else if (childrenList != null) {
for (String childResourceName : childrenList) {
Resource childResource = getResource(resourceResolver, path + "/" + childResourceName);
resourceList.add(childResource);
}
}
return resourceList.listIterator();
}