use of com.synopsys.integration.alert.api.common.model.exception.AlertRuntimeException in project hub-alert by blackducksoftware.
the class JiraCustomFieldResolver method convertValueToRequestObject.
protected Object convertValueToRequestObject(CustomFieldDefinitionModel fieldDefinition, JiraCustomFieldConfig jiraCustomFieldConfig) {
String fieldType = fieldDefinition.getFieldType();
String innerFieldValue = extractUsableInnerValue(jiraCustomFieldConfig);
switch(fieldType) {
case CUSTOM_FIELD_TYPE_STRING_VALUE:
return innerFieldValue;
case CUSTOM_FIELD_TYPE_ARRAY_VALUE:
return createJsonArray(innerFieldValue, fieldDefinition.getFieldArrayItems());
case CUSTOM_FIELD_TYPE_OPTION_VALUE:
return createJsonObject("value", innerFieldValue);
case CUSTOM_FIELD_TYPE_PRIORITY_VALUE:
return createJsonObject("name", innerFieldValue);
case CUSTOM_FIELD_TYPE_USER_VALUE:
// "name" is used for Jira Server (ignored on Jira Cloud)
JsonObject createUserObject = createJsonObject("name", innerFieldValue);
// "accountId" is used for Jira Cloud (ignored on Jira Server)
createUserObject.addProperty("accountId", innerFieldValue);
// TODO consider separating this functionality depending on which Jira channel is being used
return createUserObject;
default:
throw new AlertRuntimeException(String.format("Unsupported field type '%s' for field: %s", fieldType, jiraCustomFieldConfig.getFieldName()));
}
}
use of com.synopsys.integration.alert.api.common.model.exception.AlertRuntimeException in project hub-alert by blackducksoftware.
the class JobNotificationMapper method createRequestModelFromNotifications.
private FilteredDistributionJobRequestModel createRequestModelFromNotifications(List<DetailedNotificationContent> detailedContents, List<FrequencyType> frequencies) {
Long commonProviderConfigId = detailedContents.stream().map(DetailedNotificationContent::getProviderConfigId).findAny().orElseThrow(() -> new AlertRuntimeException("Notification(s) missing provider configuration id"));
FilteredDistributionJobRequestModel filteredDistributionJobRequestModel = new FilteredDistributionJobRequestModel(commonProviderConfigId, frequencies);
for (DetailedNotificationContent detailedNotificationContent : detailedContents) {
detailedNotificationContent.getProjectName().ifPresent(filteredDistributionJobRequestModel::addProjectName);
filteredDistributionJobRequestModel.addNotificationType(detailedNotificationContent.getNotificationContentWrapper().extractNotificationType());
filteredDistributionJobRequestModel.addVulnerabilitySeverities(detailedNotificationContent.getVulnerabilitySeverities());
detailedNotificationContent.getPolicyName().ifPresent(filteredDistributionJobRequestModel::addPolicyName);
}
return filteredDistributionJobRequestModel;
}
Aggregations