From 1487d09f85747d398ab99e40a843734e72967df1 Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Fri, 01 Jun 2007 09:19:04 +0000
Subject: [PATCH] Handler server Group renaming
---
opends/src/ads/org/opends/admin/ads/ADSContext.java | 34 +++++++++++++++++++++++++++++++---
1 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/opends/src/ads/org/opends/admin/ads/ADSContext.java b/opends/src/ads/org/opends/admin/ads/ADSContext.java
index 484fc16..869da1a 100644
--- a/opends/src/ads/org/opends/admin/ads/ADSContext.java
+++ b/opends/src/ads/org/opends/admin/ads/ADSContext.java
@@ -663,7 +663,7 @@
catch (NamingException x)
{
throw new ADSContextException(
- ADSContextException.ErrorType.ERROR_UNEXPECTED, x);
+ ADSContextException.ErrorType.BROKEN_INSTALL, x);
}
}
@@ -681,12 +681,40 @@
LdapName dn = nameFromDN("cn=" + Rdn.escapeValue(groupID) + "," +
getServerGroupContainerDN());
- BasicAttributes attrs =
- makeAttrsFromServerGroupProperties(serverGroupProperties);
try
{
+ // Entry renaming ?
+ if (serverGroupProperties.containsKey(ServerGroupProperty.UID))
+ {
+ String newGroupId = serverGroupProperties
+ .get(ServerGroupProperty.UID).toString();
+ if (!newGroupId.equals(groupID))
+ {
+ // Rename to entry
+ LdapName newDN = nameFromDN("cn=" + Rdn.escapeValue(newGroupId)
+ + "," + getServerGroupContainerDN());
+ dirContext.rename(dn, newDN);
+ dn = newDN ;
+ }
+
+ // In any case, we remove the "cn" attribute.
+ serverGroupProperties.remove(ServerGroupProperty.UID);
+ }
+ if (serverGroupProperties.isEmpty())
+ {
+ return ;
+ }
+
+ BasicAttributes attrs =
+ makeAttrsFromServerGroupProperties(serverGroupProperties);
+ // attribute modification
dirContext.modifyAttributes(dn, DirContext.REPLACE_ATTRIBUTE, attrs);
}
+ catch (NameNotFoundException x)
+ {
+ throw new ADSContextException(
+ ADSContextException.ErrorType.NOT_YET_REGISTERED);
+ }
catch (NameAlreadyBoundException x)
{
throw new ADSContextException(
--
Gitblit v1.10.0