From ffb9044301d1c169f934e0adf4f473e99da39a47 Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Mon, 27 Aug 2007 18:58:10 +0000
Subject: [PATCH] This adds the numSubordinates and hasSubordinates operational attribute support in OpenDS. - Implemented as virtual attributes - They are enabled by default - numSubordinates and hasSubordinates methods added to the backend API and implemented for all existing backends - JE implementation uses the id2children index to keep count of the number of subordinates for each entry. - The behavior of exceeding the index-entry-limit (ALL-IDs) has changed to store a 8 byte entry ID set count with the most significant bit set to 1 instead of a 0 byte array to signify the index-entry-limit has been exceeded. The previous format is still compatible but all requests for numSubordinates will return undefined (-1). - The DBTest tool is also included in this fix. This can be used to list root containers, entry containers, database containers, index status, as well as dumping a database with or without decoding the data.
---
opends/src/server/org/opends/server/backends/jeb/EntryContainer.java | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java b/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
index 0080ff6..8a66f65 100644
--- a/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
+++ b/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
@@ -704,6 +704,32 @@
}
/**
+ * Determine the number of subordinate entries for a given entry.
+ *
+ * @param entryDN The distinguished name of the entry.
+ * @return The number of subordinate entries for the given entry or -1 if
+ * the entry does not exist.
+ * @throws DatabaseException If an error occurs in the JE database.
+ */
+ public long getNumSubordinates(DN entryDN) throws DatabaseException
+ {
+ EntryID entryID = dn2id.get(null, entryDN);
+ if (entryID != null)
+ {
+ DatabaseEntry key =
+ new DatabaseEntry(JebFormat.entryIDToDatabase(entryID.longValue()));
+ EntryIDSet entryIDSet =
+ id2children.readKey(key, null, LockMode.DEFAULT);
+ long count = entryIDSet.size();
+ if(count != Long.MAX_VALUE)
+ {
+ return count;
+ }
+ }
+ return -1;
+ }
+
+ /**
* Processes the specified search in this entryContainer.
* Matching entries should be provided back to the core server using the
* <CODE>SearchOperation.returnEntry</CODE> method.
--
Gitblit v1.10.0