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

jvergara
17.43.2007 89f3d335b1cd9effc7caf83c08a968b9cb496365
opendj-sdk/opends/src/server/org/opends/server/tools/tasks/TaskTool.java
@@ -74,6 +74,9 @@
   */
  public static final String NOW = "0";
  private static final int RUN_OFFLINE = 51;
  private static final int RUN_ONLINE = 52;
  // Number of milliseconds this utility will wait before reloading
  // this task's entry in the directory while it is polling for status
  private static final int SYNCHRONOUS_TASK_POLL_INTERVAL = 1000;
@@ -98,6 +101,10 @@
  // Client for interacting with the task backend
  TaskClient taskClient;
  // Argument used to know whether we must test if we must run in offline
  // mode.
  BooleanArgument testIfOfflineArg;
  /**
   * Called when this utility should perform its actions locally in this
   * JVM.
@@ -121,8 +128,8 @@
   * @return LDAPConnectionArgumentParser for processing CLI input
   */
  protected LDAPConnectionArgumentParser createArgParser(String className,
                                           Message toolDescription)
  {
      Message toolDescription)
    {
    ArgumentGroup ldapGroup = new ArgumentGroup(
            INFO_DESCRIPTION_TASK_LDAP_ARGS.get(), 1001);
@@ -191,6 +198,12 @@
                FailedDependencyAction.defaultValue().name()));
      argParser.addArgument(failedDependencyActionArg, taskGroup);
      testIfOfflineArg = new BooleanArgument(
          "testIfOffline", null, "testIfOffline",
          INFO_DESCRIPTION_TEST_IF_OFFLINE.get());
      testIfOfflineArg.setHidden(true);
      argParser.addArgument(testIfOfflineArg);
    } catch (ArgumentException e) {
      // should never happen
    }
@@ -351,6 +364,18 @@
                        PrintStream out, PrintStream err) {
    int ret;
    if (testIfOffline())
    {
      if (!processAsTask())
      {
        return RUN_OFFLINE;
      }
      else
      {
        return RUN_ONLINE;
      }
    }
    if (processAsTask())
    {
      if (initializeServer)
@@ -449,4 +474,19 @@
    return argParser.connectionArgumentsPresent();
  }
  /**
   * Indicates whether we must return if the command must be run in offline
   * mode.
   * @return <CODE>true</CODE> if we must return if the command must be run in
   * offline mode and <CODE>false</CODE> otherwise.
   */
  private boolean testIfOffline()
  {
    boolean returnValue = false;
    if (testIfOfflineArg != null)
    {
      returnValue = testIfOfflineArg.isPresent();
    }
    return returnValue;
  }
}