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

Matthew Swift
12.38.2012 3d2f59e7f9a73db8743019beff4d3b69849f1fbc
Fix OPENDJ-446: setup - improve method of checking whether config has been modified

Thanks to Danny Turner for the patch contribution.
3 files modified
70 ■■■■■ changed files
opends/src/quicksetup/org/opends/quicksetup/CurrentInstallStatus.java 35 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/Installation.java 18 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/Status.java 17 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/CurrentInstallStatus.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions copyright 2012 ForgeRock AS.
 */
package org.opends.quicksetup;
@@ -87,10 +88,11 @@
        msgs.add(INFO_INSTALLSTATUS_DBFILEEXIST.get());
      }
      if (isConfigFileModified())
      if (archivedConfigsExist())
      {
        msgs.add(INFO_INSTALLSTATUS_CONFIGFILEMODIFIED.get());
      }
      canOverwriteCurrentInstall = (msgs.size() == 1) && dbFileExists;
      isInstalled = msgs.size() > 0;
      if (canOverwriteCurrentInstall)
@@ -182,6 +184,8 @@
    return port;
  }
  /**
   * Indicates whether there are database files under this installation.
   *
@@ -190,35 +194,24 @@
   */
  private boolean dbFilesExist()
  {
    boolean dbFilesExist = false;
    File dbDir = Installation.getLocal().getDatabasesDirectory();
    File[] children = dbDir.listFiles();
    if ((children != null) && (children.length > 0))
    {
      dbFilesExist = true;
    }
    return dbFilesExist;
    return ((children != null) && (children.length > 0));
  }
  /**
   * Indicates whether the config.ldif file has been modified (compared to what
   * we had in the zip file). This is used to know if we have configured the
   * current binaries or not.
   * Indicates whether there are archived config files under this installation.
   *
   * @return <CODE>true</CODE> if the config.ldif file has been modified, or
   * @return <CODE>true</CODE> if there are archived config files, or
   *         <CODE>false</CODE> if not.
   */
  private boolean isConfigFileModified()
  private boolean archivedConfigsExist()
  {
    boolean mod = false;
    try {
      mod = Installation.getLocal().getCurrentConfiguration()
              .hasBeenModified();
    } catch (IOException ioe) {
      LOG.log(Level.INFO, "failed to determine if config modified", ioe);
    }
    return mod;
    File archDir = Installation.getLocal().getArchivedConfigsDirectory();
    File[] children = archDir.listFiles();
    return ((children != null) && (children.length > 0));
  }
}
opends/src/quicksetup/org/opends/quicksetup/Installation.java
@@ -23,7 +23,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011 ForgeRock AS
 *      Portions Copyright 2011-2012 ForgeRock AS
 */
package org.opends.quicksetup;
@@ -114,6 +114,12 @@
  public static final String CONFIG_PATH_RELATIVE = "config";
  /**
   * The relative path where the archived config files are.
   */
  public static final String ARCHIVED_CONFIG_PATH_RELATIVE =
      CONFIG_PATH_RELATIVE + File.separator + "archived-configs";
  /**
   * The relative path where the config files are.
   */
  public static final String HISTORY_PATH_RELATIVE = "history";
@@ -467,7 +473,6 @@
  /**
   * Indicates if the install and instance are in the same directory.
   * @return true if the install and instance are in the same directory.
   */
  private boolean instanceAndInstallInSameDir;
@@ -884,6 +889,15 @@
  }
  /**
   * Returns the path to the archived config files under the install path.
   *
   * @return the path to the archived config files under the install path.
   */
  public File getArchivedConfigsDirectory() {
    return new File(getInstanceDirectory(), ARCHIVED_CONFIG_PATH_RELATIVE);
  }
  /**
   * Returns the path to the config files under the install path.
   *
   * @return the path to the config files under the install path.
opends/src/quicksetup/org/opends/quicksetup/Status.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions copyright 2012 ForgeRock AS.
 */
package org.opends.quicksetup;
@@ -33,7 +34,6 @@
import org.opends.quicksetup.util.Utils;
import java.io.File;
import java.io.IOException;
/**
 * This class represents the current state of a particular installation.
@@ -64,21 +64,6 @@
  }
  /**
   * Determines whether or not the configuration has been modified for this
   * installation.
   * @return boolean where true means the configuration has been modified
   */
  public boolean configurationHasBeenModified() {
    boolean mod = false;
    try {
      mod = installation.getCurrentConfiguration().hasBeenModified();
    } catch (IOException e) {
      // do nothing for now;
    }
    return mod;
  }
  /**
   * Determines whether or not the schema has been modified for this
   * installation.
   * @return boolean where true means the schema has been modified