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

Matthew Swift
09.12.2015 f2ed2687b95fc639e35208731e0968957b9204f6
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -737,6 +737,37 @@
    };
  }
  /**
   * Removes the specified file from the file-system.
   *
   * @param file
   *          The file to be removed.
   * @return An upgrade task which removes the specified file from the file-system.
   */
  public static UpgradeTask deleteFile(final File file)
  {
    return new AbstractUpgradeTask()
    {
      @Override
      public void perform(UpgradeContext context) throws ClientException
      {
        LocalizableMessage msg = UPGRADE_TASK_DELETE_FILE.get(file);
        ProgressNotificationCallback pnc = new ProgressNotificationCallback(0, msg, 0);
        context.notifyProgress(pnc);
        try
        {
          FileManager.deleteRecursively(file);
          context.notifyProgress(pnc.setProgress(100));
        }
        catch (Exception e)
        {
          logger.error(LocalizableMessage.raw(e.getMessage()));
          context.notifyProgress(pnc.setProgress(-1));
        }
      }
    };
  }
  private static void displayChangeCount(final String fileName,
      final int changeCount)
  {