changes.add(Modification.onModified(res.setProperty(
JCR_DATA, fileIns).getPath()));
NodeIterator nodeItr = res.getNodes(SlingPostConstants.CHUNK_NODE_NAME
+ "*");
while (nodeItr.hasNext()) {
Node nodeRange = nodeItr.nextNode();
changes.add(Modification.onDeleted(nodeRange.getPath()));
nodeRange.remove();
}
if (res.hasProperty(SlingPostConstants.NT_SLING_FILE_LENGTH)) {
javax.jcr.Property expLenProp = res.getProperty(SlingPostConstants.NT_SLING_FILE_LENGTH);
changes.add(Modification.onDeleted(expLenProp.getPath()));
expLenProp.remove();
}
if (res.hasProperty(SlingPostConstants.NT_SLING_CHUNKS_LENGTH)) {
javax.jcr.Property currLenProp = res.getProperty(SlingPostConstants.NT_SLING_CHUNKS_LENGTH);
changes.add(Modification.onDeleted(currLenProp.getPath()));
currLenProp.remove();
}
res.removeMixin(SlingPostConstants.NT_SLING_CHUNK_MIXIN);
} finally {
try {
fileIns.close();
file.delete();
} catch (IOException ign) {
}
}
} else {
Node rangeNode = res.addNode(nodeName,
SlingPostConstants.NT_SLING_CHUNK_NODETYPE);
changes.add(Modification.onCreated(rangeNode.getPath()));
changes.add(Modification.onModified(rangeNode.setProperty(
JCR_DATA, value.getInputStream()).getPath()));
changes.add(Modification.onModified(rangeNode.setProperty(
SlingPostConstants.NT_SLING_CHUNK_OFFSET, chunkOffset).getPath()));
changes.add(Modification.onModified(res.setProperty(
SlingPostConstants.NT_SLING_CHUNKS_LENGTH,
currentLength + value.getSize()).getPath()));
}