mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

lutoff
01.40.2007 7fa3260d1b3d3902f71f98392b1f8cf0483bc941
Use DsframeworkReturnCode enum in a more 'classical' way
10 files modified
287 ■■■■ changed files
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliAds.java 19 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliGlobalAdmin.java 28 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliMain.java 24 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliParser.java 20 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliReturnCode.java 57 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java 28 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServerGroup.java 75 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliSubCommandGroup.java 3 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/CliTest.java 5 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/DsframeworkTestCase.java 28 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliAds.java
@@ -41,12 +41,13 @@
import org.opends.admin.ads.ADSContext;
import org.opends.admin.ads.ADSContextException;
import org.opends.admin.ads.ADSContextHelper;
import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.ReturnCode;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.BooleanArgument;
import org.opends.server.util.args.StringArgument;
import org.opends.server.util.args.SubCommand;
import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
/**
 * This class is handling server group CLI.
 */
@@ -215,14 +216,14 @@
  /**
   * {@inheritDoc}
   */
  public ReturnCode performSubCommand(SubCommand subCmd, OutputStream outStream,
      OutputStream errStream)
  public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
      OutputStream outStream, OutputStream errStream)
      throws ADSContextException, ArgumentException
  {
    ADSContext adsCtx = null ;
    InitialLdapContext ctx = null ;
    ReturnCode returnCode = ReturnCode.ERROR_UNEXPECTED;
    DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED;
    try
    {
@@ -234,11 +235,11 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        adsCtx.createAdminData(backendName);
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      else if (subCmd.getName().equals(deleteAdsSubCmd.getName()))
      {
@@ -247,18 +248,18 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        helper
            .removeAdministrationSuffix(adsCtx.getDirContext(), backendName);
        returnCode =  ReturnCode.SUCCESSFUL;
        returnCode =  SUCCESSFUL;
      }
      else
      {
        // Should never occurs: If we are here, it means that the code to
        // handle to subcommand is not yet written.
        returnCode = ReturnCode.ERROR_UNEXPECTED;
        returnCode = ERROR_UNEXPECTED;
      }
    }
    catch (ADSContextException e)
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliGlobalAdmin.java
@@ -48,7 +48,6 @@
import org.opends.admin.ads.ADSContextException;
import org.opends.admin.ads.ADSContext.AdministratorProperty;
import org.opends.admin.ads.ADSContextException.ErrorType;
import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.ReturnCode;
import org.opends.server.tools.dsconfig.ArgumentExceptionFactory;
import org.opends.server.util.args.Argument;
import org.opends.server.util.args.ArgumentException;
@@ -58,6 +57,7 @@
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TextTablePrinter;
import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
/**
 * This class is handling user Admin CLI.
 */
@@ -414,14 +414,14 @@
  /**
   * {@inheritDoc}
   */
  public ReturnCode performSubCommand(SubCommand subCmd,
  public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
      OutputStream outStream, OutputStream errStream)
      throws ADSContextException, ArgumentException
  {
    ADSContext adsCtx = null;
    InitialLdapContext ctx = null;
    ReturnCode returnCode = ReturnCode.ERROR_UNEXPECTED;
    DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED;
    try
    {
@@ -438,12 +438,12 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        adsCtx.createAdministrator(map);
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
@@ -459,12 +459,12 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        adsCtx.deleteAdministrator(map);
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
@@ -475,7 +475,7 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        Set<Map<AdministratorProperty, Object>> adminUserList = adsCtx
@@ -488,7 +488,7 @@
          out.println(AdministratorProperty.UID.getAttributeName() + ": "
              + user.get(AdministratorProperty.UID));
        }
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
@@ -499,7 +499,7 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        Set<Map<AdministratorProperty, Object>> adsAdminUserList = adsCtx
@@ -529,7 +529,7 @@
          }
          out.println();
        }
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
@@ -551,11 +551,11 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        adsCtx.updateAdministrator(map, newServerId);
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
@@ -605,7 +605,7 @@
        }
        TextTablePrinter printer = new TextTablePrinter(outStream);
        table.print(printer);
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      // -----------------------
      // ERROR
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliMain.java
@@ -177,7 +177,7 @@
      String message = getMessage(msgID, ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return ReturnCode.CANNOT_INITIALIZE_ARGS.getReturnCode();
      return CANNOT_INITIALIZE_ARGS.getReturnCode();
    }
    // Parse the command-line arguments provided to this program.
