Search in sources :

Example 6 with NotificationSet

use of com.iplanet.services.comm.share.NotificationSet in project OpenAM by OpenRock.

the class SMSJAXRPCObjectImpl method objectChanged.

// Implementation for SMSObjectListener
public synchronized void objectChanged(String name, int type) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());
    String cacheIndex = calendarToString(calendar);
    Set modDNs = (Set) cache.get(cacheIndex);
    if (modDNs == null) {
        modDNs = new HashSet();
        cache.put(cacheIndex, modDNs);
        // Maintain cacheIndex
        cacheIndices.addFirst(cacheIndex);
        if (cacheIndices.size() > cacheSize) {
            String index = (String) cacheIndices.removeLast();
            cache.remove(index);
        }
    }
    String modItem = null;
    switch(type) {
        case ADD:
            modItem = "ADD:" + name;
            break;
        case DELETE:
            modItem = "DEL:" + name;
            break;
        default:
            modItem = "MOD:" + name;
    }
    modDNs.add(modItem);
    // If notification URLs are present, send notifications
    synchronized (notificationURLs) {
        for (Map.Entry<String, URL> entry : notificationURLs.entrySet()) {
            String id = entry.getKey();
            URL url = entry.getValue();
            // Construct NotificationSet
            Notification notification = new Notification(modItem);
            NotificationSet ns = new NotificationSet(JAXRPCUtil.SMS_SERVICE);
            ns.addNotification(notification);
            try {
                PLLServer.send(url, ns);
                if (debug.messageEnabled()) {
                    debug.message("SMSJAXRPCObjectImpl:objectChanged sent notification to " + "URL: " + url + " Data: " + ns);
                }
            } catch (SendNotificationException ne) {
                if (debug.warningEnabled()) {
                    debug.warning("SMSJAXRPCObjectImpl:objectChanged failed sending " + "notification to: " + url + "\nRemoving " + "URL from notification list.", ne);
                }
                // Remove the URL from Notification List
                notificationURLs.remove(id);
            }
        }
    }
}
Also used : NotificationSet(com.iplanet.services.comm.share.NotificationSet) HashSet(java.util.HashSet) NotificationSet(com.iplanet.services.comm.share.NotificationSet) Set(java.util.Set) SendNotificationException(com.iplanet.services.comm.server.SendNotificationException) Calendar(java.util.Calendar) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) Date(java.util.Date) URL(java.net.URL) Notification(com.iplanet.services.comm.share.Notification) HashSet(java.util.HashSet)

Aggregations

Notification (com.iplanet.services.comm.share.Notification)6 NotificationSet (com.iplanet.services.comm.share.NotificationSet)6 SendNotificationException (com.iplanet.services.comm.server.SendNotificationException)5 URL (java.net.URL)5 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Set (java.util.Set)3 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)2 MalformedURLException (java.net.MalformedURLException)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)2 SSOException (com.iplanet.sso.SSOException)1 SSOToken (com.iplanet.sso.SSOToken)1 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)1 IdRepoException (com.sun.identity.idm.IdRepoException)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 ServletException (javax.servlet.ServletException)1