directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r569700 - /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/enumeration/ReferralHandlingEnumeration.java
Date Sat, 25 Aug 2007 16:32:15 GMT
Author: elecharny
Date: Sat Aug 25 09:32:14 2007
New Revision: 569700

URL: http://svn.apache.org/viewvc?rev=569700&view=rev
Log:
° Replaced REF_ATTR by the newly constant declared in SchemaConstant for "ref"
° Used generics for List, Map and Enumerations.
° next() and nextElement() methods are now returning a SearchResult
° using a StringBuilder instead of a StringBuffer (it's supposed to be faster because not
synchronized)
° Minor refactoring (affing some NL)

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/enumeration/ReferralHandlingEnumeration.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/enumeration/ReferralHandlingEnumeration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/enumeration/ReferralHandlingEnumeration.java?rev=569700&r1=569699&r2=569700&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/enumeration/ReferralHandlingEnumeration.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/enumeration/ReferralHandlingEnumeration.java
Sat Aug 25 09:32:14 2007
@@ -37,8 +37,10 @@
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.codec.util.LdapURL;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapReferralException;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.OidNormalizer;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,11 +52,10 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ReferralHandlingEnumeration implements NamingEnumeration
+public class ReferralHandlingEnumeration implements NamingEnumeration<SearchResult>
 {
-    private static final String REF_ATTR = "ref";
     private final Logger log = LoggerFactory.getLogger( ReferralHandlingEnumeration.class
);
-    private final List referrals = new ArrayList();
+    private final List<SearchResult> referrals = new ArrayList<SearchResult>();
     private final NamingEnumeration underlying;
     private final ReferralLut lut;
     private final PartitionNexus nexus;
@@ -66,7 +67,7 @@
     /**
      * The OIDs normalizer map
      */
-    private Map normalizerMap;
+    private Map<String, OidNormalizer> normalizerMap;
 
     public ReferralHandlingEnumeration( NamingEnumeration underlying, ReferralLut lut, AttributeTypeRegistry
registry,
         PartitionNexus nexus, int scope, boolean doThrow ) throws NamingException
@@ -94,6 +95,7 @@
                 referrals.add( result );
                 continue;
             }
+            
             prefetched = result;
             return;
         }
@@ -107,7 +109,7 @@
     }
 
 
-    public Object next() throws NamingException
+    public SearchResult next() throws NamingException
     {
         SearchResult retval = prefetched;
         prefetch();
@@ -153,7 +155,7 @@
     }
 
 
-    public Object nextElement()
+    public SearchResult nextElement()
     {
         try
         {
@@ -171,12 +173,13 @@
     public void doReferralExceptionOnSearchBase() throws NamingException
     {
         // the refs attribute may be filtered out so we might need to lookup the entry
-        Attribute refs = prefetched.getAttributes().get( REF_ATTR );
+        Attribute refs = prefetched.getAttributes().get( SchemaConstants.REF_AT );
+        
         if ( refs == null )
         {
             LdapDN prefetchedDn = new LdapDN( prefetched.getName() );
             prefetchedDn.normalize( normalizerMap );
-            refs = nexus.lookup( new LookupOperationContext( prefetchedDn ) ).get( REF_ATTR
);
+            refs = nexus.lookup( new LookupOperationContext( prefetchedDn ) ).get( SchemaConstants.REF_AT
);
         }
 
         if ( refs == null )
@@ -185,7 +188,8 @@
                 + " does not seem like a referral but we're trying to handle it as one."
);
         }
 
-        List list = new ArrayList( refs.size() );
+        List<String> list = new ArrayList<String>( refs.size() );
+        
         for ( int ii = 0; ii < refs.size(); ii++ )
         {
             String val = ( String ) refs.get( ii );
@@ -210,14 +214,16 @@
                         + ".  Reference will be ignored." );
             }
 
-            StringBuffer buf = new StringBuffer();
+            StringBuilder buf = new StringBuilder();
             buf.append( ldapUrl.getScheme() );
             buf.append( ldapUrl.getHost() );
+            
             if ( ldapUrl.getPort() > 0 )
             {
                 buf.append( ":" );
                 buf.append( ldapUrl.getPort() );
             }
+            
             buf.append( "/" );
             buf.append( ldapUrl.getDn() );
             buf.append( "??" );
@@ -233,15 +239,18 @@
                 case ( SearchControls.ONELEVEL_SCOPE  ):
                     buf.append( "base" );
                     break;
+                    
                 case ( SearchControls.OBJECT_SCOPE  ):
                     buf.append( "base" );
                     break;
+                    
                 default:
                     throw new IllegalStateException( "Unknown recognized search scope: "
+ scope );
             }
 
             list.add( buf.toString() );
         }
+        
         LdapReferralException lre = new LdapReferralException( list );
         throw lre;
     }



Mime
View raw message