public void handleRequest(RequestContext rc) throws CLIException {
  super.handleRequest(rc);
  ldapLogin();
  SSOToken adminSSOToken=getAdminSSOToken();
  IOutput outputWriter=getOutputWriter();
  String realm=getStringOptionValue(IArgument.REALM_NAME);
  String patternType=getStringOptionValue(IArgument.AGENT_TYPE);
  String filter=getStringOptionValue(IArgument.FILTER);
  if (patternType == null) {
    patternType="";
  }
  if ((filter == null) || (filter.length() == 0)) {
    filter="*";
  }
  String[] params={realm,patternType,filter};
  writeLog(LogWriter.LOG_ACCESS,Level.INFO,"ATTEMPT_LIST_AGENT_GROUPS",params);
  try {
    AMIdentityRepository amir=new AMIdentityRepository(adminSSOToken,realm);
    IdSearchResults isr=amir.searchIdentities(IdType.AGENTGROUP,filter,new IdSearchControl());
    Set results=isr.getSearchResults();
    if ((results != null) && !results.isEmpty()) {
      for (Iterator i=results.iterator(); i.hasNext(); ) {
        AMIdentity amid=(AMIdentity)i.next();
        if (!matchType(amid,patternType)) {
          i.remove();
        }
      }
    }
    if ((results != null) && !results.isEmpty()) {
      for (Iterator i=results.iterator(); i.hasNext(); ) {
        AMIdentity amid=(AMIdentity)i.next();
        Object[] args={amid.getName(),amid.getUniversalId()};
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("format-search-agent-group-results"),args));
      }
    }
 else {
      outputWriter.printlnMessage(getResourceString("search-agent-group-no-entries"));
    }
    writeLog(LogWriter.LOG_ACCESS,Level.INFO,"SUCCEED_LIST_AGENT_GROUPS",params);
  }
 catch (  IdRepoException e) {
    String[] args={realm,patternType,filter,e.getMessage()};
    debugError("ListAgentGroups.handleRequest",e);
    writeLog(LogWriter.LOG_ERROR,Level.INFO,"FAILED_LIST_AGENT_GROUPS",args);
    throw new CLIException(e,ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
  }
catch (  SSOException e) {
    String[] args={realm,patternType,filter,e.getMessage()};
    debugError("ListAgentGroups.handleRequest",e);
    writeLog(LogWriter.LOG_ERROR,Level.INFO,"FAILED_LIST_AGENT_GROUPS",args);
    throw new CLIException(e,ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
  }
}

public void handleRequest ( RequestContext rc ) throws CLIException { super . handleRequest ( rc ) ; ldapLogin ( ) ; SSOToken adminSSOToken = getAdminSSOToken ( ) ; IOutput outputWriter = getOutputWriter ( ) ; String realm = getStringOptionValue ( IArgument . REALM_NAME ) ; String patternType = getStringOptionValue ( IArgument . AGENT_TYPE ) ; String filter = getStringOptionValue ( IArgument . FILTER ) ; if ( patternType == null ) { patternType = "" ; } if ( ( filter == null ) || ( filter . length ( ) == 0 ) ) { filter = "*" ; } String [ ] params = { realm , patternType , filter } ; writeLog ( LogWriter . LOG_ACCESS , Level . INFO , "ATTEMPT_LIST_AGENT_GROUPS" , params ) ; try { AMIdentityRepository amir = new AMIdentityRepository ( adminSSOToken , realm ) ; IdSearchResults isr = amir . searchIdentities ( IdType . AGENTGROUP , filter , new IdSearchControl ( ) ) ; Set results = isr . getSearchResults ( ) ; if ( ( results != null ) && ! results . isEmpty ( ) ) { for ( Iterator i = results . iterator ( ) ; i . hasNext ( ) ; ) { AMIdentity amid = ( AMIdentity ) i . next ( ) ; if ( ! matchType ( amid , patternType ) ) { i . remove ( ) ; } } } if ( ( results != null ) && ! results . isEmpty ( ) ) { for ( Iterator i = results . iterator ( ) ; i . hasNext ( ) ; ) { AMIdentity amid = ( AMIdentity ) i . next ( ) ; Object [ ] args = { amid . getName ( ) , amid . getUniversalId ( ) } ; outputWriter . printlnMessage ( MessageFormat . format ( getResourceString ( "format-search-agent-group-results" ) , args ) ) ; } } else { outputWriter . printlnMessage ( getResourceString ( "search-agent-group-no-entries" ) ) ; } writeLog ( LogWriter . LOG_ACCESS , Level . INFO , "SUCCEED_LIST_AGENT_GROUPS" , params ) ; } catch ( IdRepoException e ) { String [ ] args = { realm , patternType , filter , e . getMessage ( ) } ; debugError ( "ListAgentGroups.handleRequest" , e ) ; writeLog ( LogWriter . LOG_ERROR , Level . INFO , "FAILED_LIST_AGENT_GROUPS" , args ) ; throw new CLIException ( e , ExitCodes . REQUEST_CANNOT_BE_PROCESSED ) ; } catch ( SSOException e ) { String [ ] args = { realm , patternType , filter , e . getMessage ( ) } ; debugError ( "ListAgentGroups.handleRequest" , e ) ; writeLog ( LogWriter . LOG_ERROR , Level . INFO , "FAILED_LIST_AGENT_GROUPS" , args ) ; throw new CLIException ( e , ExitCodes . REQUEST_CANNOT_BE_PROCESSED ) ; } }
services a commandline request .
