directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r916986 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java
Date Sat, 27 Feb 2010 16:46:09 GMT
Author: elecharny
Date: Sat Feb 27 16:46:09 2010
New Revision: 916986

URL: http://svn.apache.org/viewvc?rev=916986&view=rev
Log:
Removed the JNDI SearchControl from this class

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java?rev=916986&r1=916985&r2=916986&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java
Sat Feb 27 16:46:09 2010
@@ -30,7 +30,6 @@
 import java.util.Set;
 
 import javax.naming.InvalidNameException;
-import javax.naming.directory.SearchControls;
 
 import org.apache.directory.shared.asn1.codec.binary.Hex;
 import org.apache.directory.shared.ldap.codec.util.HttpClientError;
@@ -38,6 +37,7 @@
 import org.apache.directory.shared.ldap.codec.util.URIException;
 import org.apache.directory.shared.ldap.codec.util.UrlDecoderException;
 import org.apache.directory.shared.ldap.filter.FilterParser;
+import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
 
@@ -98,7 +98,7 @@
     private List<String> attributes;
 
     /** The scope */
-    private int scope;
+    private SearchScope scope;
 
     /** The filter as a string */
     private String filter;
@@ -129,7 +129,7 @@
         port = -1;
         dn = null;
         attributes = new ArrayList<String>();
-        scope = SearchControls.OBJECT_SCOPE;
+        scope = SearchScope.OBJECT;
         filter = null;
         extensionList = new ArrayList<Extension>( 2 );
     }
@@ -147,7 +147,7 @@
         port = -1;
         dn = null;
         attributes = new ArrayList<String>();
-        scope = SearchControls.OBJECT_SCOPE;
+        scope = SearchScope.OBJECT;
         filter = null;
         extensionList = new ArrayList<Extension>( 2 );
 
@@ -957,7 +957,7 @@
                     if ( StringTools.isCharASCII( chars, pos, 'e' ) || StringTools.isCharASCII(
chars, pos, 'E' ) )
                     {
                         pos++;
-                        scope = SearchControls.OBJECT_SCOPE;
+                        scope = SearchScope.OBJECT;
                         return pos;
                     }
                 }
@@ -975,7 +975,7 @@
                 {
                     pos++;
 
-                    scope = SearchControls.ONELEVEL_SCOPE;
+                    scope = SearchScope.ONELEVEL;
                     return pos;
                 }
             }
@@ -992,7 +992,7 @@
                 {
                     pos++;
 
-                    scope = SearchControls.SUBTREE_SCOPE;
+                    scope = SearchScope.SUBTREE;
                     return pos;
                 }
             }
@@ -1354,7 +1354,7 @@
             sb.append( '/' ).append( urlEncode( dn.getName(), false ) );
 
             if ( attributes.size() != 0 || forceScopeRendering
-                || ( ( scope != SearchControls.OBJECT_SCOPE ) || ( filter != null ) || (
extensionList.size() != 0 ) ) )
+                || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || ( extensionList.size()
!= 0 ) ) )
             {
                 sb.append( '?' );
 
@@ -1379,46 +1379,20 @@
             {
                 sb.append( '?' );
 
-                switch ( scope )
-                {
-
-                    case SearchControls.OBJECT_SCOPE:
-                        sb.append( "base" );
-                        break;
-
-                    case SearchControls.ONELEVEL_SCOPE:
-                        sb.append( "one" );
-                        break;
-
-                    case SearchControls.SUBTREE_SCOPE:
-                        sb.append( "sub" );
-                        break;
-
-                    default:
-                        break;
-                }
+                sb.append( scope.getLdapUrlValue() );
             }
 
             else
             {
-                if ( ( scope != SearchControls.OBJECT_SCOPE ) || ( filter != null ) || (
extensionList.size() != 0 ) )
+                if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || ( extensionList.size()
!= 0 ) )
                 {
                     sb.append( '?' );
 
                     switch ( scope )
                     {
-
-                        case SearchControls.OBJECT_SCOPE:
-
-                            // This is the default value.
-                            break;
-
-                        case SearchControls.ONELEVEL_SCOPE:
-                            sb.append( "one" );
-                            break;
-
-                        case SearchControls.SUBTREE_SCOPE:
-                            sb.append( "sub" );
+                        case ONELEVEL:
+                        case SUBTREE:
+                            sb.append( scope.getLdapUrlValue() );
                             break;
 
                         default:
@@ -1577,14 +1551,14 @@
 
 
     /**
-     * Returns the scope, one of {@link SearchControls.OBJECT_SCOPE}, 
-     * {@link SearchControls.ONELEVEL_SCOPE} or {@link SearchControls.SUBTREE_SCOPE}.
+     * Returns the scope, one of {@link SearchScope.OBJECT}, 
+     * {@link SearchScope.ONELEVEL} or {@link SearchScope.SUBTREE}.
      * 
      * @return Returns the scope.
      */
     public int getScope()
     {
-        return scope;
+        return scope.ordinal();
     }
 
 
@@ -1750,21 +1724,21 @@
 
 
     /**
-     * Sets the scope. Must be one of {@link SearchControls.OBJECT_SCOPE}, 
-     * {@link SearchControls.ONELEVEL_SCOPE} or {@link SearchControls.SUBTREE_SCOPE},
-     * otherwise {@link SearchControls.OBJECT_SCOPE} is assumed as default.
+     * Sets the scope. Must be one of {@link SearchScope.OBJECT}, 
+     * {@link SearchScope.ONELEVEL} or {@link SearchScope.SUBTREE},
+     * otherwise {@link SearchScope.OBJECT} is assumed as default.
      * 
      * @param scope the new scope
      */
     public void setScope( int scope )
     {
-        if ( scope == SearchControls.ONELEVEL_SCOPE || scope == SearchControls.SUBTREE_SCOPE
)
+        try 
         {
-            this.scope = scope;
+            this.scope = SearchScope.getSearchScope( scope );
         }
-        else
+        catch ( IllegalArgumentException iae )
         {
-            this.scope = SearchControls.OBJECT_SCOPE;
+            this.scope = SearchScope.OBJECT;
         }
     }
 



Mime
View raw message