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);
}
}
}
}
Aggregations