limit = UtilMethods.isSet(range)?Long.parseLong(range.split("=")[1].split("-")[1]):limit;
limit += 1;
JSONArray notificationsJSON = new JSONArray();
NotificationAPI notificationAPI = APILocator.getNotificationAPI();
// Let's get the total count
Long total = notificationAPI.getNotificationsCount();
// Let's mark the new notifications as read
notificationAPI.markNotificationsAsRead(user.getUserId());
List<Notification> notifications = allUsers?notificationAPI.getNotifications(offset, limit):notificationAPI.getNotifications(user.getUserId(), offset, limit);
for (Notification n : notifications) {
JSONObject notificationJSON = new JSONObject();
notificationJSON.put("id", n.getId());
notificationJSON.put("message", n.getMessage());