use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class ConfigurationFieldModelConverter method convertToFieldModel.
public FieldModel convertToFieldModel(ConfigurationModel configurationModel) {
Long configId = configurationModel.getConfigurationId();
String descriptorName = getDescriptorName(configurationModel);
Map<String, FieldValueModel> fields = new HashMap<>();
for (ConfigurationFieldModel fieldModel : configurationModel.getCopyOfFieldList()) {
populateAndSecureFields(fieldModel, fields);
}
return new FieldModel(configId.toString(), descriptorName, configurationModel.getDescriptorContext().name(), configurationModel.getCreatedAt(), configurationModel.getLastUpdated(), fields);
}
use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class FieldModelProcessor method populateTestFieldModel.
private FieldModel populateTestFieldModel(Long id, FieldModel fieldModel) throws AlertException {
Collection<ConfigurationFieldModel> configurationFieldModels = fillFieldModelWithExistingData(id, fieldModel);
Map<String, FieldValueModel> fields = new HashMap<>();
for (ConfigurationFieldModel configurationFieldModel : configurationFieldModels) {
FieldValueModel fieldValueModel = new FieldValueModel(configurationFieldModel.getFieldValues(), configurationFieldModel.isSet());
fields.put(configurationFieldModel.getFieldKey(), fieldValueModel);
}
FieldModel newFieldModel = new FieldModel("", "", fieldModel.getCreatedAt(), fieldModel.getLastUpdated(), fields);
return fieldModel.fill(newFieldModel);
}
use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationFieldModelValidatorTest method createValidKeyToValues.
private Map<String, FieldValueModel> createValidKeyToValues() {
Map<String, FieldValueModel> keyToValues = new HashMap<>();
FieldValueModel url = new FieldValueModel(List.of("http://url.com"), true);
FieldValueModel username = new FieldValueModel(List.of("username"), true);
FieldValueModel password = new FieldValueModel(List.of("password"), true);
keyToValues.put(JiraServerDescriptor.KEY_SERVER_URL, url);
keyToValues.put(JiraServerDescriptor.KEY_SERVER_USERNAME, username);
keyToValues.put(JiraServerDescriptor.KEY_SERVER_PASSWORD, password);
return keyToValues;
}
use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class AuthenticationApiAction method addSAMLMetadata.
private void addSAMLMetadata(FieldModel fieldModel) {
try {
boolean samlEnabled = fieldModel.getFieldValueModel(AuthenticationDescriptor.KEY_SAML_ENABLED).flatMap(FieldValueModel::getValue).map(BooleanUtils::toBoolean).orElse(false);
Optional<FieldValueModel> metadataURLFieldValueOptional = fieldModel.getFieldValueModel(AuthenticationDescriptor.KEY_SAML_METADATA_URL);
Optional<FieldValueModel> metadataEntityFieldValueOptional = fieldModel.getFieldValueModel(AuthenticationDescriptor.KEY_SAML_ENTITY_ID);
Optional<FieldValueModel> metadataBaseURLFieldValueOptional = fieldModel.getFieldValueModel(AuthenticationDescriptor.KEY_SAML_ENTITY_BASE_URL);
if (metadataEntityFieldValueOptional.isPresent() && metadataBaseURLFieldValueOptional.isPresent()) {
FieldValueModel metadataEntityFieldValue = metadataEntityFieldValueOptional.get();
FieldValueModel metadataBaseUrValueModel = metadataBaseURLFieldValueOptional.get();
String metadataURL = metadataURLFieldValueOptional.flatMap(FieldValueModel::getValue).orElse("");
String entityId = metadataEntityFieldValue.getValue().orElse("");
String baseUrl = metadataBaseUrValueModel.getValue().orElse("");
samlManager.updateSAMLConfiguration(samlEnabled, metadataURL, entityId, baseUrl);
}
} catch (Exception ex) {
logger.error("Error adding SAML settings", ex);
}
}
use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class AbstractJobResourceActions method correctProjectsField.
// FIXME More tech debt until we fix the Jobs API
private void correctProjectsField(JobFieldModel jobFieldModel) {
List<JobProviderProjectFieldModel> projects = jobFieldModel.getConfiguredProviderProjects();
if (null == projects) {
projects = List.of();
}
String projectFieldKey = "channel.common.configured.project";
for (FieldModel fieldModel : jobFieldModel.getFieldModels()) {
Map<String, FieldValueModel> keyToValues = fieldModel.getKeyToValues();
if (keyToValues.containsKey(projectFieldKey)) {
FieldValueModel projectFieldValues = createProjectFieldValues(projects);
keyToValues.put(projectFieldKey, projectFieldValues);
return;
}
}
}
Aggregations