@@ -192,13 +192,13 @@
      err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(argParser.getUsage());
      return ReturnCode.ERROR_PARSING_ARGS.getReturnCode();
      return ERROR_PARSING_ARGS.getReturnCode();
    }
    // If we should just display usage information, then print it and exit.
    if (argParser.usageOrVersionDisplayed())
    {
      return ReturnCode.SUCCESSFUL.getReturnCode();
      return SUCCESSFUL.getReturnCode();
    }
    if (argParser.getSubCommand() == null)
@@ -209,19 +209,19 @@
      err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println();
      err.println(argParser.getHelpUsageReference());
      return ReturnCode.ERROR_PARSING_ARGS.getReturnCode();
      return ERROR_PARSING_ARGS.getReturnCode();
    }
    // Validate args
    int ret = argParser.validateGlobalOption(err);
    if (ret != ReturnCode.SUCCESSFUL_NOP.getReturnCode())
    if (ret != SUCCESSFUL_NOP.getReturnCode())
    {
      return ret;
    }
    // Check if we need a connection
    ReturnCode returnCode = ReturnCode.SUCCESSFUL;
    DsFrameworkCliReturnCode returnCode = SUCCESSFUL;
    // Should we initialize the server in client mode?
@@ -238,12 +238,12 @@
      catch (InitializationException e)
      {
        err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
        return ReturnCode.ERROR_UNEXPECTED.getReturnCode();
        return ERROR_UNEXPECTED.getReturnCode();
      }
      catch (IllegalStateException e)
      {
        err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
        return ReturnCode.ERROR_UNEXPECTED.getReturnCode();
        return ERROR_UNEXPECTED.getReturnCode();
      }
    }
@@ -260,7 +260,7 @@
          .getError());
      if (returnCode == null)
      {
        returnCode = ReturnCode.ERROR_UNEXPECTED;
        returnCode = ERROR_UNEXPECTED;
      }
    }
    catch (ArgumentException ae)
