directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r915599 - in /directory: apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/ apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ apacheds/trunk/protocol-ldap/sr...
Date Tue, 23 Feb 2010 23:57:13 GMT
Author: elecharny
Date: Tue Feb 23 23:57:13 2010
New Revision: 915599

URL: http://svn.apache.org/viewvc?rev=915599&view=rev
Log:
Started to remove the JNDI SearchControl class from the code : some preliminary fixes in SearchScope

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyMVAttributeIT.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
    directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequestCodec.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SearchScope.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java?rev=915599&r1=915598&r2=915599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java
Tue Feb 23 23:57:13 2010
@@ -376,7 +376,7 @@
     {
         SearchControls controls = new SearchControls();
         controls.setCountLimit( sizeLimit );
-        controls.setSearchScope( scope.getJndiScope() );
+        controls.setSearchScope( scope.getScope() );
         controls.setTimeLimit( timeLimit );
 
         Set<String> allReturningAttributes = new HashSet<String>();

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyMVAttributeIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyMVAttributeIT.java?rev=915599&r1=915598&r2=915599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyMVAttributeIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyMVAttributeIT.java
Tue Feb 23 23:57:13 2010
@@ -87,14 +87,23 @@
      * With this test the Master table will grow crazy.
      */
     @Test
-    @Ignore
+    //@Ignore
     public void testAdd500Members() throws Exception
     {
         LdapContext sysRoot = getSystemContext( service );
+        long t0 = System.currentTimeMillis();
         
         // Add 600 members
-        for ( int i = 0; i < 600; i++ )
+        for ( int i = 0; i < 100000; i++ )
         {
+            if ( i% 100 == 0)
+            {
+                long t1 = System.currentTimeMillis();
+                long delta = ( t1 - t0 );
+                System.out.println( "Done : " + i + " in " + delta + "ms" );
+                t0 = t1;
+            }
+            
             String newValue = "cn=member" + i + ",ou=people,o=sevenSeas";
             Attributes attrs = new BasicAttributes( "uniqueMember", newValue, true );
             sysRoot.modifyAttributes( "cn=testing00", DirContext.ADD_ATTRIBUTE, attrs );

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java?rev=915599&r1=915598&r2=915599&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java
Tue Feb 23 23:57:13 2010
@@ -325,7 +325,7 @@
             {
                 ldapUrl.setForceScopeRendering( true );
                 ldapUrl.setAttributes( req.getAttributes() );
-                ldapUrl.setScope( req.getScope().getJndiScope() );
+                ldapUrl.setScope( req.getScope().getScope() );
                 referral.addLdapUrl( ldapUrl.toString() );
                 continue;
             }
@@ -349,7 +349,7 @@
             ldapUrl.getDn().addAll( extra );
             ldapUrl.setForceScopeRendering( true );
             ldapUrl.setAttributes( req.getAttributes() );
-            ldapUrl.setScope( req.getScope().getJndiScope() );
+            ldapUrl.setScope( req.getScope().getScope() );
             referral.addLdapUrl( ldapUrl.toString() );
         }
         

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=915599&r1=915598&r2=915599&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 Feb 23 23:57:13 2010
@@ -816,11 +816,11 @@
                 switch( req.getScope() )
                 {
                     case SUBTREE:
-                        ldapUrl.setScope( SearchScope.SUBTREE.getJndiScope() );
+                        ldapUrl.setScope( SearchScope.SUBTREE.getScope() );
                         break;
                         
                     case ONELEVEL: // one level here is object level on remote server
-                        ldapUrl.setScope( SearchScope.OBJECT.getJndiScope() );
+                        ldapUrl.setScope( SearchScope.OBJECT.getScope() );
                         break;
                         
                     default:
@@ -1199,7 +1199,7 @@
             
             ldapUrl.setForceScopeRendering( true );
             ldapUrl.setAttributes( req.getAttributes() );
-            ldapUrl.setScope( req.getScope().getJndiScope() );
+            ldapUrl.setScope( req.getScope().getScope() );
             referral.addLdapUrl( ldapUrl.toString() );
         }
 

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java?rev=915599&r1=915598&r2=915599&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
Tue Feb 23 23:57:13 2010
@@ -66,7 +66,7 @@
     private int searchTimeout = 0;
 
     /** the search scope */
-    private int searchScope = SearchScope.ONELEVEL.getJndiScope();
+    private int searchScope = SearchScope.ONELEVEL.getScope();
 
     /** the replica's id */
     private int replicaId;

Modified: directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java?rev=915599&r1=915598&r2=915599&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
(original)
+++ directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
Tue Feb 23 23:57:13 2010
@@ -35,6 +35,7 @@
 import org.apache.directory.ldap.client.api.message.LdapResult;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
@@ -60,6 +61,19 @@
         @CreateTransport( protocol = "LDAP" ),
         @CreateTransport( protocol = "LDAPS" ) 
     })
