From 0d97a7da226d93b8b87467efde523aa2120ceabc Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Fri, 07 Jun 2013 14:08:13 +0000
Subject: [PATCH] Fix for OPENDJ-925, OPENDJ-926, and overall schema management. Review CR-1806. Back a few years ago, when we did the SVR4 package, we split the schema into read-only (Install) and writable (Instance). With the template model in 2.6, the whole schema is under config, and we should never edit/change the one in the template. So, I've removed all code related to the 2 locations for schema, reverted some I10N messages to their previous versions, and tidy up code and tests. All unit-tests are passing. And it's also possible to change the instance.loc and run setup and have a fully functioning server :-)
---
opends/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java | 55 +++++++++----------------------------------------------
1 files changed, 9 insertions(+), 46 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 363545a..6b33ccb 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java
@@ -23,6 +23,7 @@
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
+ * Portions Copyright 2013 ForgeRock AS.
*/
package org.opends.guitools.controlpanel.util;
@@ -106,10 +107,10 @@
}
}
- private static String getSchemaDirectoryPath(boolean userSchema)
+ private static String getSchemaDirectoryPath()
{
File schemaDir =
- DirectoryServer.getEnvironmentConfig().getSchemaDirectory(userSchema);
+ DirectoryServer.getEnvironmentConfig().getSchemaDirectory();
if (schemaDir != null) {
return schemaDir.getAbsolutePath();
} else {
@@ -130,16 +131,11 @@
{
schema = getBaseSchema();
- String[] fileNames = null;
+ String[] fileNames;
+ String schemaDirPath= getSchemaDirectoryPath();
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())
{
@@ -177,27 +173,11 @@
return accept;
}
};
- File[] schemaInstallDirFiles = schemaDir.listFiles(ldifFiles);
- File[] schemaInstanceDirFiles = null ;
- int size = schemaInstallDirFiles.length;
-
- if (! installPath.equals(instancePath))
- {
- schemaDirPath= getSchemaDirectoryPath(true);
- schemaDir = new File(schemaDirPath);
- if (schemaDirPath != null
- &&
- schemaDir.exists()
- &&
- schemaDir.isDirectory())
- {
- schemaInstanceDirFiles = schemaDir.listFiles(ldifFiles);
- size += schemaInstanceDirFiles.length;
- }
- }
+ File[] schemaFiles = schemaDir.listFiles(ldifFiles);
+ int size = schemaFiles.length;
ArrayList<String> fileList = new ArrayList<String>(size);
- for (File f : schemaInstallDirFiles)
+ for (File f : schemaFiles)
{
if (f.isFile())
{
@@ -205,26 +185,10 @@
}
}
- 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);
}
- catch (Throwable t)
- {
- t.printStackTrace();
- }
- /*
catch (InitializationException ie)
{
throw ie;
@@ -232,10 +196,9 @@
catch (Exception e)
{
Message message = ERR_CONFIG_SCHEMA_CANNOT_LIST_FILES.get(
- schemaDirPath, getExceptionMessage(e));
+ schemaDirPath, e.getMessage());
throw new InitializationException(message, e);
}
- */
// Iterate through the schema files and read them as an LDIF file containing
// a single entry. Then get the attributeTypes and objectClasses attributes
--
Gitblit v1.10.0