in src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java [685:726]
public void createFileAndResourceNode(String name, InputStream data, String mimeType, long lastModified)
throws RepositoryException {
int lastSlash = name.lastIndexOf('/');
name = (lastSlash < 0) ? name : name.substring(lastSlash + 1);
final Node parentNode = this.parentNodeStack.peek();
// if node already exists but should be overwritten, delete it
if (parentNode.hasNode(name)) {
this.parentNodeStack.push(parentNode.getNode(name));
Node contentNode = parentNode.getNode(name).getNode("jcr:content");
this.parentNodeStack.push(contentNode);
long nodeLastModified = 0L;
if (contentNode.hasProperty(JCR_LAST_MODIFIED)) {
nodeLastModified = contentNode.getProperty(JCR_LAST_MODIFIED).getDate().getTimeInMillis();
}
if (!this.configuration.isOverwrite() && nodeLastModified >= lastModified) {
return;
}
log.debug("Updating {} lastModified:{} New Content LastModified:{}", parentNode.getNode(name).getPath(),
new Date(nodeLastModified), new Date(lastModified));
} else {
this.createNode(name, "nt:file", null);
this.createNode("jcr:content", "nt:resource", null);
}
// ensure content type
if (mimeType == null) {
mimeType = contentHelper.getMimeType(name);
if (mimeType == null) {
log.debug("createFile: Cannot find content type for {}, using {}", name, DEFAULT_CONTENT_TYPE);
mimeType = DEFAULT_CONTENT_TYPE;
}
}
// ensure sensible last modification date
if (lastModified <= 0) {
lastModified = System.currentTimeMillis();
}
this.createProperty("jcr:mimeType", mimeType, true);
this.createProperty(JCR_LAST_MODIFIED, lastModified, true);
this.createProperty("jcr:data", data, true);
}