From 6bd13ae6e0e4cea50b69c22526822de99bf4ac3f Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Fri, 12 Oct 2007 12:48:38 +0000
Subject: [PATCH] Fix for issue #2207 (setup/ADS does not add registered server in group"ALL")

---
 opends/src/messages/messages/admin.properties                                  |    2 +-
 opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java |   25 ++++++++++++++++++++++---
 opends/src/ads/org/opends/admin/ads/ADSContext.java                            |   28 ++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/opends/src/ads/org/opends/admin/ads/ADSContext.java b/opends/src/ads/org/opends/admin/ads/ADSContext.java
index 946d575..ffad97e 100644
--- a/opends/src/ads/org/opends/admin/ads/ADSContext.java
+++ b/opends/src/ads/org/opends/admin/ads/ADSContext.java
@@ -426,6 +426,34 @@
       {
         registerInstanceKeyCertificate(serverProperties, dn);
       }
+
+      // register this server into "all" groups
+      HashMap<ServerGroupProperty, Object> serverGroupProperties =
+        new HashMap<ServerGroupProperty, Object>();
+      Set<String> memberList = getServerGroupMemberList(ALL_SERVERGROUP_NAME);
+      if (memberList == null) {
+        memberList = new HashSet<String>();
+      }
+      String newMember = "cn="
+          + Rdn.escapeValue(serverProperties.get(ServerProperty.ID));
+
+      memberList.add(newMember);
+      serverGroupProperties.put(ServerGroupProperty.MEMBERS, memberList);
+
+      updateServerGroup(ALL_SERVERGROUP_NAME, serverGroupProperties);
+
+      // Update the server property "GROUPS"
+      Set rawGroupList = (Set) serverProperties.get(ServerProperty.GROUPS);
+      Set<String> groupList = new HashSet<String>();
+      if (rawGroupList != null) {
+        for (Object elm : rawGroupList.toArray()) {
+          groupList.add(elm.toString());
+        }
+      }
+      groupList.add(ALL_SERVERGROUP_NAME);
+      serverProperties.put(ServerProperty.GROUPS, groupList);
+    updateServer(serverProperties, null);
+
     }
     catch (ADSContextException ace)
     {
diff --git a/opends/src/messages/messages/admin.properties b/opends/src/messages/messages/admin.properties
index de7a129..28926ff 100644
--- a/opends/src/messages/messages/admin.properties
+++ b/opends/src/messages/messages/admin.properties
@@ -150,7 +150,7 @@
 INFO_ADMIN_ARG_MEMBERNAME_DESCRIPTION_55=The member's identifier. This is a \
  required argument
 INFO_ADMIN_ARG_BACKENDNAME_DESCRIPTION_56=The name of the backend in which \
- the admin data will be stored. This is a required argument
+ the admin data will be stored
 SEVERE_ERR_ADMIN_UNABLE_TO_REGISTER_LISTENER_57=Unable to register an \
  add/delete listener against the entry "%s" because it does not exist in the \
  configuration
diff --git a/opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java b/opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java
index 87b584a..23e6373 100644
--- a/opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java
+++ b/opends/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java
@@ -550,6 +550,27 @@
       serverProperties.put(prop, arg);
     }
 
+   /**
+    * The INSTANCE_KEY_ID used to identify the server key ID.
+    */
+    {
+      ServerProperty prop = ServerProperty.INSTANCE_KEY_ID;
+      String attName = prop.getAttributeName();
+      StringArgument arg = new StringArgument(attName, null, prop
+          .getAttributeName(), false, false, true, "", null, null, null);
+      serverProperties.put(prop, arg);
+    }
+
+    /**
+     * The INSTANCE_PUBLIC_KEY_CERTIFICATE associated to the server.
+     */
+    {
+      ServerProperty prop = ServerProperty.INSTANCE_PUBLIC_KEY_CERTIFICATE;
+      String attName = prop.getAttributeName();
+      StringArgument arg = new StringArgument(attName, null, prop
+          .getAttributeName(), false, false, true, "", null, null, null);
+      serverProperties.put(prop, arg);
+    }
   }
 
   /**
@@ -600,9 +621,7 @@
         adsCtx = new ADSContext(ctx);
         adsCtx.registerServer(map);
 
-        // Add this server in the default "all-servers" group.
-        returnCode = DsFrameworkCliServerGroup.addServerTogroup(adsCtx,
-            ADSContext.ALL_SERVERGROUP_NAME, map);
+        returnCode = SUCCESSFUL;
       }
       else
       // -----------------------

--
Gitblit v1.10.0