From 974d84fec523fb2ab9592c78683abec2a34e5ada Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 23 Jan 2015 09:59:42 +0000
Subject: [PATCH] Code cleanup: - reduced methods visibility - removed unnecessary method overloading
---
opendj3-server-dev/src/server/org/opends/server/backends/jeb/ID2Entry.java | 30 ++-------
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java | 17 +++--
opendj3-server-dev/src/server/org/opends/server/backends/jeb/DatabaseContainer.java | 18 +----
opendj3-server-dev/src/server/org/opends/server/backends/jeb/DN2ID.java | 19 ++----
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/ID2Entry.java | 26 ++------
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DN2ID.java | 15 +---
6 files changed, 37 insertions(+), 88 deletions(-)
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 7c2dc7b..55c204c 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
@@ -22,21 +22,21 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.backends.jeb;
+import static com.sleepycat.je.LockMode.*;
+import static com.sleepycat.je.OperationStatus.*;
+
+import static org.opends.server.backends.jeb.JebFormat.*;
+
import java.util.Comparator;
import org.opends.server.types.DN;
import com.sleepycat.je.*;
-import static com.sleepycat.je.LockMode.*;
-import static com.sleepycat.je.OperationStatus.*;
-
-import static org.opends.server.backends.jeb.JebFormat.*;
-
/**
* This class represents the DN database, or dn2id, which has one record
* for each entry. The key is the normalized entry DN and the value
@@ -122,13 +122,6 @@
return delete(txn, key) == SUCCESS;
}
- /** {@inheritDoc} */
- @Override
- protected OperationStatus delete(Transaction txn, DatabaseEntry key) throws DatabaseException
- {
- return super.delete(txn, key);
- }
-
/**
* Fetch the entry ID for a given DN.
* @param txn A JE database transaction to be used for the database read, or
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/DatabaseContainer.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/DatabaseContainer.java
index f2bd4d0..44e55e9 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/DatabaseContainer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/DatabaseContainer.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2011-2014 ForgeRock AS
+ * Portions Copyright 2011-2015 ForgeRock AS
*/
package org.opends.server.backends.jeb;
@@ -147,9 +147,7 @@
* @return The operation status.
* @throws DatabaseException If an error occurs in the JE operation.
*/
- protected OperationStatus put(Transaction txn, DatabaseEntry key,
- DatabaseEntry data)
- throws DatabaseException
+ OperationStatus put(Transaction txn, DatabaseEntry key, DatabaseEntry data) throws DatabaseException
{
OperationStatus status = database.put(txn, key, data);
if (logger.isTraceEnabled())
@@ -170,9 +168,7 @@
* @return The operation status.
* @throws DatabaseException If an error occurs in the JE operation.
*/
- protected OperationStatus read(Transaction txn,
- DatabaseEntry key, DatabaseEntry data,
- LockMode lockMode)
+ OperationStatus read(Transaction txn, DatabaseEntry key, DatabaseEntry data, LockMode lockMode)
throws DatabaseException
{
OperationStatus status = database.get(txn, key, data, lockMode);
@@ -192,9 +188,7 @@
* @return The operation status.
* @throws DatabaseException If an error occurs in the JE operation.
*/
- protected OperationStatus insert(Transaction txn,
- DatabaseEntry key, DatabaseEntry data)
- throws DatabaseException
+ OperationStatus insert(Transaction txn, DatabaseEntry key, DatabaseEntry data) throws DatabaseException
{
OperationStatus status = database.putNoOverwrite(txn, key, data);
if (logger.isTraceEnabled())
@@ -212,9 +206,7 @@
* @return The operation status.
* @throws DatabaseException If an error occurs in the JE operation.
*/
- protected OperationStatus delete(Transaction txn,
- DatabaseEntry key)
- throws DatabaseException
+ OperationStatus delete(Transaction txn, DatabaseEntry key) throws DatabaseException
{
OperationStatus status = database.delete(txn, key);
if (logger.isTraceEnabled())
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/ID2Entry.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/ID2Entry.java
index 95fa0da..a594cb9 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/ID2Entry.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/ID2Entry.java
@@ -22,10 +22,16 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2012-2014 ForgeRock AS.
+ * Portions Copyright 2012-2015 ForgeRock AS.
*/
package org.opends.server.backends.jeb;
+import static com.sleepycat.je.OperationStatus.*;
+
+import static org.forgerock.util.Utils.*;
+import static org.opends.messages.JebMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
+
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.DataFormatException;
@@ -47,12 +53,6 @@
import com.sleepycat.je.*;
-import static com.sleepycat.je.OperationStatus.*;
-
-import static org.forgerock.util.Utils.*;
-import static org.opends.messages.JebMessages.*;
-import static org.opends.server.core.DirectoryServer.*;
-
/**
* Represents the database containing the LDAP entries. The database key is
* the entry ID and the value is the entry contents.
@@ -370,22 +370,6 @@
}
/**
- * Write a pre-formatted record into the entry database.
- *
- * @param txn The database transaction or null if none.
- * @param key The key containing a pre-formatted entry ID.
- * @param data The data value containing a pre-formatted LDAP entry.
- * @return true if the entry was written, false if it was not.
- * @throws DatabaseException If an error occurs in the JE database.
- */
- @Override
- public OperationStatus put(Transaction txn, DatabaseEntry key, DatabaseEntry data)
- throws DatabaseException
- {
- return super.put(txn, key, data);
- }
-
- /**
* Remove a record from the entry database.
*
* @param txn The database transaction or null if none.
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DN2ID.java b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DN2ID.java
index 9879ae7..4c090ba6 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DN2ID.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DN2ID.java
@@ -22,10 +22,12 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
package org.opends.server.backends.pluggable;
+import static org.opends.server.backends.pluggable.JebFormat.*;
+
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.backends.pluggable.spi.ReadableStorage;
@@ -35,8 +37,6 @@
import org.opends.server.backends.pluggable.spi.WriteableStorage;
import org.opends.server.types.DN;
-import static org.opends.server.backends.pluggable.JebFormat.*;
-
/**
* This class represents the DN database, or dn2id, which has one record
* for each entry. The key is the normalized entry DN and the value
@@ -136,19 +136,12 @@
return delete(txn, key);
}
- /** {@inheritDoc} */
- @Override
- protected boolean delete(WriteableStorage txn, ByteSequence key) throws StorageRuntimeException
- {
- return super.delete(txn, key);
- }
-
/**
* Fetch the entry ID for a given DN.
* @param txn A JE database transaction to be used for the database read, or
* null if none is required.
* @param dn The DN for which the entry ID is desired.
- * @param isRMW
+ * @param isRMW whether the read operation is part of a larger read-modify-write operation
* @return The entry ID, or null if the given DN is not in the DN database.
* @throws StorageRuntimeException If an error occurs in the JE database.
*/
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java
index 5df206d..8504747 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2011-2014 ForgeRock AS
+ * Portions Copyright 2011-2015 ForgeRock AS
*/
package org.opends.server.backends.pluggable;
@@ -75,6 +75,7 @@
* database configuration is transactional, a transaction will be
* created and used to perform the open.
*
+ * @param txn The JE transaction handle, or null if none.
* @throws StorageRuntimeException if a JE database error occurs while
* opening the index.
*/
@@ -121,8 +122,7 @@
* @param value The record value.
* @throws StorageRuntimeException If an error occurs in the JE operation.
*/
- protected void put(WriteableStorage txn, ByteSequence key, ByteSequence value)
- throws StorageRuntimeException
+ void put(WriteableStorage txn, ByteSequence key, ByteSequence value) throws StorageRuntimeException
{
txn.create(treeName, key, value);
if (logger.isTraceEnabled())
@@ -136,13 +136,13 @@
* simple wrapper around the JE Database.get method.
* @param txn The JE transaction handle, or null if none.
* @param key The key of the record to be read.
+ * @param isRMW whether the read operation is part of a larger read-modify-write operation
* @return The operation status.
* @throws StorageRuntimeException If an error occurs in the JE operation.
*/
- protected ByteString read(ReadableStorage txn, ByteSequence key, boolean isRMW) throws StorageRuntimeException
+ ByteString read(ReadableStorage txn, ByteSequence key, boolean isRMW) throws StorageRuntimeException
{
- ByteString value = isRMW ? txn.getRMW(treeName, key) : txn.read(treeName,
- key);
+ ByteString value = isRMW ? txn.getRMW(treeName, key) : txn.read(treeName, key);
if (logger.isTraceEnabled())
{
logger.trace(messageToLog(value != null, treeName, txn, key, value));
@@ -159,7 +159,7 @@
* @return <code>true</code> if the key-value mapping could be inserted, <code>false</code> if the key was already mapped to another value
* @throws StorageRuntimeException If an error occurs in the JE operation.
*/
- protected boolean insert(WriteableStorage txn, ByteString key, ByteString value) throws StorageRuntimeException
+ boolean insert(WriteableStorage txn, ByteString key, ByteString value) throws StorageRuntimeException
{
boolean result = txn.putIfAbsent(treeName, key, value);
if (logger.isTraceEnabled())
@@ -177,7 +177,7 @@
* @return <code>true</code> if the key mapping was removed, <code>false</code> otherwise
* @throws StorageRuntimeException If an error occurs in the JE operation.
*/
- protected boolean delete(WriteableStorage txn, ByteSequence key) throws StorageRuntimeException
+ boolean delete(WriteableStorage txn, ByteSequence key) throws StorageRuntimeException
{
boolean result = txn.remove(treeName, key);
if (logger.isTraceEnabled())
@@ -204,6 +204,7 @@
/**
* Get the count of key/data pairs in the database in a JE database.
* This is a simple wrapper around the JE Database.count method.
+ * @param txn The JE transaction handle, or null if none.
* @return The count of key/data pairs in the database.
* @throws StorageRuntimeException If an error occurs in the JE operation.
*/
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/ID2Entry.java b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/ID2Entry.java
index f2a7fba..361ef01 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/ID2Entry.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/ID2Entry.java
@@ -22,10 +22,14 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2012-2014 ForgeRock AS.
+ * Portions Copyright 2012-2015 ForgeRock AS.
*/
package org.opends.server.backends.pluggable;
+import static org.forgerock.util.Utils.*;
+import static org.opends.messages.JebMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
+
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.DataFormatException;
@@ -36,7 +40,6 @@
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
-import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.DecodeException;
@@ -51,10 +54,6 @@
import org.opends.server.types.Entry;
import org.opends.server.types.LDAPException;
-import static org.forgerock.util.Utils.*;
-import static org.opends.messages.JebMessages.*;
-import static org.opends.server.core.DirectoryServer.*;
-
/**
* Represents the database containing the LDAP entries. The database key is
* the entry ID and the value is the entry contents.
@@ -370,20 +369,6 @@
}
/**
- * Write a pre-formatted record into the entry database.
- *
- * @param txn The database transaction or null if none.
- * @param key The key containing a pre-formatted entry ID.
- * @param value The data value containing a pre-formatted LDAP entry.
- * @throws StorageRuntimeException If an error occurs in the JE database.
- */
- @Override
- public void put(WriteableStorage txn, ByteSequence key, ByteSequence value) throws StorageRuntimeException
- {
- super.put(txn, key, value);
- }
-
- /**
* Remove a record from the entry database.
*
* @param txn The database transaction or null if none.
@@ -401,6 +386,7 @@
*
* @param txn The database transaction or null if none.
* @param id The desired entry ID which forms the key.
+ * @param isRMW whether the read operation is part of a larger read-modify-write operation
* @return The requested entry, or null if there is no such record.
* @throws DirectoryException If a problem occurs while getting the entry.
* @throws StorageRuntimeException If an error occurs in the JE database.
--
Gitblit v1.10.0