From 9ff775c3cb78c7cc6c51027b1d9d7cf2ff448f98 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 30 Apr 2007 13:10:57 +0000
Subject: [PATCH] Refactor some code:

---
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java |   41 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java
index 48c8fe5..52842d1 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java
@@ -28,12 +28,15 @@
 package org.opends.quicksetup.ui;
 
 import org.opends.quicksetup.*;
+import org.opends.quicksetup.util.ServerController;
 import org.opends.quicksetup.webstart.WebStartDownloader;
 
 import javax.swing.*;
 import java.awt.event.WindowEvent;
+import java.io.IOException;
 import java.util.LinkedHashSet;
 import java.util.Set;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 /**
@@ -390,10 +393,10 @@
    * process, then maxRatio will be 25.  When the download is complete this
    * method will send a notification to the ProgressUpdateListeners with a ratio
    * of 25 %.
-   * @throws org.opends.quicksetup.QuickSetupException if something goes wrong
+   * @throws org.opends.quicksetup.ApplicationException if something goes wrong
    *
    */
-  protected void waitForLoader(Integer maxRatio) throws QuickSetupException {
+  protected void waitForLoader(Integer maxRatio) throws ApplicationException {
     int lastPercentage = -1;
     WebStartDownloader.Status lastStatus =
       WebStartDownloader.Status.DOWNLOADING;
@@ -455,4 +458,38 @@
   public int getExtraDialogHeight() {
     return 0;
   }
+
+  /**
+   * Starts the server to be able to update its configuration but not allowing
+   * it to listen to external connections.
+   * @throws ApplicationException if the server could not be started.
+   */
+  protected void startServerWithoutConnectionHandlers()
+  throws ApplicationException {
+    try {
+      ServerController control = new ServerController(this);
+      if (getInstallation().getStatus().isServerRunning()) {
+        control.stopServer();
+      }
+      control.startServerInProcess(true);
+    } catch (IOException e) {
+      String msg = "Failed to determine server state: " +
+      e.getLocalizedMessage();
+      LOG.log(Level.INFO, msg, e);
+      throw new ApplicationException(ApplicationException.Type.IMPORT_ERROR,
+          msg, e);
+    } catch (org.opends.server.types.InitializationException e) {
+      String msg = "Failed to start server due to initialization error:" +
+      e.getLocalizedMessage();
+      LOG.log(Level.INFO, msg, e);
+      throw new ApplicationException(ApplicationException.Type.IMPORT_ERROR,
+          msg, e);
+    } catch (org.opends.server.config.ConfigException e) {
+      String msg = "Failed to start server due to configuration error: " +
+      e.getLocalizedMessage();
+      LOG.log(Level.INFO, msg, e);
+      throw new ApplicationException(ApplicationException.Type.IMPORT_ERROR,
+          msg, e);
+    }
+  }
 }

--
Gitblit v1.10.0