directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r979354 - in /directory: apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/
Date Mon, 26 Jul 2010 16:39:50 GMT
Author: elecharny
Date: Mon Jul 26 16:39:49 2010
New Revision: 979354

URL: http://svn.apache.org/viewvc?rev=979354&view=rev
Log:
The SearchRequest message now takes a DN as a baseDn

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
    directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchRequest.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java?rev=979354&r1=979353&r2=979354&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
Mon Jul 26 16:39:49 2010
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.server.ldap.replication;
 
@@ -65,6 +65,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
@@ -89,11 +90,11 @@ import org.slf4j.LoggerFactory;
 
 
 /**
- * 
+ *
  * Implementation of syncrepl slave a.k.a consumer.
- * 
+ *
  * TODO write test cases
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class SyncReplConsumer implements ConnectionClosedEventListener
@@ -250,11 +251,11 @@ public class SyncReplConsumer implements
 
 
     /**
-     * 
+     *
      *  prepares a SearchRequest for syncing DIT content.
      *
      */
-    public void prepareSyncSearchRequest()
+    public void prepareSyncSearchRequest() throws LdapException
     {
         String baseDn = config.getBaseDn();
 
@@ -442,7 +443,7 @@ public class SyncReplConsumer implements
 
             List<byte[]> uuidList = syncInfoValue.getSyncUUIDs();
             // if refreshDeletes set to true then delete all the entries with entryUUID
-            // present in the syncIdSet 
+            // present in the syncIdSet
             if ( syncInfoValue.isRefreshDeletes() )
             {
                 deleteEntries( uuidList, false );
@@ -536,7 +537,7 @@ public class SyncReplConsumer implements
 
         syncReq.setMode( syncType );
         syncReq.setReloadHint( reloadHint );
-        
+
         if ( syncCookie != null )
         {
             LOG.debug( "searching with searchRequest, cookie '{}'", StringTools.utf8ToString(
syncCookie ) );
@@ -569,7 +570,7 @@ public class SyncReplConsumer implements
         }
 
         ResultCodeEnum resultCode = handleSearchDone( ( SearchResultDone ) resp );
-        
+
         LOG.debug( "sync operation returned result code {}", resultCode );
         if ( resultCode == ResultCodeEnum.NO_SUCH_OBJECT )
         {
@@ -593,7 +594,7 @@ public class SyncReplConsumer implements
                 LOG.error( "Failed to delete the replica base as part of handling E_SYNC_REFRESH_REQUIRED,
disconnecting the consumer", e );
                 disconnet();
             }
-            
+
             removeCookie();
             doSyncSearch( syncType, true );
         }
@@ -854,8 +855,8 @@ public class SyncReplConsumer implements
 
     /**
      * deletes the entries having the UUID given in the list
-     * 
-     * @param uuidList the list of UUIDs 
+     *
+     * @param uuidList the list of UUIDs
      * @throws Exception in case of any problems while deleting the entries
      */
     public void deleteEntries( List<byte[]> uuidList, boolean isRefreshPresent ) throws
Exception
@@ -872,7 +873,7 @@ public class SyncReplConsumer implements
 
         // if it is refreshPresent list then send all the UUIDs for
         // filtering, otherwise breaking the list will cause the
-        // other present entries to be deleted from DIT 
+        // other present entries to be deleted from DIT
         if ( isRefreshPresent )
         {
             LOG.debug( "refresh present syncinfo list has {} UUIDs", uuidList.size() );
@@ -1021,28 +1022,28 @@ public class SyncReplConsumer implements
 
     /**
      * removes all child entries present under the given DN and finally the DN itself
-     * 
+     *
      * Working:
      *          This is a recursive function which maintains a Map<DN,Cursor>.
-     *          The way the cascade delete works is by checking for children for a 
+     *          The way the cascade delete works is by checking for children for a
      *          given DN(i.e opening a search cursor) and if the cursor is empty
      *          then delete the DN else for each entry's DN present in cursor call
      *          deleteChildren() with the DN and the reference to the map.
-     *          
+     *
      *          The reason for opening a search cursor is based on an assumption
      *          that an entry *might* contain children, consider the below DIT fragment
-     *          
+     *
      *          parent
      *          /     \
      *        child1   child2
      *                 /     \
      *               grand21  grand22
-     *               
-     *           The below method works better in the case where the tree depth is >1

-     *          
+     *
+     *           The below method works better in the case where the tree depth is >1
+     *
      *   In the case of passing a non-null DeleteListener, the return value will always be
null, cause the
      *   operation is treated as asynchronous and response result will be sent using the
listener callback
-     *   
+     *
      * @param rootDn the DN which will be removed after removing its children
      * @param map a map to hold the Cursor related to a DN
      * @throws Exception If the DN is not valid or if the deletion failed

Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchRequest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchRequest.java?rev=979354&r1=979353&r2=979354&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchRequest.java
(original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchRequest.java
Mon Jul 26 16:39:49 2010
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.ldap.client.api.message;
 
@@ -23,19 +23,21 @@ package org.apache.directory.ldap.client
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.name.DN;
 
 
 /**
  * Search request protocol message interface.
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
  */
 public class SearchRequest extends AbstractRequest implements AbandonableRequest, RequestWithResponse
 {
     /** Search base distinguished name */
-    private String baseDn;
+    private DN baseDn;
 
     /** Search filter expression tree's root node */
     private String filter;
@@ -58,9 +60,9 @@ public class SearchRequest extends Abstr
     /** Attributes to return */
     private Set<String> attributes = new HashSet<String>();
 
-    
+
     /**
-     * 
+     *
      * Creates a new instance of SearchRequestImpl.
      *
      * @param messageId The message ID
@@ -69,8 +71,8 @@ public class SearchRequest extends Abstr
     {
         super();
     }
-    
-    
+
+
     // ------------------------------------------------------------------------
     // SearchRequest Interface Method Implementations
     // ------------------------------------------------------------------------
@@ -93,7 +95,7 @@ public class SearchRequest extends Abstr
      * objectClasses or attributeTypes, unless they are listed by name, since
      * there may be extremely large number of values for certain operational
      * attributes.
-     * 
+     *
      * @return the attributes to return for this request
      */
     public Set<String> getAttributes()
@@ -104,10 +106,10 @@ public class SearchRequest extends Abstr
 
     /**
      * Gets the search base as a distinguished name.
-     * 
+     *
      * @return the search base
      */
-    public String getBaseDn()
+    public DN getBaseDn()
     {
         return baseDn;
     }
@@ -115,18 +117,29 @@ public class SearchRequest extends Abstr
 
     /**
      * Sets the search base as a distinguished name.
-     * 
+     *
      * @param baseDn the search base
      */
-    public void setBaseDn( String baseDn )
+    public void setBaseDn( DN baseDn )
     {
         this.baseDn = baseDn;
     }
 
 
     /**
+     * Sets the search base as a distinguished name.
+     *
+     * @param baseDn the search base
+     */
+    public void setBaseDn( String baseDn ) throws LdapException
+    {
+        this.baseDn = new DN( baseDn );
+    }
+
+
+    /**
      * Gets the alias handling parameter.
-     * 
+     *
      * @return the alias handling parameter enumeration.
      */
     public AliasDerefMode getDerefAliases()
@@ -137,7 +150,7 @@ public class SearchRequest extends Abstr
 
     /**
      * Sets the alias handling parameter.
-     * 
+     *
      * @param aliasDerefAliases the alias handling parameter enumeration.
      */
     public void setDerefAliases( AliasDerefMode aliasDerefAliases )
@@ -148,7 +161,7 @@ public class SearchRequest extends Abstr
 
     /**
      * Gets the search filter associated with this search request.
-     * 
+     *
      * @return the expression node for the root of the filter expression tree.
      */
     public String getFilter()
@@ -159,8 +172,8 @@ public class SearchRequest extends Abstr
 
     /**
      * Sets the search filter associated with this search request.
-     * 
-     * @param filter the expression node for the root of the filter 
+     *
+     * @param filter the expression node for the root of the filter
      * expression tree.
      */
     public void setFilter( String filter )
@@ -171,7 +184,7 @@ public class SearchRequest extends Abstr
 
     /**
      * Gets the search scope parameter enumeration.
-     * 
+     *
      * @return the scope enumeration parameter.
      */
     public SearchScope getScope()
@@ -182,7 +195,7 @@ public class SearchRequest extends Abstr
 
     /**
      * Sets the search scope parameter enumeration.
-     * 
+     *
      * @param scope the scope enumeration parameter.
      */
     public void setScope( SearchScope scope )
@@ -196,7 +209,7 @@ public class SearchRequest extends Abstr
      * as a result of the search. A value of 0 in this field indicates that no
      * client-requested sizelimit restrictions are in effect for the search.
      * Servers may enforce a maximum number of entries to return.
-     * 
+     *
      * @return search size limit.
      */
     public long getSizeLimit()
@@ -210,7 +223,7 @@ public class SearchRequest extends Abstr
      * returned as a result of the search. A value of 0 in this field indicates
      * that no client-requested sizelimit restrictions are in effect for the
      * search. Servers may enforce a maximum number of entries to return.
-     * 
+     *
      * @param entriesMax maximum search result entries to return.
      */
     public void setSizeLimit( long entriesMax )
@@ -223,7 +236,7 @@ public class SearchRequest extends Abstr
      * Gets the timelimit that restricts the maximum time (in seconds) allowed
      * for a search. A value of 0 in this field indicates that no client-
      * requested timelimit restrictions are in effect for the search.
-     * 
+     *
      * @return the search time limit in seconds.
      */
     public int getTimeLimit()
@@ -236,7 +249,7 @@ public class SearchRequest extends Abstr
      * Sets the timelimit that restricts the maximum time (in seconds) allowed
      * for a search. A value of 0 in this field indicates that no client-
      * requested timelimit restrictions are in effect for the search.
-     * 
+     *
      * @param secondsMax the search time limit in seconds.
      */
     public void setTimeLimit( int secondsMax )
@@ -250,7 +263,7 @@ public class SearchRequest extends Abstr
      * types and values, or just attribute types. Setting this field to TRUE
      * causes only attribute types (no values) to be returned. Setting this
      * field to FALSE causes both attribute types and values to be returned.
-     * 
+     *
      * @return true for only types, false for types and values.
      */
     public boolean getTypesOnly()
@@ -264,7 +277,7 @@ public class SearchRequest extends Abstr
      * types and values, or just attribute types. Setting this field to TRUE
      * causes only attribute types (no values) to be returned. Setting this
      * field to FALSE causes both attribute types and values to be returned.
-     * 
+     *
      * @param typesOnly
      *            true for only types, false for types and values.
      */
@@ -276,7 +289,7 @@ public class SearchRequest extends Abstr
 
     /**
      * Adds attributes to the set of entry attributes to return.
-     * 
+     *
      * @param attributes the attributes description or identifier.
      * @return The object itself, to allow chaining
      */
@@ -286,24 +299,24 @@ public class SearchRequest extends Abstr
         {
             return this;
         }
-        
+
         if ( this.attributes == null )
         {
             this.attributes = new HashSet<String>( attributes.length );
         }
-        
+
         for ( String attribute:attributes )
         {
             this.attributes.add( attribute );
         }
-        
+
         return this;
     }
 
 
     /**
      * Removes attributes to the set of entry attributes to return.
-     * 
+     *
      * @param attributes the attributes description or identifier.
      * @return The object itself, to allow chaining
      */
@@ -313,17 +326,17 @@ public class SearchRequest extends Abstr
         {
             return this;
         }
-        
+
         if ( this.attributes == null )
         {
             this.attributes = new HashSet<String>( attributes.length );
         }
-        
+
         for ( String attribute:attributes )
         {
             this.attributes.remove( attribute );
         }
-        
+
         return this;
     }
 }



Mime
View raw message