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

Gaetan Boismal
11.29.2016 d148d18d07ef35f675f1e79df542d05434628916
OPENDJ-2763 Code cleanup

* isRebuildAllIndexesTaskAccepted == true implies isRebuildAllIndexesIsPresent == true so simplifies boolean conditions of postUpgradeRebuildIndexes().postUpgrade(...)

* Replace UpgradeTasks.getConfigFile() by a String constant in
UpgradeUtils which contains the config file path.
2 files modified
27 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java 23 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -21,7 +21,6 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.tools.upgrade.FileManager.copy;
import static org.opends.server.tools.upgrade.Installation.CURRENT_CONFIG_FILE_NAME;
import static org.opends.server.tools.upgrade.UpgradeUtils.*;
import static org.opends.server.util.StaticUtils.isClassAvailable;
@@ -667,16 +666,15 @@
      @Override
      public void postUpgrade(final UpgradeContext context) throws ClientException
      {
        LocalizableMessage message = null;
        LocalizableMessage message;
        final List<String> args = new LinkedList<>();
        if (isRebuildAllIndexesIsPresent && isRebuildAllIndexesTaskAccepted)
        if (isRebuildAllIndexesTaskAccepted)
        {
          args.add("--rebuildAll");
          message = INFO_UPGRADE_REBUILD_ALL.get();
        }
        else if (!indexesToRebuild.isEmpty()
            && !isRebuildAllIndexesTaskAccepted)
        else if (!indexesToRebuild.isEmpty())
        {
          message = INFO_UPGRADE_REBUILD_INDEX_STARTS.get(indexesToRebuild);
@@ -697,7 +695,7 @@
        context.notifyProgress(pnc);
        // Sets the arguments like the rebuild index command line.
        args.addAll(Arrays.asList("-f", getConfigLdifFile().getAbsolutePath()));
        args.addAll(Arrays.asList("-f", CONFIG_FILE_PATH));
        /*
         * Index(es) could be contained in several backends or none, If none,
@@ -1222,13 +1220,9 @@
    try
    {
      final File configFile = getConfigLdifFile();
      final Filter filterVal = filter != null ? Filter.valueOf(filter) : null;
      final int changeCount = updateConfigFile(
          configFile.getPath(), filterVal, changeOperationType, ldif);
      displayChangeCount(configFile.getPath(), changeCount);
      final int changeCount = updateConfigFile(CONFIG_FILE_PATH, filterVal, changeOperationType, ldif);
      displayChangeCount(CONFIG_FILE_PATH, changeCount);
      context.notifyProgress(pnc.setProgress(100));
    }
@@ -1238,11 +1232,6 @@
    }
  }
  private static File getConfigLdifFile()
  {
    return new File(configDirectory, CURRENT_CONFIG_FILE_NAME);
  }
  static UpgradeTask clearReplicationDbDirectory()
  {
    return new AbstractUpgradeTask()
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java
@@ -23,6 +23,7 @@
import java.io.FileReader;
import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -93,6 +94,9 @@
  static final File binDirectory = new File(getInstallationPath(), UNIX_BINARIES_PATH_RELATIVE);
  /** The bat folder of the current installation. */
  static final File batDirectory = new File(getInstallationPath(), WINDOWS_BINARIES_PATH_RELATIVE);
  /** The server configuration file path */
  static final String CONFIG_FILE_PATH =
      Paths.get(configDirectory.getAbsolutePath(), CURRENT_CONFIG_FILE_NAME).toString();
  /**
   * Returns the path of the installation of the directory server. Note that