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();
}
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;
}
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();
}
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();
}
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();
}
Aggregations