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

jvergara
07.54.2008 7f020de74c831dc15d5e70a7f423f87f4d5e8a37
Fix for issue 2780.

The problem was that cn=admin data was being overwritten by the reversion. This must not be done. A new file filter class (specific to the reversion) has been added to fix the issue.
1 files added
5 files modified
91 ■■■■ changed files
opends/src/ads/org/opends/admin/ads/ADSContext.java 6 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/Installation.java 8 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/RevertFileFilter.java 53 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java 8 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/Stage.java 11 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java 5 ●●●●● patch | view | raw | blame | history
opends/src/ads/org/opends/admin/ads/ADSContext.java
@@ -22,11 +22,12 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2007 Sun Microsystems, Inc.
 *      Portions Copyright 2007-2008 Sun Microsystems, Inc.
 */
package org.opends.admin.ads;
import java.io.File;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Set;
@@ -57,6 +58,7 @@
import javax.naming.ldap.Control;
import javax.naming.ldap.LdapContext;
/**
 * Class used to update and read the contents of the Administration Data.
 */
@@ -2140,7 +2142,7 @@
   */
  public static String getAdminLDIFFile()
  {
    return "config/admin-backend.ldif";
    return "config"+File.separator+"admin-backend.ldif";
  }
opends/src/quicksetup/org/opends/quicksetup/Installation.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.quicksetup;
@@ -261,6 +261,12 @@
  public static final String DEFAULT_JAVA_PROPERTIES_FILE = "java.properties";
  /**
   * The default java properties file relative path.
   */
  public static final String RELATIVE_JAVA_PROPERTIES_FILE =
    CONFIG_PATH_RELATIVE+File.separator+"java.properties";
  /**
   * The set java home and arguments properties file for Windows.
   */
  public static final String SET_JAVA_PROPERTIES_FILE_WINDOWS =
opends/src/quicksetup/org/opends/quicksetup/upgrader/RevertFileFilter.java
New file
@@ -0,0 +1,53 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2008 Sun Microsystems, Inc.
 */
package org.opends.quicksetup.upgrader;
import java.io.File;
import java.util.HashSet;
/**
   * Filter defining files we want to manage in the upgrade
 * process.
 */
class RevertFileFilter extends UpgradeFileFilter {
  /**
   * Creates a filter for ignoring in an OpenDS installation at
   * <code>root</code>certain OpenDS files below root.
   * @param root the root of the installation
   */
  public RevertFileFilter(File root) {
    super(root);
    this.filesToIgnore = new HashSet<File>();
    for (String rootFileNamesToIgnore :
            Upgrader.ROOT_FILES_TO_IGNORE_DURING_BACKUP) {
      filesToIgnore.add(new File(root, rootFileNamesToIgnore));
    }
  }
}
opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
@@ -549,6 +549,7 @@
            notifyListeners(getLineBreak());
          }
        } catch (ApplicationException ae) {
          runError = ae;
          notifyListeners(getFormattedErrorWithLineBreak());
        }
      }
@@ -598,6 +599,7 @@
            notifyListeners(getLineBreak());
          }
        } catch (ApplicationException ae) {
          runError = ae;
          notifyListeners(getFormattedErrorWithLineBreak());
        }
      }
@@ -626,7 +628,7 @@
    {
      log = getFormattedWithPoints(log);
    }
    notifyListeners(progress, log, log);
    notifyListeners(progress, summary, log);
  }
  private void initialize() throws ApplicationException {
@@ -644,7 +646,7 @@
      File filesBackupDirectory = getTempBackupDirectory();
      FileManager fm = new FileManager();
      File root = getInstallation().getRootDirectory();
      FileFilter filter = new UpgradeFileFilter(root);
      FileFilter filter = new RevertFileFilter(root);
      for (String fileName : root.list()) {
        File f = new File(root, fileName);
@@ -676,7 +678,7 @@
      Stage stage = getStage();
      Installation installation = getInstallation();
      File root = installation.getRootDirectory();
      stage.move(root);
      stage.move(root, new RevertFileFilter(getReversionFilesDirectory()));
      // The bits should now be of the new version.  Have
      // the installation update the build information so
opends/src/quicksetup/org/opends/quicksetup/upgrader/Stage.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.quicksetup.upgrader;
@@ -35,6 +35,7 @@
import org.opends.quicksetup.util.FileManager;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -71,14 +72,16 @@
   * Moves the files in the staging area to a destination directory.
   *
   * @param destination for the staged files
   * @param fileFilter the file filter to be used
   * @throws ApplicationException if something goes wrong
   */
  public void move(File destination) throws ApplicationException {
    UpgradeFileFilter ff = new UpgradeFileFilter(root);
  public void move(File destination, FileFilter fileFilter)
  throws ApplicationException {
    for (String fileName : root.list()) {
      File dest = new File(destination, fileName);
      File src = getSourceForCopy(fileName, dest);
      fm.copyRecursively(src, destination, ff, /*overwrite=*/true);
      //fm.copyRecursively(src, destination, fileFilter, /*overwrite=*/true);
      fm.copyRecursively(src, destination, fileFilter, /*overwrite=*/true);
    }
  }
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2007 Sun Microsystems, Inc.
 *      Portions Copyright 2008 Sun Microsystems, Inc.
 */
package org.opends.quicksetup.upgrader;
@@ -139,6 +139,7 @@
  // Files that will be ignored during backup
  static final String[] FILES_TO_IGNORE_DURING_BACKUP = {
          TOOLS_PROPERTIES, // tools.properties
          RELATIVE_JAVA_PROPERTIES_FILE, // java.properties
          ADSContext.getAdminLDIFFile() // admin-backend.ldif
  };
@@ -1357,7 +1358,7 @@
      Stage stage = getStage();
      Installation installation = getInstallation();
      File root = installation.getRootDirectory();
      stage.move(root);
      stage.move(root, new UpgradeFileFilter(getStageDirectory()));
      // The bits should now be of the new version.  Have
      // the installation update the build information so