this.runtimeProperties = runtimeProperties;
}
@Override
public Profile createOrUpdateMQProfile(String versionId, String profileId, String brokerName, Map<String, String> configs, boolean replicated) {
Version version = profileService.getRequiredVersion(versionId);
String parentProfileName = null;
if (configs != null && configs.containsKey("parent")) {
parentProfileName = configs.remove("parent");
}
if (Strings.isNullOrBlank(parentProfileName)) {
parentProfileName = replicated ? MQ_PROFILE_REPLICATED : MQ_PROFILE_BASE;
}
Profile parentProfile = version.getRequiredProfile(parentProfileName);
if (brokerName == null || profileId == null) {
return parentProfile;
}
String pidName = getBrokerPID(brokerName);
// lets check we have a config value
ProfileBuilder builder;
// create a profile if it doesn't exist
Map<String, String> config = null;
boolean create = !version.hasProfile(profileId);
if (create) {
builder = ProfileBuilder.Factory.create(versionId, profileId);
if (parentProfile != null) {
builder.addParent(parentProfile.getId());
}
} else {
Profile profile = version.getRequiredProfile(profileId);
builder = ProfileBuilder.Factory.createFrom(profile);
config = new HashMap<>(builder.getConfiguration(pidName));
}
Map<String, String> parentProfileConfig = parentProfile.getConfiguration(MQ_PID_TEMPLATE);