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

kenneth_suter
11.14.2007 2c18c7eda8c978ea6c0b7f6facd631e828a15533
This commit addresses issue 1973 "exclude some config subdirectories from copy during upgrade".  During an upgrade, the contents of the old config directory are recursively copied to the new config directory in order to retain things like the keystore and other SSL related artifacts and tasks.ldif.  There are however some files that should not be copied over, namely the contents of the upgrade and schema subdirectories.  This commit excludes those subdirectories. 
2 files modified
40 ■■■■■ changed files
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java 14 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java 26 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -1378,7 +1378,19 @@
    File newConfigDir =
            getInstallation().getConfigurationDirectory();
    FileManager fm = new FileManager();
    fm.synchronize(oldConfigDir, newConfigDir);
    // Define a filter for files that we don't want to copy over
    // from the old config directory.
    final File oldConfigUpgradeDir = new File(oldConfigDir, "upgrade");
    final File oldConfigSchemaDir = new File(oldConfigDir, "schema");
    FileFilter filter = new FileFilter() {
      public boolean accept(File f) {
        return !Utils.isDescendant(f, oldConfigUpgradeDir) &&
                !Utils.isDescendant(f, oldConfigSchemaDir);
      }
    };
    fm.synchronize(oldConfigDir, newConfigDir, filter);
  }
  private boolean calculateConfigCustomizations() throws ApplicationException {
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java
@@ -112,6 +112,32 @@
  }
  /**
   * Recursively copies any files or directories appearing in
   * <code>source</code> or a subdirectory of <code>source</code>
   * to the corresponding directory under <code>target</code>.  Files
   * in under <code>source</code> are not copied to <code>target</code>
   * if a file by the same name already exists in <code>target</code>.
   *
   * @param source source directory
   * @param target target directory
   * @param filter for specifying particular files to synchronize
   * @throws ApplicationException if there is a problem copying files
   */
  public void synchronize(File source, File target, FileFilter filter)
          throws ApplicationException
  {
    if (source != null && target != null) {
      String[] sourceFileNames = source.list();
      if (sourceFileNames != null) {
        for (String sourceFileName : sourceFileNames) {
          File sourceFile = new File(source, sourceFileName);
          copyRecursively(sourceFile, target, filter, false);
        }
      }
    }
  }
  /**
   * Renames the source file to the target file.  If the target file exists
   * it is first deleted.  The rename and delete operation return values
   * are checked for success and if unsuccessful, this method throws an