Commits

Colin Chauvet committed ecbc599

Fixes from code review

Comments (0)

Files changed (2)

         </plugins>
     </build>
     <properties>
-        <confluence.version>4.3-rc3</confluence.version>
-        <confluence.data.version>4.3-rc3</confluence.data.version>
+        <confluence.version>4.3</confluence.version>
+        <confluence.data.version>4.3</confluence.data.version>
         <amps.version>3.11</amps.version>
     </properties>
 </project>

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

  * A resource of creating and listing notifications
  */
 @Path ("/")
-@Consumes (MediaType.APPLICATION_JSON)
-@Produces (MediaType.APPLICATION_JSON)
+@Consumes ((MediaType.APPLICATION_JSON)) // prevents XSRF !
 public class NotificationResource
 {
 
 }
 
 @GET
+@Produces (MediaType.APPLICATION_JSON)
 public Response findAllNotifications() throws Exception{
     if (isAdmin()) {
         // find all the notifications received by the logged in user
         final Iterable<Notification> notifications = notificationService.findAll(AuthenticatedUserThreadLocal.getUser().getName());
-        Iterables.filter(notifications, new Predicate<Notification>() {
+        Iterables.filter(notifications, new Predicate<Notification>()
+        {
             @Override
-            public boolean apply(@Nullable final Notification notification){
+            public boolean apply(@Nullable final Notification notification)
+            {
                 // we are only interested in the notification send by our plugin
                 return PLUGIN_KEY.equals(notification.getApplication());
             }
         throws ExecutionException, InterruptedException
 {
     Pager<String> memberNames = userAccessor.getMemberNames(new DefaultGroup(UserAccessor.GROUP_CONFLUENCE_USERS));
-    while (memberNames.iterator().hasNext())
+    for (String memberName : memberNames)
     {
-        sendNotification(memberNames.iterator().next(), title, message);
+        sendNotification(memberName, title, message);
     }
 }
 
             .title("Message from your beloved administrator")
             .itemTitle(title)
             .description(message)
-            .globalId("com.example.plugins.tutorial.confluence.notification") // a key to aggregate notifications
+            .groupingId("com.example.plugins.tutorial.confluence.notification") // a key to aggregate notifications
             .createNotification()).get();
     return notification;
 }