From 43ba6d721185f9a810761720fcb05103b31d17b7 Mon Sep 17 00:00:00 2001
From: chebrard <chebrard@localhost>
Date: Wed, 29 Oct 2008 10:39:44 +0000
Subject: [PATCH] Fix 3534: Provide native Solaris packages (fix also 3533: upgrade fails starting server adding entry ds-cfg-key-id)

---
 opends/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java |   48 +++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java b/opends/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java
index 7f9dd88..5d64d5e 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java
@@ -60,10 +60,10 @@
     schema = DirectoryServer.getSchema().duplicate();
   }
 
-  private static String getSchemaDirectoryPath()
+  private static String getSchemaDirectoryPath(boolean userSchema)
   {
     File schemaDir =
-      DirectoryServer.getEnvironmentConfig().getSchemaDirectory();
+      DirectoryServer.getEnvironmentConfig().getSchemaDirectory(userSchema);
     if (schemaDir != null) {
       return schemaDir.getAbsolutePath();
     } else {
@@ -79,8 +79,6 @@
    */
   public void readSchema() throws ConfigException, InitializationException
   {
-    String schemaDirPath= getSchemaDirectoryPath();
-    File schemaDir = new File(schemaDirPath);
     String[] attrsToKeep = {
         ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC,
         ConfigConstants.ATTR_OBJECTCLASSES_LC,
@@ -126,6 +124,14 @@
     String[] fileNames = null;
     try
     {
+      String installPath  =
+        new File(DirectoryServer.getServerRoot()).getCanonicalPath();
+      String instancePath =
+        new File(DirectoryServer.getInstanceRoot()).getCanonicalPath();
+
+      // Load install directory schema
+      String schemaDirPath= getSchemaDirectoryPath(false);
+      File schemaDir = new File(schemaDirPath);
       if (schemaDirPath == null || ! schemaDir.exists())
       {
         Message message = ERR_CONFIG_SCHEMA_NO_SCHEMA_DIR.get(schemaDirPath);
@@ -137,10 +143,27 @@
           ERR_CONFIG_SCHEMA_DIR_NOT_DIRECTORY.get(schemaDirPath);
         throw new InitializationException(message);
       }
+      File[] schemaInstallDirFiles = schemaDir.listFiles();
+      File[] schemaInstanceDirFiles = null ;
+      int size = schemaInstallDirFiles.length;
 
-      File[] schemaDirFiles = schemaDir.listFiles();
-      ArrayList<String> fileList = new ArrayList<String>(schemaDirFiles.length);
-      for (File f : schemaDirFiles)
+      if (! installPath.equals(instancePath))
+      {
+        schemaDirPath= getSchemaDirectoryPath(true);
+        schemaDir = new File(schemaDirPath);
+        if (schemaDirPath != null
+            &&
+            schemaDir.exists()
+            &&
+            schemaDir.isDirectory())
+        {
+          schemaInstanceDirFiles = schemaDir.listFiles();
+          size += schemaInstanceDirFiles.length;
+        }
+      }
+
+      ArrayList<String> fileList = new ArrayList<String>(size);
+      for (File f : schemaInstallDirFiles)
       {
         if (f.isFile())
         {
@@ -148,6 +171,17 @@
         }
       }
 
+      if (schemaInstanceDirFiles != null)
+      {
+        for (File f : schemaInstanceDirFiles)
+        {
+          if (f.isFile())
+          {
+            fileList.add(f.getName());
+          }
+        }
+      }
+
       fileNames = new String[fileList.size()];
       fileList.toArray(fileNames);
       Arrays.sort(fileNames);

--
Gitblit v1.10.0