Search in sources :

Example 1 with SystemMessage

use of org.graylog2.system.activities.SystemMessage in project graylog2-server by Graylog2.

the class MessagesResource method all.

@GET
@Timed
@ApiOperation(value = "Get internal Graylog system messages")
@RequiresPermissions(RestPermissions.SYSTEMMESSAGES_READ)
@Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> all(@ApiParam(name = "page", value = "Page") @QueryParam("page") int page) {
    final List<Map<String, Object>> messages = Lists.newArrayList();
    for (SystemMessage sm : systemMessageService.all(page(page))) {
        Map<String, Object> message = Maps.newHashMapWithExpectedSize(4);
        message.put("caller", sm.getCaller());
        message.put("content", sm.getContent());
        message.put("timestamp", Tools.getISO8601String(sm.getTimestamp()));
        message.put("node_id", sm.getNodeId());
        messages.add(message);
    }
    return ImmutableMap.of("messages", messages, "total", systemMessageService.totalCount());
}
Also used : SystemMessage(org.graylog2.system.activities.SystemMessage) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Map (java.util.Map)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)1 SystemMessage (org.graylog2.system.activities.SystemMessage)1