public void handleRequest(RequestContext rc) throws CLIException {
  super.handleRequest(rc);
  ldapLogin();
  SSOToken adminSSOToken=getAdminSSOToken();
  IOutput outputWriter=getOutputWriter();
  String realm=getStringOptionValue(IArgument.REALM_NAME);
  String agentGroupName=getStringOptionValue(IArgument.AGENT_GROUP_NAME);
  List agentNames=rc.getOption(IArgument.AGENT_NAMES);
  String[] params={realm,agentGroupName,""};
  String agentName="";
  try {
    AMIdentity agentGroup=new AMIdentity(adminSSOToken,agentGroupName,IdType.AGENTGROUP,realm,null);
    if (!agentGroup.isExists()) {
      Object[] p={agentGroupName};
      throw new CLIException(MessageFormat.format(getResourceString("remove-agent-to-group-agent-invalid-group"),p),ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
    validateAgents(realm,adminSSOToken,agentGroup,agentNames);
    for (Iterator i=agentNames.iterator(); i.hasNext(); ) {
      agentName=(String)i.next();
      params[2]=agentName;
      writeLog(LogWriter.LOG_ACCESS,Level.INFO,"ATTEMPT_REMOVE_AGENT_FROM_GROUP",params);
      AMIdentity amid=new AMIdentity(adminSSOToken,agentName,IdType.AGENTONLY,realm,null);
      AgentConfiguration.removeAgentGroup(amid,agentGroup);
      writeLog(LogWriter.LOG_ACCESS,Level.INFO,"SUCCEED_REMOVE_AGENT_FROM_GROUP",params);
    }
    if (agentNames.size() > 1) {
      outputWriter.printlnMessage(getResourceString("remove-agent-to-group-succeeded-pural"));
    }
 else {
      outputWriter.printlnMessage(getResourceString("remove-agent-to-group-succeeded"));
    }
  }
 catch (  IdRepoException e) {
    String[] args={realm,agentGroupName,agentName,e.getMessage()};
    debugError("RemoveAgentsFromGroup.handleRequest",e);
    writeLog(LogWriter.LOG_ERROR,Level.INFO,"FAILED_REMOVE_AGENT_FROM_GROUP",args);
    throw new CLIException(e,ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
  }
catch (  SSOException e) {
    String[] args={realm,agentGroupName,agentName,e.getMessage()};
    debugError("RemoveAgentsFromGroup.handleRequest",e);
    writeLog(LogWriter.LOG_ERROR,Level.INFO,"FAILED_REMOVE_AGENT_FROM_GROUP",args);
    throw new CLIException(e,ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
  }
catch (  SMSException e) {
    String[] args={realm,agentGroupName,agentName,e.getMessage()};
    debugError("RemoveAgentsFromGroup.handleRequest",e);
    writeLog(LogWriter.LOG_ERROR,Level.INFO,"FAILED_REMOVE_AGENT_FROM_GROUP",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 agentGroupName = getStringOptionValue ( IArgument . AGENT_GROUP_NAME ) ; List agentNames = rc . getOption ( IArgument . AGENT_NAMES ) ; String [ ] params = { realm , agentGroupName , "" } ; String agentName = "" ; try { AMIdentity agentGroup = new AMIdentity ( adminSSOToken , agentGroupName , IdType . AGENTGROUP , realm , null ) ; if ( ! agentGroup . isExists ( ) ) { Object [ ] p = { agentGroupName } ; throw new CLIException ( MessageFormat . format ( getResourceString ( "remove-agent-to-group-agent-invalid-group" ) , p ) , ExitCodes . REQUEST_CANNOT_BE_PROCESSED ) ; } validateAgents ( realm , adminSSOToken , agentGroup , agentNames ) ; for ( Iterator i = agentNames . iterator ( ) ; i . hasNext ( ) ; ) { agentName = ( String ) i . next ( ) ; params [ 2 ] = agentName ; writeLog ( LogWriter . LOG_ACCESS , Level . INFO , "ATTEMPT_REMOVE_AGENT_FROM_GROUP" , params ) ; AMIdentity amid = new AMIdentity ( adminSSOToken , agentName , IdType . AGENTONLY , realm , null ) ; AgentConfiguration . removeAgentGroup ( amid , agentGroup ) ; writeLog ( LogWriter . LOG_ACCESS , Level . INFO , "SUCCEED_REMOVE_AGENT_FROM_GROUP" , params ) ; } if ( agentNames . size ( ) > 1 ) { outputWriter . printlnMessage ( getResourceString ( "remove-agent-to-group-succeeded-pural" ) ) ; } else { outputWriter . printlnMessage ( getResourceString ( "remove-agent-to-group-succeeded" ) ) ; } } catch ( IdRepoException e ) { String [ ] args = { realm , agentGroupName , agentName , e . getMessage ( ) } ; debugError ( "RemoveAgentsFromGroup.handleRequest" , e ) ; writeLog ( LogWriter . LOG_ERROR , Level . INFO , "FAILED_REMOVE_AGENT_FROM_GROUP" , args ) ; throw new CLIException ( e , ExitCodes . REQUEST_CANNOT_BE_PROCESSED ) ; } catch ( SSOException e ) { String [ ] args = { realm , agentGroupName , agentName , e . getMessage ( ) } ; debugError ( "RemoveAgentsFromGroup.handleRequest" , e ) ; writeLog ( LogWriter . LOG_ERROR , Level . INFO , "FAILED_REMOVE_AGENT_FROM_GROUP" , args ) ; throw new CLIException ( e , ExitCodes . REQUEST_CANNOT_BE_PROCESSED ) ; } catch ( SMSException e ) { String [ ] args = { realm , agentGroupName , agentName , e . getMessage ( ) } ; debugError ( "RemoveAgentsFromGroup.handleRequest" , e ) ; writeLog ( LogWriter . LOG_ERROR , Level . INFO , "FAILED_REMOVE_AGENT_FROM_GROUP" , args ) ; throw new CLIException ( e , ExitCodes . REQUEST_CANNOT_BE_PROCESSED ) ; } }
services a commandline request .
