directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r687218 - in /directory/apacheds/trunk: core/src/main/java/org/apache/directory/server/core/event/EventType.java protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
Date Wed, 20 Aug 2008 01:36:18 GMT
Author: akarasulu
Date: Tue Aug 19 18:36:18 2008
New Revision: 687218

URL: http://svn.apache.org/viewvc?rev=687218&view=rev
Log:
Adding changeTypes and notification criteria handling for persistent search.

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventType.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventType.java?rev=687218&r1=687217&r2=687218&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventType.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventType.java
Tue Aug 19 18:36:18 2008
@@ -19,6 +19,10 @@
  */
 package org.apache.directory.server.core.event;
 
+import java.util.ArrayList;
+
+import org.apache.directory.shared.ldap.message.PersistentSearchControl;
+
 
 /**
  * The different kinds of events a {@link DirectoryListener} may register for 
@@ -36,7 +40,7 @@
     
     public static final int ALL_EVENT_TYPES_MASK = getAllEventTypesMask();
     public static final int MOVE_OR_RENAME_MASK = MOVE.mask | RENAME.mask;
-    
+    private static final EventType[] EMPTY_EVENT_ARRAY = new EventType[0];
     
     private int mask;
     
@@ -51,6 +55,53 @@
     {
         return mask;
     }
+
+    
+    /**
+     * Gets an array of EventTypes from the PSearchControl changeTypes 
+     * parameter value.  According to the documentation of the changeTypes 
+     * field of the Persistent Search Control:
+     * 
+     * <code>
+     * The changeTypes field is the logical OR of one or more of these values:
+     * add (1), delete (2), modify (4), modDN (8). By default this is set to 1 |
+     * 2 | 4 | 8 which is the integer value 0x0F or 15.
+     * </code>
+     * 
+     * NOTE: When the changeTypes mask includes a modDN(8) we include both the 
+     * RENAME and MOVE EventType objects in the array.
+     * 
+     * @see PersistentSearchControl
+     * @param psearchChangeTypes the value of the changeTypes parameter
+     * @return array of EventType objects
+     */
+    public static EventType[] getEventTypes( int psearchChangeTypes )
+    {
+        ArrayList<EventType> types = new ArrayList<EventType>();
+        
+        if ( isAdd( psearchChangeTypes ) )
+        {
+            types.add( ADD );
+        }
+        
+        if ( isDelete( psearchChangeTypes ) )
+        {
+            types.add( DELETE );
+        }
+        
+        if ( isModify( psearchChangeTypes ) )
+        {
+            types.add( MODIFY );
+        }
+        
+        if ( ( psearchChangeTypes & 8 ) > 0 )
+        {
+            types.add( MOVE );
+            types.add( RENAME );
+        }
+        
+        return types.toArray( EMPTY_EVENT_ARRAY );
+    }
     
     
     private static int getAllEventTypesMask()

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java?rev=687218&r1=687217&r2=687218&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
Tue Aug 19 18:36:18 2008
@@ -23,6 +23,7 @@
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.entry.ServerStringValue;
+import org.apache.directory.server.core.event.EventType;
 import org.apache.directory.server.core.event.NotificationCriteria;
 import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.ldap.LdapSession;
@@ -110,11 +111,16 @@
         // now we process entries for ever as they change
         PersistentSearchListener handler = new PersistentSearchListener( session, req );
         
-        // TODO what about notification criteria ?????????????????? TODO add it 
+        // compose notification criteria and add the listener to the event 
+        // service using that notification criteria to determine which events 
+        // are to be delivered to the persistent search issuing client
         NotificationCriteria criteria = new NotificationCriteria();
         criteria.setAliasDerefMode( req.getDerefAliases() );
         criteria.setBase( req.getBase() );
-        getLdapServer().getDirectoryService().getEventService().addListener( handler );
+        criteria.setFilter( req.getFilter() );
+        criteria.setScope( req.getScope() );
+        criteria.setEventMask( EventType.getEventTypes( psearchControl.getChangeTypes() )
);
+        getLdapServer().getDirectoryService().getEventService().addListener( handler, criteria
);
         return;
     }
     



Mime
View raw message