You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/11/29 11:08:57 UTC
svn commit: r1415111 -
/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
Author: elecharny
Date: Thu Nov 29 10:08:56 2012
New Revision: 1415111
URL: http://svn.apache.org/viewvc?rev=1415111&view=rev
Log:
o Created a specific method to handle replication
o renamed the readResults method to writeResults : this is what this method do, anyway...
Modified:
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java?rev=1415111&r1=1415110&r2=1415111&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java Thu Nov 29 10:08:56 2012
@@ -162,7 +162,7 @@ public class SearchRequestHandler extend
}
// now we process entries forever as they change
- PersistentSearchListener handler = new PersistentSearchListener( session, req );
+ PersistentSearchListener persistentSearchListener = new PersistentSearchListener( session, req );
// compose notification criteria and add the listener to the event
// service using that notification criteria to determine which events
@@ -173,8 +173,8 @@ public class SearchRequestHandler extend
criteria.setFilter( req.getFilter() );
criteria.setScope( req.getScope() );
criteria.setEventMask( EventType.getEventTypes( psearch.getChangeTypes() ) );
- getLdapServer().getDirectoryService().getEventService().addListener( handler, criteria );
- req.addAbandonListener( new SearchAbandonListener( ldapServer, handler ) );
+ getLdapServer().getDirectoryService().getEventService().addListener( persistentSearchListener, criteria );
+ req.addAbandonListener( new SearchAbandonListener( ldapServer, persistentSearchListener ) );
}
@@ -191,22 +191,7 @@ public class SearchRequestHandler extend
// check first for the syncrepl search request decorator
if ( req.getControls().containsKey( SyncRequestValue.OID ) )
{
- if ( replicationReqHandler != null )
- {
- replicationReqHandler.handleSyncRequest( session, req );
- }
- else
- {
- LOG.warn( "This server does not allow replication" );
- // Replication is not allowed on this server. generate a error message
- LdapResult result = req.getResultResponse().getLdapResult();
-
- result.setDiagnosticMessage( "Replication is not allowed on this server" );
- result.setResultCode( ResultCodeEnum.OTHER );
- session.getIoSession().write( req.getResultResponse() );
-
- return;
- }
+ handleReplication( session, req );
}
// if we have the ManageDSAIt decorator, go directly
// to the handling without pre-processing the request
@@ -237,6 +222,30 @@ public class SearchRequestHandler extend
}
}
}
+
+
+ /**
+ * Handle the replication request.
+ */
+ private void handleReplication( LdapSession session, SearchRequest searchRequest ) throws LdapException
+ {
+ if ( replicationReqHandler != null )
+ {
+ replicationReqHandler.handleSyncRequest( session, searchRequest );
+ }
+ else
+ {
+ // Replication is not allowed on this server. generate a error message
+ LOG.warn( "This server does not allow replication" );
+ LdapResult result = searchRequest.getResultResponse().getLdapResult();
+
+ result.setDiagnosticMessage( "Replication is not allowed on this server" );
+ result.setResultCode( ResultCodeEnum.OTHER );
+ session.getIoSession().write( searchRequest.getResultResponse() );
+
+ return;
+ }
+ }
/**
@@ -374,7 +383,7 @@ public class SearchRequestHandler extend
}
- private void readResults( LdapSession session, SearchRequest req, LdapResult ldapResult,
+ private void writeResults( LdapSession session, SearchRequest req, LdapResult ldapResult,
EntryFilteringCursor cursor, long sizeLimit ) throws Exception
{
long count = 0;
@@ -636,6 +645,12 @@ public class SearchRequestHandler extend
if ( Strings.isEmpty( cookie ) )
{
+ // No cursor : do a search.
+ cursor = session.getCoreSession().search( req );
+
+ // Position the cursor at the beginning
+ cursor.beforeFirst();
+
// This is a new search. We have a special case when the paged size
// is above the server size limit : in this case, we default to a
// standard search
@@ -644,14 +659,8 @@ public class SearchRequestHandler extend
// Normal search : create the cursor, and set pagedControl to false
try
{
- // No cursor : do a search.
- cursor = session.getCoreSession().search( req );
-
- // Position the cursor at the beginning
- cursor.beforeFirst();
-
- // And read the entries
- readResults( session, req, ldapResult, cursor, sizeLimit );
+ // And write the entries
+ writeResults( session, req, ldapResult, cursor, sizeLimit );
}
finally
{
@@ -667,6 +676,7 @@ public class SearchRequestHandler extend
// If we had a cookie in the session, remove it
removeContext( session, pagedContext );
+
return req.getResultResponse();
}
else
@@ -682,12 +692,6 @@ public class SearchRequestHandler extend
pagedResultsControl.setSize( 0 );
pagedResultsControl.setCritical( true );
- // No cursor : do a search.
- cursor = session.getCoreSession().search( req );
-
- // Position the cursor at the beginning
- cursor.beforeFirst();
-
// And stores the cursor into the session
pagedContext.setCursor( cursor );
}
@@ -745,7 +749,6 @@ public class SearchRequestHandler extend
pagedResultsControl.setCookie( cookie );
pagedResultsControl.setSize( 0 );
pagedResultsControl.setCritical( true );
-
}
}
@@ -835,7 +838,7 @@ public class SearchRequestHandler extend
long sizeLimit = min( requestLimit, serverLimit );
- readResults( session, req, ldapResult, cursor, sizeLimit );
+ writeResults( session, req, ldapResult, cursor, sizeLimit );
}
finally
{