Search in sources :

Example 1 with NotificationFilter

use of de.codecentric.boot.admin.notify.filter.NotificationFilter in project spring-boot-admin by codecentric.

the class NotificationFilterController method addFilter.

@RequestMapping(method = { RequestMethod.POST }, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public ResponseEntity<?> addFilter(@RequestParam(name = "id", required = false) String id, @RequestParam(name = "name", required = false) String name, @RequestParam(name = "ttl", required = false, defaultValue = "-1") long ttl) {
    if (hasText(id) || hasText(name)) {
        NotificationFilter filter = createFilter(id, name, ttl);
        String filterId = filteringNotifier.addFilter(filter);
        return ResponseEntity.ok(Collections.singletonMap(filterId, filter));
    } else {
        return ResponseEntity.badRequest().body("Either 'id' or 'name' must be set");
    }
}
Also used : NotificationFilter(de.codecentric.boot.admin.notify.filter.NotificationFilter) ApplicationIdNotificationFilter(de.codecentric.boot.admin.notify.filter.ApplicationIdNotificationFilter) ApplicationNameNotificationFilter(de.codecentric.boot.admin.notify.filter.ApplicationNameNotificationFilter) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with NotificationFilter

use of de.codecentric.boot.admin.notify.filter.NotificationFilter in project spring-boot-admin by codecentric.

the class NotificationFilterController method createFilter.

private NotificationFilter createFilter(String id, String name, long ttl) {
    long expiry = ttl > 0L ? System.currentTimeMillis() + ttl : ttl;
    NotificationFilter filter = hasText(id) ? new ApplicationIdNotificationFilter(id, expiry) : new ApplicationNameNotificationFilter(name, expiry);
    return filter;
}
Also used : ApplicationNameNotificationFilter(de.codecentric.boot.admin.notify.filter.ApplicationNameNotificationFilter) ApplicationIdNotificationFilter(de.codecentric.boot.admin.notify.filter.ApplicationIdNotificationFilter) NotificationFilter(de.codecentric.boot.admin.notify.filter.NotificationFilter) ApplicationIdNotificationFilter(de.codecentric.boot.admin.notify.filter.ApplicationIdNotificationFilter) ApplicationNameNotificationFilter(de.codecentric.boot.admin.notify.filter.ApplicationNameNotificationFilter)

Aggregations

ApplicationIdNotificationFilter (de.codecentric.boot.admin.notify.filter.ApplicationIdNotificationFilter)2 ApplicationNameNotificationFilter (de.codecentric.boot.admin.notify.filter.ApplicationNameNotificationFilter)2 NotificationFilter (de.codecentric.boot.admin.notify.filter.NotificationFilter)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1