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/server/org/opends/server/tasks/AddSchemaFileTask.java |   24 ++++++++----------------
 1 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/opends/src/server/org/opends/server/tasks/AddSchemaFileTask.java b/opends/src/server/org/opends/server/tasks/AddSchemaFileTask.java
index 970e558..3ebb6b6 100644
--- a/opends/src/server/org/opends/server/tasks/AddSchemaFileTask.java
+++ b/opends/src/server/org/opends/server/tasks/AddSchemaFileTask.java
@@ -23,12 +23,12 @@
  *
  *
  *      Copyright 2008 Sun Microsystems, Inc.
+ *      Portions Copyright 2013 ForgeRock AS.
  */
 package org.opends.server.tasks;
+
 import org.opends.messages.Message;
 
-
-
 import java.io.File;
 import java.util.LinkedList;
 import java.util.List;
@@ -113,10 +113,8 @@
 
     // Get the name(s) of the schema files to add and make sure they exist in
     // the schema directory.
-    String schemaInstallDirectory  =
-      SchemaConfigManager.getSchemaDirectoryPath(false);
     String schemaInstanceDirectory =
-      SchemaConfigManager.getSchemaDirectoryPath(true);
+      SchemaConfigManager.getSchemaDirectoryPath();
     filesToAdd = new TreeSet<String>();
     for (Attribute a : attrList)
     {
@@ -127,19 +125,13 @@
 
         try
         {
-          File schemaFile = new File(schemaInstallDirectory, filename);
-          if ((! schemaFile.exists()) ||
-              (! schemaFile.getParent().equals(schemaInstallDirectory)))
+          File schemaFile = new File(schemaInstanceDirectory, filename);
+          if (! schemaFile.exists())
           {
-            // try in the instance
-            schemaFile = new File(schemaInstanceDirectory, filename);
-            if (! schemaFile.exists())
-            {
             Message message = ERR_TASK_ADDSCHEMAFILE_NO_SUCH_FILE.get(
-                filename, schemaInstallDirectory, schemaInstanceDirectory);
+                filename, schemaInstanceDirectory);
             throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                          message);
-            }
           }
         }
         catch (Exception e)
@@ -150,7 +142,7 @@
           }
 
           Message message = ERR_TASK_ADDSCHEMAFILE_ERROR_CHECKING_FOR_FILE.get(
-              filename, schemaInstallDirectory, schemaInstanceDirectory,
+              filename, schemaInstanceDirectory,
               getExceptionMessage(e));
           throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                        message, e);
@@ -240,7 +232,7 @@
             for (AttributeValue v : a)
             {
               String s = v.getValue().toString();
-              if (s.indexOf(SCHEMA_PROPERTY_FILENAME) < 0)
+              if (!s.contains(SCHEMA_PROPERTY_FILENAME))
               {
                 if (s.endsWith(" )"))
                 {

--
Gitblit v1.10.0