From 81b66dafd30d3893f5199a7ca5efaae9eff3e180 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 05 Nov 2007 22:14:14 +0000
Subject: [PATCH] Complete fix for issue 2263.

---
 opends/src/ads/org/opends/admin/ads/ServerDescriptor.java |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java b/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
index c8890e7..6b8b387 100644
--- a/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
+++ b/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
@@ -57,7 +57,6 @@
   private Map<ServerProperty, Object> serverProperties =
     new HashMap<ServerProperty, Object>();
   private TopologyCacheException lastException;
-
   /**
    * Enumeration containing the different server properties that we can keep in
    * the ServerProperty object.
@@ -129,7 +128,11 @@
      * The instance key-pair public-key certificate. The associated value is a
      * byte[] (ds-cfg-public-key-certificate;binary).
      */
-    INSTANCE_PUBLIC_KEY_CERTIFICATE
+    INSTANCE_PUBLIC_KEY_CERTIFICATE,
+    /**
+     * The schema generation ID.
+     */
+    SCHEMA_GENERATION_ID
   }
 
   private ServerDescriptor()
@@ -425,6 +428,15 @@
   }
 
   /**
+   * Returns the schema generation ID of the server.
+   * @return the schema generation ID of the server.
+   */
+  public String getSchemaReplicationID()
+  {
+    return (String)serverProperties.get(ServerProperty.SCHEMA_GENERATION_ID);
+  }
+
+  /**
    * Returns the last exception that was encountered reading the configuration
    * of the server.  Returns null if there was no problem loading the
    * configuration of the server.
@@ -545,6 +557,7 @@
     updateReplicas(desc, ctx);
     updateReplication(desc, ctx);
     updatePublicKeyCertificate(desc, ctx);
+    updateMiscellaneous(desc, ctx);
 
     desc.serverProperties.put(ServerProperty.HOST_NAME,
         ConnectionUtils.getHostName(ctx));
@@ -995,6 +1008,29 @@
     }
   }
 
+  private static void updateMiscellaneous(ServerDescriptor desc,
+      InitialLdapContext ctx) throws NamingException
+  {
+    SearchControls ctls = new SearchControls();
+    ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+    ctls.setReturningAttributes(
+        new String[] {
+            "ds-sync-generation-id"
+        });
+    String filter = "|(objectclass=*)(objectclass=ldapsubentry)";
+
+    LdapName jndiName = new LdapName("cn=schema");
+    NamingEnumeration listeners = ctx.search(jndiName, filter, ctls);
+
+    while(listeners.hasMore())
+    {
+      SearchResult sr = (SearchResult)listeners.next();
+
+      desc.serverProperties.put(ServerProperty.SCHEMA_GENERATION_ID,
+          getFirstValue(sr, "ds-sync-generation-id"));
+    }
+  }
+
   /**
    Seeds the bound instance's local ads-truststore with a set of instance
    key-pair public key certificates. The result is the instance will trust any

--
Gitblit v1.10.0