From dd4bfab457b0d66f0558e851067fdbc00db5a4bc Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Mon, 14 May 2007 19:43:48 +0000
Subject: [PATCH] fixed web start class loading issues

---
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java              |  172 +++++++++++-----------------------
 opendj-sdk/opends/build.xml                                                                |   17 ---
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java |  109 +++++++++++++++++++++
 3 files changed, 164 insertions(+), 134 deletions(-)

diff --git a/opendj-sdk/opends/build.xml b/opendj-sdk/opends/build.xml
index 7d8ce6e..7507f64 100644
--- a/opendj-sdk/opends/build.xml
+++ b/opendj-sdk/opends/build.xml
@@ -530,24 +530,7 @@
       <include name="**/org/opends/server/util/CertificateManager.java"/>
       <include name="**/org/opends/server/util/DynamicConstants.java"/>
       <include name="**/org/opends/server/types/OperatingSystem.java"/>
-      <include name="**/org/opends/server/loggers/debug/TextDebugLogPublisher.java"/>
-      <include name="**/org/opends/server/loggers/debug/DebugLogger.java"/>
-      <include name="**/org/opends/server/loggers/TextErrorLogPublisher.java"/>
-      <include name="**/org/opends/server/loggers/TextWriter.java"/>
-      <include name="**/org/opends/server/loggers/ErrorLogger.java"/>
-      <include name="**/org/opends/server/loggers/TextAccessLogPublisher.java"/>
-      <include name="**/org/opends/server/loggers/AccessLogger.java"/>
-      <include name="**/org/opends/server/types/DN.java"/>
-      <include name="**/org/opends/server/api/DebugLogPublisher.java"/>
-      <include name="**/org/opends/server/api/ErrorLogPublisher.java"/>
-      <include name="**/org/opends/server/api/AccessLogPublisher.java"/>
       <compilerarg value="-Xlint:all" />
-      <classpath>
-        <fileset dir="${lib.dir}">
-          <include name="*.jar" />
-        </fileset>
-        <pathelement path="${classes.dir}"/>
-      </classpath>
     </javac>
     <javac srcdir="${quicksetup.src.dir}" destdir="${quicksetup.classes.dir}"
          debug="on" debuglevel="${build.debuglevel}" source="1.5"
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
index dd70c12..0794172 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -27,28 +27,54 @@
 
 package org.opends.quicksetup.upgrader;
 
-import org.opends.quicksetup.*;
-import org.opends.quicksetup.upgrader.ui.WelcomePanel;
+import org.opends.quicksetup.CliApplication;
+import static org.opends.quicksetup.Installation.*;
+import org.opends.quicksetup.WizardStep;
+import org.opends.quicksetup.ProgressStep;
+import org.opends.quicksetup.ApplicationException;
+import org.opends.quicksetup.Installation;
+import org.opends.quicksetup.QuickSetupLog;
+import org.opends.quicksetup.UserData;
+import org.opends.quicksetup.ButtonName;
+import org.opends.quicksetup.UserDataException;
+import org.opends.quicksetup.Step;
+import org.opends.quicksetup.BuildInformation;
+import org.opends.quicksetup.CurrentInstallStatus;
+import org.opends.quicksetup.util.Utils;
+import org.opends.quicksetup.util.ZipExtractor;
+import org.opends.quicksetup.util.ServerController;
+import org.opends.quicksetup.util.InProcessServerController;
+import org.opends.quicksetup.util.ServerHealthChecker;
+import org.opends.quicksetup.util.FileManager;
+import org.opends.quicksetup.ui.GuiApplication;
+import org.opends.quicksetup.ui.QuickSetupDialog;
+import org.opends.quicksetup.ui.UIFactory;
+import org.opends.quicksetup.ui.ProgressPanel;
+import org.opends.quicksetup.ui.QuickSetupStepPanel;
+import org.opends.quicksetup.ui.QuickSetup;
+import org.opends.quicksetup.ui.FieldName;
 import org.opends.quicksetup.upgrader.ui.ChooseVersionPanel;
 import org.opends.quicksetup.upgrader.ui.UpgraderReviewPanel;
