Search in sources :

Example 1 with ConfigurationFieldValidator

use of com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator in project hub-alert by blackducksoftware.

the class JiraServerDistributionConfigurationValidator method validate.

@Override
public Set<AlertFieldStatus> validate(JobFieldModel jobFieldModel) {
    HashSet<AlertFieldStatus> validationResults = new HashSet<>();
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromJobFieldModel(jobFieldModel);
    commonChannelDistributionValidator.validate(configurationFieldValidator);
    configurationFieldValidator.validateRequiredFieldsAreNotBlank(JiraServerDescriptor.KEY_JIRA_PROJECT_NAME, JiraServerDescriptor.KEY_ISSUE_TYPE);
    configurationFieldValidator.validateRequiredRelatedSet(JiraServerDescriptor.KEY_OPEN_WORKFLOW_TRANSITION, JiraServerDescriptor.LABEL_OPEN_WORKFLOW_TRANSITION, JiraServerDescriptor.KEY_RESOLVE_WORKFLOW_TRANSITION);
    // Validate custom field mappings
    jobFieldModel.getFieldModels().stream().filter(fieldModel -> jiraServerChannelKey.getUniversalKey().equals(fieldModel.getDescriptorName())).findFirst().flatMap(fieldModel -> fieldModel.getFieldValueModel(JiraServerDescriptor.KEY_FIELD_MAPPING)).flatMap(fieldValueModel -> jiraFieldMappingValidator.validateFieldMappings(JiraServerDescriptor.KEY_FIELD_MAPPING, fieldValueModel)).ifPresent(validationResults::add);
    validationResults.addAll(configurationFieldValidator.getValidationResults());
    return validationResults;
}
Also used : HashSet(java.util.HashSet) CommonChannelDistributionValidator(com.synopsys.integration.alert.api.channel.CommonChannelDistributionValidator) JiraServerDescriptor(com.synopsys.integration.alert.channel.jira.server.descriptor.JiraServerDescriptor) Component(org.springframework.stereotype.Component) JiraServerChannelKey(com.synopsys.integration.alert.descriptor.api.JiraServerChannelKey) JiraFieldMappingValidator(com.synopsys.integration.alert.api.channel.jira.validation.JiraFieldMappingValidator) AlertFieldStatus(com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) DistributionConfigurationValidator(com.synopsys.integration.alert.common.descriptor.validator.DistributionConfigurationValidator) ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator) JobFieldModel(com.synopsys.integration.alert.common.rest.model.JobFieldModel) ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator) AlertFieldStatus(com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus) HashSet(java.util.HashSet)

Example 2 with ConfigurationFieldValidator

use of com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator in project hub-alert by blackducksoftware.

the class AzureBoardsDistributionConfigurationValidator method validate.

@Override
public Set<AlertFieldStatus> validate(JobFieldModel jobFieldModel) {
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromJobFieldModel(jobFieldModel);
    commonChannelDistributionValidator.validate(configurationFieldValidator);
    configurationFieldValidator.validateRequiredFieldsAreNotBlank(AzureBoardsDescriptor.KEY_AZURE_PROJECT, AzureBoardsDescriptor.KEY_WORK_ITEM_TYPE);
    configurationFieldValidator.validateRequiredRelatedSet(AzureBoardsDescriptor.KEY_WORK_ITEM_REOPEN_STATE, AzureBoardsDescriptor.LABEL_WORK_ITEM_REOPEN_STATE, AzureBoardsDescriptor.KEY_WORK_ITEM_COMPLETED_STATE);
    return configurationFieldValidator.getValidationResults();
}
Also used : ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator)

Example 3 with ConfigurationFieldValidator

use of com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator in project hub-alert by blackducksoftware.

the class AzureBoardsGlobalConfigurationFieldModelValidator method validate.

@Override
public Set<AlertFieldStatus> validate(FieldModel fieldModel) {
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromFieldModel(fieldModel);
    configurationFieldValidator.validateRequiredFieldIsNotBlank(AzureBoardsDescriptor.KEY_ORGANIZATION_NAME);
    configurationFieldValidator.validateRequiredFieldIsNotBlank(AzureBoardsDescriptor.KEY_CLIENT_ID);
    configurationFieldValidator.validateRequiredFieldIsNotBlank(AzureBoardsDescriptor.KEY_CLIENT_SECRET);
    if (oAuthRequestValidator.hasRequests()) {
        configurationFieldValidator.addValidationResults(AlertFieldStatus.error(AzureBoardsDescriptor.KEY_OAUTH, "Authentication in progress cannot perform current action."));
    }
    return configurationFieldValidator.getValidationResults();
}
Also used : ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator)

Example 4 with ConfigurationFieldValidator

use of com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator in project hub-alert by blackducksoftware.

the class BlackDuckGlobalConfigurationFieldModelValidator method validate.

@Override
public Set<AlertFieldStatus> validate(FieldModel fieldModel) {
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromFieldModel(fieldModel);
    configurationFieldValidator.validateRequiredFieldsAreNotBlank(List.of(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME, BlackDuckDescriptor.KEY_BLACKDUCK_URL, BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY, BlackDuckDescriptor.KEY_BLACKDUCK_TIMEOUT));
    configurationFieldValidator.validateIsAURL(BlackDuckDescriptor.KEY_BLACKDUCK_URL);
    validateAPIToken(configurationFieldValidator);
    validateDuplicateNames(fieldModel).ifPresent(configurationFieldValidator::addValidationResults);
    validateTimeout(configurationFieldValidator);
    return configurationFieldValidator.getValidationResults();
}
Also used : ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator)

Example 5 with ConfigurationFieldValidator

use of com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator in project hub-alert by blackducksoftware.

the class JiraServerGlobalConfigurationFieldModelValidator method validate.

@Override
public Set<AlertFieldStatus> validate(FieldModel fieldModel) {
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromFieldModel(fieldModel);
    configurationFieldValidator.validateRequiredFieldIsNotBlank(JiraServerDescriptor.KEY_SERVER_URL);
    configurationFieldValidator.validateIsAURL(JiraServerDescriptor.KEY_SERVER_URL);
    configurationFieldValidator.validateRequiredFieldIsNotBlank(JiraServerDescriptor.KEY_SERVER_USERNAME);
    configurationFieldValidator.validateRequiredFieldIsNotBlank(JiraServerDescriptor.KEY_SERVER_PASSWORD);
    return configurationFieldValidator.getValidationResults();
}
Also used : ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator)

Aggregations

ConfigurationFieldValidator (com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator)15 CommonChannelDistributionValidator (com.synopsys.integration.alert.api.channel.CommonChannelDistributionValidator)2 JiraFieldMappingValidator (com.synopsys.integration.alert.api.channel.jira.validation.JiraFieldMappingValidator)2 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)2 DistributionConfigurationValidator (com.synopsys.integration.alert.common.descriptor.validator.DistributionConfigurationValidator)2 JobFieldModel (com.synopsys.integration.alert.common.rest.model.JobFieldModel)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Component (org.springframework.stereotype.Component)2 JiraCloudDescriptor (com.synopsys.integration.alert.channel.jira.cloud.descriptor.JiraCloudDescriptor)1 JiraServerDescriptor (com.synopsys.integration.alert.channel.jira.server.descriptor.JiraServerDescriptor)1 FieldValueModel (com.synopsys.integration.alert.common.rest.model.FieldValueModel)1 JiraCloudChannelKey (com.synopsys.integration.alert.descriptor.api.JiraCloudChannelKey)1 JiraServerChannelKey (com.synopsys.integration.alert.descriptor.api.JiraServerChannelKey)1