Search in sources :

Example 6 with ConfigurationFieldValidator

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

the class JiraCloudGlobalConfigurationFieldModelValidator method validate.

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

Example 7 with ConfigurationFieldValidator

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

the class JiraCloudDistributionConfigurationValidator method validate.

@Override
public Set<AlertFieldStatus> validate(JobFieldModel jobFieldModel) {
    HashSet<AlertFieldStatus> validationResults = new HashSet<>();
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromJobFieldModel(jobFieldModel);
    commonChannelDistributionValidator.validate(configurationFieldValidator);
    configurationFieldValidator.validateRequiredFieldsAreNotBlank(JiraCloudDescriptor.KEY_JIRA_PROJECT_NAME, JiraCloudDescriptor.KEY_ISSUE_TYPE);
    configurationFieldValidator.validateRequiredRelatedSet(JiraCloudDescriptor.KEY_OPEN_WORKFLOW_TRANSITION, JiraCloudDescriptor.LABEL_OPEN_WORKFLOW_TRANSITION, JiraCloudDescriptor.KEY_RESOLVE_WORKFLOW_TRANSITION);
    // Validate custom field mappings
    jobFieldModel.getFieldModels().stream().filter(fieldModel -> jiraCloudChannelKey.getUniversalKey().equals(fieldModel.getDescriptorName())).findFirst().flatMap(fieldModel -> fieldModel.getFieldValueModel(JiraCloudDescriptor.KEY_FIELD_MAPPING)).flatMap(fieldValueModel -> jiraFieldMappingValidator.validateFieldMappings(JiraCloudDescriptor.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) JiraCloudDescriptor(com.synopsys.integration.alert.channel.jira.cloud.descriptor.JiraCloudDescriptor) Component(org.springframework.stereotype.Component) JiraCloudChannelKey(com.synopsys.integration.alert.descriptor.api.JiraCloudChannelKey) 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 8 with ConfigurationFieldValidator

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

the class EmailGlobalConfigurationFieldModelValidator method validate.

@Override
public Set<AlertFieldStatus> validate(FieldModel fieldModel) {
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromFieldModel(fieldModel);
    configurationFieldValidator.validateRequiredFieldIsNotBlank(EmailPropertyKeys.JAVAMAIL_HOST_KEY.getPropertyKey());
    configurationFieldValidator.validateRequiredFieldIsNotBlank(EmailPropertyKeys.JAVAMAIL_FROM_KEY.getPropertyKey());
    configurationFieldValidator.validateIsANumber(EmailPropertyKeys.JAVAMAIL_PORT_KEY.getPropertyKey());
    configurationFieldValidator.validateIsANumber(EmailPropertyKeys.JAVAMAIL_CONNECTION_TIMEOUT_KEY.getPropertyKey());
    configurationFieldValidator.validateIsANumber(EmailPropertyKeys.JAVAMAIL_TIMEOUT_KEY.getPropertyKey());
    configurationFieldValidator.validateIsANumber(EmailPropertyKeys.JAVAMAIL_WRITETIMEOUT_KEY.getPropertyKey());
    configurationFieldValidator.validateIsANumber(EmailPropertyKeys.JAVAMAIL_LOCALHOST_PORT_KEY.getPropertyKey());
    configurationFieldValidator.validateIsANumber(EmailPropertyKeys.JAVAMAIL_AUTH_NTLM_FLAGS_KEY.getPropertyKey());
    configurationFieldValidator.validateIsANumber(EmailPropertyKeys.JAVAMAIL_PROXY_PORT_KEY.getPropertyKey());
    configurationFieldValidator.validateIsANumber(EmailPropertyKeys.JAVAMAIL_SOCKS_PORT_KEY.getPropertyKey());
    boolean useAuth = fieldModel.getFieldValueModel(EmailPropertyKeys.JAVAMAIL_AUTH_KEY.getPropertyKey()).flatMap(FieldValueModel::getValue).map(Boolean::valueOf).orElse(false);
    if (useAuth) {
        configurationFieldValidator.validateRequiredFieldsAreNotBlank(List.of(EmailPropertyKeys.JAVAMAIL_USER_KEY.getPropertyKey(), EmailPropertyKeys.JAVAMAIL_PASSWORD_KEY.getPropertyKey()));
    }
    return configurationFieldValidator.getValidationResults();
}
Also used : ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator) FieldValueModel(com.synopsys.integration.alert.common.rest.model.FieldValueModel)

Example 9 with ConfigurationFieldValidator

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

the class EmailDistributionConfigurationValidator method validate.

@Override
public Set<AlertFieldStatus> validate(JobFieldModel jobFieldModel) {
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromJobFieldModel(jobFieldModel);
    commonChannelDistributionValidator.validate(configurationFieldValidator);
    configurationFieldValidator.validateRequiredRelatedSet(EmailDescriptor.KEY_EMAIL_ADDITIONAL_ADDRESSES, EmailDescriptor.LABEL_ADDITIONAL_ADDRESSES, ChannelDescriptor.KEY_PROVIDER_TYPE, ProviderDescriptor.KEY_PROVIDER_CONFIG_ID);
    boolean additionalEmailsOnly = configurationFieldValidator.getBooleanValue(EmailDescriptor.KEY_EMAIL_ADDITIONAL_ADDRESSES_ONLY).orElse(false);
    boolean projectOwnerOnly = configurationFieldValidator.getBooleanValue(EmailDescriptor.KEY_PROJECT_OWNER_ONLY).orElse(false);
    if (additionalEmailsOnly && projectOwnerOnly) {
        configurationFieldValidator.addValidationResults(AlertFieldStatus.error(EmailDescriptor.KEY_EMAIL_ADDITIONAL_ADDRESSES_ONLY, String.format("Cannot be set if %s is already set", EmailDescriptor.LABEL_PROJECT_OWNER_ONLY)), AlertFieldStatus.error(EmailDescriptor.KEY_PROJECT_OWNER_ONLY, String.format("Cannot be set if %s is already set", EmailDescriptor.LABEL_ADDITIONAL_ADDRESSES_ONLY)));
    }
    if (additionalEmailsOnly) {
        configurationFieldValidator.validateRequiredRelatedSet(EmailDescriptor.KEY_EMAIL_ADDITIONAL_ADDRESSES_ONLY, EmailDescriptor.LABEL_ADDITIONAL_ADDRESSES, EmailDescriptor.KEY_EMAIL_ADDITIONAL_ADDRESSES);
    }
    return configurationFieldValidator.getValidationResults();
}
Also used : ConfigurationFieldValidator(com.synopsys.integration.alert.common.descriptor.validator.ConfigurationFieldValidator)

Example 10 with ConfigurationFieldValidator

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

the class BlackDuckDistributionConfigurationValidator method validate.

@Override
public Set<AlertFieldStatus> validate(JobFieldModel jobFieldModel) {
    ConfigurationFieldValidator configurationFieldValidator = ConfigurationFieldValidator.fromJobFieldModel(jobFieldModel);
    commonProviderDistributionValidator.validate(configurationFieldValidator);
    configurationFieldValidator.validateRequiredRelatedSet(BlackDuckDescriptor.KEY_BLACKDUCK_POLICY_NOTIFICATION_TYPE_FILTER, BlackDuckDescriptor.LABEL_BLACKDUCK_POLICY_NOTIFICATION_TYPE_FILTER, ProviderDescriptor.KEY_NOTIFICATION_TYPES, ChannelDescriptor.KEY_PROVIDER_TYPE, ProviderDescriptor.KEY_PROVIDER_CONFIG_ID);
    configurationFieldValidator.validateRequiredRelatedSet(BlackDuckDescriptor.KEY_BLACKDUCK_VULNERABILITY_NOTIFICATION_TYPE_FILTER, BlackDuckDescriptor.LABEL_BLACKDUCK_VULNERABILITY_NOTIFICATION_TYPE_FILTER, ProviderDescriptor.KEY_NOTIFICATION_TYPES);
    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