-import org.opends.quicksetup.util.*;
-import org.opends.quicksetup.ui.*;
+import org.opends.quicksetup.upgrader.ui.WelcomePanel;
 
+import javax.swing.*;
 import java.awt.event.WindowEvent;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.io.*;
-import java.net.URL;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.net.InetSocketAddress;
 import java.net.MalformedURLException;
 import java.net.Proxy;
 import java.net.SocketAddress;
-import java.net.InetSocketAddress;
-
-import static org.opends.quicksetup.Installation.*;
-
-
-import javax.swing.*;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * QuickSetup application of ugrading the bits of an installation of
@@ -946,7 +972,9 @@
 
         try {
           LOG.log(Level.INFO, "stopping server");
-          new InProcessServerController(getInstallation()).stopServer();
+          // This class imports classes from the server
+          new InProcessServerController(
+                  getInstallation()).stopServer();
           LOG.log(Level.INFO, "server stopped");
         } catch (Throwable t) {
           LOG.log(Level.INFO, "Error stopping server", t);
@@ -1236,16 +1264,18 @@
     try {
       File configDiff = getCustomConfigDiffFile();
       if (configDiff.exists()) {
-        applyCustomizationLdifFile(configDiff);
+        new InProcessServerController(
+                getInstallation()).applyCustomizationLdifFile(configDiff);
+
       }
     } catch (IOException e) {
-      String msg = "IO Error applying configuration customization: " +
+      String msg = "I/O Error applying configuration customization: " +
               e.getLocalizedMessage();
       LOG.log(Level.INFO, msg, e);
       throw new ApplicationException(ApplicationException.Type.IMPORT_ERROR,
               msg, e);
-    } catch (org.opends.server.util.LDIFException e) {
-      String msg = "LDIF error applying configuration customization: " +
+    } catch (Exception e) {
+      String msg = "Error applying configuration customization: " +
               e.getLocalizedMessage();
       LOG.log(Level.INFO, msg, e);
       throw new ApplicationException(ApplicationException.Type.IMPORT_ERROR,
@@ -1257,16 +1287,17 @@
     try {
       File schemaDiff = getCustomSchemaDiffFile();
       if (schemaDiff.exists()) {
-        applyCustomizationLdifFile(schemaDiff);
+        new InProcessServerController(
+                getInstallation()).applyCustomizationLdifFile(schemaDiff);
       }
     } catch (IOException e) {
-      String msg = "IO Error applying schema customization: " +
+      String msg = "I/O Error applying schema customization: " +
               e.getLocalizedMessage();
       LOG.log(Level.INFO, msg, e);
       throw new ApplicationException(ApplicationException.Type.IMPORT_ERROR,
               msg, e);
-    } catch (org.opends.server.util.LDIFException e) {
-      String msg = "LDIF error applying schema customization: " +
+    } catch (Exception e) {
+      String msg = "Error applying schema customization: " +
               e.getLocalizedMessage();
       LOG.log(Level.INFO, msg, e);
       throw new ApplicationException(ApplicationException.Type.IMPORT_ERROR,
@@ -1274,99 +1305,6 @@
     }
   }
 
-
-  /**
-   * Applies configuration or schema customizations.
-   * NOTE: Assumes that the server is running in process.
-   *
-   * @param ldifFile LDIF file to apply
-   * @throws IOException
-   * @throws org.opends.server.util.LDIFException
-   *
-   * @throws ApplicationException
-   */
-  private void applyCustomizationLdifFile(File ldifFile)
-          throws IOException, org.opends.server.util.LDIFException,
-          ApplicationException {
-    try {
-      org.opends.server.protocols.internal.InternalClientConnection cc =
-              org.opends.server.protocols.internal.
-                      InternalClientConnection.getRootConnection();
-      org.opends.server.types.LDIFImportConfig importCfg =
-              new org.opends.server.types.LDIFImportConfig(
-                      Utils.getPath(ldifFile));
-      org.opends.server.util.LDIFReader ldifReader =
-              new org.opends.server.util.LDIFReader(importCfg);
-      org.opends.server.util.ChangeRecordEntry cre;
-      while (null != (cre = ldifReader.readChangeRecord(false))) {
-        if (cre instanceof org.opends.server.util.ModifyChangeRecordEntry) {
-          org.opends.server.util.ModifyChangeRecordEntry mcre =
-                  (org.opends.server.util.ModifyChangeRecordEntry) cre;
-          org.opends.server.types.ByteString dnByteString =
-                  org.opends.server.types.ByteStringFactory.create(
-                          mcre.getDN().toString());
-          org.opends.server.core.ModifyOperation op =
-                  cc.processModify(dnByteString, mcre.getModifications());
-          org.opends.server.types.ResultCode rc = op.getResultCode();
-          if (rc.equals(
-                  org.opends.server.types.ResultCode.
-                          OBJECTCLASS_VIOLATION)) {
-            // try again without schema checking
-            org.opends.server.core.DirectoryServer.setCheckSchema(false);
-            op = cc.processModify(dnByteString, mcre.getModifications());
-            rc = op.getResultCode();
-          }
-          if (rc.equals(org.opends.server.types.ResultCode.
-                  SUCCESS)) {
-            LOG.log(Level.INFO, "processed server modification " +
-                    (org.opends.server.core.DirectoryServer.checkSchema() ?
-                            ":" : "(schema checking off):" +
-                            modListToString(op.getModifications())));
-            if (!org.opends.server.core.DirectoryServer.checkSchema()) {
-              org.opends.server.core.DirectoryServer.setCheckSchema(true);
-            }
-          } else if (rc.equals(
-                  org.opends.server.types.ResultCode.
-                          ATTRIBUTE_OR_VALUE_EXISTS)) {
-            // ignore this error
-            LOG.log(Level.INFO, "ignoring attribute that already exists: " +
-                    modListToString(op.getModifications()));
-          } else {
-            // report the error to the user
-            StringBuilder error = op.getErrorMessage();
-            if (error != null) {
-              throw new ApplicationException(
-                      ApplicationException.Type.IMPORT_ERROR,
-                      "error processing custom configuration "
-                              + error.toString(),
-                      null);
-            }
-          }
-        } else {
-          throw new ApplicationException(
-                  ApplicationException.Type.IMPORT_ERROR,
-                  "unexpected change record type " + cre.getClass(),
-                  null);
-        }
-      }
-    } catch (Throwable t) {
-      throw new ApplicationException(ApplicationException.Type.BUG,
-              t.getMessage(), t);
-    }
-  }
-
-  private String modListToString(
-          List<org.opends.server.types.Modification> modifications) {
-    StringBuilder modsMsg = new StringBuilder();
-    for (int i = 0; i < modifications.size(); i++) {
-      modsMsg.append(modifications.get(i).toString());
-      if (i < modifications.size() - 1) {
-        modsMsg.append(" ");
-      }
-    }
-    return modsMsg.toString();
-  }
-
   private Long writeInitialHistoricalRecord(
           Integer fromVersion,
           Integer toVersion)
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
index 3c64fd3..7e55038 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
@@ -36,16 +36,34 @@
 import org.opends.server.loggers.TextAccessLogPublisher;
 import org.opends.server.loggers.AccessLogger;
 import org.opends.server.types.DN;
+import org.opends.server.types.Modification;
+import org.opends.server.types.ResultCode;
+import org.opends.server.types.LDIFImportConfig;
+import org.opends.server.types.ByteStringFactory;
+import org.opends.server.types.ByteString;
 import org.opends.server.api.DebugLogPublisher;
 import org.opends.server.api.ErrorLogPublisher;
 import org.opends.server.api.AccessLogPublisher;
+import org.opends.server.util.LDIFException;
+import org.opends.server.util.LDIFReader;
+import org.opends.server.util.ModifyChangeRecordEntry;
+import org.opends.server.protocols.internal.InternalClientConnection;
+import org.opends.server.core.ModifyOperation;
+import org.opends.server.core.DirectoryServer;
 
 import java.util.logging.Logger;
 import java.util.logging.Level;
+import java.util.List;
+import java.io.File;
+import java.io.IOException;
 
 /**
  * Class used to manipulate an OpenDS server in the same JVM process as
  * the client class.
+ *
+ * NOTE:  this class imports classes from the server packages.  You should
+ * refer to the class using a fully qualified package name and insure that
+ * that this class does not appear in any import statements.
  */
 public class InProcessServerController {
 
@@ -189,6 +207,97 @@
   }
 
   /**
+   * Applies configuration or schema customizations.
+   * NOTE: Assumes that the server is running in process.
+   *
+   * @param ldifFile LDIF file to apply
+   * @throws IOException if there is an IO Error
+   * @throws LDIFException if there is an LDIF error
+   * @throws ApplicationException if there is an application specific error
+   */
+  public void applyCustomizationLdifFile(File ldifFile)
+          throws IOException, LDIFException,
+          ApplicationException {
+    try {
+      InternalClientConnection cc =
+              InternalClientConnection.getRootConnection();
+      LDIFImportConfig importCfg =
+              new LDIFImportConfig(
+                      Utils.getPath(ldifFile));
+      LDIFReader ldifReader =
+              new LDIFReader(importCfg);
+      org.opends.server.util.ChangeRecordEntry cre;
+      while (null != (cre = ldifReader.readChangeRecord(false))) {
+        if (cre instanceof org.opends.server.util.ModifyChangeRecordEntry) {
+          ModifyChangeRecordEntry mcre =
+                  (ModifyChangeRecordEntry) cre;
+          ByteString dnByteString =
+                  ByteStringFactory.create(
+                          mcre.getDN().toString());
+          ModifyOperation op =
+                  cc.processModify(dnByteString, mcre.getModifications());
+          ResultCode rc = op.getResultCode();
+          if (rc.equals(
+                  ResultCode.
+                          OBJECTCLASS_VIOLATION)) {
+            // try again without schema checking
+            DirectoryServer.setCheckSchema(false);
+            op = cc.processModify(dnByteString, mcre.getModifications());
+            rc = op.getResultCode();
+          }
+          if (rc.equals(ResultCode.
+                  SUCCESS)) {
+            LOG.log(Level.INFO, "processed server modification " +
+                    (DirectoryServer.checkSchema() ?
+                            ":" : "(schema checking off):" +
+                            modListToString(op.getModifications())));
+            if (!DirectoryServer.checkSchema()) {
+              DirectoryServer.setCheckSchema(true);
+            }
+          } else if (rc.equals(
+                  ResultCode.
+                          ATTRIBUTE_OR_VALUE_EXISTS)) {
+            // ignore this error
+            LOG.log(Level.INFO, "ignoring attribute that already exists: " +
+                    modListToString(op.getModifications()));
+          } else {
+            // report the error to the user
+            StringBuilder error = op.getErrorMessage();
+            if (error != null) {
+              throw new ApplicationException(
+                      ApplicationException.Type.IMPORT_ERROR,
+                      "error processing custom configuration "
+                              + error.toString(),
+                      null);
+            }
+          }
+        } else {
+          throw new ApplicationException(
+                  ApplicationException.Type.IMPORT_ERROR,
+                  "unexpected change record type " + cre.getClass(),
+                  null);
+        }
+      }
+    } catch (Throwable t) {
+      throw new ApplicationException(ApplicationException.Type.BUG,
+              t.getMessage(), t);
+    }
+  }
+
+  private String modListToString(
+          List<Modification> modifications) {
+    StringBuilder modsMsg = new StringBuilder();
+    for (int i = 0; i < modifications.size(); i++) {
+      modsMsg.append(modifications.get(i).toString());
+      if (i < modifications.size() - 1) {
+        modsMsg.append(" ");
+      }
+    }
+    return modsMsg.toString();
+  }
+
+
+  /**
    * Pushes messages published by the server loggers into OperationOutput.
    */
   private abstract class ServerControllerTextWriter implements TextWriter {

--
Gitblit v1.10.0