From f62c39ffa948c06d92702924bb33e435c6c6f529 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 12 Dec 2014 12:45:19 +0000
Subject: [PATCH] Code cleanup

---
 opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java |   15 ++++++---------
 opendj3-server-dev/src/server/org/opends/server/backends/jeb/DN2ID.java          |   20 --------------------
 opendj3-server-dev/src/server/org/opends/server/backends/jeb/State.java          |    7 ++-----
 3 files changed, 8 insertions(+), 34 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java
index 085c75f..290d631 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java
@@ -372,19 +372,19 @@
   }
 
   /**
-   * Makes a byte array representing a substring index key for
+   * Makes a byte string representing a substring index key for
    * one substring of a value.
    *
    * @param bytes The byte array containing the value.
    * @param pos The starting position of the substring.
    * @param len The length of the substring.
-   * @return A byte array containing a substring key.
+   * @return A byte string containing a substring key.
    */
-  private byte[] makeSubstringKey(byte[] bytes, int pos, int len)
+  private ByteString makeSubstringKey(byte[] bytes, int pos, int len)
   {
     byte[] keyBytes = new byte[len];
     System.arraycopy(bytes, pos, keyBytes, 0, len);
-    return keyBytes;
+    return ByteString.wrap(keyBytes);
   }
 
   /**
@@ -411,15 +411,12 @@
     // We produce the keys ABC BCD CDE DE E
     // To find values containing a short substring such as DE,
     // iterate through keys with prefix DE. To find values
-    // containing a longer substring such as BCDE, read keys
-    // BCD and CDE.
+    // containing a longer substring such as BCDE, read keys BCD and CDE.
     for (int i = 0, remain = value.length; remain > 0; i++, remain--)
     {
       int len = Math.min(substrLength, remain);
-      byte[] keyBytes = makeSubstringKey(value, i, len);
-      set.add(ByteString.wrap(keyBytes));
+      set.add(makeSubstringKey(value, i, len));
     }
-
     return set;
   }
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/DN2ID.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/DN2ID.java
index 594d304..7c2dc7b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/DN2ID.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/DN2ID.java
@@ -90,26 +90,6 @@
   }
 
   /**
-   * Write a record to the DN database.  If a record with the given key already
-   * exists, the record will be replaced, otherwise a new record will be
-   * inserted.
-   * @param txn A JE database transaction to be used for the database operation,
-   * or null if none.
-   * @param dn The entry DN, which is the key to the record.
-   * @param id The entry ID, which is the value of the record.
-   * @return true if the record was written, false if it was not written.
-   * @throws DatabaseException If an error occurred while attempting to write
-   * the record.
-   */
-  public boolean put(Transaction txn, DN dn, EntryID id) throws DatabaseException
-  {
-    DatabaseEntry key = new DatabaseEntry(dnToDNKey(dn, prefixRDNComponents));
-    DatabaseEntry data = id.getDatabaseEntry();
-
-    return put(txn, key, data) == SUCCESS;
-  }
-
-  /**
    * Write a record to the DN database, where the key and value are already
    * formatted.
    * @param txn A JE database transaction to be used for the database operation,
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/State.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/State.java
index 18a556b..1e43ec8 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/State.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/State.java
@@ -118,19 +118,16 @@
    * @param txn The database transaction or null if none.
    * @param index The index storing the trusted state info.
    * @param trusted The state value to put into the database.
-   * @return true if the entry was written, false if it was not.
    * @throws DatabaseException If an error occurs in the JE database.
    */
-  public boolean putIndexTrustState(Transaction txn, DatabaseContainer index,
-                                    boolean trusted)
+  public void putIndexTrustState(Transaction txn, DatabaseContainer index, boolean trusted)
        throws DatabaseException
   {
     DatabaseEntry key = keyForIndex(index);
     DatabaseEntry data = new DatabaseEntry();
 
     data.setData(trusted ? trueBytes : falseBytes);
-
-    return put(txn, key, data) == SUCCESS;
+    put(txn, key, data);
   }
 
 }

--
Gitblit v1.10.0