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

kenneth_suter
02.22.2007 d7d24d90f880c29b1fc2de388de8c6b5c6e0ea31
mproves the amount of logging that is done in quicksetup applications.  Much of what was simply relayed to the user as progress messages is not logged also.

- Make the output of progress messages from various operations optional for applications. This is done to allow the upgrader to use the new abbreviated form of output while maintaining the other QuickSetup applications as the are currently.

- Progress page now produces percentage completed messages for the build download step.

- Disables parental loggers when setting up QuickSetup logs to prevent polution of the console by the root console logger.
11 files modified
482 ■■■■ changed files
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ApplicationException.java 25 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java 1 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/i18n/ResourceProvider.java 2 ●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties 6 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractor.java 24 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/RemoteBuildManager.java 26 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java 202 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java 40 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java 124 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java 30 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/i18n/ResourceProvider.java 2 ●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ApplicationException.java
@@ -40,6 +40,8 @@
{
  private static final long serialVersionUID = -3527273444231560341L;
  private String formattedMsg = null;
  private Type type;
  /**
@@ -124,6 +126,21 @@
  }
  /**
   * The constructor of the ApplicationException.
   * @param type the type of error we have.
   * @param localizedMsg a localized string describing the problem.
   * @param formattedMsg a localized message with extra formatting
   * @param rootCause the root cause of this exception.
   */
  public ApplicationException(Type type, String localizedMsg,
                              String formattedMsg, Throwable rootCause)
  {
    super(localizedMsg, rootCause);
    this.formattedMsg = formattedMsg;
    this.type = type;
  }
  /**
   * Returns the Type of this exception.
   * @return the Type of this exception.
   */
@@ -133,6 +150,14 @@
  }
  /**
   * Gets the localized message with extra formatting markup.
   * @return String representing a formatted message.
   */
  public String getFormattedMessage() {
    return formattedMsg;
  }
  /**
   * {@inheritDoc}
   */
  public String toString()
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java
@@ -55,6 +55,7 @@
      FileHandler fileHandler = new FileHandler(logFile.getCanonicalPath());
      fileHandler.setFormatter(new SimpleFormatter());
      Logger logger = Logger.getLogger("org.opends.quicksetup");
      logger.setUseParentHandlers(false); // disable logging to console
      logger.addHandler(fileHandler);
      logger.log(Level.INFO, getInitialLogRecord());
    }
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/i18n/ResourceProvider.java
@@ -119,7 +119,7 @@
   * @throws IllegalArgumentException if the key could not be found in the
   * properties file.
   */
  public String getMsg(String key, String[] args)
  public String getMsg(String key, String... args)
  throws IllegalArgumentException
  {
    String msg;
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -792,7 +792,7 @@
summary-upgrade-verifying=Verifying Upgrade...
summary-upgrade-history=Recording Upgrade History...
summary-upgrade-cleanup=Cleaning Up...
summary-upgrade-abort=Aborting Upgrade Due to Error...
summary-upgrade-abort=Aborting Upgrade...
summary-upgrade-finished-successfully=<b>OpenDS QuickSetup Completed \
  Successfully.</b><br>The OpenDS installation at {0} has now been upgraded \
  to version {1}.
@@ -982,5 +982,9 @@
upgrade-review-panel-start-server-tooltip=Check this check box if you want to \
  start the server once the upgrade has completed
build-manager-downloading-build-progress=Downloading Build: {0}% Completed
build-manager-downloading-build=Downloading Build...
build-manager-downloading-build-done=Finished Downloading Build
general-loading=Loading...
general-see-for-details=See {0} for a detailed log of this operation.
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractor.java
@@ -38,6 +38,8 @@
import java.io.File;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
 * BuildExtractor unzips an OpenDS installation package (.zip file) from a user
@@ -54,11 +56,23 @@
 */
public class BuildExtractor extends Application implements Runnable {
  static private final Logger LOG =
          Logger.getLogger(BuildExtractor.class.getName());
  /**
   * Creates and run a BuildExtractor using command line arguments.
   * @param args String[] command line arguments
   */
  public static void main(String[] args) {
    try {
      QuickSetupLog.initLogFileHandler(
              File.createTempFile(
                      UpgradeLauncher.LOG_FILE_PREFIX + "-ext-",
                      UpgradeLauncher.LOG_FILE_SUFFIX));
    } catch (Throwable t) {
      System.err.println("Unable to initialize log");
      t.printStackTrace();
    }
    new BuildExtractor(args).run();
  }
@@ -100,6 +114,7 @@
      retCode = 1;
      notifyListeners(t.getLocalizedMessage() + getLineBreak());
    }
    LOG.log(Level.INFO, "extractor exiting code=" + retCode);
    System.exit(retCode);
  }
