From c36a6780c20f526df1bc6e1a3a3b71dfa8b9ec3d Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Wed, 28 Feb 2007 14:06:57 +0000
Subject: [PATCH] This set of changes allow to have the schema synchronization working by configuring synchronization for suffix cn=schema (issue 613) .

---
 opends/src/server/org/opends/server/backends/SchemaBackend.java |   48 ++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/SchemaBackend.java b/opends/src/server/org/opends/server/backends/SchemaBackend.java
index 6a4a349..0d2ed35 100644
--- a/opends/src/server/org/opends/server/backends/SchemaBackend.java
+++ b/opends/src/server/org/opends/server/backends/SchemaBackend.java
@@ -189,6 +189,9 @@
   // The attribute type that will be used to include the defined name forms.
   private AttributeType nameFormsType;
 
+  // The attribute type that will be used to save the synchronization state.
+  private AttributeType synchronizationStateType;
+
   // The value containing DN of the user we'll say created the configuration.
   private AttributeValue creatorsName;
 
@@ -293,6 +296,8 @@
     matchingRuleUsesType =
          DirectoryServer.getAttributeType(ATTR_MATCHING_RULE_USE_LC, true);
     nameFormsType = DirectoryServer.getAttributeType(ATTR_NAME_FORMS_LC, true);
+    synchronizationStateType =
+      DirectoryServer.getAttributeType(ATTR_SYNCHRONIZATION_STATE_LC, true);
 
 
     // Initialize the lastmod attributes.
@@ -797,6 +802,20 @@
                                valueSet));
     operationalAttrs.put(modifyTimestampType, attrList);
 
+    //  Add the synchronization State attribute.
+    valueSet = DirectoryServer.getSchema().getSynchronizationState();
+    attr = new Attribute(synchronizationStateType,
+                         ATTR_SYNCHRONIZATION_STATE_LC, valueSet);
+    attrList = new ArrayList<Attribute>(1);
+    attrList.add(attr);
+    if (synchronizationStateType.isOperational() && (! showAllAttributes))
+    {
+      operationalAttrs.put(synchronizationStateType, attrList);
+    }
+    else
+    {
+      userAttrs.put(synchronizationStateType, attrList);
+    }
 
     // Add all the user-defined attributes.
     for (Attribute a : userDefinedAttributes)
@@ -1350,10 +1369,19 @@
 
 
         default:
-          int    msgID   = MSGID_SCHEMA_INVALID_MODIFICATION_TYPE;
-          String message = getMessage(msgID, m.getModificationType());
-          throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message,
-                                       msgID);
+          if (!modifyOperation.isSynchronizationOperation())
+          {
+            int    msgID   = MSGID_SCHEMA_INVALID_MODIFICATION_TYPE;
+            String message = getMessage(msgID, m.getModificationType());
+            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
+                                         message, msgID);
+          }
+          else
+          {
+            if (at.equals(synchronizationStateType))
+              newSchema.setSynchronizationState(a.getValues());
+            modifiedSchemaFiles.add(FILE_USER_SCHEMA_ELEMENTS);
+          }
       }
     }
 
@@ -3438,6 +3466,18 @@
       schemaEntry.putAttribute(matchingRuleUsesType, attrList);
     }
 
+    if (schemaFile.equals(FILE_USER_SCHEMA_ELEMENTS))
+    {
+      values = schema.getSynchronizationState();
+      if (values != null)
+      {
+        ArrayList<Attribute> attrList = new ArrayList<Attribute>(1);
+        attrList.add(new Attribute(matchingRuleUsesType,
+                                 matchingRuleUsesType.getPrimaryName(),
+                                 values));
+        schemaEntry.putAttribute(matchingRuleUsesType, attrList);
+      }
+    }
 
     // Create a temporary file to which we can write the schema entry.
     File tempFile = File.createTempFile(schemaFile, "temp");

--
Gitblit v1.10.0