boolean addRESTRemotePolicyListener(SSOToken appToken,String serviceName,String notificationURL,boolean reRegister){
  boolean status=false;
  if (debug.messageEnabled()) {
    debug.message("ResourceResultCache.addRESTRemotePolicyListener():" + "serviceName=" + serviceName + ":notificationURL="+ notificationURL);
  }
  if (remotePolicyListeners.contains(serviceName) && !reRegister) {
    if (debug.messageEnabled()) {
      debug.message("ResourceResultCache.addRESTRemotePolicyListener():" + "serviceName=" + serviceName + ":notificationURL="+ notificationURL+ ":is already registered");
    }
    return status;
  }
  if (appToken != null) {
    try {
      String policyServiceListenerURL=null;
      policyServiceListenerURL=getRESTPolicyServiceListenerURL(appToken);
      String rootURL=getRootURL(notificationURL);
      if (debug.messageEnabled()) {
        debug.message("ResourceResultCache." + "addRESTRemotePolicyListener():" + "serviceName=" + serviceName + ":notificationURL="+ notificationURL+ ":rootURL="+ rootURL+ ":policyServiceListenerURL="+ policyServiceListenerURL);
      }
      Set<String> resourceNames=new HashSet<String>();
      resourceNames.add(rootURL);
      String queryString=buildRegisterListenerQueryString(appToken,serviceName,resourceNames);
      queryString+="&url=" + URLEncoder.encode(notificationURL,"UTF-8");
      String resourceContent=postForm(appToken,policyServiceListenerURL,queryString);
      if (debug.messageEnabled()) {
        debug.message("ResourceResultCache." + "addRESTRemotePolicyListener():" + ":resourceContent="+ resourceContent);
      }
      status=true;
      remotePolicyListeners.add(serviceName);
    }
 catch (    UnsupportedEncodingException e) {
      debug.error("ResourceResultCache.addRESTRemotePolicyListener():" + "Can not add policy listner",e);
    }
catch (    SSOException se) {
      debug.error("ResourceResultCache.addRESTRemotePolicyListener():" + "Can not add policy listner",se);
    }
catch (    PolicyException pe) {
      debug.error("ResourceResultCache.addRESTRemotePolicyListener():" + "Can not add policy listner",pe);
    }
  }
 else {
    if (debug.messageEnabled()) {
      debug.message("ResourceResultCache.addRESTRemotePolicyListener():" + "not adding listener, app sso token is null");
    }
  }
  return status;
}

boolean addRESTRemotePolicyListener ( SSOToken appToken , String serviceName , String notificationURL , boolean reRegister ) { boolean status = false ; if ( debug . messageEnabled ( ) ) { debug . message ( "ResourceResultCache.addRESTRemotePolicyListener():" + "serviceName=" + serviceName + ":notificationURL=" + notificationURL ) ; } if ( remotePolicyListeners . contains ( serviceName ) && ! reRegister ) { if ( debug . messageEnabled ( ) ) { debug . message ( "ResourceResultCache.addRESTRemotePolicyListener():" + "serviceName=" + serviceName + ":notificationURL=" + notificationURL + ":is already registered" ) ; } return status ; } if ( appToken != null ) { try { String policyServiceListenerURL = null ; policyServiceListenerURL = getRESTPolicyServiceListenerURL ( appToken ) ; String rootURL = getRootURL ( notificationURL ) ; if ( debug . messageEnabled ( ) ) { debug . message ( "ResourceResultCache." + "addRESTRemotePolicyListener():" + "serviceName=" + serviceName + ":notificationURL=" + notificationURL + ":rootURL=" + rootURL + ":policyServiceListenerURL=" + policyServiceListenerURL ) ; } Set < String > resourceNames = new HashSet < String > ( ) ; resourceNames . add ( rootURL ) ; String queryString = buildRegisterListenerQueryString ( appToken , serviceName , resourceNames ) ; queryString += "&url=" + URLEncoder . encode ( notificationURL , "UTF-8" ) ; String resourceContent = postForm ( appToken , policyServiceListenerURL , queryString ) ; if ( debug . messageEnabled ( ) ) { debug . message ( "ResourceResultCache." + "addRESTRemotePolicyListener():" + ":resourceContent=" + resourceContent ) ; } status = true ; remotePolicyListeners . add ( serviceName ) ; } catch ( UnsupportedEncodingException e ) { debug . error ( "ResourceResultCache.addRESTRemotePolicyListener():" + "Can not add policy listner" , e ) ; } catch ( SSOException se ) { debug . error ( "ResourceResultCache.addRESTRemotePolicyListener():" + "Can not add policy listner" , se ) ; } catch ( PolicyException pe ) { debug . error ( "ResourceResultCache.addRESTRemotePolicyListener():" + "Can not add policy listner" , pe ) ; } } else { if ( debug . messageEnabled ( ) ) { debug . message ( "ResourceResultCache.addRESTRemotePolicyListener():" + "not adding listener, app sso token is null" ) ; } } return status ; }
registers a rest listener with policy service to recieve notifications on policy changes
