From 87d97e3d8e4f2c1e7072255407c084bf6a16a576 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 19 Apr 2013 07:24:20 +0000
Subject: [PATCH] SearchOperationBasis.java, InternalSearchOperation.java, AddRequestProtocolOp.java, ModifyRequestProtocolOp.java, SearchRequestProtocolOp.java: Replaced the use of collections' concrete classes by interfaces in the method signatures.
---
opends/src/server/org/opends/server/core/SearchOperationBasis.java | 142 ++++++++++++++++-------
opends/src/server/org/opends/server/protocols/internal/InternalSearchOperation.java | 11 +
opends/src/server/org/opends/server/protocols/ldap/AddRequestProtocolOp.java | 25 ++--
opends/src/server/org/opends/server/protocols/ldap/ModifyRequestProtocolOp.java | 27 ++-
opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestModifyRequestProtocolOp.java | 87 ++++++--------
opends/src/server/org/opends/server/protocols/ldap/SearchRequestProtocolOp.java | 43 ++++---
6 files changed, 199 insertions(+), 136 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/SearchOperationBasis.java b/opends/src/server/org/opends/server/core/SearchOperationBasis.java
index e5646eb..2b42632 100644
--- a/opends/src/server/org/opends/server/core/SearchOperationBasis.java
+++ b/opends/src/server/org/opends/server/core/SearchOperationBasis.java
@@ -27,9 +27,6 @@
*/
package org.opends.server.core;
-import org.opends.messages.MessageBuilder;
-import org.opends.messages.Message;
-
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -38,6 +35,8 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.opends.messages.Message;
+import org.opends.messages.MessageBuilder;
import org.opends.server.api.AuthenticationPolicyState;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.plugin.PluginResult;
@@ -54,12 +53,12 @@
import org.opends.server.types.operation.SearchReferenceSearchOperation;
import org.opends.server.util.TimeThread;
-import static org.opends.server.core.CoreConstants.*;
-import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
-import static org.opends.server.loggers.AccessLogger.*;
import static org.opends.messages.CoreMessages.*;
-import static org.opends.server.util.StaticUtils.toLowerCase;
+import static org.opends.server.core.CoreConstants.*;
+import static org.opends.server.loggers.AccessLogger.*;
+import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
/**
* This class defines an operation that may be used to locate entries in the
@@ -78,86 +77,98 @@
*/
private static final DebugTracer TRACER = DebugLogger.getTracer();
- // Indicates whether a search result done response has been sent to the
- // client.
+ /**
+ * Indicates whether a search result done response has been sent to the
+ * client.
+ */
private AtomicBoolean responseSent;
- // Indicates whether the client is able to handle referrals.
+ /** Indicates whether the client is able to handle referrals. */
private boolean clientAcceptsReferrals;
- // Indicates whether to include the account usable control with search result
- // entries.
+ /**
+ * Indicates whether to include the account usable control with search result
+ * entries.
+ */
private boolean includeUsableControl;
- // Indicates whether to only real attributes should be returned.
+ /** Indicates whether to only real attributes should be returned. */
private boolean realAttributesOnly;
- // Indicates whether only LDAP subentries should be returned.
+ /** Indicates whether only LDAP subentries should be returned. */
private boolean returnSubentriesOnly;
- // Indicates whether the filter references subentry or ldapSubentry object
- // class.
+ /**
+ * Indicates whether the filter references subentry or ldapSubentry object
+ * class.
+ */
private boolean filterIncludesSubentries;
private boolean filterNeedsCheckingForSubentries = true;
- // Indicates whether to include attribute types only or both types and values.
+ /**
+ * Indicates whether to include attribute types only or both types and values.
+ */
private boolean typesOnly;
- // Indicates whether to only virtual attributes should be returned.
+ /** Indicates whether to only virtual attributes should be returned. */
private boolean virtualAttributesOnly;
- // The raw, unprocessed base DN as included in the request from the client.
+ /**
+ * The raw, unprocessed base DN as included in the request from the client.
+ */
private ByteString rawBaseDN;
- // The dereferencing policy for the search operation.
+ /** The dereferencing policy for the search operation. */
private DereferencePolicy derefPolicy;
- // The base DN for the search operation.
+ /** The base DN for the search operation. */
private DN baseDN;
- // The proxied authorization target DN for this operation.
+ /** The proxied authorization target DN for this operation. */
private DN proxiedAuthorizationDN;
- // The number of entries that have been sent to the client.
+ /** The number of entries that have been sent to the client. */
private int entriesSent;
- // The number of search result references that have been sent to the client.
+ /**
+ * The number of search result references that have been sent to the client.
+ */
private int referencesSent;
- // The size limit for the search operation.
+ /** The size limit for the search operation. */
private int sizeLimit;
- // The time limit for the search operation.
+ /** The time limit for the search operation. */
private int timeLimit;
- // The raw, unprocessed filter as included in the request from the client.
+ /** The raw, unprocessed filter as included in the request from the client. */
private RawFilter rawFilter;
- // The set of attributes that should be returned in matching entries.
+ /** The set of attributes that should be returned in matching entries. */
private Set<String> attributes;
- // The set of response controls for this search operation.
+ /** The set of response controls for this search operation. */
private List<Control> responseControls;
- // The time that processing started on this operation.
+ /** The time that processing started on this operation. */
private long processingStartTime;
- // The time that processing ended on this operation.
+ /** The time that processing ended on this operation. */
private long processingStopTime;
- // The time that the search time limit has expired.
+ /** The time that the search time limit has expired. */
private long timeLimitExpiration;
- // The matched values control associated with this search operation.
+ /** The matched values control associated with this search operation. */
private MatchedValuesControl matchedValuesControl;
- // The search filter for the search operation.
+ /** The search filter for the search operation. */
private SearchFilter filter;
- // The search scope for the search operation.
+ /** The search scope for the search operation. */
private SearchScope scope;
- // Indicates wether to send the search result done to the client or not
+ /** Indicates whether to send the search result done to the client or not. */
private boolean sendResponse = true;
/**
@@ -188,7 +199,7 @@
ByteString rawBaseDN, SearchScope scope,
DereferencePolicy derefPolicy, int sizeLimit,
int timeLimit, boolean typesOnly, RawFilter rawFilter,
- LinkedHashSet<String> attributes)
+ Set<String> attributes)
{
super(clientConnection, operationID, messageID, requestControls);
@@ -287,7 +298,7 @@
DN baseDN, SearchScope scope,
DereferencePolicy derefPolicy, int sizeLimit,
int timeLimit, boolean typesOnly, SearchFilter filter,
- LinkedHashSet<String> attributes)
+ Set<String> attributes)
{
super(clientConnection, operationID, messageID, requestControls);
@@ -363,6 +374,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final ByteString getRawBaseDN()
{
return rawBaseDN;
@@ -373,6 +385,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void setRawBaseDN(ByteString rawBaseDN)
{
this.rawBaseDN = rawBaseDN;
@@ -384,6 +397,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final DN getBaseDN()
{
try
@@ -412,6 +426,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void setBaseDN(DN baseDN)
{
this.baseDN = baseDN;
@@ -420,6 +435,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final SearchScope getScope()
{
return scope;
@@ -428,6 +444,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void setScope(SearchScope scope)
{
this.scope = scope;
@@ -436,6 +453,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final DereferencePolicy getDerefPolicy()
{
return derefPolicy;
@@ -444,6 +462,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void setDerefPolicy(DereferencePolicy derefPolicy)
{
this.derefPolicy = derefPolicy;
@@ -452,6 +471,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final int getSizeLimit()
{
return sizeLimit;
@@ -460,6 +480,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void setSizeLimit(int sizeLimit)
{
this.sizeLimit = sizeLimit;
@@ -468,6 +489,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final int getTimeLimit()
{
return timeLimit;
@@ -476,6 +498,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void setTimeLimit(int timeLimit)
{
this.timeLimit = timeLimit;
@@ -484,6 +507,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final boolean getTypesOnly()
{
return typesOnly;
@@ -492,6 +516,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void setTypesOnly(boolean typesOnly)
{
this.typesOnly = typesOnly;
@@ -500,6 +525,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final RawFilter getRawFilter()
{
return rawFilter;
@@ -508,6 +534,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void setRawFilter(RawFilter rawFilter)
{
this.rawFilter = rawFilter;
@@ -518,6 +545,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final SearchFilter getFilter()
{
try
@@ -545,6 +573,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final Set<String> getAttributes()
{
return attributes;
@@ -553,6 +582,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void setAttributes(Set<String> attributes)
{
if (attributes == null)
@@ -568,6 +598,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final int getEntriesSent()
{
return entriesSent;
@@ -576,6 +607,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final int getReferencesSent()
{
return referencesSent;
@@ -584,6 +616,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final boolean returnEntry(Entry entry, List<Control> controls)
{
return returnEntry(entry, controls, true);
@@ -592,6 +625,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final boolean returnEntry(Entry entry, List<Control> controls,
boolean evaluateAci)
{
@@ -856,6 +890,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final boolean returnReference(DN dn, SearchResultReference reference)
{
return returnReference(dn, reference, true);
@@ -864,6 +899,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final boolean returnReference(DN dn, SearchResultReference reference,
boolean evaluateAci)
{
@@ -944,6 +980,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public final void sendSearchResultDone()
{
// Send the search result done message to the client. We want to make sure
@@ -1087,6 +1124,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public DN getProxiedAuthorizationDN()
{
return proxiedAuthorizationDN;
@@ -1157,6 +1195,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setTimeLimitExpiration(Long timeLimitExpiration){
this.timeLimitExpiration = timeLimitExpiration;
}
@@ -1164,6 +1203,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isReturnSubentriesOnly()
{
return returnSubentriesOnly;
@@ -1172,6 +1212,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setReturnSubentriesOnly(boolean returnLDAPSubentries)
{
this.returnSubentriesOnly = returnLDAPSubentries;
@@ -1180,6 +1221,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public MatchedValuesControl getMatchedValuesControl()
{
return matchedValuesControl;
@@ -1188,6 +1230,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setMatchedValuesControl(MatchedValuesControl controls)
{
this.matchedValuesControl = controls;
@@ -1196,6 +1239,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isIncludeUsableControl()
{
return includeUsableControl;
@@ -1204,6 +1248,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setIncludeUsableControl(boolean includeUsableControl)
{
this.includeUsableControl = includeUsableControl;
@@ -1212,6 +1257,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Long getTimeLimitExpiration()
{
return timeLimitExpiration;
@@ -1220,6 +1266,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isClientAcceptsReferrals()
{
return clientAcceptsReferrals;
@@ -1228,6 +1275,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setClientAcceptsReferrals(boolean clientAcceptReferrals)
{
this.clientAcceptsReferrals = clientAcceptReferrals;
@@ -1236,6 +1284,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void incrementEntriesSent()
{
entriesSent++;
@@ -1244,6 +1293,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void incrementReferencesSent()
{
referencesSent++;
@@ -1252,6 +1302,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isSendResponse()
{
return sendResponse;
@@ -1260,15 +1311,16 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setSendResponse(boolean sendResponse)
{
this.sendResponse = sendResponse;
-
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isRealAttributesOnly()
{
return this.realAttributesOnly;
@@ -1277,6 +1329,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isVirtualAttributesOnly()
{
return this.virtualAttributesOnly;
@@ -1285,6 +1338,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setRealAttributesOnly(boolean realAttributesOnly)
{
this.realAttributesOnly = realAttributesOnly;
@@ -1293,6 +1347,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setVirtualAttributesOnly(boolean virtualAttributesOnly)
{
this.virtualAttributesOnly = virtualAttributesOnly;
@@ -1301,17 +1356,19 @@
/**
* {@inheritDoc}
*/
+ @Override
public void sendSearchEntry(SearchResultEntry searchEntry)
- throws DirectoryException
- {
+ throws DirectoryException
+ {
getClientConnection().sendSearchEntry(this, searchEntry);
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean sendSearchReference(SearchResultReference searchReference)
- throws DirectoryException
+ throws DirectoryException
{
return getClientConnection().sendSearchReference(this, searchReference);
}
@@ -1319,6 +1376,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN)
{
this.proxiedAuthorizationDN = proxiedAuthorizationDN;
diff --git a/opends/src/server/org/opends/server/protocols/internal/InternalSearchOperation.java b/opends/src/server/org/opends/server/protocols/internal/InternalSearchOperation.java
index 04868c0..f98084a 100644
--- a/opends/src/server/org/opends/server/protocols/internal/InternalSearchOperation.java
+++ b/opends/src/server/org/opends/server/protocols/internal/InternalSearchOperation.java
@@ -23,6 +23,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2013 ForgeRock AS
*/
package org.opends.server.protocols.internal;
@@ -31,6 +32,7 @@
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
import org.opends.server.api.ClientConnection;
import org.opends.server.core.SearchOperationBasis;
@@ -62,14 +64,13 @@
public final class InternalSearchOperation
extends SearchOperationBasis
{
- // The internal search listener for this search, if one was
- // provided.
+ /** The internal search listener for this search, if one was provided. */
private InternalSearchListener searchListener;
- // The set of matching entries returned for this search.
+ /** The set of matching entries returned for this search. */
private LinkedList<SearchResultEntry> entryList;
- // The set of search references returned for this search.
+ /** The set of search references returned for this search. */
private LinkedList<SearchResultReference> referenceList;
@@ -113,7 +114,7 @@
List<Control> requestControls, ByteString rawBaseDN,
SearchScope scope, DereferencePolicy derefPolicy,
int sizeLimit, int timeLimit, boolean typesOnly,
- RawFilter rawFilter, LinkedHashSet<String> attributes,
+ RawFilter rawFilter, Set<String> attributes,
InternalSearchListener searchListener)
{
super(internalConnection, operationID, messageID, requestControls,
diff --git a/opends/src/server/org/opends/server/protocols/ldap/AddRequestProtocolOp.java b/opends/src/server/org/opends/server/protocols/ldap/AddRequestProtocolOp.java
index 9fc264a..22103b2 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/AddRequestProtocolOp.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/AddRequestProtocolOp.java
@@ -23,29 +23,26 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2013 ForgeRock AS
*/
package org.opends.server.protocols.ldap;
-
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.io.IOException;
-import org.opends.server.protocols.asn1.*;
-import org.opends.server.types.RawAttribute;
+import org.opends.server.loggers.debug.DebugTracer;
+import org.opends.server.protocols.asn1.ASN1Writer;
import org.opends.server.types.ByteString;
+import org.opends.server.types.RawAttribute;
import org.opends.server.util.Base64;
-
import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
-
-
/**
* This class defines the structures and methods for an LDAP add request
* protocol op, which is used to add a new entry to the Directory Server.
@@ -58,10 +55,10 @@
*/
private static final DebugTracer TRACER = getTracer();
- // The set of attributes for this add request.
+ /** The set of attributes for this add request. */
private List<RawAttribute> attributes;
- // The DN for this add request.
+ /** The DN for this add request. */
private ByteString dn;
@@ -87,8 +84,7 @@
* @param dn The DN for this add request.
* @param attributes The set of attributes for this add request.
*/
- public AddRequestProtocolOp(ByteString dn,
- ArrayList<RawAttribute> attributes)
+ public AddRequestProtocolOp(ByteString dn, List<RawAttribute> attributes)
{
this.dn = dn;
@@ -133,6 +129,7 @@
*
* @return The BER type for this protocol op.
*/
+ @Override
public byte getType()
{
return OP_TYPE_ADD_REQUEST;
@@ -145,6 +142,7 @@
*
* @return The name for this protocol op type.
*/
+ @Override
public String getProtocolOpName()
{
return "Add Request";
@@ -156,6 +154,7 @@
* @param stream The ASN.1 output stream to write to.
* @throws IOException If a problem occurs while writing to the stream.
*/
+ @Override
public void write(ASN1Writer stream) throws IOException
{
stream.writeStartSequence(OP_TYPE_ADD_REQUEST);
@@ -180,6 +179,7 @@
*
* @param buffer The buffer to which the string should be appended.
*/
+ @Override
public void toString(StringBuilder buffer)
{
buffer.append("AddRequest(dn=");
@@ -211,6 +211,7 @@
* @param indent The number of spaces from the margin that the lines should
* be indented.
*/
+ @Override
public void toString(StringBuilder buffer, int indent)
{
StringBuilder indentBuf = new StringBuilder(indent);
diff --git a/opends/src/server/org/opends/server/protocols/ldap/ModifyRequestProtocolOp.java b/opends/src/server/org/opends/server/protocols/ldap/ModifyRequestProtocolOp.java
index e9b1ea9..01fcba1 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/ModifyRequestProtocolOp.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/ModifyRequestProtocolOp.java
@@ -23,24 +23,24 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2013 ForgeRock AS
*/
package org.opends.server.protocols.ldap;
-
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
-import java.io.IOException;
+import java.util.List;
-import org.opends.server.protocols.asn1.*;
-import org.opends.server.types.RawModification;
+import org.opends.server.loggers.debug.DebugTracer;
+import org.opends.server.protocols.asn1.ASN1Writer;
import org.opends.server.types.ByteString;
+import org.opends.server.types.RawModification;
import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.util.ServerConstants.*;
-
/**
* This class defines the structures and methods for an LDAP modify request
* protocol op, which is used to alter the contents of an entry in the Directory
@@ -54,10 +54,10 @@
*/
private static final DebugTracer TRACER = getTracer();
- // The set of modifications for this modify request.
- private ArrayList<RawModification> modifications;
+ /** The set of modifications for this modify request. */
+ private List<RawModification> modifications;
- // The DN for this modify request.
+ /** The DN for this modify request. */
private ByteString dn;
@@ -84,7 +84,7 @@
* @param modifications The set of modifications for this modify request.
*/
public ModifyRequestProtocolOp(ByteString dn,
- ArrayList<RawModification> modifications)
+ List<RawModification> modifications)
{
this.dn = dn;
@@ -118,7 +118,7 @@
*
* @return The set of modifications for this modify request.
*/
- public ArrayList<RawModification> getModifications()
+ public List<RawModification> getModifications()
{
return modifications;
}
@@ -130,6 +130,7 @@
*
* @return The BER type for this protocol op.
*/
+ @Override
public byte getType()
{
return OP_TYPE_MODIFY_REQUEST;
@@ -142,6 +143,7 @@
*
* @return The name for this protocol op type.
*/
+ @Override
public String getProtocolOpName()
{
return "Modify Request";
@@ -153,6 +155,7 @@
* @param stream The ASN.1 output stream to write to.
* @throws IOException If a problem occurs while writing to the stream.
*/
+ @Override
public void write(ASN1Writer stream) throws IOException
{
stream.writeStartSequence(OP_TYPE_MODIFY_REQUEST);
@@ -176,6 +179,7 @@
*
* @param buffer The buffer to which the string should be appended.
*/
+ @Override
public void toString(StringBuilder buffer)
{
buffer.append("ModifyRequest(dn=");
@@ -207,6 +211,7 @@
* @param indent The number of spaces from the margin that the lines should
* be indented.
*/
+ @Override
public void toString(StringBuilder buffer, int indent)
{
StringBuilder indentBuf = new StringBuilder(indent);
diff --git a/opends/src/server/org/opends/server/protocols/ldap/SearchRequestProtocolOp.java b/opends/src/server/org/opends/server/protocols/ldap/SearchRequestProtocolOp.java
index 424b5b5..b169745 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/SearchRequestProtocolOp.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/SearchRequestProtocolOp.java
@@ -23,24 +23,26 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2013 ForgeRock AS
*/
package org.opends.server.protocols.ldap;
-
+import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedHashSet;
-import java.io.IOException;
+import java.util.Set;
-import org.opends.server.protocols.asn1.*;
-import org.opends.server.types.*;
+import org.opends.server.loggers.debug.DebugTracer;
+import org.opends.server.protocols.asn1.ASN1Writer;
+import org.opends.server.types.ByteString;
+import org.opends.server.types.DereferencePolicy;
+import org.opends.server.types.RawFilter;
+import org.opends.server.types.SearchScope;
import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.util.ServerConstants.*;
-
-
/**
* This class defines the structures and methods for an LDAP search request
* protocol op, which is used to locate entries based on a set of criteria.
@@ -53,28 +55,28 @@
*/
private static final DebugTracer TRACER = getTracer();
- // The typesOnly flag for this search request.
+ /** The typesOnly flag for this search request. */
private boolean typesOnly;
- // The alias dereferencing policy for this search request.
+ /** The alias dereferencing policy for this search request. */
private DereferencePolicy dereferencePolicy;
- // The base DN for this search request.
+ /** The base DN for this search request. */
private ByteString baseDN;
- // The size limit for this search request.
+ /** The size limit for this search request. */
private int sizeLimit;
- // The time limit for this search request.
+ /** The time limit for this search request. */
private int timeLimit;
- // The filter for this search request.
+ /** The filter for this search request. */
private RawFilter filter;
- // The set of requested attributes for this search request.
- private LinkedHashSet<String> attributes;
+ /** The set of requested attributes for this search request. */
+ private Set<String> attributes;
- // The scope for this search request.
+ /** The scope for this search request. */
private SearchScope scope;
@@ -97,7 +99,7 @@
DereferencePolicy dereferencePolicy,
int sizeLimit, int timeLimit,
boolean typesOnly, RawFilter filter,
- LinkedHashSet<String> attributes)
+ Set<String> attributes)
{
this.baseDN = baseDN;
this.scope = scope;
@@ -207,7 +209,7 @@
*
* @return The set of requested attributes for this search request.
*/
- public LinkedHashSet<String> getAttributes()
+ public Set<String> getAttributes()
{
return attributes;
}
@@ -219,6 +221,7 @@
*
* @return The BER type for this protocol op.
*/
+ @Override
public byte getType()
{
return OP_TYPE_SEARCH_REQUEST;
@@ -231,6 +234,7 @@
*
* @return The name for this protocol op type.
*/
+ @Override
public String getProtocolOpName()
{
return "Search Request";
@@ -242,6 +246,7 @@
* @param stream The ASN.1 output stream to write to.
* @throws IOException If a problem occurs while writing to the stream.
*/
+ @Override
public void write(ASN1Writer stream) throws IOException
{
stream.writeStartSequence(OP_TYPE_SEARCH_REQUEST);
@@ -271,6 +276,7 @@
*
* @param buffer The buffer to which the string should be appended.
*/
+ @Override
public void toString(StringBuilder buffer)
{
buffer.append("SearchRequest(baseDN=");
@@ -314,6 +320,7 @@
* @param indent The number of spaces from the margin that the lines should
* be indented.
*/
+ @Override
public void toString(StringBuilder buffer, int indent)
{
StringBuilder indentBuf = new StringBuilder(indent);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestModifyRequestProtocolOp.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestModifyRequestProtocolOp.java
index 08c3ba4..ab1286f 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestModifyRequestProtocolOp.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestModifyRequestProtocolOp.java
@@ -23,21 +23,25 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2013 ForgeRock AS
*/
package org.opends.server.protocols.ldap;
-import static org.opends.server.util.ServerConstants.EOL;
-import org.opends.server.types.*;
-import org.opends.server.protocols.asn1.ASN1Writer;
-import org.opends.server.protocols.asn1.ASN1;
-import org.opends.server.protocols.asn1.ASN1Reader;
-import org.testng.annotations.Test;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
+import static org.opends.server.util.ServerConstants.*;
+import static org.testng.Assert.*;
import java.util.ArrayList;
-import java.util.Random;
+import java.util.List;
+
+import org.opends.server.protocols.asn1.ASN1;
+import org.opends.server.protocols.asn1.ASN1Reader;
+import org.opends.server.protocols.asn1.ASN1Writer;
+import org.opends.server.types.ByteString;
+import org.opends.server.types.ByteStringBuilder;
+import org.opends.server.types.LDAPException;
+import org.opends.server.types.ModificationType;
+import org.opends.server.types.RawModification;
+import org.testng.annotations.Test;
/**
* This class defines a set of tests for the
@@ -81,18 +85,15 @@
* @return The generate attributes.
*
*/
- private ArrayList<RawModification> generateModifications(int numAttributes,
+ private List<RawModification> generateModifications(int numAttributes,
String prefix)
{
- ArrayList<RawModification> modifies = new ArrayList<RawModification>();
- LDAPAttribute attribute;
+ List<RawModification> modifies = new ArrayList<RawModification>();
ModificationType modificationType;
- Random randomGenerator = new Random(0);
- int i, j;
- for(i = 0; i < numAttributes; i++)
+ for(int i = 0; i < numAttributes; i++)
{
- attribute = new LDAPAttribute("testAttribute"+i);
+ LDAPAttribute attribute = new LDAPAttribute("testAttribute" + i);
switch(i % 4)
{
case 0 : modificationType = ModificationType.ADD;
@@ -112,22 +113,18 @@
return modifies;
}
- private Boolean modificationsEquals(ArrayList<RawModification> modifies1,
- ArrayList<RawModification> modifies2)
+ private Boolean modificationsEquals(List<RawModification> modifies1,
+ List<RawModification> modifies2)
{
if(modifies1.size() != modifies2.size())
{
return false;
}
- int i, j;
- RawModification modify1;
- RawModification modify2;
-
- for(i = 0; i < modifies1.size(); i++)
+ for(int i = 0; i < modifies1.size(); i++)
{
- modify1 = modifies1.get(i);
- modify2 = modifies2.get(i);
+ RawModification modify1 = modifies1.get(i);
+ RawModification modify2 = modifies2.get(i);
if(!modify1.getAttribute().getAttributeType().equals(
modify2.getAttribute().getAttributeType()))
{
@@ -179,7 +176,7 @@
public void testConstructors() throws Exception
{
ModifyRequestProtocolOp modifyRequest;
- ArrayList<RawModification> modifications;
+ List<RawModification> modifications;
//Test to make sure the constructor with dn param works.
modifyRequest = new ModifyRequestProtocolOp(dn);
@@ -280,13 +277,12 @@
ByteStringBuilder builder = new ByteStringBuilder();
ASN1Writer writer = ASN1.getWriter(builder);
ModifyRequestProtocolOp modifyEncoded;
- ModifyRequestProtocolOp modifyDecoded;
modifyEncoded = new ModifyRequestProtocolOp(null, null);
modifyEncoded.write(writer);
ASN1Reader reader = ASN1.getReader(builder.toByteString());
- modifyDecoded = (ModifyRequestProtocolOp)LDAPReader.readProtocolOp(reader);
+ LDAPReader.readProtocolOp(reader);
}
/**
@@ -301,7 +297,7 @@
ASN1Writer writer = ASN1.getWriter(builder);
ModifyRequestProtocolOp modifyEncoded;
ModifyRequestProtocolOp modifyDecoded;
- ArrayList<RawModification> modifies;
+ List<RawModification> modifies;
//Test case for a full encode decode operation with normal params.
@@ -348,20 +344,17 @@
@Test
public void TestToStringSingleLine() throws Exception
{
- ModifyRequestProtocolOp modifyRequest;
- ArrayList<RawModification> modifications;
StringBuilder buffer = new StringBuilder();
StringBuilder key = new StringBuilder();
- int i;
- int numModifications;
-
- numModifications = 10;
- modifications = generateModifications(numModifications, "test");
- modifyRequest = new ModifyRequestProtocolOp(dn, modifications);
+ int numModifications = 10;
+ List<RawModification> modifications =
+ generateModifications(numModifications, "test");
+ ModifyRequestProtocolOp modifyRequest =
+ new ModifyRequestProtocolOp(dn, modifications);
modifyRequest.toString(buffer);
key.append("ModifyRequest(dn="+dn+", mods={");
- for(i = 0; i < numModifications; i++)
+ for (int i = 0; i < numModifications; i++)
{
modifications.get(i).toString(key);
if(i < numModifications - 1)
@@ -382,21 +375,19 @@
@Test
public void TestToStringMultiLine() throws Exception
{
- ModifyRequestProtocolOp modifyRequest;
- ArrayList<RawModification> modifications;
StringBuilder buffer = new StringBuilder();
StringBuilder key = new StringBuilder();
- int i;
- int numModifications, indent;
- numModifications = 10;
- indent = 5;
- modifications = generateModifications(numModifications, "test");
- modifyRequest = new ModifyRequestProtocolOp(dn, modifications);
+ int numModifications = 10;
+ int indent = 5;
+ List<RawModification> modifications =
+ generateModifications(numModifications, "test");
+ ModifyRequestProtocolOp modifyRequest =
+ new ModifyRequestProtocolOp(dn, modifications);
modifyRequest.toString(buffer, indent);
StringBuilder indentBuf = new StringBuilder(indent);
- for (i=0 ; i < indent; i++)
+ for (int i = 0; i < indent; i++)
{
indentBuf.append(' ');
}
--
Gitblit v1.10.0