use of com.synopsys.integration.alert.common.action.ActionResponse in project hub-alert by blackducksoftware.
the class ProviderConfigSelectCustomFunctionAction method createActionResponse.
@Override
public ActionResponse<LabelValueSelectOptions> createActionResponse(FieldModel fieldModel, HttpServletContentWrapper servletContentWrapper) {
String providerName = fieldModel.getDescriptorName();
Optional<DescriptorKey> descriptorKey = descriptorMap.getDescriptorKey(providerName);
List<LabelValueSelectOption> options = List.of();
if (descriptorKey.isPresent()) {
List<ConfigurationModel> configurationModels = configurationModelConfigurationAccessor.getConfigurationsByDescriptorKeyAndContext(descriptorKey.get(), ConfigContextEnum.GLOBAL);
options = configurationModels.stream().map(this::createNameToIdOption).flatMap(Optional::stream).collect(Collectors.toList());
}
LabelValueSelectOptions optionList = new LabelValueSelectOptions(options);
return new ActionResponse<>(HttpStatus.OK, optionList);
}
use of com.synopsys.integration.alert.common.action.ActionResponse in project hub-alert by blackducksoftware.
the class AuditEntryActions method queryForAuditInfoInJobs.
public ActionResponse<AuditJobStatusesModel> queryForAuditInfoInJobs(JobIdsRequestModel queryRequestModel) {
if (!authorizationManager.hasReadPermission(ConfigContextEnum.GLOBAL, descriptorKey)) {
return new ActionResponse<>(HttpStatus.FORBIDDEN, ActionResponse.FORBIDDEN_MESSAGE);
}
List<UUID> jobIds = queryRequestModel.getJobIds();
for (UUID jobId : jobIds) {
if (null == jobId) {
return new ActionResponse<>(HttpStatus.BAD_REQUEST, "The field 'jobIds' cannot contain null values");
}
}
List<AuditJobStatusModel> auditJobStatusModels = auditAccessor.findByJobIds(jobIds);
return new ActionResponse<>(HttpStatus.OK, new AuditJobStatusesModel(auditJobStatusModels));
}
use of com.synopsys.integration.alert.common.action.ActionResponse in project hub-alert by blackducksoftware.
the class AuditEntryActions method resendNotification.
public ActionResponse<AuditEntryPageModel> resendNotification(Long notificationId, @Nullable UUID requestedJobId) {
if (!authorizationManager.hasExecutePermission(ConfigContextEnum.GLOBAL, descriptorKey)) {
return new ActionResponse<>(HttpStatus.FORBIDDEN, ActionResponse.FORBIDDEN_MESSAGE);
}
Optional<AlertNotificationModel> notification = notificationAccessor.findById(notificationId);
if (notification.isEmpty()) {
return new ActionResponse<>(HttpStatus.GONE, "No notification with this id exists.");
}
AlertNotificationModel notificationContent = notification.get();
if (null != requestedJobId) {
Optional<DistributionJobModel> optionalDistributionJob = jobAccessor.getJobById(requestedJobId);
if (optionalDistributionJob.isEmpty()) {
String message = String.format("The Distribution Job with this id could not be found. %s", requestedJobId.toString());
return new ActionResponse<>(HttpStatus.GONE, message);
}
DistributionJobModel distributionJob = optionalDistributionJob.get();
if (distributionJob.isEnabled()) {
ProcessedNotificationDetails processedNotificationDetails = ProcessedNotificationDetails.fromDistributionJob(distributionJob);
jobNotificationProcessor.processNotificationForJob(processedNotificationDetails, distributionJob.getProcessingType(), List.of(notificationContent));
} else {
UUID jobConfigId = distributionJob.getJobId();
logger.warn("The Distribution Job with Id {} was disabled. This notification could not be sent", jobConfigId);
String message = String.format("The Distribution Job is currently disabled. %s", jobConfigId);
return new ActionResponse<>(HttpStatus.BAD_REQUEST, message);
}
} else {
notificationProcessor.processNotifications(List.of(notificationContent), List.of(FrequencyType.DAILY, FrequencyType.REAL_TIME));
}
return get();
}
use of com.synopsys.integration.alert.common.action.ActionResponse in project hub-alert by blackducksoftware.
the class ProcessingSelectCustomFunctionAction method createActionResponse.
@Override
public ActionResponse<LabelValueSelectOptions> createActionResponse(FieldModel fieldModel, HttpServletContentWrapper servletContentWrapper) {
String channelName = fieldModel.getFieldValue(ChannelDescriptor.KEY_CHANNEL_NAME).orElse("");
List<LabelValueSelectOption> options = Arrays.stream(ProcessingType.values()).filter(processingType -> this.shouldInclude(processingType, channelName)).map(processingType -> new LabelValueSelectOption(processingType.getLabel(), processingType.name())).collect(Collectors.toList());
LabelValueSelectOptions optionList = new LabelValueSelectOptions(options);
return new ActionResponse<>(HttpStatus.OK, optionList);
}
use of com.synopsys.integration.alert.common.action.ActionResponse in project hub-alert by blackducksoftware.
the class SystemActions method getSystemMessagesAfter.
private ActionResponse<MultiSystemMessageModel> getSystemMessagesAfter(String startDate) throws ParseException {
OffsetDateTime date = DateUtils.parseDateFromJsonString(startDate);
List<SystemMessageModel> messages = systemMessageAccessor.getSystemMessagesAfter(date);
return new ActionResponse<>(HttpStatus.OK, new MultiSystemMessageModel(messages));
}
Aggregations