use of com.netflix.spinnaker.front50.events.ApplicationPermissionEventListener.Type in project front50 by spinnaker.
the class NotificationController method listByApplication.
@PostAuthorize("hasPermission(#name, 'APPLICATION', 'READ')")
@RequestMapping(value = "{type}/{name}", method = RequestMethod.GET)
public Notification listByApplication(@PathVariable(value = "type") String type, @PathVariable(value = "name") String name) {
HierarchicalLevel level = getLevel(type);
final Notification notification = notificationDAO.get(level, name);
if (level.equals(HierarchicalLevel.APPLICATION)) {
final Object global = getGlobal();
NotificationDAO.NOTIFICATION_FORMATS.forEach(it -> {
if (UntypedUtils.hasProperty(global, it)) {
if (!UntypedUtils.hasProperty(notification, it)) {
UntypedUtils.setProperty(notification, it, new ArrayList<>());
}
((List) UntypedUtils.getProperty(notification, it)).addAll((List) UntypedUtils.getProperty(global, it));
}
});
}
return notification;
}
use of com.netflix.spinnaker.front50.events.ApplicationPermissionEventListener.Type in project front50 by spinnaker.
the class NotificationController method delete.
@PreAuthorize("@fiatPermissionEvaluator.storeWholePermission() and hasPermission(#name, 'APPLICATION', 'WRITE')")
@RequestMapping(value = "{type}/{name}", method = RequestMethod.DELETE)
public void delete(@PathVariable(value = "type") String type, @PathVariable(value = "name") String name) {
HierarchicalLevel level = getLevel(type);
notificationDAO.delete(level, name);
}
use of com.netflix.spinnaker.front50.events.ApplicationPermissionEventListener.Type in project front50 by spinnaker.
the class PipelineController method validatePipeline.
/**
* Ensure basic validity of the pipeline. Invalid pipelines will raise runtime exceptions.
*
* @param pipeline The Pipeline to validate
*/
private void validatePipeline(final Pipeline pipeline, Boolean staleCheck) {
// Pipelines must have an application and a name
if (StringUtils.isAnyBlank(pipeline.getApplication(), pipeline.getName())) {
throw new InvalidEntityException("A pipeline requires name and application fields");
}
// Check if pipeline type is templated
if (TYPE_TEMPLATED.equals(pipeline.getType())) {
PipelineTemplateDAO templateDAO = getTemplateDAO();
// Check templated pipelines to ensure template is valid
String source;
switch(pipeline.getSchema()) {
case "v2":
V2TemplateConfiguration v2Config = objectMapper.convertValue(pipeline, V2TemplateConfiguration.class);
source = v2Config.getTemplate().getReference();
break;
default:
TemplateConfiguration v1Config = objectMapper.convertValue(pipeline.getConfig(), TemplateConfiguration.class);
source = v1Config.getPipeline().getTemplate().getSource();
break;
}
// Check if template id which is after :// is in the store
if (source.startsWith(SPINNAKER_PREFIX)) {
String templateId = source.substring(SPINNAKER_PREFIX.length());
try {
templateDAO.findById(templateId);
} catch (NotFoundException notFoundEx) {
throw new BadRequestException("Configured pipeline template not found", notFoundEx);
}
}
}
checkForDuplicatePipeline(pipeline.getApplication(), pipeline.getName().trim(), pipeline.getId());
final ValidatorErrors errors = new ValidatorErrors();
pipelineValidators.forEach(it -> it.validate(pipeline, errors));
if (staleCheck && !Strings.isNullOrEmpty(pipeline.getId()) && pipeline.getLastModified() != null) {
checkForStalePipeline(pipeline, errors);
}
if (errors.hasErrors()) {
String message = errors.getAllErrorsMessage();
throw new ValidationException(message, errors.getAllErrors());
}
}
Aggregations