+@ApplyLdifs( {
+    // Entry # 1
+    "dn: uid=superuser,ou=system",
+    "objectClass: person",
+    "objectClass: organizationalPerson",
+    "objectClass: inetOrgPerson",
+    "objectClass: top",
+    "cn: superuser",
+    "sn: administrator",
+    "displayName: Directory Superuser",
+    "uid: superuser",
+    "userPassword: test"
+})
 public class SimpleBindRequestTest extends AbstractLdapTestUnit
 {
     private LdapConnection connection;
@@ -150,41 +164,50 @@
     @Test
     public void testSimpleBindAnonymous() throws Exception
     {
-        // Try with no parameters
-        BindResponse bindResponse = connection.bind();
-        
-        assertNotNull( bindResponse );
-        assertNotNull( bindResponse.getLdapResult() );
-        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
-        assertEquals( 1, bindResponse.getMessageId() );
-        assertTrue( connection.isAuthenticated() );
-
-        connection.unBind();
-        assertFalse( connection.isConnected() );
-
-        // Try with empty strings
-        connection = new LdapConnection( "localhost", ldapServer.getPort() );
-        bindResponse = connection.bind( "", "" );
-        
-        assertNotNull( bindResponse );
-        assertNotNull( bindResponse.getLdapResult() );
-        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
-        assertEquals( 1, bindResponse.getMessageId() );
-        assertTrue( connection.isAuthenticated() );
+        for ( int i = 0; i < 1; i++)
+        {
+            System.out.print( "." );
+            // Try with no parameters
+            BindResponse bindResponse = connection.bind();
+            
+            assertNotNull( bindResponse );
+            assertNotNull( bindResponse.getLdapResult() );
+            assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
+            assertEquals( 1, bindResponse.getMessageId() );
+            assertTrue( connection.isAuthenticated() );
+    
+            connection.unBind();
+            assertFalse( connection.isConnected() );
+    
+            // Try with empty strings
+            connection = new LdapConnection( "localhost", ldapServer.getPort() );
+            bindResponse = connection.bind( "", "" );
+            
+            assertNotNull( bindResponse );
+            assertNotNull( bindResponse.getLdapResult() );
+            assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
+            assertEquals( 1, bindResponse.getMessageId() );
+            assertTrue( connection.isAuthenticated() );
+    
+            connection.unBind();
+            assertFalse( connection.isConnected() );
+    
+            // Try with null parameters
+            connection = new LdapConnection( "localhost", ldapServer.getPort() );
+            bindResponse = connection.bind( (String)null, (String)null );
+            
+            assertNotNull( bindResponse );
+            assertNotNull( bindResponse.getLdapResult() );
+            assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
+            assertEquals( 1, bindResponse.getMessageId() );
+            assertTrue( connection.isAuthenticated() );
+            assertTrue( connection.isConnected() );
 
-        connection.unBind();
-        assertFalse( connection.isConnected() );
+            connection.unBind();
+            assertFalse( connection.isConnected() );
 
-        // Try with null parameters
-        connection = new LdapConnection( "localhost", ldapServer.getPort() );
-        bindResponse = connection.bind( (String)null, (String)null );
-        
-        assertNotNull( bindResponse );
-        assertNotNull( bindResponse.getLdapResult() );
-        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
-        assertEquals( 1, bindResponse.getMessageId() );
-        assertTrue( connection.isAuthenticated() );
-        assertTrue( connection.isConnected() );
+            connection = new LdapConnection( "localhost", ldapServer.getPort() );
+        }
     }
 
     
@@ -289,50 +312,118 @@
     @Test
     public void testRequestWhileBinding() throws Exception
     {
-        // Inject the interceptor that waits 1 second when binding 
-        // in order to be able to send a request before we get the response
-        service.getInterceptorChain().addFirst( new BaseInterceptor()
-            {
-            /**
-             * Wait 1 second before going any further
-             */
-            public void bind( NextInterceptor next, BindOperationContext opContext ) throws
Exception
+        try
+        {
+            // Inject the interceptor that waits 1 second when binding 
+            // in order to be able to send a request before we get the response
+            service.getInterceptorChain().addFirst( new BaseInterceptor()
+                {
+                /**
+                 * Wait 1 second before going any further
+                 */
+                public void bind( NextInterceptor next, BindOperationContext opContext )
throws Exception
+                {
+                    // Wait 1 second
+                    Thread.sleep( 1000 );
+                    
+                    next.bind( opContext );
+                }
+            } );
+            
+            // Send another BindRequest
+            BindRequest bindRequest = new BindRequest();
+            bindRequest.setName( "uid=admin,ou=system" );
+            bindRequest.setCredentials( "secret" );
+            
+            BindFuture bindFuture = connection.bindAsync( bindRequest );
+            
+            // Wait a bit to be sure the server is processing the bind request
+            Thread.sleep( 200 );
+            
+            // It will take 1 seconds to bind, let's send another bind request : it should
fail
+            BindResponse response = connection.bind( "uid=admin,ou=system", "secret" );
+            
+            assertFalse( connection.isAuthenticated() );
+            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode()
);
+            
+            // Now get back the BindResponse
+            try
             {
-                // Wait 1 second
-                Thread.sleep( 1000 );
+                BindResponse bindResponse = bindFuture.get( 2000, TimeUnit.MILLISECONDS );
                 
-                next.bind( opContext );
+                assertNotNull( bindResponse );
+                assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
+                assertTrue( connection.isAuthenticated() );
             }
-        } );
+            catch ( TimeoutException toe )
+            {
+                fail();
+            }
+        }
+        finally
+        {
+            service.getInterceptorChain().remove( this.getClass().getName() + "$1" );
+        }
+    }
+    
+    
+    /**
+     * Bind with a new user when the connection is establish with an anonymous authent.
+     */
+    @Test
+    public void testBindUserWhenAnonymous() throws Exception
+    {
+        // Bind anonymous
+        BindResponse bindResponse = connection.bind();
         
-        // Send another BindRequest
-        BindRequest bindRequest = new BindRequest();
-        bindRequest.setName( "uid=admin,ou=system" );
-        bindRequest.setCredentials( "secret" );
+        assertNotNull( bindResponse );
+        assertNotNull( bindResponse.getLdapResult() );
+        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
+        assertEquals( 1, bindResponse.getMessageId() );
+        assertTrue( connection.isAuthenticated() );
         
-        BindFuture bindFuture = connection.bindAsync( bindRequest );
+        // Now bind with some credentials
+        bindResponse = connection.bind( "uid=admin, ou=system", "secret" );
         
-        // Wait a bit to be sure the server is processing the bind request
-        Thread.sleep( 200 );
+        assertNotNull( bindResponse );
+        assertNotNull( bindResponse.getLdapResult() );
+        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
+        assertEquals( 2, bindResponse.getMessageId() );
+        assertTrue( connection.isAuthenticated() );
         
-        // It will take 1 seconds to bind, let's send another bind request : it should fail
-        BindResponse response = connection.bind( "uid=admin,ou=system", "secret" );
+        //And back to anonymous
+        bindResponse = connection.bind();
         
-        assertFalse( connection.isAuthenticated() );
-        assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode()
);
+        assertNotNull( bindResponse );
+        assertNotNull( bindResponse.getLdapResult() );
+        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
+        assertEquals( 3, bindResponse.getMessageId() );
+        assertTrue( connection.isAuthenticated() );
+    }
+    
+    
+    /**
+     * Bind with a new user when the connection is establish with an anonymous authent.
+     */
+    @Test
+    public void testBindUserWhenAlreadyBound() throws Exception
+    {
+        // Bind with some credentials
+        BindResponse bindResponse = connection.bind( "uid=admin, ou=system", "secret" );
         
-        // Now get back the BindResponse
-        try
-        {
-            BindResponse bindResponse = bindFuture.get( 2000, TimeUnit.MILLISECONDS );
-            
-            assertNotNull( bindResponse );
-            assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
-            assertTrue( connection.isAuthenticated() );
-        }
-        catch ( TimeoutException toe )
-        {
-            fail();
-        }
+        assertNotNull( bindResponse );
+        assertNotNull( bindResponse.getLdapResult() );
+        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
+        assertEquals( 1, bindResponse.getMessageId() );
+        assertTrue( connection.isAuthenticated() );
+        
+        // Bind with another user
+        bindResponse = connection.bind( "uid=superuser,ou=system", "test");
+        
+        assertNotNull( bindResponse );
+        assertNotNull( bindResponse.getLdapResult() );
+        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
+        assertEquals( 2, bindResponse.getMessageId() );
+        assertTrue( connection.isAuthenticated() );
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequestCodec.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequestCodec.java?rev=915599&r1=915598&r2=915599&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequestCodec.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequestCodec.java
Tue Feb 23 23:57:13 2010
@@ -565,7 +565,7 @@
             Value.encode( buffer, LdapDN.getBytes( baseObject ) );
 
             // The scope
-            Value.encodeEnumerated( buffer, scope.getJndiScope() );
+            Value.encodeEnumerated( buffer, scope.getScope() );
 
             // The derefAliases
             Value.encodeEnumerated( buffer, derefAliases );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java?rev=915599&r1=915598&r2=915599&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
Tue Feb 23 23:57:13 2010
@@ -144,7 +144,7 @@
         h = h*17 + super.hashCode();
         h = h*17 + ( aliasDerefAliases != null ? aliasDerefAliases.hashCode() : 0 );
         h = h*17 + ( baseDn != null ? baseDn.hashCode() : 0 );
-        h = h*17 + scope.getJndiScope();
+        h = h*17 + scope.getScope();
         
         return h;
     }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SearchScope.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SearchScope.java?rev=915599&r1=915598&r2=915599&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SearchScope.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SearchScope.java
