Search in sources :

Example 6 with FieldValueModel

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);
}
Also used : ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) HashMap(java.util.HashMap) DefinedFieldModel(com.synopsys.integration.alert.common.persistence.model.DefinedFieldModel) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) FieldValueModel(com.synopsys.integration.alert.common.rest.model.FieldValueModel)

Example 7 with FieldValueModel

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);
}
Also used : ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) HashMap(java.util.HashMap) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) FieldValueModel(com.synopsys.integration.alert.common.rest.model.FieldValueModel)

Example 8 with FieldValueModel

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;
}
Also used : HashMap(java.util.HashMap) FieldValueModel(com.synopsys.integration.alert.common.rest.model.FieldValueModel)

Example 9 with FieldValueModel

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);
    }
}
Also used : FieldValueModel(com.synopsys.integration.alert.common.rest.model.FieldValueModel)

Example 10 with FieldValueModel

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;
        }
    }
}
Also used : JobProviderProjectFieldModel(com.synopsys.integration.alert.common.rest.model.JobProviderProjectFieldModel) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) JobFieldModel(com.synopsys.integration.alert.common.rest.model.JobFieldModel) JobProviderProjectFieldModel(com.synopsys.integration.alert.common.rest.model.JobProviderProjectFieldModel) MultiJobFieldModel(com.synopsys.integration.alert.common.rest.model.MultiJobFieldModel) FieldValueModel(com.synopsys.integration.alert.common.rest.model.FieldValueModel)

Aggregations

FieldValueModel (com.synopsys.integration.alert.common.rest.model.FieldValueModel)58 HashMap (java.util.HashMap)27 FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)24 Test (org.junit.jupiter.api.Test)18 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)12 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)6 GlobalConfigurationValidatorAsserter (com.synopsys.integration.alert.test.common.channel.GlobalConfigurationValidatorAsserter)6 JobFieldModel (com.synopsys.integration.alert.common.rest.model.JobFieldModel)5 JobProviderProjectFieldModel (com.synopsys.integration.alert.common.rest.model.JobProviderProjectFieldModel)4 ConfigurationManager (com.synopsys.integration.alert.performance.utility.ConfigurationManager)4 IntegrationPerformanceTestRunner (com.synopsys.integration.alert.performance.utility.IntegrationPerformanceTestRunner)4 Disabled (org.junit.jupiter.api.Disabled)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)3 DescriptorAccessor (com.synopsys.integration.alert.common.persistence.accessor.DescriptorAccessor)3 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)3 EncryptionUtility (com.synopsys.integration.alert.common.security.EncryptionUtility)3 AlertRequestUtility (com.synopsys.integration.alert.performance.utility.AlertRequestUtility)3 BlackDuckProviderService (com.synopsys.integration.alert.performance.utility.BlackDuckProviderService)3 List (java.util.List)3