use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method createFieldModel.
private FieldModel createFieldModel() {
String value = "testValue";
Map<String, FieldValueModel> keyToValues = new HashMap<>();
keyToValues.put(FieldModelTestAction.KEY_CUSTOM_TOPIC, new FieldValueModel(List.of(value), false));
keyToValues.put(ChannelDescriptor.KEY_NAME, new FieldValueModel(List.of(value), false));
return new FieldModel(descriptorKey.getUniversalKey(), ConfigContextEnum.DISTRIBUTION.name(), keyToValues);
}
use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class JobConfigActions method convertFieldToConfigurationField.
private Optional<ConfigurationFieldModel> convertFieldToConfigurationField(FieldModel fieldModel, String fieldKey) {
Optional<FieldValueModel> fieldValueModel = fieldModel.getFieldValueModel(fieldKey);
if (fieldValueModel.isPresent()) {
ConfigurationFieldModel configurationFieldModel = ConfigurationFieldModel.create(fieldKey);
configurationFieldModel.setFieldValues(fieldValueModel.get().getValues());
return Optional.of(configurationFieldModel);
}
return Optional.empty();
}
use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class PolicyNotificationFilterCustomFunctionAction method createPagedActionResponse.
@Override
public ActionResponse<NotificationFilterModelOptions> createPagedActionResponse(FieldModel fieldModel, HttpServletContentWrapper servletContentWrapper, int pageNumber, int pageSize, String searchTerm) throws IntegrationException {
Optional<FieldValueModel> fieldValueModel = fieldModel.getFieldValueModel(ProviderDescriptor.KEY_NOTIFICATION_TYPES);
Collection<String> selectedNotificationTypes = fieldValueModel.map(FieldValueModel::getValues).orElse(List.of());
int totalPages = 1;
List<NotificationFilterModel> options = List.of();
if (isJobFilterableByPolicy(selectedNotificationTypes)) {
try {
Optional<BlackDuckServicesFactory> blackDuckServicesFactory = createBlackDuckServicesFactory(fieldModel);
if (blackDuckServicesFactory.isPresent()) {
BlackDuckPageResponse<PolicyRuleView> policyRulesPage = retrievePolicyRules(blackDuckServicesFactory.get(), pageNumber, pageSize, searchTerm);
totalPages = (policyRulesPage.getTotalCount() + (pageSize - 1)) / pageSize;
options = convertToNotificationFilterModel(policyRulesPage.getItems());
}
} catch (IntegrationException e) {
logger.errorAndDebug("There was an issue communicating with Black Duck. " + e.getMessage(), e);
throw new AlertException("Unable to communicate with Black Duck.", e);
}
}
NotificationFilterModelOptions notificationFilterModelOptions = new NotificationFilterModelOptions(totalPages, pageNumber, pageSize, options);
return new ActionResponse<>(HttpStatus.OK, notificationFilterModelOptions);
}
use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class VulnerabilityNotificationFilterCustomFunctionAction method createActionResponse.
@Override
public ActionResponse<LabelValueSelectOptions> createActionResponse(FieldModel fieldModel, HttpServletContentWrapper servletContentWrapper) {
Optional<FieldValueModel> fieldValueModel = fieldModel.getFieldValueModel(ProviderDescriptor.KEY_NOTIFICATION_TYPES);
Collection<String> selectedNotificationTypes = fieldValueModel.map(FieldValueModel::getValues).orElse(List.of());
List<LabelValueSelectOption> options = List.of();
if (isFilterableVulnerability(selectedNotificationTypes)) {
options = retrieveBlackDuckVulnerabilityOptions();
}
LabelValueSelectOptions optionList = new LabelValueSelectOptions(options);
return new ActionResponse<>(HttpStatus.OK, optionList);
}
use of com.synopsys.integration.alert.common.rest.model.FieldValueModel in project hub-alert by blackducksoftware.
the class SettingsGlobalConfigurationFieldModelValidatorTest method createProxyKeyToValues.
private Map<String, FieldValueModel> createProxyKeyToValues() {
Map<String, FieldValueModel> keyToValues = createKeyToValues();
FieldValueModel proxyHost = new FieldValueModel(List.of("proxyHost"), true);
FieldValueModel proxyPort = new FieldValueModel(List.of("99"), true);
keyToValues.put(ProxyManager.KEY_PROXY_HOST, proxyHost);
keyToValues.put(ProxyManager.KEY_PROXY_PORT, proxyPort);
return keyToValues;
}
Aggregations