Tue Feb 23 23:57:13 2010
@@ -31,19 +31,19 @@
  */
 public enum SearchScope
 {
-    OBJECT( SearchControls.OBJECT_SCOPE, "base" ), 
-    ONELEVEL( SearchControls.ONELEVEL_SCOPE, "one" ), 
-    SUBTREE( SearchControls.SUBTREE_SCOPE, "sub" );
+    OBJECT( 0, "base" ), 
+    ONELEVEL( 1, "one" ), 
+    SUBTREE( 2, "sub" );
     
     /** 
      * The corresponding JNDI scope constant value as defined in 
      * SearchControls.
      * 
-     * @see javax.naming.directory.SearchControls#OBJECT_SCOPE
-     * @see javax.naming.directory.SearchControls#ONELEVEL_SCOPE
-     * @see javax.naming.directory.SearchControls#SUBTREE_SCOPE
+     * @see SearchScope#OBJECT
+     * @see SearchScope#ONELEVEL
+     * @see SearchScope#SUBTREE
      */ 
-    private final int jndiScope;
+    private final int scope;
     
     /**
      * The LDAP URL string value of either base, one or sub as defined in RFC
@@ -58,12 +58,12 @@
      * Creates a new instance of SearchScope based on the respective 
      * SearchControls scope constant.
      *
-     * @param jndiScope the JNDI scope constant
+     * @param scope the JNDI scope constant
      * @param ldapUrlValue LDAP URL scope string value: base, one, or sub
      */
-    private SearchScope( int jndiScope, String ldapUrlValue )
+    private SearchScope( int scope, String ldapUrlValue )
     {
-        this.jndiScope = jndiScope;
+        this.scope = scope;
         this.ldapUrlValue = ldapUrlValue;
     }
 
@@ -84,14 +84,11 @@
      * Gets the corresponding JNDI scope constant value as defined in 
      * SearchControls.
      * 
-     * @return the jndiScope
-     * @see javax.naming.directory.SearchControls#OBJECT_SCOPE
-     * @see javax.naming.directory.SearchControls#ONELEVEL_SCOPE
-     * @see javax.naming.directory.SearchControls#SUBTREE_SCOPE
+     * @return the scope
      */
-    public int getJndiScope()
+    public int getScope()
     {
-        return jndiScope;
+        return scope;
     }
     
     
@@ -115,18 +112,21 @@
      * @param jndiScope the JNDI numeric value to get SearchScope for
      * @return the SearchScope enumerated type for JNDI numeric value
      */
-    public static SearchScope getSearchScope( int jndiScope )
+    public static SearchScope getSearchScope( int scope )
     {
-        switch( jndiScope )
+        switch( scope )
         {
-            case( SearchControls.OBJECT_SCOPE ): 
+            case 0 : 
                 return OBJECT;
-            case( SearchControls.ONELEVEL_SCOPE ):
+            
+            case 1 :
                 return ONELEVEL;
-            case( SearchControls.SUBTREE_SCOPE ):
+                
+            case 2 :
                 return SUBTREE;
+                
             default:
-                throw new IllegalArgumentException( I18n.err( I18n.ERR_04160, jndiScope )
);
+                throw new IllegalArgumentException( I18n.err( I18n.ERR_04160, scope ) );
         }
     }
 
@@ -138,24 +138,23 @@
      * @param ldapUrlValue the LDAP URL scope value to get SearchScope for
      * @return the SearchScope enumerated type for the LDAP URL scope value
      */
-    public static SearchScope getSearchScope( String ldapUrlValue )
+    public static int getSearchScope( String ldapUrlValue )
     {
         if ( "base".equalsIgnoreCase( ldapUrlValue ) )
         {
-            return OBJECT;
+            return OBJECT.getScope();
         }
         else if ( "one".equalsIgnoreCase( ldapUrlValue ) )
         {
-            return ONELEVEL;
+            return ONELEVEL.getScope();
         }
         else if ( "sub".equalsIgnoreCase( ldapUrlValue ) )
         {
-            return SUBTREE;
+            return SUBTREE.getScope();
         }
         else
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_04161, ldapUrlValue )
);
         }
     }
-
 }



Mime
View raw message