use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class ConfigurationFieldModelConverter method convertToFieldValuesMap.
public Map<String, FieldValueModel> convertToFieldValuesMap(Collection<ConfigurationFieldModel> configurationFieldModels) {
Map<String, FieldValueModel> fields = new HashMap<>();
for (ConfigurationFieldModel fieldModel : configurationFieldModels) {
String key = fieldModel.getFieldKey();
Collection<String> values = fieldModel.getFieldValues();
FieldValueModel fieldValueModel = new FieldValueModel(values, fieldModel.isSet());
fields.put(key, fieldValueModel);
}
return fields;
}
use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class FieldModelProcessor method updateConfigurationWithSavedConfiguration.
private Map<String, FieldValueModel> updateConfigurationWithSavedConfiguration(Map<String, FieldValueModel> newConfiguration, Collection<ConfigurationFieldModel> savedConfiguration) {
Collection<ConfigurationFieldModel> sensitiveFields = savedConfiguration.stream().filter(ConfigurationFieldModel::isSensitive).collect(Collectors.toSet());
for (ConfigurationFieldModel sensitiveConfigurationFieldModel : sensitiveFields) {
String key = sensitiveConfigurationFieldModel.getFieldKey();
if (newConfiguration.containsKey(key)) {
FieldValueModel sensitiveFieldValueModel = newConfiguration.get(key);
if (sensitiveFieldValueModel.getIsSet() && !sensitiveFieldValueModel.hasValues()) {
FieldValueModel newFieldModel = newConfiguration.get(key);
newFieldModel.setValues(sensitiveConfigurationFieldModel.getFieldValues());
}
}
}
return newConfiguration;
}
use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class BlackDuckGlobalApiAction method afterDeleteAction.
@Override
public void afterDeleteAction(FieldModel fieldModel) {
Map<String, FieldValueModel> keyToValues = fieldModel.getKeyToValues();
FieldValueModel fieldValueModel = keyToValues.get(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME);
String blackDuckGlobalConfigName = fieldValueModel.getValue().orElse("");
Long configId = Long.parseLong(fieldModel.getId());
providerLifecycleManager.unscheduleTasksForProviderConfig(configId);
List<ProviderProject> blackDuckProjects = providerDataAccessor.getProjectsByProviderConfigName(blackDuckGlobalConfigName);
providerDataAccessor.deleteProjects(blackDuckProjects);
}
use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class EmailConfigActionTestIT method updateReadExistingPasswordEmailGlobalConfigTest.
@Test
void updateReadExistingPasswordEmailGlobalConfigTest() throws AlertConfigurationException {
AuthorizationManager authorizationManager = createEmailAuthorizationManager();
EmailGlobalCrudActions emailGlobalCrudActions = createEmailCrudActions(authorizationManager);
GlobalConfigurationModelToConcreteConversionService globalConfigurationModelToConcreteConversionService = createConversionService(emailGlobalCrudActions);
ConfigActions configActions = new ConfigActions(authorizationManager, descriptorAccessor, configurationModelConfigurationAccessor, fieldModelProcessor, descriptorProcessor, configurationFieldModelConverter, descriptorMap, pkixErrorResponseFactory, encryptionUtility, settingsDescriptorKey, globalConfigurationModelToConcreteConversionService);
FieldModel fieldModel = createEmailFieldModel();
fieldModel = configActions.create(fieldModel).getContent().orElseThrow(() -> new AlertConfigurationException("Couldn't create configuration"));
String updatedHost = "updated." + TEST_SMTP_HOST;
fieldModel.putField(EmailPropertyKeys.JAVAMAIL_HOST_KEY.getPropertyKey(), new FieldValueModel(List.of(updatedHost), false));
configActions.update(Long.valueOf(fieldModel.getId()), fieldModel);
Optional<EmailGlobalConfigModel> staticEmailConfig = emailGlobalConfigAccessor.getConfiguration();
assertTrue(staticEmailConfig.isPresent());
EmailGlobalConfigModel staticModel = staticEmailConfig.get();
assertEquals(Boolean.TRUE, staticModel.getSmtpAuth().orElse(null));
assertEquals(TEST_AUTH_USER, staticModel.getSmtpUsername().orElse(null));
assertEquals(TEST_AUTH_PASSWORD, staticModel.getSmtpPassword().orElse(null));
assertEquals(updatedHost, staticModel.getSmtpHost().orElse(null));
assertEquals(Integer.valueOf(TEST_SMTP_PORT), staticModel.getSmtpPort().orElse(null));
assertEquals(TEST_FROM, staticModel.getSmtpFrom().orElse(null));
String propertyValue = staticModel.getAdditionalJavaMailProperties().map(map -> map.get(EmailPropertyKeys.JAVAMAIL_EHLO_KEY.getPropertyKey())).orElse(null);
assertEquals("true", propertyValue);
}
use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class JobFieldModelPopulationUtils method putField.
private static void putField(FieldModel fieldModel, String key, List<String> values) {
FieldValueModel fieldValueModel = new FieldValueModel(values, true);
fieldModel.putField(key, fieldValueModel);
}
Aggregations