Search in sources :

Example 6 with ServerEntryNotFoundException

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;
}
Also used : MalformedURLException(java.net.MalformedURLException) ServerEntryNotFoundException(com.iplanet.services.naming.ServerEntryNotFoundException) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) URL(java.net.URL)

Aggregations

ServerEntryNotFoundException (com.iplanet.services.naming.ServerEntryNotFoundException)6 MalformedURLException (java.net.MalformedURLException)4 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)3 URL (java.net.URL)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Cache (com.iplanet.am.util.Cache)1 SessionException (com.iplanet.dpro.session.SessionException)1 SSOException (com.iplanet.sso.SSOException)1 AuthException (com.sun.identity.authentication.service.AuthException)1 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)1 PolicyException (com.sun.identity.policy.PolicyException)1 SOAPClient (com.sun.identity.shared.jaxrpc.SOAPClient)1 SMSException (com.sun.identity.sm.SMSException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)1