From e125c2b257b8664c2ecb6b775c659836b70bac0f Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 19 Dec 2014 10:49:18 +0000
Subject: [PATCH] OPENDJ-1602 New pluggable storage based backend

---
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java |   79 ++++++++++++++++++++++-----------------
 1 files changed, 45 insertions(+), 34 deletions(-)

diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java
index ef0dfee..823734d 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/EntryContainer.java
@@ -1971,8 +1971,27 @@
    *                            the entry.
    * @throws StorageRuntimeException An error occurred during a database operation.
    */
-  public Entry getEntry(final DN entryDN)
-  throws StorageRuntimeException, DirectoryException
+  public Entry getEntry(final DN entryDN) throws StorageRuntimeException, DirectoryException
+  {
+    try
+    {
+      return storage.read(new ReadOperation<Entry>()
+      {
+        @Override
+        public Entry run(ReadableStorage txn) throws Exception
+        {
+          return getEntry0(txn, entryDN);
+        }
+      });
+    }
+    catch (Exception e)
+    {
+      throw new StorageRuntimeException(e);
+    }
+
+  }
+
+  private Entry getEntry0(ReadableStorage txn, final DN entryDN) throws StorageRuntimeException, DirectoryException
   {
     final EntryCache<?> entryCache = DirectoryServer.getEntryCache();
     Entry entry = null;
@@ -1987,40 +2006,32 @@
     {
       try
       {
-        return storage.read(new ReadOperation<Entry>()
+        // Read dn2id.
+        EntryID entryID = dn2id.get(txn, entryDN, false);
+        if (entryID == null)
         {
-          @Override
-          public Entry run(ReadableStorage txn) throws Exception
-          {
-            // Read dn2id.
-            EntryID entryID = dn2id.get(txn, entryDN, false);
-            if (entryID == null)
-            {
-              // The entryDN does not exist.
-              // Check for referral entries above the target entry.
-              dn2uri.targetEntryReferrals(txn, entryDN, null);
-              return null;
-            }
+          // The entryDN does not exist.
+          // Check for referral entries above the target entry.
+          dn2uri.targetEntryReferrals(txn, entryDN, null);
+          return null;
+        }
 
-            // Read id2entry.
-            Entry entry2 = id2entry.get(txn, entryID, false);
-            if (entry2 == null)
-            {
-              // The entryID does not exist.
-              throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), ERR_JEB_MISSING_ID2ENTRY_RECORD
-                  .get(entryID));
-            }
+        // Read id2entry.
+        Entry entry2 = id2entry.get(txn, entryID, false);
+        if (entry2 == null)
+        {
+          // The entryID does not exist.
+          throw new DirectoryException(getServerErrorResultCode(), ERR_JEB_MISSING_ID2ENTRY_RECORD.get(entryID));
+        }
 
-            // Put the entry in the cache making sure not to overwrite
-            // a newer copy that may have been inserted since the time
-            // we read the cache.
-            if (entryCache != null)
-            {
-              entryCache.putEntryIfAbsent(entry2, backend, entryID.longValue());
-            }
-            return entry2;
-          }
-        });
+        // Put the entry in the cache making sure not to overwrite
+        // a newer copy that may have been inserted since the time
+        // we read the cache.
+        if (entryCache != null)
+        {
+          entryCache.putEntryIfAbsent(entry2, backend, entryID.longValue());
+        }
+        return entry2;
       }
       catch (Exception e)
       {
@@ -3308,7 +3319,7 @@
     Entry baseEntry = null;
     try
     {
-      baseEntry = getEntry(baseDN);
+      baseEntry = getEntry0(txn, baseDN);
     }
     catch (Exception e)
     {

--
Gitblit v1.10.0