public void assignService(String realm) throws AMConsoleException {
  String[] params={realm,AMAdminConstants.DISCOVERY_SERVICE};
  try {
    AMIdentityRepository repo=new AMIdentityRepository(getUserSSOToken(),realm);
    AMIdentity realmIdentity=repo.getRealmIdentity();
    Set servicesFromIdRepo=realmIdentity.getAssignableServices();
    if (servicesFromIdRepo.contains(AMAdminConstants.DISCOVERY_SERVICE)) {
      realmIdentity.assignService(AMAdminConstants.DISCOVERY_SERVICE,Collections.EMPTY_MAP);
    }
 else {
      OrganizationConfigManager orgCfgMgr=new OrganizationConfigManager(getUserSSOToken(),realm);
      orgCfgMgr.assignService(AMAdminConstants.DISCOVERY_SERVICE,Collections.EMPTY_MAP);
    }
  }
 catch (  SSOException e) {
    String strError=getErrorString(e);
    String[] paramsEx={realm,AMAdminConstants.DISCOVERY_SERVICE,strError};
    logEvent("SSO_EXCEPTION_ASSIGN_SERVICE_TO_REALM",paramsEx);
    throw new AMConsoleException(strError);
  }
catch (  IdRepoException e) {
    String strError=getErrorString(e);
    String[] paramsEx={realm,AMAdminConstants.DISCOVERY_SERVICE,strError};
    logEvent("IDREPO_EXCEPTION_ASSIGN_SERVICE_TO_REALM",paramsEx);
    throw new AMConsoleException(strError);
  }
catch (  SMSException e) {
    String strError=getErrorString(e);
    String[] paramsEx={realm,AMAdminConstants.DISCOVERY_SERVICE,strError};
    logEvent("SMS_EXCEPTION_ASSIGN_SERVICE_TO_REALM",paramsEx);
    throw new AMConsoleException(strError);
  }
}

public void assignService ( String realm ) throws AMConsoleException { String [ ] params = { realm , AMAdminConstants . DISCOVERY_SERVICE } ; try { AMIdentityRepository repo = new AMIdentityRepository ( getUserSSOToken ( ) , realm ) ; AMIdentity realmIdentity = repo . getRealmIdentity ( ) ; Set servicesFromIdRepo = realmIdentity . getAssignableServices ( ) ; if ( servicesFromIdRepo . contains ( AMAdminConstants . DISCOVERY_SERVICE ) ) { realmIdentity . assignService ( AMAdminConstants . DISCOVERY_SERVICE , Collections . EMPTY_MAP ) ; } else { OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager ( getUserSSOToken ( ) , realm ) ; orgCfgMgr . assignService ( AMAdminConstants . DISCOVERY_SERVICE , Collections . EMPTY_MAP ) ; } } catch ( SSOException e ) { String strError = getErrorString ( e ) ; String [ ] paramsEx = { realm , AMAdminConstants . DISCOVERY_SERVICE , strError } ; logEvent ( "SSO_EXCEPTION_ASSIGN_SERVICE_TO_REALM" , paramsEx ) ; throw new AMConsoleException ( strError ) ; } catch ( IdRepoException e ) { String strError = getErrorString ( e ) ; String [ ] paramsEx = { realm , AMAdminConstants . DISCOVERY_SERVICE , strError } ; logEvent ( "IDREPO_EXCEPTION_ASSIGN_SERVICE_TO_REALM" , paramsEx ) ; throw new AMConsoleException ( strError ) ; } catch ( SMSException e ) { String strError = getErrorString ( e ) ; String [ ] paramsEx = { realm , AMAdminConstants . DISCOVERY_SERVICE , strError } ; logEvent ( "SMS_EXCEPTION_ASSIGN_SERVICE_TO_REALM" , paramsEx ) ; throw new AMConsoleException ( strError ) ; } }
assigns service to a realm .
