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

Jean-Noel Rouvignac
11.14.2014 8f8b9f854c6c482995b005c7abbae590ba4dda60
opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -85,8 +85,8 @@
  static boolean isRebuildAllIndexesTaskAccepted = false;
  /**
   * Returns a new upgrade task which applies an LDIF record to all
   * configuration entries matching the provided filter.
   * Returns a new upgrade task which adds a config entry to the underlying
   * config file.
   *
   * @param summary
   *          The summary of this upgrade task.
@@ -207,6 +207,30 @@
  }
  /**
   * Returns a new upgrade task which deletes a config entry from the underlying
   * config file.
   *
   * @param summary
   *          The summary of this upgrade task.
   * @param dnInLDIF
   *          The dn to delete in the form of LDIF.
   * @return A new upgrade task which applies an LDIF record to all
   *         configuration entries matching the provided filter.
   */
  public static UpgradeTask deleteConfigEntry(final Message summary,
      final String dnInLDIF)
  {
    return new AbstractUpgradeTask()
    {
      @Override
      public void perform(final UpgradeContext context) throws ClientException
      {
        perform0(summary, null, ChangeOperationType.DELETE, context, dnInLDIF);
      }
    };
  }
  /**
   * Returns a new upgrade task which applies an LDIF record to all
   * configuration entries matching the provided filter.
   *
@@ -809,33 +833,7 @@
      {
        if (userConfirmation)
        {
          displayTaskLogInformation(summary.toString(), null, ldif);
          final ProgressNotificationCallback pnc =
              new ProgressNotificationCallback(0, summary, 20);
          context.notifyProgress(pnc);
          try
          {
            // TODO change the directory to the config if it exists.
            final File configFile =
                new File(configDirectory,
                    Installation.CURRENT_CONFIG_FILE_NAME);
            final int changeCount =
                updateConfigFile(configFile.getPath(), null,
                    ChangeOperationType.ADD, ldif);
            displayChangeCount(configFile.getPath(), changeCount);
            context.notifyProgress(pnc.setProgress(100));
          }
          catch (final Exception e)
          {
            manageTaskException(context, Message.fromObject(e.getMessage()),
                pnc);
          }
          perform0(summary, null, ChangeOperationType.ADD, context, ldif);
        }
      }
    };
@@ -915,37 +913,44 @@
      {
        if (userConfirmation)
        {
          displayTaskLogInformation(summary.toString(), filter, ldif);
          final ProgressNotificationCallback pnc =
              new ProgressNotificationCallback(0, summary, 20);
          context.notifyProgress(pnc);
          try
          {
            final File configFile =
                new File(configDirectory,
                    Installation.CURRENT_CONFIG_FILE_NAME);
            final int changeCount =
                updateConfigFile(configFile.getPath(), Filter.valueOf(filter),
                    ChangeOperationType.MODIFY, ldif);
            displayChangeCount(configFile.getPath(), changeCount);
            context.notifyProgress(pnc.setProgress(100));
          }
          catch (final Exception e)
          {
            manageTaskException(context, Message.fromObject(e.getMessage()),
                pnc);
          }
          perform0(summary, filter, ChangeOperationType.MODIFY, context, ldif);
        }
      }
    };
  }
  private static void perform0(final Message summary, final String filter,
      final ChangeOperationType changeOperationType,
      final UpgradeContext context, final String... ldif)
      throws ClientException
  {
    displayTaskLogInformation(summary.toString(), filter, ldif);
    final ProgressNotificationCallback pnc =
        new ProgressNotificationCallback(0, summary, 20);
    context.notifyProgress(pnc);
    try
    {
      final File configFile =
          new File(configDirectory, Installation.CURRENT_CONFIG_FILE_NAME);
      final Filter filterVal = filter != null ? Filter.valueOf(filter) : null;
      final int changeCount =
          updateConfigFile(configFile.getPath(), filterVal,
              changeOperationType, ldif);
      displayChangeCount(configFile.getPath(), changeCount);
      context.notifyProgress(pnc.setProgress(100));
    }
    catch (final Exception e)
    {
      manageTaskException(context, Message.fromObject(e.getMessage()), pnc);
    }
  }
  // Prevent instantiation.
  private UpgradeTasks()