From 76e4f2c7318b9d71677e6916f92082319d461a00 Mon Sep 17 00:00:00 2001
From: coulbeck <coulbeck@localhost>
Date: Thu, 05 Oct 2006 15:55:02 +0000
Subject: [PATCH] Fix for issue 749. Reviewed by dugan.
---
opendj-sdk/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java | 48 +++++++++++++++++-------
opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ImportJob.java | 16 +++-----
opendj-sdk/opends/src/server/org/opends/server/backends/jeb/DN2URI.java | 3 +
3 files changed, 42 insertions(+), 25 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/DN2URI.java b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/DN2URI.java
index 790df5f..7cb76a9 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/DN2URI.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/DN2URI.java
@@ -514,7 +514,8 @@
DatabaseEntry data = new DatabaseEntry();
// Go up through the DIT hierarchy until we find a referral.
- for (DN dn = targetDN.getParent(); dn != null; dn = dn.getParent())
+ for (DN dn = entryContainer.getParentWithinBase(targetDN); dn != null;
+ dn = entryContainer.getParentWithinBase(dn))
{
// Look for a record whose key matches the current DN.
String normDN = dn.toNormalizedString();
diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
index 5b0632c..006f7c7 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
@@ -1412,7 +1412,7 @@
public AddEntryTransaction(Entry entry)
{
this.entry = entry;
- this.parentDN = entry.getDN().getParent();
+ this.parentDN = getParentWithinBase(entry.getDN());
}
/**
@@ -1498,7 +1498,8 @@
id2subtree.insertID(txn, parentID.getDatabaseEntry(), entryID);
// Iterate up through the superior entries, starting above the parent.
- for (DN dn = parentDN.getParent(); dn != null; dn = dn.getParent())
+ for (DN dn = getParentWithinBase(parentDN); dn != null;
+ dn = getParentWithinBase(dn))
{
// Read the ID from dn2id.
EntryID nodeID = dn2id.get(txn, dn);
@@ -1663,7 +1664,8 @@
// Iterate up through the superior entries.
boolean isParent = true;
- for (DN dn = leafDN.getParent(); dn != null; dn = dn.getParent())
+ for (DN dn = getParentWithinBase(leafDN); dn != null;
+ dn = getParentWithinBase(dn))
{
// Read the ID from dn2id.
EntryID nodeID = dn2id.get(txn, dn);
@@ -1760,7 +1762,8 @@
// Iterate up through the superior entries.
boolean isParent = true;
- for (DN dn = leafDN.getParent(); dn != null; dn = dn.getParent())
+ for (DN dn = getParentWithinBase(leafDN); dn != null;
+ dn = getParentWithinBase(dn))
{
// Read the ID from dn2id.
EntryID nodeID = dn2id.get(txn, dn);
@@ -2553,8 +2556,8 @@
ModifyDNOperation modifyDNOperation)
{
this.oldApexDN = currentDN;
- this.oldSuperiorDN = currentDN.getParent();
- this.newSuperiorDN = entry.getDN().getParent();
+ this.oldSuperiorDN = getParentWithinBase(currentDN);
+ this.newSuperiorDN = getParentWithinBase(entry.getDN());
this.newApexEntry = entry;
this.modifyDNOperation = modifyDNOperation;
}
@@ -2766,7 +2769,7 @@
{
DN oldDN = oldEntry.getDN();
DN newDN = newEntry.getDN();
- DN newParentDN = newDN.getParent();
+ DN newParentDN = getParentWithinBase(newDN);
// Remove the old DN from dn2id.
dn2id.remove(txn, oldDN);
@@ -2805,7 +2808,7 @@
id2entry.put(txn, newID, newEntry);
// Remove the old parentID:ID from id2children.
- DN oldParentDN = oldDN.getParent();
+ DN oldParentDN = getParentWithinBase(oldDN);
if (oldParentDN != null)
{
EntryID currentParentID = dn2id.get(txn, oldParentDN);
@@ -2824,14 +2827,15 @@
// Remove the old nodeID:ID from id2subtree.
- for (DN dn = oldDN.getParent(); dn != null; dn = dn.getParent())
+ for (DN dn = getParentWithinBase(oldDN); dn != null;
+ dn = getParentWithinBase(dn))
{
EntryID nodeID = dn2id.get(txn, dn);
id2sBuffered.removeID(nodeID.getDatabaseEntry().getData(), oldID);
}
// Put the new nodeID:ID in id2subtree.
- for (DN dn = newParentDN; dn != null; dn = dn.getParent())
+ for (DN dn = newParentDN; dn != null; dn = getParentWithinBase(dn))
{
EntryID nodeID = dn2id.get(txn, dn);
id2sBuffered.insertID(config.getBackendIndexEntryLimit(),
@@ -2921,7 +2925,7 @@
throws JebException, DirectoryException, DatabaseException
{
DN oldDN = oldEntry.getDN();
- DN newParentDN = newDN.getParent();
+ DN newParentDN = getParentWithinBase(newDN);
// Remove the old DN from dn2id.
dn2id.remove(txn, oldDN);
@@ -2979,7 +2983,7 @@
}
// Remove the old nodeID:ID from id2subtree
- for (DN dn = oldSuperiorDN; dn != null; dn = dn.getParent())
+ for (DN dn = oldSuperiorDN; dn != null; dn = getParentWithinBase(dn))
{
EntryID nodeID = dn2id.get(txn, dn);
id2sBuffered.removeID(nodeID.getDatabaseEntry().getData(),
@@ -2987,7 +2991,7 @@
}
// Put the new nodeID:ID in id2subtree.
- for (DN dn = newParentDN; dn != null; dn = dn.getParent())
+ for (DN dn = newParentDN; dn != null; dn = getParentWithinBase(dn))
{
if (!newID.equals(oldID) || dn.isAncestorOf(newSuperiorDN))
{
@@ -3759,4 +3763,20 @@
{
return baseDN;
}
-}
\ No newline at end of file
+
+ /**
+ * Get the parent of a DN in the scope of the base DN.
+ *
+ * @param dn A DN which is in the scope of the base DN.
+ * @return The parent DN, or null if the given DN is the base DN.
+ */
+ public DN getParentWithinBase(DN dn)
+ {
+ if (dn.equals(baseDN))
+ {
+ return null;
+ }
+ return dn.getParent();
+ }
+
+}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ImportJob.java b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ImportJob.java
index 93143fc..5508dcd 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ImportJob.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ImportJob.java
@@ -214,7 +214,7 @@
rootContainer.openEntryContainers(config.getBaseDNs());
- // Create the import contextes for each base DN.
+ // Create the import contexts for each base DN.
EntryID highestID = null;
DN baseDN;
@@ -672,11 +672,8 @@
{
// Make sure the parent entry exists, unless this entry is a base DN.
EntryID parentID = null;
- DN parentDN = null;
- if (!entryDN.equals(importContext.getBaseDN()))
- {
- parentDN = entryDN.getParent();
- }
+ DN parentDN = importContext.getEntryContainer().
+ getParentWithinBase(entryDN);
if (parentDN != null)
{
parentID = dn2id.get(txn, parentDN);
@@ -713,10 +710,9 @@
if (parentID != null)
{
IDs.add(parentID);
- DN baseDN = importContext.getBaseDN();
- for (DN dn = parentDN.equals(baseDN) ? null : parentDN.getParent();
- dn != null;
- dn = dn.equals(baseDN) ? null : dn.getParent())
+ EntryContainer ec = importContext.getEntryContainer();
+ for (DN dn = ec.getParentWithinBase(parentDN); dn != null;
+ dn = ec.getParentWithinBase(dn))
{
// Read the ID from dn2id.
EntryID nodeID = dn2id.get(txn, dn);
--
Gitblit v1.10.0