/** * @param appAlert * @param targetUsers */ public static void addAlert(AlertEntry appAlert, List<User> targetUsers) { AlertEntry clone; if (appAlert != null && targetUsers != null && targetUsers.size() > 0) { for (User targetUser : targetUsers) { Vector<AlertEntry> userAlerts = alerts.get(targetUser.getUID()); if (userAlerts == null) { alerts.put(targetUser.getUID(), userAlerts = new Vector<AlertEntry>()); } // Get the clone so that each user will have separate copy of the alert clone = appAlert.getClone(); userAlerts.add(clone); Collections.sort( userAlerts, new Comparator<AlertEntry>() { public int compare(AlertEntry arg0, AlertEntry arg1) { return arg1.getTimeStamp().compareTo(arg0.getTimeStamp()); } }); SessionRendererHelper.render(SessionRendererHelper.getPortalSessionRendererId(targetUser)); } } }
/** @param user */ public static void removeAllAlerts(User user) { if (user != null) { List<AlertEntry> userAlerts = alerts.get(user.getUID()); if (userAlerts != null) { userAlerts.clear(); } SessionRendererHelper.render(SessionRendererHelper.getPortalSessionRendererId(user)); } }
/** * @param user * @return */ public static List<AlertEntry> getAlerts(User user) { if (user != null) { List<AlertEntry> userAlert = alerts.get(user.getUID()); if (userAlert == null) { userAlert = new Vector<AlertEntry>(); } return userAlert; } else { return new ArrayList<AlertEntry>(); } }
/** * @param alert * @param user * @return */ public static boolean removeAlert(AlertEntry alert, User user) { if (user != null) { List<AlertEntry> userAlerts = alerts.get(user.getUID()); if (userAlerts != null) { boolean ret = userAlerts.remove(alert); SessionRendererHelper.render(SessionRendererHelper.getPortalSessionRendererId(user)); return ret; } else { return true; } } return false; }