use of com.synopsys.integration.alert.common.rest.model.JobFieldModel in project hub-alert by blackducksoftware.
the class AbstractJobResourceActions method getOne.
public final ActionResponse<JobFieldModel> getOne(UUID id) {
Set<String> descriptorNames = getDescriptorNames();
if (!authorizationManager.anyReadPermission(List.of(ConfigContextEnum.DISTRIBUTION), descriptorNames)) {
return ActionResponse.createForbiddenResponse();
}
Optional<JobFieldModel> optionalModel = findJobFieldModel(id);
if (optionalModel.isPresent()) {
JobFieldModel fieldModel = optionalModel.get();
boolean hasPermissions = hasRequiredPermissions(fieldModel.getFieldModels(), authorizationManager::hasReadPermission);
if (!hasPermissions) {
return ActionResponse.createForbiddenResponse();
}
return new ActionResponse<>(HttpStatus.OK, fieldModel);
}
return new ActionResponse<>(HttpStatus.NOT_FOUND);
}
use of com.synopsys.integration.alert.common.rest.model.JobFieldModel in project hub-alert by blackducksoftware.
the class AbstractJobResourceActions method delete.
public final ActionResponse<JobFieldModel> delete(UUID id) {
Optional<JobFieldModel> optionalModel = findJobFieldModel(id);
if (optionalModel.isPresent()) {
JobFieldModel jobFieldModel = optionalModel.get();
boolean hasPermissions = hasRequiredPermissions(jobFieldModel.getFieldModels(), authorizationManager::hasDeletePermission);
if (!hasPermissions) {
return ActionResponse.createForbiddenResponse();
}
} else {
return new ActionResponse<>(HttpStatus.NOT_FOUND);
}
return deleteWithoutChecks(id);
}
Aggregations