Search in sources :

Example 1 with Notification

use of com.netflix.spinnaker.front50.model.notification.Notification 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;
}
Also used : HierarchicalLevel(com.netflix.spinnaker.front50.model.notification.HierarchicalLevel) ArrayList(java.util.ArrayList) List(java.util.List) Notification(com.netflix.spinnaker.front50.model.notification.Notification) PostAuthorize(org.springframework.security.access.prepost.PostAuthorize)

Aggregations

HierarchicalLevel (com.netflix.spinnaker.front50.model.notification.HierarchicalLevel)1 Notification (com.netflix.spinnaker.front50.model.notification.Notification)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 PostAuthorize (org.springframework.security.access.prepost.PostAuthorize)1