From 7e5ca61ac195cb92e37895a83abddc29e98ac78a Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 04 Sep 2013 15:08:23 +0000
Subject: [PATCH] SearchOperation*.java: Change one field from Long to long.
---
opends/src/server/org/opends/server/core/SearchOperationBasis.java | 122 +++++++++++++---------------------------
opends/src/server/org/opends/server/core/SearchOperationWrapper.java | 17 ++---
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java | 31 +++++-----
opends/src/server/org/opends/server/core/SearchOperation.java | 4
4 files changed, 66 insertions(+), 108 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/SearchOperation.java b/opends/src/server/org/opends/server/core/SearchOperation.java
index fd86b41..8d3de98 100644
--- a/opends/src/server/org/opends/server/core/SearchOperation.java
+++ b/opends/src/server/org/opends/server/core/SearchOperation.java
@@ -135,7 +135,7 @@
*
* @return the timeLimitExpiration
*/
- public abstract Long getTimeLimitExpiration();
+ public abstract long getTimeLimitExpiration();
/**
* Specifies the time limit for this search operation. This should only be
@@ -312,7 +312,7 @@
*
* @param timeLimitExpiration - Time after which the search has expired
*/
- public abstract void setTimeLimitExpiration(Long timeLimitExpiration);
+ public abstract void setTimeLimitExpiration(long timeLimitExpiration);
/**
* Indicates whether LDAP subentries should be returned or not.
diff --git a/opends/src/server/org/opends/server/core/SearchOperationBasis.java b/opends/src/server/org/opends/server/core/SearchOperationBasis.java
index 822cbf3..3f0f22e 100644
--- a/opends/src/server/org/opends/server/core/SearchOperationBasis.java
+++ b/opends/src/server/org/opends/server/core/SearchOperationBasis.java
@@ -27,12 +27,6 @@
*/
package org.opends.server.core;
-import static org.opends.messages.CoreMessages.*;
-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.*;
-
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -53,6 +47,12 @@
import org.opends.server.types.operation.SearchReferenceSearchOperation;
import org.opends.server.util.TimeThread;
+import static org.opends.messages.CoreMessages.*;
+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
* Directory Server based on a given set of criteria.
@@ -214,40 +214,8 @@
this.attributes = attributes;
}
-
- if (clientConnection.getSizeLimit() <= 0)
- {
- this.sizeLimit = sizeLimit;
- }
- else
- {
- if (sizeLimit <= 0)
- {
- this.sizeLimit = clientConnection.getSizeLimit();
- }
- else
- {
- this.sizeLimit = Math.min(sizeLimit, clientConnection.getSizeLimit());
- }
- }
-
-
- if (clientConnection.getTimeLimit() <= 0)
- {
- this.timeLimit = timeLimit;
- }
- else
- {
- if (timeLimit <= 0)
- {
- this.timeLimit = clientConnection.getTimeLimit();
- }
- else
- {
- this.timeLimit = Math.min(timeLimit, clientConnection.getTimeLimit());
- }
- }
-
+ this.sizeLimit = getSizeLimit(sizeLimit, clientConnection);
+ this.timeLimit = getTimeLimit(timeLimit, clientConnection);
baseDN = null;
filter = null;
@@ -264,8 +232,6 @@
virtualAttributesOnly = false;
}
-
-
/**
* Creates a new search operation with the provided information.
*
@@ -316,40 +282,8 @@
rawBaseDN = ByteString.valueOf(baseDN.toString());
rawFilter = new LDAPFilter(filter);
-
- if (clientConnection.getSizeLimit() <= 0)
- {
- this.sizeLimit = sizeLimit;
- }
- else
- {
- if (sizeLimit <= 0)
- {
- this.sizeLimit = clientConnection.getSizeLimit();
- }
- else
- {
- this.sizeLimit = Math.min(sizeLimit, clientConnection.getSizeLimit());
- }
- }
-
-
- if (clientConnection.getTimeLimit() <= 0)
- {
- this.timeLimit = timeLimit;
- }
- else
- {
- if (timeLimit <= 0)
- {
- this.timeLimit = clientConnection.getTimeLimit();
- }
- else
- {
- this.timeLimit = Math.min(timeLimit, clientConnection.getTimeLimit());
- }
- }
-
+ this.sizeLimit = getSizeLimit(sizeLimit, clientConnection);
+ this.timeLimit = getTimeLimit(timeLimit, clientConnection);
entriesSent = 0;
referencesSent = 0;
@@ -363,6 +297,32 @@
}
+ private int getSizeLimit(int sizeLimit, ClientConnection clientConnection)
+ {
+ if (clientConnection.getSizeLimit() <= 0)
+ {
+ return sizeLimit;
+ }
+ else if (sizeLimit <= 0)
+ {
+ return clientConnection.getSizeLimit();
+ }
+ return Math.min(sizeLimit, clientConnection.getSizeLimit());
+ }
+
+ private int getTimeLimit(int timeLimit, ClientConnection clientConnection)
+ {
+ if (clientConnection.getTimeLimit() <= 0)
+ {
+ return timeLimit;
+ }
+ else if (timeLimit <= 0)
+ {
+ return clientConnection.getTimeLimit();
+ }
+ return Math.min(timeLimit, clientConnection.getTimeLimit());
+ }
+
/**
* {@inheritDoc}
@@ -1078,7 +1038,8 @@
* {@inheritDoc}
*/
@Override
- public void setTimeLimitExpiration(Long timeLimitExpiration){
+ public void setTimeLimitExpiration(long timeLimitExpiration)
+ {
this.timeLimitExpiration = timeLimitExpiration;
}
@@ -1140,7 +1101,7 @@
* {@inheritDoc}
*/
@Override
- public Long getTimeLimitExpiration()
+ public long getTimeLimitExpiration()
{
return timeLimitExpiration;
}
@@ -1285,7 +1246,7 @@
DirectoryServer.getPluginConfigManager();
int timeLimit = getTimeLimit();
- Long timeLimitExpiration;
+ long timeLimitExpiration;
if (timeLimit <= 0)
{
timeLimitExpiration = Long.MAX_VALUE;
@@ -1293,8 +1254,7 @@
else
{
// FIXME -- Factor in the user's effective time limit.
- timeLimitExpiration =
- getProcessingStartTime() + (1000L * timeLimit);
+ timeLimitExpiration = getProcessingStartTime() + (1000L * timeLimit);
}
setTimeLimitExpiration(timeLimitExpiration);
diff --git a/opends/src/server/org/opends/server/core/SearchOperationWrapper.java b/opends/src/server/org/opends/server/core/SearchOperationWrapper.java
index 474e3fa..28ede49 100644
--- a/opends/src/server/org/opends/server/core/SearchOperationWrapper.java
+++ b/opends/src/server/org/opends/server/core/SearchOperationWrapper.java
@@ -27,14 +27,12 @@
*/
package org.opends.server.core;
-
import java.util.List;
import java.util.Set;
import org.opends.server.controls.MatchedValuesControl;
import org.opends.server.types.*;
-
/**
* This abstract class wraps/decorates a given search operation.
* This class will be extended by sub-classes to enhance the
@@ -303,7 +301,7 @@
* {@inheritDoc}
*/
@Override
- public void setTimeLimitExpiration(Long timeLimitExpiration)
+ public void setTimeLimitExpiration(long timeLimitExpiration)
{
getOperation().setTimeLimitExpiration(timeLimitExpiration);
}
@@ -366,7 +364,7 @@
* {@inheritDoc}
*/
@Override
- public Long getTimeLimitExpiration()
+ public long getTimeLimitExpiration()
{
return getOperation().getTimeLimitExpiration();
}
@@ -445,7 +443,8 @@
* {@inheritDoc}
*/
@Override
- public boolean isVirtualAttributesOnly(){
+ public boolean isVirtualAttributesOnly()
+ {
return getOperation().isVirtualAttributesOnly();
}
@@ -462,8 +461,8 @@
*/
@Override
public void sendSearchEntry(SearchResultEntry entry)
- throws DirectoryException
- {
+ throws DirectoryException
+ {
getOperation().sendSearchEntry(entry);
}
@@ -472,8 +471,8 @@
*/
@Override
public boolean sendSearchReference(SearchResultReference reference)
- throws DirectoryException
- {
+ throws DirectoryException
+ {
return getOperation().sendSearchReference(reference);
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
index f1f606a..853fb8d 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
@@ -957,16 +957,16 @@
}
private InternalSearchOperation searchOnChangelog(String filterString,
- Set<String> attributes, List<Control> controls) throws LDAPException
+ Set<String> attributes, List<Control> controls) throws Exception
{
return connection.processSearch(
- ByteString.valueOf("cn=changelog"),
+ "cn=changelog",
SearchScope.WHOLE_SUBTREE,
DereferencePolicy.NEVER_DEREF_ALIASES,
0, // Size limit
0, // Time limit
false, // Types only
- LDAPFilter.decode(filterString),
+ filterString,
attributes,
controls,
null);
@@ -2315,9 +2315,9 @@
String filter = "(objectclass=*)";
debugInfo(tn, " Search: " + filter);
InternalSearchOperation op = connection.processSearch(
- ByteString.valueOf("cn=changelog"),
+ "cn=changelog",
SearchScope.WHOLE_SUBTREE,
- LDAPFilter.decode(filter));
+ filter);
// success
assertEquals(op.getResultCode(), ResultCode.SUCCESS, op.getErrorMessage().toString());
@@ -2708,15 +2708,14 @@
"changelog", "lastExternalChangelogCookie");
debugInfo(tn, " Search: " + TEST_ROOT_DN_STRING);
- InternalSearchOperation searchOp =
- connection.processSearch(
- ByteString.valueOf(TEST_ROOT_DN_STRING),
+ InternalSearchOperation searchOp = connection.processSearch(
+ TEST_ROOT_DN_STRING,
SearchScope.BASE_OBJECT,
DereferencePolicy.NEVER_DEREF_ALIASES,
0, // Size limit
0, // Time limit
false, // Types only
- LDAPFilter.decode("(objectclass=*)"),
+ "(objectclass=*)",
attributes,
NO_CONTROL,
null);
@@ -2783,13 +2782,13 @@
throws Exception
{
final InternalSearchOperation searchOp = connection.processSearch(
- ByteString.valueOf(""),
+ "",
SearchScope.BASE_OBJECT,
DereferencePolicy.NEVER_DEREF_ALIASES,
0, // Size limit
0, // Time limit
false, // Types only
- LDAPFilter.decode("(objectclass=*)"),
+ "(objectclass=*)",
attributes,
NO_CONTROL,
null);
@@ -3198,16 +3197,16 @@
private void waitOpResult(Operation operation, ResultCode expectedResult)
throws Exception
{
- int ii=0;
+ int i = 0;
while (operation.getResultCode() == ResultCode.UNDEFINED
|| operation.getResultCode() != expectedResult)
{
sleep(50);
- ii++;
- if (ii>10)
+ i++;
+ if (i > 10)
{
- assertEquals(operation.getResultCode(), expectedResult, operation
- .getErrorMessage().toString());
+ assertEquals(operation.getResultCode(), expectedResult,
+ operation.getErrorMessage().toString());
}
}
}
--
Gitblit v1.10.0