From 4738da898c0e9289f0b1171d7f3023c6c834d82e Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Mon, 22 Oct 2007 21:47:06 +0000
Subject: [PATCH] Added the ability to retrieve the number of entries in the entire subordinate subtree to the numSubordinates method in the backend API. Changed the replication code to use numSubordinates of the entires subtree to determine how many entries will be exported and imported during initialization.
---
opendj-sdk/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java | 29 +++++++++++++++++++++--------
1 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
index 658a352..6b57243 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
@@ -1163,18 +1163,18 @@
public ConditionResult hasSubordinates(DN entryDN)
throws DirectoryException
{
- long ret = numSubordinates(entryDN);
- if(ret < 0)
+ ConfigEntry baseEntry = configEntries.get(entryDN);
+ if(baseEntry == null)
{
return ConditionResult.UNDEFINED;
}
- else if(ret == 0)
+ else if(baseEntry.hasChildren())
{
- return ConditionResult.FALSE;
+ return ConditionResult.TRUE;
}
else
{
- return ConditionResult.TRUE;
+ return ConditionResult.FALSE;
}
}
@@ -1184,8 +1184,8 @@
* {@inheritDoc}
*/
@Override()
- public long numSubordinates(DN entryDN)
- throws DirectoryException
+ public long numSubordinates(DN entryDN, boolean subtree)
+ throws DirectoryException
{
ConfigEntry baseEntry = configEntries.get(entryDN);
if (baseEntry == null)
@@ -1193,7 +1193,20 @@
return -1;
}
- return baseEntry.getChildren().size();
+ if(!subtree)
+ {
+ return baseEntry.getChildren().size();
+ }
+ else
+ {
+ long count = 0;
+ for(ConfigEntry child : baseEntry.getChildren().values())
+ {
+ count += numSubordinates(child.getDN(), true);
+ count ++;
+ }
+ return count;
+ }
}
--
Gitblit v1.10.0