use of com.synopsys.integration.alert.common.action.ActionResponse in project blackduck-alert by blackducksoftware.
the class ConfigActions method createWithoutChecks.
@Override
protected ActionResponse<FieldModel> createWithoutChecks(FieldModel resource) {
Optional<DescriptorKey> descriptorKey = descriptorMap.getDescriptorKey(resource.getDescriptorName());
if (descriptorKey.isPresent()) {
try {
FieldModel modifiedFieldModel = fieldModelProcessor.performBeforeSaveAction(resource);
String context = modifiedFieldModel.getContext();
Map<String, ConfigurationFieldModel> configurationFieldModelMap = modelConverter.convertToConfigurationFieldModelMap(modifiedFieldModel);
ConfigurationModel configuration = configurationModelConfigurationAccessor.createConfiguration(descriptorKey.get(), EnumUtils.getEnum(ConfigContextEnum.class, context), configurationFieldModelMap.values());
globalConfigurationModelToConcreteConversionService.createDefaultConcreteModel(modifiedFieldModel.getDescriptorName(), configuration);
FieldModel dbSavedModel = modelConverter.convertToFieldModel(configuration);
FieldModel afterSaveAction = fieldModelProcessor.performAfterSaveAction(dbSavedModel);
FieldModel responseModel = dbSavedModel.fill(afterSaveAction);
return new ActionResponse<>(HttpStatus.OK, responseModel);
} catch (AlertException ex) {
logger.error("Error creating configuration", ex);
return new ActionResponse<>(HttpStatus.INTERNAL_SERVER_ERROR, String.format("Error creating config: %s", ex.getMessage()));
}
}
return new ActionResponse<>(HttpStatus.BAD_REQUEST, "descriptorName is missing or invalid");
}
use of com.synopsys.integration.alert.common.action.ActionResponse in project blackduck-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 blackduck-alert by blackducksoftware.
the class SystemActions method getSystemMessagesBefore.
private ActionResponse<MultiSystemMessageModel> getSystemMessagesBefore(String endDate) throws ParseException {
OffsetDateTime date = DateUtils.parseDateFromJsonString(endDate);
List<SystemMessageModel> messages = systemMessageAccessor.getSystemMessagesBefore(date);
return new ActionResponse<>(HttpStatus.OK, new MultiSystemMessageModel(messages));
}
use of com.synopsys.integration.alert.common.action.ActionResponse in project blackduck-alert by blackducksoftware.
the class SystemActions method getSystemMessagesBetween.
private ActionResponse<MultiSystemMessageModel> getSystemMessagesBetween(String startDate, String endDate) throws ParseException {
DateRange dateRange = DateRange.of(startDate, endDate);
List<SystemMessageModel> messages = systemMessageAccessor.findBetween(dateRange);
return new ActionResponse<>(HttpStatus.OK, new MultiSystemMessageModel(messages));
}
use of com.synopsys.integration.alert.common.action.ActionResponse in project blackduck-alert by blackducksoftware.
the class DescriptorMetadataActions method getDescriptorsByPermissions.
public ActionResponse<DescriptorsResponseModel> getDescriptorsByPermissions(@Nullable String name, @Nullable String type, @Nullable String context) {
Predicate<Descriptor> descriptorFilter = ignored -> true;
Set<ConfigContextEnum> requestedContexts = Set.of(ConfigContextEnum.GLOBAL, ConfigContextEnum.DISTRIBUTION);
if (StringUtils.isNotBlank(name)) {
descriptorFilter = descriptorFilter.and(descriptor -> name.equals(descriptor.getDescriptorKey().getUniversalKey()));
}
if (StringUtils.isNotBlank(type)) {
descriptorFilter = descriptorFilter.and(descriptor -> type.equals(descriptor.getType().name()));
}
if (StringUtils.isNotBlank(context)) {
ConfigContextEnum requestedContext = EnumUtils.getEnum(ConfigContextEnum.class, context);
if (null != requestedContext) {
requestedContexts = Set.of(requestedContext);
} else {
requestedContexts = Set.of();
}
}
return createDescriptorResponse(descriptorFilter, requestedContexts);
}
Aggregations