Commits

Colin Chauvet committed ebe3f29

Limiting the number of past notifications that are displayed on the admin page

  • Participants
  • Parent commits 76c027a

Comments (0)

Files changed (1)

File src/main/java/com/example/plugins/tutorial/confluence/notification/resource/NotificationResource.java

 import com.atlassian.mywork.model.NotificationBuilder;
 import com.atlassian.mywork.service.LocalNotificationService;
 
+import com.google.common.collect.Iterables;
+
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.node.ObjectNode;
 
 @Produces (MediaType.APPLICATION_JSON)
 public class NotificationResource {
 
+    public static final int MAX_RESULT = 3;
     private final LocalNotificationService notificationService;
 
     public NotificationResource(final LocalNotificationService notificationService) {
     public Response findAllNotifications() throws Exception{
 
         final Iterable<Notification> notifications = notificationService.find("admin", "com.example.plugins.tutorial.confluence.notification");
-
-        return Response.ok(notifications).build();
+        return Response.ok(Iterables.limit(notifications, MAX_RESULT)).build();
     }