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

jvergara
22.52.2007 34eeb0f7371dcd4fb24dae2c25918a96d9a65f32
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/MigrationManager.java
@@ -38,6 +38,7 @@
import org.opends.quicksetup.Constants;
import org.opends.quicksetup.util.ExternalTools;
import org.opends.quicksetup.util.FileManager;
import org.opends.quicksetup.util.Utils;
import org.opends.quicksetup.util.OperationOutput;
import org.opends.quicksetup.util.InProcessServerController;
@@ -184,6 +185,59 @@
  }
  /**
   * Tells whether the ADS backend file must be migrated or not.
   * This method assumes that the ADS backend file in the original install
   * has not been overwritten.
   * @return <CODE>true</CODE> if the tools properties file must be migrated
   * and <CODE>false</CODE> otherwise.
   * @throws IOException if there is an error accessing the installation
   * information.
   */
  public boolean mustMigrateADS() throws IOException {
    return !installation.getADSBackendFile().exists();
  }
  /**
   * Migrates the ADS backend file.
   * @param newADSFile the new ADS backend file.
   * @throws ApplicationException if there is an error copying the new
   * ADS backend file.
   */
  public void migrateADS(File newADSFile) throws ApplicationException
  {
    FileManager fileManager = new FileManager();
    fileManager.copy(newADSFile, installation.getConfigurationDirectory(),
        true);
  }
  /**
   * Tells whether the tools properties file must be migrated or not.
   * This method assumes that the tools properties file in the original install
   * has not been overwritten.
   * @return <CODE>true</CODE> if the tools properties file must be migrated
   * and <CODE>false</CODE> otherwise.
   */
  public boolean mustMigrateToolProperties()
  {
   return !installation.getToolsPropertiesFile().exists();
  }
  /**
   * Migrates the tools properties file.
   * @param newPropertiesFile the new properties file.
   * @throws ApplicationException if there is an error copying the new
   * properties file.
   */
  public void migrateToolPropertiesFile(File newPropertiesFile)
  throws ApplicationException
  {
    FileManager fileManager = new FileManager();
    fileManager.copy(newPropertiesFile,
        installation.getConfigurationDirectory(), true);
  }
  /**
   * Migrates a schema using the diff file generated by a call
   * to {@link MigrationManager#calculateSchemaCustomizations()}.
   * @throws ApplicationException if there is an error migrating the
@@ -223,7 +277,7 @@
   * {@link #calculateConfigCustomizations()} must first be made in
   * order for this value to be valid.
   *
   * @return boolean where true indicates schema customization
   * @return boolean where true indicates configuration customization
   * @throws java.io.IOException if there was a problem reading the
   *         current configuration file.
   */
@@ -231,6 +285,7 @@
    return installation.getCurrentConfiguration().hasBeenModified();
  }
  /**
   * Applies modifications contained in an LDIF file to the server.
   *
@@ -301,32 +356,82 @@
  private Message getModificationErrorMessage(ChangeRecordEntry cre) {
    MessageBuilder msg = new MessageBuilder();
    msg.append(Constants.HTML_LINE_BREAK);
    if (Utils.isCli())
    {
      msg.append(Constants.LINE_SEPARATOR);
    }
    else
    {
      msg.append(Constants.HTML_LINE_BREAK);
    }
    if (cre != null) {
      switch (cre.getChangeOperationType()) {
        case MODIFY:
          msg.append(INFO_ERROR_UPGRADE_MIGRATION_MODIFY.get(
                  cre.getDN().toNormalizedString()));
          if (Utils.isCli())
          {
            msg.append(INFO_ERROR_UPGRADE_MIGRATION_MODIFY_CLI.get(
                cre.getDN().toNormalizedString()));
          }
          else
          {
            msg.append(INFO_ERROR_UPGRADE_MIGRATION_MODIFY.get(
                cre.getDN().toNormalizedString()));
          }
          break;
        case ADD:
          msg.append(INFO_ERROR_UPGRADE_MIGRATION_ADD.get(
                  cre.getDN().toNormalizedString()));
          if (Utils.isCli())
          {
            msg.append(INFO_ERROR_UPGRADE_MIGRATION_ADD_CLI.get(
                cre.getDN().toNormalizedString()));
          }
          else
          {
            msg.append(INFO_ERROR_UPGRADE_MIGRATION_ADD.get(
                cre.getDN().toNormalizedString()));
          }
          break;
        case DELETE:
          msg.append(INFO_ERROR_UPGRADE_MIGRATION_DELETE.get(
                  cre.getDN().toNormalizedString()));
          if (Utils.isCli())
          {
            msg.append(INFO_ERROR_UPGRADE_MIGRATION_DELETE_CLI.get(
                cre.getDN().toNormalizedString()));
          }
          else
          {
            msg.append(INFO_ERROR_UPGRADE_MIGRATION_DELETE.get(
                cre.getDN().toNormalizedString()));
          }
          break;
        default:
          LOG.log(Level.INFO, "Unexpected change operation type " +
                cre.getChangeOperationType());
              cre.getChangeOperationType());
        if (Utils.isCli())
        {
          msg.append(INFO_ERROR_UPGRADE_MIGRATION_UNEXPECTED_CLI.get(
              cre.getDN().toNormalizedString()));
        }
        else
        {
          msg.append(INFO_ERROR_UPGRADE_MIGRATION_UNEXPECTED.get(
                  cre.getDN().toNormalizedString()));
          break;
              cre.getDN().toNormalizedString()));
        }
        break;
      }
    }
    msg.append(Constants.HTML_LINE_BREAK);
    msg.append(Constants.HTML_LINE_BREAK);
    msg.append(INFO_ERROR_UPGRADE_MIGRATION_NOTE.get(Utils.getPath(backupDir)));
    if (Utils.isCli())
    {
      msg.append(Constants.LINE_SEPARATOR);
      msg.append(Constants.LINE_SEPARATOR);
      msg.append(INFO_ERROR_UPGRADE_MIGRATION_NOTE_CLI.get(
          Utils.getPath(backupDir)));
    }
    else
    {
      msg.append(Constants.HTML_LINE_BREAK);
      msg.append(Constants.HTML_LINE_BREAK);
      msg.append(INFO_ERROR_UPGRADE_MIGRATION_NOTE.get(
          Utils.getPath(backupDir)));
    }
    return msg.toMessage();
  }
@@ -355,4 +460,7 @@
    return new File(backupDir, "schema.custom.diff");
  }
  private File getCustomADSDiffFile() throws IOException {
    return new File(backupDir, "admin-backend.custom.diff");
  }
}