use of com.iplanet.services.comm.share.Notification in project OpenAM by OpenRock.
the class DirectoryManagerImpl method processEntryChanged.
// Implementation to process entry changed events
protected static void processEntryChanged(String method, String name, int type, Set attrNames) {
debug.message("DirectoryManagerImpl.processEntryChaged method " + "processing");
initializeCacheSize();
// Construct the XML document for the event change
StringBuilder sb = new StringBuilder(100);
sb.append("<EventNotification><AttributeValuePair>").append("<Attribute name=\"method\" /><Value>").append(method).append("</Value></AttributeValuePair>").append("<AttributeValuePair><Attribute name=\"entityName\" />").append("<Value>").append(name).append("</Value></AttributeValuePair>");
if (method.equalsIgnoreCase("objectChanged") || method.equalsIgnoreCase("objectsChanged")) {
sb.append("<AttributeValuePair><Attribute name=\"eventType\" />").append("<Value>").append(type).append("</Value></AttributeValuePair>");
if (method.equalsIgnoreCase("objectsChanged")) {
sb.append("<AttributeValuePair><Attribute ").append("name=\"attrNames\"/>");
for (Iterator items = attrNames.iterator(); items.hasNext(); ) {
String attr = (String) items.next();
sb.append("<Value>").append(attr).append("</Value>");
}
sb.append("</AttributeValuePair>");
}
}
sb.append("</EventNotification>");
if (cacheSize > 0) {
Set<String> modDNs = getCachedValues(cache);
// Add to cache
modDNs.add(sb.toString());
if (debug.messageEnabled()) {
debug.message("DirectoryManagerImpl::processing entry change: " + sb.toString());
}
}
if (debug.messageEnabled()) {
debug.message("DirectoryManagerImpl = notificationURLS" + notificationURLs.values());
}
// If notification URLs are present, send notifications
NotificationSet ns = null;
synchronized (notificationURLs) {
for (Map.Entry<String, URL> entry : notificationURLs.entrySet()) {
String id = entry.getKey();
URL url = entry.getValue();
// Construct NotificationSet
if (ns == null) {
Notification notification = new Notification(sb.toString());
ns = new NotificationSet(com.iplanet.am.sdk.remote.RemoteServicesImpl.SDK_SERVICE);
ns.addNotification(notification);
}
try {
PLLServer.send(url, ns);
if (debug.messageEnabled()) {
debug.message("DirectorManagerImpl:sentNotification " + "URL: " + url + " Data: " + ns);
}
} catch (SendNotificationException ne) {
if (debug.warningEnabled()) {
debug.warning("DirectoryManagerImpl: failed sending " + "notification to: " + url + "\nRemoving " + "URL from notification list.", ne);
}
// Remove the URL from Notification List
notificationURLs.remove(id);
}
}
}
}
use of com.iplanet.services.comm.share.Notification in project OpenAM by OpenRock.
the class IdRepoJAXRPCObjectImpl method processEntryChanged_idrepo.
// Implementation to process entry changed events
protected static void processEntryChanged_idrepo(String method, String name, int type, Set attrNames) {
if (idRepoDebug.messageEnabled()) {
idRepoDebug.message("IdRepoJAXRPCObjectImpl.processEntryChaged " + "method processing method: " + method + " name: " + name + " type: " + type + " attrName: " + attrNames);
}
initializeCacheSize();
// Return if cache size is 0 or there are no remote clients
if (cacheSize == 0 && idRepoNotificationURLs.isEmpty()) {
if (idRepoDebug.messageEnabled()) {
idRepoDebug.message("IdRepoJAXRPCObjectImpl." + "processEntryChaged No registered notification URLs: " + idRepoNotificationURLs + " and cache size is: " + cacheSize);
}
return;
}
// Construct the XML document for the event change
StringBuilder sb = new StringBuilder(100);
sb.append("<EventNotification><AttributeValuePair>").append("<Attribute name=\"method\" /><Value>").append(method).append("</Value></AttributeValuePair>").append("<AttributeValuePair><Attribute name=\"entityName\" />").append("<Value>").append(XMLUtils.escapeSpecialCharacters(name)).append("</Value></AttributeValuePair>");
if (method.equalsIgnoreCase("objectChanged") || method.equalsIgnoreCase("objectsChanged")) {
sb.append("<AttributeValuePair><Attribute name=\"eventType\" />").append("<Value>").append(type).append("</Value></AttributeValuePair>");
if (method.equalsIgnoreCase("objectsChanged")) {
sb.append("<AttributeValuePair><Attribute ").append("name=\"attrNames\"/>");
for (Iterator items = attrNames.iterator(); items.hasNext(); ) {
String attr = (String) items.next();
sb.append("<Value>").append(attr).append("</Value>");
}
sb.append("</AttributeValuePair>");
}
}
sb.append("</EventNotification>");
// Update cache for polling by remote clients
if (cacheSize > 0) {
Set<String> modDNs = getCachedValues(idrepoCache);
// Add to cache
modDNs.add(sb.toString());
if (idRepoDebug.messageEnabled()) {
idRepoDebug.message("IdRepoJAXRPCObjectImpl.processing " + "entry change:" + sb.toString());
}
}
// If notification URLs are present, send notifications
if (idRepoDebug.messageEnabled()) {
idRepoDebug.message("IdRepoJAXRPCObjectImpl.processEntryChaged =" + " notificationURLS " + idRepoNotificationURLs.values());
}
NotificationSet ns = null;
synchronized (idRepoNotificationURLs) {
for (Map.Entry<String, URL> entry : idRepoNotificationURLs.entrySet()) {
String id = entry.getKey();
URL url = entry.getValue();
// Construct NotificationSet
if (ns == null) {
Notification notification = new Notification(sb.toString());
ns = new NotificationSet(IDREPO_SERVICE);
ns.addNotification(notification);
}
try {
PLLServer.send(url, ns);
if (idRepoDebug.messageEnabled()) {
idRepoDebug.message("IdRepoJAXRPCObjectImpl:" + "sentNotification URL: " + url + " Data: " + ns);
}
} catch (SendNotificationException ne) {
if (idRepoDebug.warningEnabled()) {
idRepoDebug.warning("IdRepoJAXRPCObjectImpl: failed " + "sending notification to: " + url + "\nRemoving " + "URL from notification list.", ne);
}
// Remove the URL from Notification List
idRepoNotificationURLs.remove(id);
}
}
}
}
Aggregations