in src/main/java/org/apache/sling/servlets/post/impl/helper/StreamedChunk.java [312:339]
private InputStream getChunksInputStream(Resource contentResource) {
List<Resource> chunkResources = new ArrayList<>();
for (Resource r : contentResource.getChildren()) {
if (r.isResourceType(SLING_CHUNK_NT)) {
chunkResources.add(r);
}
}
Collections.sort(chunkResources, new Comparator<Resource>() {
@Override
public int compare(Resource o1, Resource o2) {
long offset1 = o1.adaptTo(ValueMap.class).get(SLING_OFFSET, Long.class);
long offset2 = o2.adaptTo(ValueMap.class).get(SLING_OFFSET, Long.class);
return (int) (offset1 - offset2);
}
});
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Finishing Chunk upload at {} consolidating {} chunks into one file of ", new Object[] {
contentResource.getPath(),
chunkResources.size(),
contentResource.adaptTo(ValueMap.class).get(SLING_CHUNKS_LENGTH)
});
LOGGER.debug("Content Resource Properties {} ", contentResource.adaptTo(ValueMap.class));
for (Resource r : chunkResources) {
LOGGER.debug("Chunk {} properties {} ", r.getPath(), r.adaptTo(ValueMap.class));
}
}
return new ResourceIteratorInputStream(chunkResources.iterator());
}