in src/main/java/org/apache/sling/jcr/contentloader/internal/BundleContentLoader.java [455:523]
private void handleFile(final String entry, final Bundle bundle, final Map<String, Node> processedEntries,
final PathEntry configuration, final Node parent, final List<String> createdNodes,
final DefaultContentCreator contentCreator) throws RepositoryException, ContentReaderUnavailableException {
final URL file = bundle.getEntry(entry);
final String name = getName(entry);
try {
if (processedEntries.containsKey(file.toString())) {
// this is a consumed node descriptor
return;
}
// check for node descriptor
URL nodeDescriptor = null;
for (String ext : contentCreator.getContentReaders().keySet()) {
nodeDescriptor = bundle.getEntry(entry + ext);
if (nodeDescriptor != null) {
break;
}
}
// install if it is a descriptor
boolean foundReader = getContentReader(entry, configuration) != null;
Node node = null;
if (foundReader) {
node = createNode(parent, name, file, contentCreator, configuration);
if (node != null) {
log.debug("Created node as {} {}", node.getPath(), name);
processedEntries.put(file.toString(), node);
} else {
log.warn("No node created for file {} {}", file, name);
}
} else {
// if we require a ContentReader for this entry but didn't find one
// then throw an exception to stop processing this bundle and put
// it into the delayedBundles list to retry later
if (configuration.isImportProviderRequired(name)) {
throw new ContentReaderUnavailableException(String.format("Unable to locate a required content reader for entry %s", entry));
} else {
log.debug("Can't find content reader for entry {} at {}", entry, name);
}
}
// otherwise just place as file
if (node == null) {
try {
createFile(configuration, parent, file, createdNodes, contentCreator);
node = parent.getNode(name);
} catch (IOException ioe) {
log.warn("Cannot create file node for {}", file, ioe);
}
}
// if we have a descriptor, which has not been processed yet,
// process it
if (nodeDescriptor != null && !processedEntries.containsKey(nodeDescriptor.toString())) {
try {
contentCreator.setIgnoreOverwriteFlag(true);
node = createNode(parent, name, nodeDescriptor, contentCreator, configuration);
processedEntries.put(nodeDescriptor.toString(), node);
} finally {
contentCreator.setIgnoreOverwriteFlag(false);
}
}
} catch (RepositoryException e) {
log.error("Failed to process file {} from {}", file, name);
throw e;
}
}