@@ -125,10 +140,10 @@
  private void expandZipFile(File buildFile)
          throws ApplicationException, IOException {
    ZipExtractor extractor = new ZipExtractor(buildFile,
            1, 10, // TODO figure out these values
            Utils.getNumberZipEntries(), this);
    LOG.log(Level.INFO, "expanding zip file " + buildFile.getPath());
    ZipExtractor extractor = new ZipExtractor(buildFile);
    extractor.extract(getStageDirectory());
    LOG.log(Level.INFO, "extraction finished");
  }
  private File getStageDirectory() throws ApplicationException {
@@ -136,7 +151,7 @@
    Installation installation = new Installation(getInstallationPath());
    stageDir = installation.getTemporaryUpgradeDirectory();
    if (stageDir.exists()) {
      FileManager fm = new FileManager(this);
      FileManager fm = new FileManager();
      fm.deleteRecursively(stageDir);
    }
    if (!stageDir.mkdirs()) {
@@ -144,6 +159,7 @@
      throw ApplicationException.createFileSystemException(
              "failed to create staging directory " + stageDir, null);
    }
    LOG.log(Level.INFO, "stage directory " + stageDir.getPath());
    return stageDir;
  }
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/RemoteBuildManager.java
@@ -28,6 +28,7 @@
package org.opends.quicksetup.upgrader;
import org.opends.quicksetup.Application;
import org.opends.quicksetup.i18n.ResourceProvider;
import org.opends.quicksetup.util.Utils;
import javax.swing.*;
@@ -187,17 +188,30 @@
    try {
      is = conn.getInputStream();
      int length = conn.getContentLength();
      fos = new FileOutputStream(destination);
      int i = 0;
      int bytesRead = 0;
      byte[] buf = new byte[1024];
      app.notifyListeners(0,
              getMsg("build-manager-downloading-build"),
              null);
      while ((i = is.read(buf)) != -1) {
        fos.write(buf, 0, i);
        bytesRead += i;
        if (app != null) {
          app.notifyListeners(".");
          bytesRead += i;
          if (length > 0) {
            int progress = (bytesRead * 100) / length;
            app.notifyListeners(0,
                    getMsg("build-manager-downloading-build-progress",
                            String.valueOf(progress)),
                    null);
        }
      }
      }
      app.notifyListeners(0,
              getMsg("build-manager-downloading-build-done"),
              null);
    } finally {
      if (is != null) {
        is.close();
@@ -379,6 +393,14 @@
    }
  }
  private String getMsg(String key) {
    return ResourceProvider.getInstance().getMsg(key);
  }
  private String getMsg(String key, String... args) {
    return ResourceProvider.getInstance().getMsg(key, args);
  }
  /**
   * For testing only.
   * @param args command line arguments
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -89,50 +89,52 @@
   */
  enum UpgradeProgressStep implements ProgressStep {
    NOT_STARTED("summary-upgrade-not-started"),
    NOT_STARTED("summary-upgrade-not-started", 0),
    DOWNLOADING("summary-upgrade-downloading"),
    DOWNLOADING("summary-upgrade-downloading", 10),
    EXTRACTING("summary-upgrade-extracting"),
    EXTRACTING("summary-upgrade-extracting", 20),
    INITIALIZING("summary-upgrade-initializing"),
    INITIALIZING("summary-upgrade-initializing", 30),
    CHECK_SERVER_HEALTH("summary-upgrade-check-server-health"),
    CHECK_SERVER_HEALTH("summary-upgrade-check-server-health", 35),
    CALCULATING_SCHEMA_CUSTOMIZATIONS(
            "summary-upgrade-calculating-schema-customization"),
            "summary-upgrade-calculating-schema-customization", 40),
    CALCULATING_CONFIGURATION_CUSTOMIZATIONS(
            "summary-upgrade-calculating-config-customization"),
            "summary-upgrade-calculating-config-customization", 45),
    BACKING_UP_DATABASES("summary-upgrade-backing-up-db"),
    BACKING_UP_DATABASES("summary-upgrade-backing-up-db", 50),
    BACKING_UP_FILESYSTEM("summary-upgrade-backing-up-files"),
    BACKING_UP_FILESYSTEM("summary-upgrade-backing-up-files",55),
    UPGRADING_COMPONENTS("summary-upgrade-upgrading-components"),
    UPGRADING_COMPONENTS("summary-upgrade-upgrading-components", 60),
    APPLYING_SCHEMA_CUSTOMIZATIONS(
            "summary-upgrade-applying-schema-customization"),
            "summary-upgrade-applying-schema-customization", 70),
    APPLYING_CONFIGURATION_CUSTOMIZATIONS(
            "summary-upgrade-applying-config-customization"),
            "summary-upgrade-applying-config-customization", 75),
    VERIFYING("summary-upgrade-verifying"),
    VERIFYING("summary-upgrade-verifying", 80),
    RECORDING_HISTORY("summary-upgrade-history"),
    RECORDING_HISTORY("summary-upgrade-history", 85),
    CLEANUP("summary-upgrade-cleanup"),
    CLEANUP("summary-upgrade-cleanup", 90),
    ABORT("summary-upgrade-abort"),
    ABORT("summary-upgrade-abort", 95),
    FINISHED_WITH_ERRORS("summary-upgrade-finished-with-errors"),
    FINISHED_WITH_ERRORS("summary-upgrade-finished-with-errors", 100),
    FINISHED("summary-upgrade-finished-successfully");
    FINISHED("summary-upgrade-finished-successfully", 100);
    private String summaryMsgKey;
    private int progress;
    private UpgradeProgressStep(String summaryMsgKey) {
    private UpgradeProgressStep(String summaryMsgKey, int progress) {
      this.summaryMsgKey = summaryMsgKey;
      this.progress = progress;
    }
    /**
@@ -145,6 +147,14 @@
    }
    /**
     * Gets the amount of progress to show in the progress meter for this step.
     * @return int representing progress
     */
    public int getProgress() {
      return this.progress;
    }
    /**
     * {@inheritDoc}
     */
    public boolean isLast() {
@@ -212,13 +222,19 @@
   */
  private Long historicalOperationId;
  /** SVN rev number of the current build. */
  /**
   * SVN rev number of the current build.
   */
  private Integer currentVersion = null;
  /** New OpenDS bits. */
  /**
   * New OpenDS bits.
   */
  private Installation stagedInstallation = null;
  /** SVN rev number of the build in the stage directory. */
  /**
   * SVN rev number of the build in the stage directory.
   */
  private Integer stagedVersion = null;
  private RemoteBuildManager remoteBuildManager = null;
@@ -267,6 +283,7 @@
  /**
   * Gets a remote build manager that this class can use to find
   * out about and download builds for upgrading.
   *
   * @return RemoteBuildManager to use for builds
   */
  public RemoteBuildManager getRemoteBuildManager() {
@@ -356,11 +373,6 @@
    String txt = null;
    if (step == UpgradeProgressStep.FINISHED) {
      txt = getFinalSuccessMessage();
    } else if (step == UpgradeProgressStep.FINISHED_WITH_ERRORS) {
      txt = getMsg(((UpgradeProgressStep) step).getSummaryMesssageKey());
      if (!Utils.isCli()) {
        txt = formatter.getFormattedError(txt, true);
      }
    } else {
      txt = getMsg(((UpgradeProgressStep) step).getSummaryMesssageKey());
    }
@@ -648,10 +660,10 @@
      if (buildZip != null) {
        try {
          setCurrentProgressStep(UpgradeProgressStep.EXTRACTING);
          ZipExtractor extractor = new ZipExtractor(buildZip,
                  1, 10, // TODO figure out these values
                  Utils.getNumberZipEntries(), this);
          ZipExtractor extractor = new ZipExtractor(buildZip);
          extractor.extract(getStageDirectory());
          notifyListeners(formatter.getFormattedDone() +
                  formatter.getLineBreak());
        } catch (ApplicationException e) {
          LOG.log(Level.INFO, "Error extracting build file", e);
          throw e;
@@ -661,6 +673,8 @@
      try {
        setCurrentProgressStep(UpgradeProgressStep.INITIALIZING);
        initialize();
        notifyListeners(formatter.getFormattedDone() +
                formatter.getLineBreak());
      } catch (ApplicationException e) {
        LOG.log(Level.INFO, "Error initializing upgrader", e);
        throw e;
@@ -669,24 +683,32 @@
      try {
        setCurrentProgressStep(UpgradeProgressStep.CHECK_SERVER_HEALTH);
        checkServerHealth();
        notifyListeners(formatter.getFormattedDone() +
                formatter.getLineBreak());
      } catch (ApplicationException e) {
        LOG.log(Level.INFO, "Server failed initial health check", e);
        throw e;
      }
      boolean schemaCustomizationPresent = false;
      try {
        setCurrentProgressStep(
                UpgradeProgressStep.CALCULATING_SCHEMA_CUSTOMIZATIONS);
        calculateSchemaCustomizations();
        schemaCustomizationPresent = calculateSchemaCustomizations();
        notifyListeners(formatter.getFormattedDone() +
                formatter.getLineBreak());
      } catch (ApplicationException e) {
        LOG.log(Level.INFO, "Error calculating schema customizations", e);
        throw e;
      }
      boolean configCustimizationPresent = false;
      try {
        setCurrentProgressStep(
                UpgradeProgressStep.CALCULATING_CONFIGURATION_CUSTOMIZATIONS);
        calculateConfigCustomizations();
        configCustimizationPresent = calculateConfigCustomizations();
        notifyListeners(formatter.getFormattedDone() +
                formatter.getLineBreak());
      } catch (ApplicationException e) {
        LOG.log(Level.INFO,
                "Error calculating config customizations", e);
@@ -696,6 +718,8 @@
      try {
        setCurrentProgressStep(UpgradeProgressStep.BACKING_UP_DATABASES);
        backupDatabases();
        notifyListeners(formatter.getFormattedDone() +
                formatter.getLineBreak());
      } catch (ApplicationException e) {
        LOG.log(Level.INFO, "Error backing up databases", e);
        throw e;
@@ -704,6 +728,8 @@
      try {
        setCurrentProgressStep(UpgradeProgressStep.BACKING_UP_FILESYSTEM);
        backupFilesytem();
        notifyListeners(formatter.getFormattedDone() +
                formatter.getLineBreak());
      } catch (ApplicationException e) {
        LOG.log(Level.INFO, "Error backing up files", e);
        throw e;
@@ -725,6 +751,7 @@
      //*  The two steps following this step require
      //*  the server to be started 'in process'.
      // *******************************************
      if (schemaCustomizationPresent || configCustimizationPresent) {
      try {
        startServerWithoutConnectionHandlers();
      } catch (ApplicationException e) {
@@ -734,25 +761,33 @@
        throw e;
      }
        if (schemaCustomizationPresent) {
      try {
        setCurrentProgressStep(
                UpgradeProgressStep.APPLYING_SCHEMA_CUSTOMIZATIONS);
        applySchemaCustomizations();
            notifyListeners(formatter.getFormattedDone() +
                    formatter.getLineBreak());
      } catch (ApplicationException e) {
        LOG.log(Level.INFO,
                "Error applying schema customizations", e);
        throw e;
      }
        }
        if (configCustimizationPresent) {
      try {
        setCurrentProgressStep(
                UpgradeProgressStep.APPLYING_CONFIGURATION_CUSTOMIZATIONS);
        applyConfigurationCustomizations();
            notifyListeners(formatter.getFormattedDone() +
                    formatter.getLineBreak());
      } catch (ApplicationException e) {
        LOG.log(Level.INFO,
                "Error applying configuration customizations", e);
        throw e;
      }
        }
      try {
        getServerController().stopServerInProcess();
@@ -762,13 +797,13 @@
        throw new ApplicationException(ApplicationException.Type.BUG,
                "Error stopping server in process", t);
      }
      }
      // This allows you to test whether or not he upgrader can successfully
      // abort an upgrade once changes have been made to the installation
      // path's filesystem.
      if ("true".equals(
              System.getProperty(SYS_PROP_CREATE_ERROR)))
      {
              System.getProperty(SYS_PROP_CREATE_ERROR))) {
        throw new ApplicationException(
                null, "ARTIFICIAL ERROR FOR TESTING ABORT PROCESS", null);
      }
@@ -776,6 +811,8 @@
      try {
        setCurrentProgressStep(UpgradeProgressStep.VERIFYING);
        verifyUpgrade();
        notifyListeners(formatter.getFormattedDone() +
                formatter.getLineBreak());
      } catch (ApplicationException e) {
        LOG.log(Level.INFO,
                "Error verifying upgrade", e);
@@ -803,21 +840,28 @@
          ProgressStep lastProgressStep = getCurrentProgressStep();
          setCurrentProgressStep(UpgradeProgressStep.ABORT);
          abort(lastProgressStep);
          notifyListeners(formatter.getFormattedDone() +
                  formatter.getLineBreak());
        }
        setCurrentProgressStep(UpgradeProgressStep.CLEANUP);
        cleanup();
        notifyListeners(formatter.getFormattedDone() +
                formatter.getLineBreak());
        // Write a record in the log file indicating success/failure
        setCurrentProgressStep(UpgradeProgressStep.RECORDING_HISTORY);
        notifyListeners("See '" +
                Utils.getPath(getInstallation().getHistoryLogFile()) +
                "'" + formatter.getLineBreak());
        writeHistoricalRecord(historicalOperationId,
                getCurrentVersion(),
                getStagedVersion(),
                status,
                note);
        notifyListeners(formatter.getFormattedDone() +
                formatter.getLineBreak());
        notifyListeners("See '" +
                Utils.getPath(getInstallation().getHistoryLogFile()) +
                "' for upgrade history" + formatter.getLineBreak());
      } catch (ApplicationException e) {
        System.err.print("Error cleaning up after upgrade: " +
                e.getLocalizedMessage());
@@ -829,6 +873,7 @@
    // It would be nice if this were simpler.
    if (runException == null) {
      LOG.log(Level.INFO, "upgrade completed successfully");
      if (!Utils.isCli()) {
        notifyListenersOfLog();
@@ -841,7 +886,7 @@
        notifyListeners(null);
      } else {
        notifyListeners(getFinalSuccessMessage());
        notifyListeners(100, getFinalSuccessMessage());
        // Don't do this until we've printed out last message
        // as doing so tells the CLI that it is finished and
@@ -850,8 +895,12 @@
      }
    } else {
      LOG.log(Level.INFO, "upgrade completed with errors", runException);
      if (!Utils.isCli()) {
        notifyListeners(formatter.getFormattedError(runException, true));
        notifyListeners(100,
                getMsg(UpgradeProgressStep.FINISHED_WITH_ERRORS.
                        getSummaryMesssageKey()),
                formatter.getFormattedError(runException, true));
        notifyListenersOfLog();
        notifyListeners(null);
        setCurrentProgressStep(UpgradeProgressStep.FINISHED_WITH_ERRORS);
@@ -870,7 +919,7 @@
   */
  private void checkServerHealth() throws ApplicationException {
    Installation installation = getInstallation();
    ServerController control = new ServerController(this, installation);
    ServerController control = new ServerController(installation);
    try {
      if (installation.getStatus().isServerRunning()) {
        control.stopServer();
@@ -925,7 +974,7 @@
      File backupDirectory;
      try {
        backupDirectory = getFilesBackupDirectory();
        FileManager fm = new FileManager(this);
        FileManager fm = new FileManager();
        boolean restoreError = false;
        for (String fileName : backupDirectory.list()) {
          File f = new File(backupDirectory, fileName);
@@ -960,7 +1009,7 @@
  }
  private void verifyUpgrade() throws ApplicationException {
    ServerController sc = new ServerController(this);
    ServerController sc = new ServerController(getInstallation());
    OperationOutput op = sc.startServer();
    if (op.getErrors() != null) {
      throw new ApplicationException(ApplicationException.Type.APPLICATION,
@@ -1016,15 +1065,16 @@
  /**
   * Applies configuration or schema customizations.
   * NOTE: Assumes that the server is running in process.
   *
   * @param ldifFile LDIF file to apply
   * @throws IOException
   * @throws org.opends.server.util.LDIFException
   *
   * @throws ApplicationException
   */
  private void applyCustomizationLdifFile(File ldifFile)
          throws IOException, org.opends.server.util.LDIFException,
          ApplicationException
  {
          ApplicationException {
    try {
      org.opends.server.protocols.internal.InternalClientConnection cc =
              org.opends.server.protocols.internal.
@@ -1055,26 +1105,19 @@
          }
          if (rc.equals(org.opends.server.types.ResultCode.
                  SUCCESS)) {
            if (org.opends.server.core.DirectoryServer.checkSchema()) {
              notifyListeners(
                      getMsg("upgrade-mod",
                              modListToString(op.getModifications()))
                      + formatter.getLineBreak());
            } else {
              notifyListeners(
                      getMsg("upgrade-mod-no-schema",
                              modListToString(op.getModifications()))
                      + formatter.getLineBreak());
            LOG.log(Level.INFO, "processed server modification " +
                    (org.opends.server.core.DirectoryServer.checkSchema() ?
                            ":" : "(schema checking off):" +
                            modListToString(op.getModifications())));
            if (!org.opends.server.core.DirectoryServer.checkSchema()) {
              org.opends.server.core.DirectoryServer.setCheckSchema(true);
            }
          } else if (rc.equals(
                  org.opends.server.types.ResultCode.
                          ATTRIBUTE_OR_VALUE_EXISTS)) {
            // ignore this error
            notifyListeners(
                    getMsg("upgrade-mod-ignore",
                            modListToString(op.getModifications()))
                    + formatter.getLineBreak());
            LOG.log(Level.INFO, "ignoring attribute that already exists: " +
                    modListToString(op.getModifications()));
          } else {
            // report the error to the user
            StringBuilder error = op.getErrorMessage();
@@ -1150,7 +1193,7 @@
    try {
      File stageDir = getStageDirectory();
      File root = getInstallation().getRootDirectory();
      FileManager fm = new FileManager(this);
      FileManager fm = new FileManager();
      for (String fileName : stageDir.list()) {
        File f = new File(stageDir, fileName);
        fm.copyRecursively(f, root,
@@ -1163,9 +1206,13 @@
    }
  }
  private void calculateConfigCustomizations() throws ApplicationException {
  private boolean calculateConfigCustomizations() throws ApplicationException {
    boolean isCustom = false;
    try {
      if (getInstallation().getCurrentConfiguration().hasBeenModified()) {
        isCustom = true;
        LOG.log(Level.INFO, "Configuration contains customizations that will " +
                "be migrated");
        try {
          ldifDiff(getInstallation().getBaseConfigurationFile(),
                   getInstallation().getCurrentConfigurationFile(),
@@ -1176,9 +1223,7 @@
                  + e.getLocalizedMessage(), e);
        }
      } else {
        // TODO i18n
        notifyListeners("No configuration customizations to migrate" +
                formatter.getLineBreak());
        LOG.log(Level.INFO, "No configuration customizations to migrate");
      }
    } catch (IOException e) {
      // TODO i18n
@@ -1186,6 +1231,7 @@
              "Could not determine configuration modifications: " +
              e.getLocalizedMessage(), e);
    }
    return isCustom;
  }
  private void ldifDiff(File source, File target, File output)
@@ -1205,9 +1251,9 @@
    args.add("-S"); // single-value changes
    // TODO i18n
    notifyListeners(formatter.getFormattedWithPoints("Diff'ing " +
    LOG.log(Level.INFO, "Diff'ing " +
            Utils.getPath(source) + " with " +
            Utils.getPath(target)));
            Utils.getPath(target));
    int ret = org.opends.server.tools.LDIFDiff.mainDiff(
            args.toArray(new String[]{}), false);
@@ -1217,21 +1263,17 @@
              .append(ret)
              .append(" when invoked with args: ")
              .append(Utils.listToString(args, " "));
      notifyListeners(formatter.getLineBreak());
      throw ApplicationException.createFileSystemException(sb.toString(),
              null);
    } else {
      notifyListeners(formatter.getFormattedDone() + formatter.getLineBreak());
    }
  }
  private void calculateSchemaCustomizations() throws ApplicationException {
  private boolean calculateSchemaCustomizations() throws ApplicationException {
    boolean isCustom = false;
    if (getInstallation().getStatus().schemaHasBeenModified()) {
      // TODO i18n
      notifyListeners(
              "Schema contains customizations and needs to be migrated" +
              formatter.getLineBreak());
      isCustom = true;
      LOG.log(Level.INFO, "Schema contains customizations that will " +
              "be migrated");
      try {
        ldifDiff(getInstallation().getBaseSchemaFile(),
                 getInstallation().getSchemaConcatFile(),
@@ -1242,16 +1284,15 @@
                e.getLocalizedMessage(), e);
      }
    } else {
      // TODO i18n
      notifyListeners("No schema customizations to migrate" +
              formatter.getLineBreak());
      LOG.log(Level.INFO, "No schema customizations to migrate");
    }
    return isCustom;
  }
  private void backupFilesytem() throws ApplicationException {
    try {
      File filesBackupDirectory = getFilesBackupDirectory();
      FileManager fm = new FileManager(this);
      FileManager fm = new FileManager();
      File root = getInstallation().getRootDirectory();
      FileFilter filter = new UpgradeFileFilter(root);
      for (String fileName : root.list()) {
@@ -1306,7 +1347,7 @@
    File stagingDir = null;
    try {
      stagingDir = getStageDirectory();
      FileManager fm = new FileManager(this);
      FileManager fm = new FileManager();
      // Doing this seems to work better than just plain
      // old delete.  Note that on Windows there are file
@@ -1426,8 +1467,9 @@
  private void setCurrentProgressStep(UpgradeProgressStep step) {
    this.currentProgressStep = step;
    int progress = step.getProgress();
    String msg = getSummary(step);
    notifyListeners(getFormattedProgress(msg) + getLineBreak());
    notifyListeners(progress, getFormattedProgress(msg), msg);
  }
  private UpgraderCliHelper getCliHelper() {
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java
@@ -31,6 +31,8 @@
import org.opends.quicksetup.i18n.ResourceProvider;
import java.io.*;
import java.util.logging.Logger;
import java.util.logging.Level;
/**
 * Utility class for use by applications containing methods for managing
@@ -39,11 +41,22 @@
 */
public class FileManager {
  static private final Logger LOG =
          Logger.getLogger(FileManager.class.getName());
  private Application application = null;
  /**
   * Creates a new file manager.
   * @param app Application managing files.
   */
  public FileManager() {
    // do nothing;
  }
  /**
   * Creates a new file manager.
   * @param app Application managing files to which progress notifications
   * will be sent
   */
  public FileManager(Application app) {
    this.application = app;
@@ -208,9 +221,14 @@
    } else {
      // Just tell that the file/directory does not exist.
      String[] arg = {file.toString()};
      if (application != null) {
      application.notifyListeners(application.getFormattedWarning(
              getMsg("file-does-not-exist", arg)));
    }
      LOG.log(Level.INFO, "file '" + file.toString() + "' does not exist");
    }
  }
  /**
@@ -299,9 +317,13 @@
        if (!destination.exists()) {
          if (Utils.insureParentsExist(destination)) {
            if (application != null) {
            application.notifyListeners(application.getFormattedWithPoints(
                    getMsg("progress-copying-file", args)));
            }
            LOG.log(Level.INFO, "copying file '" +
                    objectFile.getAbsolutePath() + "' to '" +
                    destination.getAbsolutePath() + "'");
            try {
              FileInputStream fis = new FileInputStream(objectFile);
              FileOutputStream fos = new FileOutputStream(destination);
@@ -325,8 +347,10 @@
                }
              }
              if (application != null) {
              application.notifyListeners(application.getFormattedDone() +
                      application.getLineBreak());
              }
            } catch (Exception e) {
              String errMsg = getMsg("error-copying-file", args);
@@ -340,11 +364,16 @@
                    ApplicationException.Type.FILE_SYSTEM_ERROR, errMsg, null);
          }
        } else {
          LOG.log(Level.INFO, "Ignoring file '" +
                  objectFile.getAbsolutePath() + "' since '" +
                  destination.getAbsolutePath() + "' already exists");
          if (application != null) {
          application.notifyListeners(getMsg("info-ignoring-file", args) +
                  application.getLineBreak());
        }
      }
    }
    }
  }
@@ -382,6 +411,7 @@
      String[] arg = {file.getAbsolutePath()};
      boolean isFile = file.isFile();
      if (application != null) {
      if (isFile) {
        application.notifyListeners(application.getFormattedWithPoints(
                getMsg("progress-deleting-file", arg)));
@@ -389,6 +419,10 @@
        application.notifyListeners(application.getFormattedWithPoints(
                getMsg("progress-deleting-directory", arg)));
      }
      }
      LOG.log(Level.INFO, "deleting " +
              (isFile ? " file " : " directory ") +
              file.getAbsolutePath());
      boolean delete = false;
      /*
@@ -425,10 +459,12 @@
                ApplicationException.Type.FILE_SYSTEM_ERROR, errMsg, null);
      }
      if (application != null) {
      application.notifyListeners(application.getFormattedDone() +
              application.getLineBreak());
    }
  }
  }
  /**
   * A delete operation.
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
@@ -28,12 +28,15 @@
package org.opends.quicksetup.util;
import org.opends.quicksetup.*;
import org.opends.quicksetup.i18n.ResourceProvider;
import org.opends.quicksetup.installer.InstallerHelper;
import javax.naming.NamingException;
import java.util.ArrayList;
import java.util.Map;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
@@ -43,6 +46,9 @@
 */
public class ServerController {
  static private final Logger LOG =
          Logger.getLogger(ServerController.class.getName());
  private Application application;
  private Installation installation;
@@ -57,15 +63,21 @@
  }
  /**
   * Creates a new instance that will operate on <code>application</code>'s
   * installation.
   * @param installation representing the server instance to control
   */
  public ServerController(Installation installation) {
    this(null, installation);
  }
  /**
   * Creates a new instance that will operate on <code>installation</code>
   * and use <code>application</code> for notifications.
   * @param application to use for notifications
   * @param installation representing the server instance to control
   */
  public ServerController(Application application, Installation installation) {
    if (application == null) {
      throw new NullPointerException("application cannot be null");
    }
    if (installation == null) {
      throw new NullPointerException("installation cannot be null");
    }
@@ -79,10 +91,13 @@
   * @throws org.opends.quicksetup.ApplicationException if something goes wrong.
   */
  public void stopServer() throws ApplicationException {
    if (application != null) {
    application.notifyListeners(
            application.getFormattedProgress(
                    application.getMsg("progress-stopping")) +
                    application.getLineBreak());
    }
    LOG.log(Level.INFO, "stopping server");
    ArrayList<String> argList = new ArrayList<String>();
    argList.add(Utils.getPath(installation.getServerStopCommandFile()));
@@ -131,11 +146,15 @@
            stopped = !CurrentInstallStatus.isServerRunning(
                    installation.getLocksDirectory());
            if (!stopped) {
              if (application != null) {
              String msg =
                      application.getFormattedLog(
                        application.getMsg("progress-server-waiting-to-stop")) +
                                application.getMsg(
                                        "progress-server-waiting-to-stop")) +
                        application.getLineBreak();
              application.notifyListeners(msg);
              }
              LOG.log(Level.FINE, "waiting for server to stop");
              try {
                Thread.sleep(5000);
              }
@@ -151,36 +170,38 @@
      }
      if (returnValue == clientSideError) {
        if (application != null) {
        String msg = application.getLineBreak() +
                application.getFormattedLog(
                        application.getMsg("progress-server-already-stopped")) +
                          application.getMsg(
                                  "progress-server-already-stopped")) +
                    application.getLineBreak();
        application.notifyListeners(msg);
        }
        LOG.log(Level.INFO, "server already stopped");
      } else if (returnValue != 0) {
        String[] arg = {String.valueOf(returnValue)};
        String msg = application.getMsg("error-stopping-server-code", arg);
        /*
         * The return code is not the one expected, assume the server could
         * not be stopped.
         */
        throw new ApplicationException(ApplicationException.Type.STOP_ERROR,
                msg,
                ResourceProvider.getInstance().getMsg(
                        "error-stopping-server-code",
                        String.valueOf(returnValue)),
                null);
      } else {
        if (application != null) {
        String msg = application.getFormattedLog(
                application.getMsg("progress-server-stopped"));
        application.notifyListeners(msg);
      }
    } catch (IOException ioe) {
      throw new ApplicationException(ApplicationException.Type.STOP_ERROR,
              application.getThrowableMsg("error-stopping-server", ioe), ioe);
        LOG.log(Level.INFO, "server stopped");
    }
    catch (InterruptedException ie) {
      throw new ApplicationException(ApplicationException.Type.BUG,
              application.getThrowableMsg("error-stopping-server", ie), ie);
    } catch (Exception e) {
      throw new ApplicationException(ApplicationException.Type.STOP_ERROR,
              getThrowableMsg("error-stopping-server", e), e);
    }
  }
@@ -245,10 +266,13 @@
          throws ApplicationException
  {
    OperationOutput output = new OperationOutput();
    if (application != null) {
    application.notifyListeners(
            application.getFormattedProgress(
                    application.getMsg("progress-starting")) +
        application.getLineBreak());
    }
    LOG.log(Level.INFO, "starting server");
    ArrayList<String> argList = new ArrayList<String>();
    argList.add(Utils.getPath(installation.getServerStartCommandFile()));
@@ -331,15 +355,18 @@
         * Try 5 times with an interval of 1 second between try.
         */
        boolean connected = false;
        Configuration config =
                application.getInstallation().getCurrentConfiguration();
        Configuration config = installation.getCurrentConfiguration();
        int port = config.getPort();
        String ldapUrl = "ldap://localhost:" + port;
        // See if the application has prompted for credentials.  If
        // not we'll just try to connect anonymously.
        String userDn = application.getUserData().getDirectoryManagerDn();
        String userPw = application.getUserData().getDirectoryManagerPwd();
        String userDn = null;
        String userPw = null;
        if (application != null) {
          userDn = application.getUserData().getDirectoryManagerDn();
          userPw = application.getUserData().getDirectoryManagerPwd();
        }
        if (userDn == null || userPw == null) {
          userDn = null;
          userPw = null;
@@ -370,20 +397,21 @@
        }
        if (!connected)
        {
          String[] arg = {String.valueOf(port)};
          if (Utils.isWindows())
          {
            throw new ApplicationException(
                ApplicationException.Type.START_ERROR,
                application.getMsg("error-starting-server-in-windows", arg),
                    getMsg("error-starting-server-in-windows",
                            String.valueOf(port)),
                    null);
          }
          else
          {
            throw new ApplicationException(
                ApplicationException.Type.START_ERROR,
                application.getMsg("error-starting-server-in-unix", arg), null);
                    getMsg("error-starting-server-in-unix",
                            String.valueOf(port)),
                    null);
          }
        }
      }
@@ -391,7 +419,8 @@
    } catch (IOException ioe)
    {
      throw new ApplicationException(ApplicationException.Type.START_ERROR,
          application.getThrowableMsg("error-starting-server", ioe), ioe);
              getThrowableMsg("error-starting-server", ioe),
              ioe);
    }
    return output;
  }
@@ -421,7 +450,7 @@
    directoryServer.bootstrapServer();
    String configClass = "org.opends.server.extensions.ConfigFileHandler";
    String configPath = Utils.getPath(
            application.getInstallation().getCurrentConfigurationFile());
            installation.getCurrentConfigurationFile());
    directoryServer.initializeConfiguration(configClass, configPath);
    directoryServer.startServer();
  }
@@ -444,17 +473,18 @@
     * @param isError a boolean indicating whether the BufferedReader
     *        corresponds to the standard error or to the standard output.
     */
    public StopReader(final BufferedReader reader, final boolean isError) {
    public StopReader(final BufferedReader reader,
                                      final boolean isError) {
      final String errorTag =
              isError ? "error-reading-erroroutput" : "error-reading-output";
      isFirstLine = true;
      Thread t = new Thread(new Runnable() {
        public void run() {
          try {
            String line = reader.readLine();
            while (line != null) {
              if (application != null) {
              StringBuilder buf = new StringBuilder();
              if (!isFirstLine) {
                buf.append(application.getProgressMessageFormatter().
@@ -467,17 +497,17 @@
              }
              application.notifyListeners(buf.toString());
              isFirstLine = false;
              }
              LOG.log(Level.INFO, "server: " + line);
              line = reader.readLine();
            }
          } catch (IOException ioe) {
            String errorMsg = application.getThrowableMsg(errorTag, ioe);
            application.notifyListeners(errorMsg);
          } catch (Throwable t) {
            if (application != null) {
            String errorMsg = application.getThrowableMsg(errorTag, t);
            application.notifyListeners(errorMsg);
          }
            LOG.log(Level.INFO, "error reading server messages",t);
          }
        }
      });
      t.start();
@@ -537,6 +567,7 @@
            String line = reader.readLine();
            while (line != null)
            {
              if (application != null) {
              StringBuffer buf = new StringBuffer();
              if (!isFirstLine)
              {
@@ -552,7 +583,8 @@
              }
              application.notifyListeners(buf.toString());
              isFirstLine = false;
              }
              LOG.log(Level.INFO, "server: " + line);
              if (line.indexOf("id=" + startedId) != -1)
              {
                isFinished = true;
@@ -569,19 +601,12 @@
              line = reader.readLine();
            }
          } catch (IOException ioe)
          {
            String errorMsg = application.getThrowableMsg(errorTag, ioe);
            ex =
                new ApplicationException(ApplicationException.Type.START_ERROR,
                    errorMsg, ioe);
          } catch (Throwable t)
          {
            String errorMsg = application.getThrowableMsg(errorTag, t);
            ex =
                new ApplicationException(ApplicationException.Type.START_ERROR,
                    errorMsg, t);
                    getThrowableMsg(errorTag, t), t);
          }
          isFinished = true;
        }
@@ -616,4 +641,17 @@
    }
  }
  private String getMsg(String key) {
    return ResourceProvider.getInstance().getMsg(key);
  }
  private String getMsg(String key, String... args) {
    return ResourceProvider.getInstance().getMsg(key, args);
  }
  private String getThrowableMsg(String key, Throwable t) {
    return Utils.getThrowableMsg(ResourceProvider.getInstance(),
            key, null, t);
  }
}
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java
@@ -37,6 +37,8 @@
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
 * Class for extracting the contents of a zip file and managing
@@ -44,6 +46,9 @@
 */
public class ZipExtractor {
  static private final Logger LOG =
          Logger.getLogger(ZipExtractor.class.getName());
  private InputStream is;
  private int minRatio;
  private int maxRatio;
@@ -54,6 +59,18 @@
  /**
   * Creates an instance of an ZipExtractor.
   * @param zipFile File the zip file to extract
   * @throws FileNotFoundException if the specified file does not exist
   * @throws IllegalArgumentException if the zip file is not a zip file
   */
  public ZipExtractor(File zipFile)
    throws FileNotFoundException, IllegalArgumentException
  {
    this(zipFile, 0, 0, 1, null);
  }
  /**
   * Creates an instance of an ZipExtractor.
   * @param zipFile File the zip file to extract
   * @param minRatio int indicating the max ration
   * @param maxRatio int indicating the min ration
   * @param numberZipEntries number of entries in the input stream
@@ -146,7 +163,7 @@
          try
          {
            copyZipEntry(entry, destination, zipFirstPath, zipIn,
            ratioBeforeCompleted, ratioWhenCompleted, permissions, application);
            ratioBeforeCompleted, ratioWhenCompleted, permissions);
          } catch (IOException ioe)
          {
@@ -219,13 +236,11 @@
   * copied.
   * @param permissions an ArrayList with permissions whose contents will be
   * updated.
   * @param app Application to be notified about progress
   * @throws IOException if an error occurs.
   */
  private void copyZipEntry(ZipEntry entry, String basePath,
      String zipFirstPath, ZipInputStream is, int ratioBeforeCompleted,
      int ratioWhenCompleted, Map<String, ArrayList<String>> permissions,
      Application app)
      int ratioWhenCompleted, Map<String, ArrayList<String>> permissions)
      throws IOException
  {
    String entryName = entry.getName();
@@ -235,10 +250,13 @@
      entryName = entryName.substring(zipFirstPath.length());
    }
    File path = new File(basePath, entryName);
    if (application != null) {
    String progressSummary =
            ResourceProvider.getInstance().getMsg("progress-extracting",
                    new String[]{ Utils.getPath(path) });
    app.notifyListeners(ratioBeforeCompleted, progressSummary);
      application.notifyListeners(ratioBeforeCompleted, progressSummary);
    }
    LOG.log(Level.INFO, "extracting " + Utils.getPath(path));
    if (Utils.insureParentsExist(path))
    {
      if (entry.isDirectory())
@@ -272,8 +290,10 @@
    {
      throw new IOException("Could not create parent path: " + path);
    }
    if (application != null) {
    application.notifyListenersDone(ratioWhenCompleted);
  }
  }
  /**
   * Returns the file system permissions for a directory.
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/i18n/ResourceProvider.java
@@ -129,7 +129,7 @@
   * @throws IllegalArgumentException if the key could not be found in the
   * properties file.
   */
  public String getMsg(String key, String[] args)
  public String getMsg(String key, String... args)
  throws IllegalArgumentException
  {
    String msg;