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

Violette Roche-Montane
02.34.2013 062a0efc5af3f00d411ee9032741490a813de51f
CR-2635 Second fix for OpenDJ-1196. As an issue was find by Christophe when template 02-config was deleted, added a check on template existence before copying it.
- Added i18n/path in messages.
- Added message ouput for post upgrade task.
- Moved temp file creation as it leaves .temp files in schema folder when upgrade fails.
5 files modified
50 ■■■■ changed files
opends/src/messages/messages/tools.properties 1 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/FileManager.java 15 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/Upgrade.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java 15 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java 17 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/tools.properties
@@ -2551,6 +2551,7 @@
INFO_UPGRADE_REBUILD_INDEX_ARGUMENTS_1847=The rebuild index tool arguments are %s
INFO_UPGRADE_REBUILD_ALL_1848=Rebuilding all indexes
INFO_UPGRADE_PROCESS_END_1849=End of the upgrade process
SEVERE_ERR_UPGRADE_CORRUPTED_TEMPLATE_1850='%s' is missing or empty, it is probably corrupted
# Upgrade tasks
INFO_UPGRADE_TASK_6869_SUMMARY_10000=Fixing de-DE collation matching rule OID
opends/src/server/org/opends/server/tools/upgrade/FileManager.java
@@ -40,7 +40,6 @@
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.logging.Logger;
@@ -353,7 +352,7 @@
     */
    public void apply() throws IOException
    {
      File objectFile = getObjectFile();
      final File objectFile = getObjectFile();
      if (objectFile.isDirectory())
      {
        if (!destination.exists())
@@ -363,7 +362,6 @@
      }
      else
      {
        // If overwriting and the destination exists then kill it
        if (destination.exists() && overwrite)
        {
@@ -383,7 +381,7 @@
            {
              fis = new FileInputStream(objectFile);
              fos = new FileOutputStream(destination);
              byte[] buf = new byte[1024];
              final byte[] buf = new byte[1024];
              int i;
              while ((i = fis.read(buf)) != -1)
              {
@@ -395,22 +393,21 @@
                // Java 1.6 but until then use the TestUtilities methods
                if (UpgradeUtils.isUnix())
                {
                  FilePermission permissions =
                  final FilePermission permissions =
                      getFileSystemPermissions(objectFile);
                  FilePermission.setPermissions(destination, permissions);
                }
              }
            }
            catch (FileNotFoundException e)
            catch (IOException e)
            {
              throw new IOException(e.getMessage());
              throw e;
            }
            catch (Exception e)
            {
              final Message errMsg = INFO_ERROR_COPYING_FILE.get(
                  objectFile.getAbsolutePath(), destination.getAbsolutePath());
              throw new IOException(errMsg.toString());
              throw new IOException(errMsg.toString(), e);
            }
            finally
            {
opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
@@ -478,7 +478,7 @@
        }
        catch (ClientException e)
        {
          LOG.log(Level.SEVERE, e.getMessage());
          context.notify(e.getMessageObject(), WARNING);
          isOk = false;
        }
      }
opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -151,7 +151,11 @@
        try
        {
          context.notifyProgress(pnc.setProgress(20));
          if (!schemaFileTemplate.exists() || schemaFileTemplate.length() == 0)
          {
            throw new IOException(ERR_UPGRADE_CORRUPTED_TEMPLATE
                .get(schemaFileTemplate.getPath()).toString());
          }
          copy(schemaFileTemplate, configSchemaDirectory, true);
          context.notifyProgress(pnc.setProgress(100));
        }
@@ -487,9 +491,8 @@
        // Requires answer from the user.
        final int answer = context.confirmYN(summary, ConfirmationCallback.NO);
        isATaskToPerform = (answer == ConfirmationCallback.YES);
        isRebuildAllIndexesIsPresent =  true;
        isRebuildAllIndexesTaskAccepted =  isATaskToPerform;
        isRebuildAllIndexesIsPresent = true;
        isRebuildAllIndexesTaskAccepted = isATaskToPerform;
      }
      @Override
@@ -650,9 +653,9 @@
        }
        else
        {
          LOG.log(Level.SEVERE, ERR_UPGRADE_PERFORMING_POST_TASKS_FAIL.get()
              .toString());
          final Message msg = ERR_UPGRADE_PERFORMING_POST_TASKS_FAIL.get();
          context.notifyProgress(pnc.setProgress(-100));
          throw new ClientException(EXIT_CODE_ERROR, msg);
        }
      }
    };
opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
@@ -53,6 +53,7 @@
import static org.opends.messages.ConfigMessages.INFO_CONFIG_FILE_HEADER;
import static org.opends.messages.ToolMessages.ERR_UPGRADE_UNKNOWN_OC_ATT;
import static org.opends.messages.ToolMessages.ERR_UPGRADE_CORRUPTED_TEMPLATE;
import static org.opends.server.tools.upgrade.FileManager.deleteRecursively;
import static org.opends.server.tools.upgrade.FileManager.rename;
import static org.opends.server.tools.upgrade.Installation.*;
@@ -579,9 +580,7 @@
    LDIFEntryReader reader = null;
    BufferedReader br = null;
    FileWriter fw = null;
    final File copy =
        File.createTempFile("copySchema", ".tmp",
            destination.getParentFile());
    File copy = null;
    try
    {
      reader = new LDIFEntryReader(new FileInputStream(templateFile));
@@ -589,8 +588,8 @@
      if (!reader.hasNext())
      {
        // Unless template are corrupted, this should not happen.
        throw new IOException(String.format(
            "'%s' file is empty. Template corrupted.", templateFile.getName()));
        throw new IOException(ERR_UPGRADE_CORRUPTED_TEMPLATE.get(
            templateFile.getPath()).toString());
      }
      final LinkedList<String> definitionsList = new LinkedList<String>();
@@ -640,7 +639,9 @@
      }
      // Then, open the destination file and write the new attribute
      // or objectClass definitions
      copy =
          File.createTempFile("copySchema", ".tmp",
              destination.getParentFile());
      br = new BufferedReader(new FileReader(destination));
      fw = new FileWriter(copy);
      String line = br.readLine();
@@ -743,7 +744,7 @@
        File parentDirectory = destination.getParentFile();
        if (!parentDirectory.exists())
        {
          LOG.log(Level.INFO, String.format("File %s's parent doesn't exist",
          LOG.log(Level.INFO, String.format("Parent file of %s doesn't exist",
              destination.getPath()));
          parentDirectory.mkdirs();
@@ -763,7 +764,7 @@
        writer.writeEntry(theNewSchemaEntry);
        LOG.log(Level.INFO, String.format(
            "%s file created and completed successfully.", destination
            "%s created and completed successfully.", destination
                .getAbsolutePath()));
      }
    }