in src/main/java/org/apache/sling/feature/cpconverter/handlers/AbstractConfigurationEntryHandler.java [47:93]
public final void handle(@NotNull String path, @NotNull Archive archive, @NotNull Entry entry, @NotNull ContentPackage2FeatureModelConverter converter, String runMode) throws IOException, ConverterException {
Matcher matcher = getPattern().matcher(path);
String targetRunMode;
// we are pretty sure it matches, here
if (matcher.matches()) {
if (matcher.group("dir") != null) {
// SLING-10469 - preventing invalid results as the corresponding configuration will be stripped from the resulting package causing the constraints of nt:file not to be satisfied (missing binary)
logger.info("{} is only a dir folder next to config - removing.", path);
} else {
final String id = extractId(matcher.group("pid"));
logger.info("Processing configuration '{}'.", id);
Dictionary<String, Object> configurationProperties;
try (InputStream input = Objects.requireNonNull(archive.openInputStream(entry))) {
configurationProperties = parseConfiguration(id, input);
}
if (configurationProperties == null) {
logger.info("{} entry does not contain a valid OSGi configuration, treating it as a regular resource", path);
converter.getMainPackageAssembler().addEntry(path, archive, entry);
return;
}
if (enforceConfigurationBelowConfigFolder && !"config".equals(matcher.group("foldername"))) {
throw new ConverterException("OSGi configuration are only considered if placed below a folder called 'config', but the configuration at '"+ path + "' is placed outside!");
}
// determine run mode string for current path
String runModeMatch = matcher.group("runmode");
targetRunMode = extractTargetRunMode(path, converter, runMode,
runModeMatch);
FeaturesManager featuresManager = Objects.requireNonNull(converter.getFeaturesManager());
final Configuration cfg = new Configuration(id);
featuresManager.addConfiguration(targetRunMode, cfg, path, configurationProperties);
}
} else {
throw new IllegalStateException("Something went terribly wrong: pattern '"
+ getPattern().pattern()
+ "' should have matched already with path '"
+ path
+ "' but it does not, currently");
}
}