in src/main/java/org/apache/sling/installer/provider/installhook/OsgiInstallerHook.java [359:411]
void collectResources(Archive archive, Entry entry, String dirPath, List<BundleInPackage> bundleResources,
List<String> configResources, String installPathRegex, Set<String> actualRunmodes) {
String entryName = entry.getName();
if (entryName.equals(FOLDER_META_INF)) {
return;
}
String dirPathWithoutJcrRoot = StringUtils.substringAfter(dirPath, "/jcr_root");
String entryPath = dirPathWithoutJcrRoot + entryName;
String dirPathWithoutSlash = StringUtils.chomp(dirPathWithoutJcrRoot, "/");
boolean runmodesMatch;
if (dirPathWithoutSlash.contains(DOT)) {
String[] bits = dirPathWithoutSlash.split("\\" + DOT, 2);
List<String> runmodesOfResource = Arrays.asList(bits[1].split("\\" + DOT));
Set<String> matchingRunmodes = new HashSet<String>(runmodesOfResource);
matchingRunmodes.retainAll(actualRunmodes);
LOG.debug("Entry with runmode(s): entryPath={} runmodesOfResource={} actualRunmodes={} matchingRunmodes={}",
entryPath, runmodesOfResource, actualRunmodes, matchingRunmodes);
runmodesMatch = matchingRunmodes.size() == runmodesOfResource.size();
if (!runmodesMatch) {
logger.log("Skipping installation of " + entryPath
+ " because the path is not matching all actual runmodes " + actualRunmodes);
}
} else {
runmodesMatch = true;
}
if (entryPath.matches(installPathRegex) && runmodesMatch) {
if (entryName.endsWith(CONFIG_SUFFIX)) {
configResources.add(entryPath);
} else if (entryName.endsWith(JAR_SUFFIX)) {
try (InputStream entryInputStream = archive.getInputSource(entry).getByteStream();
JarInputStream jarInputStream = new JarInputStream(entryInputStream)) {
Manifest manifest = jarInputStream.getManifest();
String symbolicName = manifest.getMainAttributes().getValue(MANIFEST_BUNDLE_SYMBOLIC_NAME);
String version = manifest.getMainAttributes().getValue(MANIFEST_BUNDLE_VERSION);
bundleResources.add(new BundleInPackage(entryPath, symbolicName, version));
} catch (Exception e) {
throw new IllegalStateException(
"Could not read symbolic name and version from manifest of bundle " + entryName);
}
}
}
for (Entry child : entry.getChildren()) {
collectResources(archive, child, dirPath + entryName + "/", bundleResources, configResources,
installPathRegex, actualRunmodes);
}
}