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

jvergara
12.35.2009 24fc3f1bec00d45b2950774b88940a5f558f763b
Frontport of fix for issue 4047 ( Uninstall deletes systematically resources and classes directories).
2 files modified
63 ■■■■■ changed files
opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java 39 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/Installation.java 24 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
@@ -649,14 +649,31 @@
    Message successMsg;
    Installation installation = getInstallation();
    String libPath = getPath(installation.getLibrariesDirectory());
    String resourcesPath = getPath(installation.getResourcesDirectory());
    String classesPath = getPath(installation.getClassesDirectory());
    boolean resourcesDefined =
     Utils.directoryExistsAndIsNotEmpty(resourcesPath);
    boolean classesDefined =
      Utils.directoryExistsAndIsNotEmpty(classesPath);
    ArrayList<String> paths = new ArrayList<String>();
    paths.add(libPath);
    if (resourcesDefined)
    {
      paths.add(resourcesPath);
    }
    if (classesDefined)
    {
      paths.add(classesPath);
    }
    if (isCli()) {
      if (getUninstallUserData().getRemoveLibrariesAndTools()) {
        String arg;
        if (isWindows()) {
          arg = installation.getUninstallBatFile() + getLineBreak().toString() +
                  getTab() + libPath;
                  getTab() + getStringFromCollection(paths,
                      getLineBreak().toString());
        } else {
          arg = libPath;
          arg = getStringFromCollection(paths, getLineBreak().toString());
        }
        successMsg =
                INFO_SUMMARY_UNINSTALL_FINISHED_SUCCESSFULLY_REMOVE_JARFILES_CLI
@@ -668,7 +685,7 @@
      if (getUninstallUserData().getRemoveLibrariesAndTools()) {
        successMsg =
                INFO_SUMMARY_UNINSTALL_FINISHED_SUCCESSFULLY_REMOVE_JARFILES
                        .get(libPath);
            .get(getStringFromCollection(paths, getLineBreak().toString()));
      } else {
        successMsg = INFO_SUMMARY_UNINSTALL_FINISHED_SUCCESSFULLY.get();
      }
@@ -1376,10 +1393,16 @@
    File quicksetupFile = installation.getQuicksetupJarFile();
    File openDSFile = installation.getOpenDSJarFile();
    File librariesFile = installation.getLibrariesDirectory();
    File activationFile = new File(librariesFile, "activation.jar");
    File aspectRuntimeFile = new File(librariesFile, "aspectjrt.jar");
    File resourcesDir = installation.getResourcesDirectory();
    File classesDir = installation.getClassesDirectory();
    File uninstallBatFile = installation.getUninstallBatFile();
    boolean canDeleteResourcesDir =
      !Utils.directoryExistsAndIsNotEmpty(resourcesDir.getAbsolutePath());
    boolean canDeleteClassesDir =
      !Utils.directoryExistsAndIsNotEmpty(classesDir.getAbsolutePath());
    File installationPath = installation.getRootDirectory();
    /**
@@ -1390,6 +1413,8 @@
      boolean[] uData = {
              userData.getRemoveLibrariesAndTools(),
              userData.getRemoveLibrariesAndTools(),
              userData.getRemoveLibrariesAndTools(),
              userData.getRemoveLibrariesAndTools(),
              userData.getRemoveDatabases(),
              userData.getRemoveLogs(),
              userData.getRemoveConfigurationAndSchema(),
@@ -1403,6 +1428,8 @@
        File[] tmp  = {
              installation.getLibrariesDirectory().getCanonicalFile(),
              installation.getBinariesDirectory().getCanonicalFile(),
              installation.getResourcesDirectory().getCanonicalFile(),
              installation.getClassesDirectory().getCanonicalFile(),
              installation.getDatabasesDirectory().getCanonicalFile(),
              installation.getLogsDirectory().getCanonicalFile(),
              installation.getConfigurationDirectory().getCanonicalFile(),
@@ -1419,6 +1446,8 @@
      boolean accept =
              !installationPath.equals(file)
                      && !equalsOrDescendant(file, librariesFile)
        && (canDeleteClassesDir  || !equalsOrDescendant(file, classesDir))
        && (canDeleteResourcesDir || !equalsOrDescendant(file, resourcesDir))
                      && !quicksetupFile.equals(file)
                      && !openDSFile.equals(file);
opends/src/quicksetup/org/opends/quicksetup/Installation.java
@@ -77,6 +77,12 @@
    SetupUtils.LIBRARIES_PATH_RELATIVE;
  /**
   * The relative path where the resources directory (to customize the product)
   * is.
   */
  public static final String RESOURCES_PATH_RELATIVE = "resources";
  /**
   * The relative path where customer classes are.
   */
  public static final String CLASSES_PATH_RELATIVE = "classes";
@@ -676,6 +682,24 @@
  }
  /**
   * Returns the path to the resources directory.
   *
   * @return the path to the resources directory.
   */
  public File getResourcesDirectory() {
    return new File(getRootDirectory(), RESOURCES_PATH_RELATIVE);
  }
  /**
   * Returns the path to the classes directory.
   *
   * @return the path to the classes directory.
   */
  public File getClassesDirectory() {
    return new File(getRootDirectory(), CLASSES_PATH_RELATIVE);
  }
  /**
   * Returns the path to the tools properties file.
   *
   * @return the path to the tools properties file.