in src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java [356:396]
public void addConfiguration(@Nullable String runMode,
@NotNull Configuration cfg,
@NotNull String path,
@NotNull Dictionary<String, Object> configurationProperties)
throws IOException, ConverterException {
if (handleRepoinitAndMappings(runMode, cfg, configurationProperties, enforceServiceMappingByPrincipal)) {
return;
}
Feature feature = getRunMode(runMode);
Configuration configuration = feature.getConfigurations().getConfiguration(cfg.getPid());
if (configuration == null) {
configuration = new Configuration(cfg.getPid());
feature.getConfigurations().add(configuration);
this.pidToPathMapping.put(cfg.getPid(), path);
} else {
switch (this.configurationHandling) {
case STRICT:
throw new ConverterException("Configuration '"
+ cfg.getPid()
+ "' already defined in Feature Model '"
+ feature.getId().toMvnId()
+ "', set the 'mergeConfigurations' flag to 'true' if you want to merge multiple configurations with same PID");
case ORDERED:
final String oldPath = this.pidToPathMapping.get(cfg.getPid());
if (oldPath == null || oldPath.compareTo(path) > 0) {
this.pidToPathMapping.put(cfg.getPid(), path);
feature.getConfigurations().remove(configuration);
configuration = new Configuration(cfg.getPid());
feature.getConfigurations().add(configuration);
} else {
return;
}
break;
case MERGE: // nothing to do
}
}
adjustConfigurationProperties(configuration, configurationProperties);
}