use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class DatabaseConfiguredFieldTest method createConfigurationFieldModel.
public ConfigurationFieldModel createConfigurationFieldModel(String key, Collection<String> values) {
ConfigurationFieldModel configurationFieldModel = BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY.equals(key) ? ConfigurationFieldModel.createSensitive(key) : ConfigurationFieldModel.create(key);
configurationFieldModel.setFieldValues(values);
return configurationFieldModel;
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTestIT method init.
@BeforeEach
public void init() {
properties = new TestProperties();
ConfigurationFieldModel providerConfigEnabled = ConfigurationFieldModel.create(ProviderDescriptor.KEY_PROVIDER_CONFIG_ENABLED);
providerConfigEnabled.setFieldValue("TRUE");
ConfigurationFieldModel providerConfigName = ConfigurationFieldModel.create(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME);
providerConfigName.setFieldValue("blackduck-config");
ConfigurationFieldModel blackduckUrl = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_URL);
blackduckUrl.setFieldValue(properties.getBlackDuckURL());
ConfigurationFieldModel blackduckApiKey = ConfigurationFieldModel.createSensitive(BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY);
blackduckApiKey.setFieldValue(properties.getBlackDuckAPIToken());
ConfigurationFieldModel blackduckTimeout = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_TIMEOUT);
blackduckTimeout.setFieldValue(String.valueOf(BlackDuckProperties.DEFAULT_TIMEOUT));
ConfigurationModel blackduckConfigurationModel = defaultConfigurationAccessor.createConfiguration(blackDuckProviderKey, ConfigContextEnum.GLOBAL, List.of(providerConfigEnabled, providerConfigName, blackduckUrl, blackduckApiKey, blackduckTimeout));
blackDuckGlobalConfigId = blackduckConfigurationModel.getConfigurationId();
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class FieldModelUtils method createConfigurationFieldModel.
public static ConfigurationFieldModel createConfigurationFieldModel(String key, Collection<String> values) {
ConfigurationFieldModel field = ConfigurationFieldModel.create(key);
field.setFieldValues(values);
return field;
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class DefaultDescriptorGlobalConfigUtility method save.
public FieldModel save(FieldModel fieldModel) throws AlertException {
FieldModel beforeAction = apiAction.beforeSaveAction(fieldModel);
Collection<ConfigurationFieldModel> values = configurationFieldModelConverter.convertToConfigurationFieldModelMap(beforeAction).values();
ConfigurationModel configuration = configurationModelConfigurationAccessor.createConfiguration(key, context, values);
FieldModel convertedFieldModel = configurationFieldModelConverter.convertToFieldModel(configuration);
return apiAction.afterSaveAction(convertedFieldModel);
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class DefaultDescriptorGlobalConfigUtility method update.
public FieldModel update(Long id, FieldModel fieldModel) throws AlertException {
FieldModel beforeUpdateActionFieldModel = apiAction.beforeUpdateAction(fieldModel);
Map<String, ConfigurationFieldModel> valueMap = configurationFieldModelConverter.convertToConfigurationFieldModelMap(beforeUpdateActionFieldModel);
Optional<ConfigurationModel> existingConfig = configurationModelConfigurationAccessor.getConfigurationById(id);
ConfigurationModel configurationModel;
if (existingConfig.isPresent()) {
Map<String, ConfigurationFieldModel> updatedValues = updateSensitiveFields(valueMap, existingConfig.get());
configurationModel = configurationModelConfigurationAccessor.updateConfiguration(id, updatedValues.values());
} else {
configurationModel = configurationModelConfigurationAccessor.createConfiguration(key, context, valueMap.values());
}
FieldModel convertedFieldModel = configurationFieldModelConverter.convertToFieldModel(configurationModel);
return apiAction.afterUpdateAction(beforeUpdateActionFieldModel, convertedFieldModel);
}
Aggregations