@@ -269,14 +269,14 @@
      String message = getMessage(msgID, ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return ReturnCode.CANNOT_INITIALIZE_ARGS.getReturnCode();
      return CANNOT_INITIALIZE_ARGS.getReturnCode();
    }
    int msgID = returnCode.getMessageId();
    String message = "" ;
    if ( (returnCode == ReturnCode.SUCCESSFUL)
    if ( (returnCode == SUCCESSFUL)
         ||
         (returnCode == ReturnCode.SUCCESSFUL_NOP))
         (returnCode == SUCCESSFUL_NOP))
    {
      if (argParser.isVerbose())
      {
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliParser.java
@@ -58,7 +58,6 @@
import org.opends.admin.ads.util.ApplicationKeyManager;
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.ReturnCode;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.util.PasswordReader;
@@ -71,6 +70,7 @@
import org.opends.server.util.args.SubCommand;
import org.opends.server.util.args.SubCommandArgumentParser;
import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
/**
 * This class will parser CLI arguments.
@@ -522,7 +522,7 @@
   *           If there is a problem with any of the parameters used
   *           to execute this subcommand.
   */
  public ReturnCode performSubCommand(OutputStream outStream,
  public DsFrameworkCliReturnCode performSubCommand(OutputStream outStream,
      OutputStream errStream)
    throws ADSContextException, ArgumentException
  {
@@ -538,7 +538,7 @@
    // Should never occurs: If we are here, it means that the code to
    // handle to subcommand is not yet written.
    return ReturnCode.ERROR_UNEXPECTED;
    return ERROR_UNEXPECTED;
  }
  /**
@@ -767,7 +767,7 @@
      String message = getMessage(msgID, bindPasswordArg.getLongIdentifier(),
                                  bindPasswordFileArg.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return ReturnCode.CONFLICTING_ARGS.getReturnCode();
      return CONFLICTING_ARGS.getReturnCode();
    }
    // Couldn't have at the same time trustAll and
@@ -778,7 +778,7 @@
      String message = getMessage(msgID, trustAllArg.getLongIdentifier(),
          trustStorePathArg.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return ReturnCode.CONFLICTING_ARGS.getReturnCode();
      return CONFLICTING_ARGS.getReturnCode();
    }
    if (trustAllArg.isPresent() && trustStorePasswordArg.isPresent())
    {
@@ -786,7 +786,7 @@
      String message = getMessage(msgID, trustAllArg.getLongIdentifier(),
          trustStorePasswordArg.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return ReturnCode.CONFLICTING_ARGS.getReturnCode();
      return CONFLICTING_ARGS.getReturnCode();
    }
    if (trustAllArg.isPresent() && trustStorePasswordFileArg.isPresent())
    {
@@ -794,7 +794,7 @@
      String message = getMessage(msgID, trustAllArg.getLongIdentifier(),
          trustStorePasswordFileArg.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return ReturnCode.CONFLICTING_ARGS.getReturnCode();
      return CONFLICTING_ARGS.getReturnCode();
    }
    // Couldn't have at the same time trustStorePasswordArg and
@@ -806,7 +806,7 @@
      String message = getMessage(msgID, trustStorePasswordArg
          .getLongIdentifier(), trustStorePasswordFileArg.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return ReturnCode.CONFLICTING_ARGS.getReturnCode();
      return CONFLICTING_ARGS.getReturnCode();
    }
    // Couldn't have at the same time startTLSArg and
@@ -818,10 +818,10 @@
      String message = getMessage(msgID, startTLSArg
          .getLongIdentifier(), useSSLArg.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return ReturnCode.CONFLICTING_ARGS.getReturnCode();
      return CONFLICTING_ARGS.getReturnCode();
    }
    return ReturnCode.SUCCESSFUL_NOP.getReturnCode();
    return SUCCESSFUL_NOP.getReturnCode();
  }
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliReturnCode.java
@@ -33,16 +33,11 @@
import org.opends.admin.ads.ADSContextException.ErrorType;
/**
 * This class is handling server group CLI.
 */
public final class DsFrameworkCliReturnCode
{
  /**
   *
   * The enumeration which defines the return code.
   *
   */
  public enum ReturnCode
  public enum DsFrameworkCliReturnCode
  {
    /**
     * successful.
@@ -55,7 +50,7 @@
    SUCCESSFUL_NOP(SUCCESSFUL.getReturnCode(), MSGID_ADMIN_SUCCESSFUL_NOP),
    /**
     * Unable to initialze arguments.
     * Unable to initialize arguments.
     */
    CANNOT_INITIALIZE_ARGS(1, MSGID_ADMIN_NO_MESSAGE),
@@ -155,7 +150,7 @@
    private final int messageId;
    // Private constructor.
    private ReturnCode(int returnCode, int messageId)
    private DsFrameworkCliReturnCode(int returnCode, int messageId)
    {
      this.returnCode = returnCode;
      this.messageId = messageId;
@@ -180,7 +175,6 @@
    {
      return returnCode;
    }
  };
  /**
   * Indicate whenever the association between ADS errors and return
@@ -188,17 +182,11 @@
   */
  private static boolean initialized = false ;
  // Prevent instantiation.
  private void DsFrameworkCliReturnCode()
  {
    // Do nothing.
  }
  /**
   * The association map between ADS Error and Return code.
   */
  private static HashMap<ErrorType, ReturnCode> adsErrorToReturnCode =
    new HashMap<ErrorType, ReturnCode>();
  private static HashMap<ErrorType, DsFrameworkCliReturnCode>
    adsErrorToReturnCode = new HashMap<ErrorType, DsFrameworkCliReturnCode>();
  /**
   * Associates a set of ADS errors to return code.
@@ -206,35 +194,35 @@
  private  static void registerAdsError()
  {
    adsErrorToReturnCode.put(ErrorType.MISSING_HOSTNAME,
        ReturnCode.MISSING_HOSTNAME);
        MISSING_HOSTNAME);
    adsErrorToReturnCode.put(ErrorType.NOVALID_HOSTNAME,
        ReturnCode.NOVALID_HOSTNAME);
        NOVALID_HOSTNAME);
    adsErrorToReturnCode.put(ErrorType.MISSING_IPATH,
        ReturnCode.MISSING_IPATH);
        MISSING_IPATH);
    adsErrorToReturnCode.put(ErrorType.NOVALID_IPATH,
        ReturnCode.NOVALID_IPATH);
        NOVALID_IPATH);
    adsErrorToReturnCode.put(ErrorType.ACCESS_PERMISSION,
        ReturnCode.ACCESS_PERMISSION);
        ACCESS_PERMISSION);
    adsErrorToReturnCode.put(ErrorType.ALREADY_REGISTERED,
        ReturnCode.ALREADY_REGISTERED);
        ALREADY_REGISTERED);
    adsErrorToReturnCode.put(ErrorType.BROKEN_INSTALL,
        ReturnCode.BROKEN_INSTALL);
        BROKEN_INSTALL);
    adsErrorToReturnCode.put(ErrorType.UNEXPECTED_ADS_BACKEND_TYPE,
        ReturnCode.BROKEN_INSTALL);
        BROKEN_INSTALL);
    adsErrorToReturnCode.put(ErrorType.NOT_YET_REGISTERED,
        ReturnCode.NOT_YET_REGISTERED);
        NOT_YET_REGISTERED);
    adsErrorToReturnCode.put(ErrorType.MISSING_PORT,
        ReturnCode.MISSING_PORT);
        MISSING_PORT);
    adsErrorToReturnCode.put(ErrorType.NOVALID_PORT,
        ReturnCode.NOVALID_PORT);
        NOVALID_PORT);
    adsErrorToReturnCode.put(ErrorType.MISSING_NAME,
        ReturnCode.MISSING_NAME);
        MISSING_NAME);
    adsErrorToReturnCode.put(ErrorType.MISSING_ADMIN_UID,
        ReturnCode.MISSING_ADMIN_UID);
        MISSING_ADMIN_UID);
    adsErrorToReturnCode.put(ErrorType.MISSING_ADMIN_PASSWORD,
        ReturnCode.MISSING_ADMIN_PASSWORD);
        MISSING_ADMIN_PASSWORD);
    adsErrorToReturnCode.put(ErrorType.ERROR_UNEXPECTED,
        ReturnCode.ERROR_UNEXPECTED);
        ERROR_UNEXPECTED);
  }
  /**
@@ -242,7 +230,8 @@
   * @param error The ADS error
   * @return the ReturnCode associated to the ADS error.
   */
  public static ReturnCode getReturncodeFromAdsError(ErrorType error)
  public static DsFrameworkCliReturnCode
    getReturncodeFromAdsError(ErrorType error)
  {
    if (! initialized)
    {
@@ -252,3 +241,5 @@
    return adsErrorToReturnCode.get(error);
  }
}
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java
@@ -48,7 +48,6 @@
import org.opends.admin.ads.ADSContextException;
import org.opends.admin.ads.ADSContext.ServerProperty;
import org.opends.admin.ads.ADSContextException.ErrorType;
import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.ReturnCode;
import org.opends.server.tools.dsconfig.ArgumentExceptionFactory;
import org.opends.server.util.args.Argument;
import org.opends.server.util.args.ArgumentException;
@@ -59,6 +58,7 @@
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TextTablePrinter;
import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
/**
 * This class is handling server group CLI.
 */
@@ -561,14 +561,14 @@
  /**
   * {@inheritDoc}
   */
  public ReturnCode performSubCommand(SubCommand subCmd,
  public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
      OutputStream outStream, OutputStream errStream)
      throws ADSContextException, ArgumentException
  {
    ADSContext adsCtx = null;
    InitialLdapContext ctx = null;
    ReturnCode returnCode = ReturnCode.ERROR_UNEXPECTED;
    DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED;
    try
    {
@@ -593,7 +593,7 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        adsCtx.registerServer(map);
@@ -608,7 +608,7 @@
      // -----------------------
      if (subCmd.getName().equals(unregisterServerSubCmd.getName()))
      {
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
        Map<ServerProperty, Object> map = new HashMap<ServerProperty, Object>();
        String serverId = null;
@@ -625,7 +625,7 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
@@ -666,7 +666,7 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        Set<Map<ServerProperty, Object>> serverList = adsCtx
@@ -679,7 +679,7 @@
          out.println(ServerProperty.ID.getAttributeName() + ": "
              + server.get(ServerProperty.ID));
        }
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
@@ -690,7 +690,7 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        Set<Map<ServerProperty, Object>> adsServerList = adsCtx
@@ -719,7 +719,7 @@
          }
          out.println();
        }
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
@@ -740,11 +740,11 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx);
        adsCtx.updateServer(map, newServerId);
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      else
      // -----------------------
@@ -794,14 +794,14 @@
        }
        TextTablePrinter printer = new TextTablePrinter(outStream);
        table.print(printer);
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      else
      {
        // Should never occurs: If we are here, it means that the code
        // to
        // handle to subcommand is not yet written.
        returnCode = ReturnCode.ERROR_UNEXPECTED;
        returnCode = ERROR_UNEXPECTED;
      }
    }
    catch (ADSContextException e)
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServerGroup.java
@@ -48,12 +48,12 @@
import org.opends.admin.ads.ADSContext.ServerGroupProperty;
import org.opends.admin.ads.ADSContext.ServerProperty;
import org.opends.admin.ads.ADSContextException.ErrorType;
import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.ReturnCode;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.BooleanArgument;
import org.opends.server.util.args.StringArgument;
import org.opends.server.util.args.SubCommand;
import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
/**
 * This class is handling server group CLI.
 */
@@ -245,12 +245,12 @@
  private StringArgument listMembersGroupNameArg;
  /**
   * The 'mlist-membership' subcommand.
   * The 'list-membership' subcommand.
   */
  private SubCommand listMembershipSubCmd;
  /**
   * The 'meber-name' argument of the 'list-membership' subcommand.
   * The 'member-name' argument of the 'list-membership' subcommand.
   */
  private StringArgument listMembershipMemberNameArg;
@@ -278,7 +278,7 @@
  /**
   * Get the display attribute name for a given attribute.
   * @param prop The server prperty
   * @param prop The server property
   * @return the display attribute name for a given attribute
   */
  public String getAttributeDisplayName(ServerGroupProperty prop)
@@ -462,14 +462,14 @@
  /**
   * {@inheritDoc}
   */
  public ReturnCode performSubCommand(SubCommand subCmd, OutputStream outStream,
      OutputStream errStream)
  public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
      OutputStream outStream, OutputStream errStream)
      throws ADSContextException, ArgumentException
  {
    ADSContext adsCtx = null ;
    InitialLdapContext ctx = null ;
    ReturnCode returnCode = ReturnCode.ERROR_UNEXPECTED;
    DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED;
    try
    {
      // -----------------------
@@ -495,22 +495,22 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;
        adsCtx.createServerGroup(serverGroupProperties);
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      // -----------------------
      // delete-group subcommand
      // -----------------------
      else if (subCmd.getName().equals(deleteGroupSubCmd.getName()))
      {
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
        String groupId = deleteGroupGroupNameArg.getValue();
        if (groupId.equals(ADSContext.ALL_SERVERGROUP_NAME))
        {
          return ReturnCode.ACCESS_PERMISSION ;
          return ACCESS_PERMISSION ;
        }
        HashMap<ServerGroupProperty, Object> serverGroupProperties =
          new HashMap<ServerGroupProperty, Object>();
@@ -519,7 +519,7 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;
@@ -527,7 +527,7 @@
        Set<String> serverList = adsCtx.getServerGroupMemberList(groupId);
        for (String serverId : serverList)
        {
          // serverId conatins "cn=" string, just remove it.
          // serverId contains "cn=" string, just remove it.
          removeServerFromGroup(adsCtx, groupId,serverId.substring(3));
        }
@@ -543,7 +543,7 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;
@@ -650,7 +650,7 @@
        catch (IOException e)
        {
        }
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      // -----------------------
      // modify-group subcommand
@@ -700,14 +700,14 @@
        // Update the server group
        if ( ! (updateRequired || removeRequired ) )
        {
          returnCode = ReturnCode.SUCCESSFUL_NOP;
          returnCode = SUCCESSFUL_NOP;
        }
        // We need to perform an update
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;
@@ -721,7 +721,7 @@
              serverGroupPropertiesToRemove);
        }
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      // -----------------------
      // add-to-group subcommand
@@ -733,7 +733,7 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;
@@ -769,7 +769,7 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;
@@ -787,7 +787,7 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;
@@ -795,7 +795,7 @@
        Set<String> memberList = adsCtx.getServerGroupMemberList(groupId);
        if (memberList == null)
        {
          returnCode = ReturnCode.SUCCESSFUL;
          returnCode = SUCCESSFUL;
        }
        StringBuffer buffer = new StringBuffer();
        for (String member : memberList)
@@ -812,7 +812,7 @@
        {
        }
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      // -----------------------
      // list-membership subcommand
@@ -823,7 +823,7 @@
        ctx = argParser.getContext(outStream, errStream);
        if (ctx == null)
        {
          return ReturnCode.CANNOT_CONNECT_TO_ADS;
          return CANNOT_CONNECT_TO_ADS;
        }
        adsCtx = new ADSContext(ctx) ;
@@ -837,7 +837,7 @@
          // Get the group name;
          String groupId = groupProps.get(ServerGroupProperty.UID).toString();
          // look for memeber list attribute
          // look for member list attribute
          for (ServerGroupProperty propName : groupProps.keySet())
          {
            if (propName.compareTo(ServerGroupProperty.MEMBERS) != 0)
@@ -866,13 +866,13 @@
        catch (IOException e)
        {
        }
        returnCode = ReturnCode.SUCCESSFUL;
        returnCode = SUCCESSFUL;
      }
      else
      {
        // Should never occurs: If we are here, it means that the code to
        // handle to subcommand is not yet written.
        returnCode = ReturnCode.ERROR_UNEXPECTED;
        returnCode = ERROR_UNEXPECTED;
      }
    }
    catch (ADSContextException e)
@@ -922,23 +922,23 @@
   *           If there is a problem with any of the parameters used
   *           to create this argument.
   */
  static ReturnCode removeServerFromGroup(ADSContext adsCtx, String groupId,
      String serverId)
  static DsFrameworkCliReturnCode removeServerFromGroup(ADSContext adsCtx,
      String groupId, String serverId)
      throws ADSContextException
  {
    ReturnCode returnCode = ReturnCode.SUCCESSFUL;
    DsFrameworkCliReturnCode returnCode = SUCCESSFUL;
    // get the current group member list
    Set<String> memberList = adsCtx.getServerGroupMemberList(groupId);
    if (memberList == null)
    {
      returnCode = ReturnCode.NOT_YET_REGISTERED;
      returnCode = NOT_YET_REGISTERED;
    }
    String memberToRemove = "cn="
        + Rdn.escapeValue(serverId);
    if (!memberList.contains(memberToRemove))
    {
      returnCode = ReturnCode.NOT_YET_REGISTERED;
      returnCode = NOT_YET_REGISTERED;
    }
    memberList.remove(memberToRemove);
@@ -964,7 +964,7 @@
    }
    if ( ! found )
    {
      return returnCode.SERVER_NOT_REGISTERED ;
      return SERVER_NOT_REGISTERED ;
    }
    Set rawGroupList = (Set) serverProperties.get(ServerProperty.GROUPS);
@@ -1001,10 +1001,11 @@
   *           If there is a problem with any of the parameters used
   *           to create this argument.
   */
  static ReturnCode addServerTogroup(ADSContext adsCtx, String groupId,
      Map<ServerProperty, Object> map) throws ADSContextException
  static DsFrameworkCliReturnCode addServerTogroup(ADSContext adsCtx,
      String groupId, Map<ServerProperty, Object> map)
      throws ADSContextException
  {
    ReturnCode returnCode = ReturnCode.SUCCESSFUL;
    DsFrameworkCliReturnCode returnCode = SUCCESSFUL;
    String serverId = (String) map.get(ServerProperty.ID);
    // Add the server inside the group
@@ -1019,7 +1020,7 @@
        + Rdn.escapeValue(serverId);
    if (memberList.contains(newMember))
    {
      returnCode = ReturnCode.ALREADY_REGISTERED;
      returnCode = ALREADY_REGISTERED;
    }
    memberList.add(newMember);
    serverGroupProperties.put(ServerGroupProperty.MEMBERS, memberList);
opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliSubCommandGroup.java
@@ -30,7 +30,6 @@
import java.util.Set;
import org.opends.admin.ads.ADSContextException;
import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.ReturnCode;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.BooleanArgument;
import org.opends.server.util.args.SubCommand;
@@ -78,7 +77,7 @@
   *           If there is a problem with any of the parameters used
   *           to execute this subcommand.
   */
  public ReturnCode performSubCommand(SubCommand subCmd,
  public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
      OutputStream outStream, OutputStream errStream)
      throws ADSContextException, ArgumentException;
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/CliTest.java
@@ -32,7 +32,6 @@
import org.testng.annotations.*;
import org.opends.admin.ads.ADSContext.ServerGroupProperty;
import org.opends.admin.ads.ADSContextException.ErrorType;
import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.ReturnCode;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.SubCommandArgumentParser;
@@ -40,6 +39,7 @@
import static org.opends.server.messages.AdminMessages.*;
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
/**
@@ -65,7 +65,8 @@
    String invalidMsgId;
    String msg;
    int messageID;
    for (ReturnCode returnCode : ReturnCode.values())
    for (DsFrameworkCliReturnCode returnCode : DsFrameworkCliReturnCode
        .values())
    {
      if ((messageID = returnCode.getMessageId()) == MSGID_ADMIN_NO_MESSAGE)
      {
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/DsframeworkTestCase.java
@@ -92,7 +92,7 @@
    };
    assertEquals(DsFrameworkCliMain.mainCLI(args, false, System.out,
        System.err), ReturnCode.SUCCESSFUL.getReturnCode());
        System.err), SUCCESSFUL.getReturnCode());
  }
  /**
@@ -112,7 +112,7 @@
    };
    assertEquals(DsFrameworkCliMain.mainCLI(args, false, System.out,
        System.err), ReturnCode.SUCCESSFUL.getReturnCode());
        System.err), SUCCESSFUL.getReturnCode());
  }
  /**
@@ -130,7 +130,7 @@
    };
    assertFalse(DsFrameworkCliMain.mainCLI(args, false, null, null)
        == ReturnCode.SUCCESSFUL.getReturnCode());
        == SUCCESSFUL.getReturnCode());
  }
  /**
@@ -148,7 +148,7 @@
    };
    assertFalse(DsFrameworkCliMain.mainCLI(args, false, System.out, System.err)
        == ReturnCode.SUCCESSFUL.getReturnCode());
        == SUCCESSFUL.getReturnCode());
  }
  /**
@@ -166,7 +166,7 @@
    };
    assertFalse(DsFrameworkCliMain.mainCLI(args, false, System.out, System.err)
        == ReturnCode.SUCCESSFUL.getReturnCode());
        == SUCCESSFUL.getReturnCode());
  }
@@ -190,7 +190,7 @@
    };
    assertEquals(DsFrameworkCliMain.mainCLI(args, false, System.out,
        System.err), ReturnCode.SUCCESSFUL.getReturnCode());
        System.err), SUCCESSFUL.getReturnCode());
  }
  /**
@@ -211,7 +211,7 @@
    };
    assertFalse(DsFrameworkCliMain.mainCLI(args, false, System.out, System.err)
        == ReturnCode.SUCCESSFUL.getReturnCode());
        == SUCCESSFUL.getReturnCode());
  }
  /**
@@ -230,7 +230,7 @@
    };
    assertEquals(DsFrameworkCliMain.mainCLI(args, false, System.out,
        System.err), ReturnCode.SUCCESSFUL.getReturnCode());
        System.err), SUCCESSFUL.getReturnCode());
  }
@@ -254,7 +254,7 @@
    };
    assertEquals(DsFrameworkCliMain.mainCLI(args, false, System.out,
        System.err), ReturnCode.SUCCESSFUL.getReturnCode());
        System.err), SUCCESSFUL.getReturnCode());
  }
@@ -275,7 +275,7 @@
    };
    assertEquals(DsFrameworkCliMain.mainCLI(args, false, null, System.err),
        ReturnCode.SUCCESSFUL.getReturnCode());
        SUCCESSFUL.getReturnCode());
  }
@@ -299,7 +299,7 @@
    };
    assertEquals(DsFrameworkCliMain.mainCLI(args, false, null, System.err),
        ReturnCode.SUCCESSFUL.getReturnCode());
        SUCCESSFUL.getReturnCode());
  }
  /**
@@ -310,15 +310,15 @@
  {
    String[] args = { "--help" };
    assertEquals(DsFrameworkCliMain.mainCLI(args, false, null, null),
        ReturnCode.SUCCESSFUL.getReturnCode());
        SUCCESSFUL.getReturnCode());
    args = new String[] { "-H" };
    assertEquals(DsFrameworkCliMain.mainCLI(args, false, null, null),
        ReturnCode.SUCCESSFUL.getReturnCode());
        SUCCESSFUL.getReturnCode());
    args = new String[] { "-?" };
    assertEquals(DsFrameworkCliMain.mainCLI(args, false, null, null),
        ReturnCode.SUCCESSFUL.getReturnCode());
        SUCCESSFUL.getReturnCode());
  }
}