in src/main/java/org/apache/sling/servlets/post/impl/helper/StreamedChunk.java [174:204]
private void updateState(Resource contentResource, List<Modification> changes) throws IllegalStateException, PersistenceException {
final ModifiableValueMap vm = contentResource.adaptTo(ModifiableValueMap.class);
if ( vm == null ) {
throw new PersistenceException("Resource at " + contentResource.getPath() + " is not modifiable.");
}
vm.put(JcrConstants.JCR_LASTMODIFIED, Calendar.getInstance());
vm.put(JcrConstants.JCR_MIMETYPE, getContentType(part));
if (chunked) {
if ( vm.containsKey(SLING_FILE_LENGTH)) {
long previousFileLength = vm.get(SLING_FILE_LENGTH, Long.class);
if (previousFileLength != fileLength) {
throw new IllegalStateException("Chunk file length has changed while cunks were being uploaded expected " + previousFileLength + " chunk contained " + fileLength);
}
}
long previousChunksLength = 0;
if ( vm.containsKey(SLING_CHUNKS_LENGTH)) {
previousChunksLength = vm.get(SLING_CHUNKS_LENGTH, Long.class);
if (previousChunksLength != offset) {
throw new IllegalStateException("Chunks recieved out of order, was expecting chunk starting at " + offset + " found last chunk ending at " + previousChunksLength);
}
}
vm.put(SLING_CHUNKS_LENGTH, previousChunksLength + chunkLength);
vm.put(JcrConstants.JCR_MIXINTYPES, SLING_CHUNK_MIXIN);
} else {
try {
vm.put(JcrConstants.JCR_DATA, part.getInputStream());
} catch (IOException e) {
throw new PersistenceException("Error while retrieving inputstream from request part.", e);
}
}
}