use of com.iplanet.services.naming.ServerEntryNotFoundException in project OpenAM by OpenRock.
the class IdRepoJAXRPCObjectImpl method registerNotificationURL.
protected String registerNotificationURL(String url, Map<String, URL> notificationURLs) {
// Default value if there are any issues with the registration process.
String id = "0";
try {
// Check URL is not the local server
if (!isClientOnSameServer(url)) {
synchronized (notificationURLs) {
URL notificationUrl = new URL(url);
// Don't add the URL again if we already have it registered
boolean alreadyRegistered = false;
for (Map.Entry<String, URL> entry : notificationURLs.entrySet()) {
if (notificationUrl.toExternalForm().equals(entry.getValue().toExternalForm())) {
// This allows us to return the existing entry ID to support clients being able to
// de-register the correct entry.
id = entry.getKey();
alreadyRegistered = true;
if (idRepoDebug.messageEnabled()) {
idRepoDebug.message("IdRepoJAXRPCObjectImpl.registerNotificationURL() - URL " + url + " already registered, returning existing ID " + id);
}
break;
}
}
// If we didn't find the url in our list, add it
if (!alreadyRegistered) {
String serverID = "";
try {
serverID = WebtopNaming.getAMServerID();
} catch (ServerEntryNotFoundException e) {
if (idRepoDebug.messageEnabled()) {
idRepoDebug.message("IdRepoJAXRPCObjectImpl.registerNotificationURL - " + "had a problem getting our serverID ", e);
}
}
// Generate a unique value that includes the serverID to have a better chance of being unique
// in a cluster should a de-register request end up on the wrong server.
id = SMSUtils.getUniqueID() + "_" + serverID;
notificationURLs.put(id, notificationUrl);
if (idRepoDebug.messageEnabled()) {
idRepoDebug.message("IdRepoJAXRPCObjectImpl.registerNotificationURL - " + "registered notification URL: " + url + " with ID " + id);
}
}
}
} else {
// Cannot add this server for notifications
if (idRepoDebug.warningEnabled()) {
idRepoDebug.warning("IdRepoJAXRPCObjectImpl.registerNotificationURL " + "cannot add local server: " + url);
}
}
} catch (MalformedURLException e) {
if (idRepoDebug.warningEnabled()) {
idRepoDebug.warning("IdRepoJAXRPCObjectImpl." + "registerNotificationURL invalid URL: " + url, e);
}
}
return id;
}
Aggregations