From cb4fffb7bf1f9de28183fe58376f5762b1e45cf9 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 20 Apr 2007 15:09:47 +0000
Subject: [PATCH] Fix for issue 1494: web start installer provides the option to create non-existent install path. 

---
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
index 8d16069..f1901dc 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
@@ -28,6 +28,7 @@
 package org.opends.quicksetup.installer.webstart;
 
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
 import java.util.ArrayList;
@@ -111,6 +112,7 @@
       notifyListeners(getTaskSeparator());
 
       status = InstallProgressStep.EXTRACTING;
+      createParentDirectoryIfRequired();
       extractZipFiles(in, getRatio(InstallProgressStep.EXTRACTING),
           getRatio(InstallProgressStep.CONFIGURING_SERVER));
       notifyListeners(getTaskSeparator());
@@ -360,6 +362,37 @@
   }
 
   /**
+   * Creates the parent Directory for the server location if it does not exist.
+   * @throws QuickSetupException if something goes wrong.
+   */
+  private void createParentDirectoryIfRequired() throws QuickSetupException
+  {
+    String serverLocation = getUserData().getServerLocation();
+    if (!Utils.parentDirectoryExists(serverLocation))
+    {
+      File f = new File(serverLocation);
+      String parent = f.getParent();
+      try
+      {
+        if (!Utils.createDirectory(parent))
+        {
+          throw new QuickSetupException(
+              QuickSetupException.Type.FILE_SYSTEM_ERROR,
+              getMsg("error-could-not-create-parent-dir",
+                  new String[] {parent}), null);
+        }
+      }
+      catch (IOException ioe)
+      {
+        throw new QuickSetupException(
+            QuickSetupException.Type.FILE_SYSTEM_ERROR,
+            getMsg("error-could-not-create-parent-dir", new String[] {parent}),
+            ioe);
+      }
+    }
+  }
+
+  /**
    * This method extracts the zip file.
    * @param is the inputstream with the contents of the zip file.
    * @param minRatio the value of the ratio in the install that corresponds to

--
Gitblit v1.10.0