directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r411557 - /directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/
Date Sun, 04 Jun 2006 13:54:19 GMT
Author: elecharny
Date: Sun Jun  4 06:54:18 2006
New Revision: 411557

URL: http://svn.apache.org/viewvc?rev=411557&view=rev
Log:
Switched to LdapDN

Modified:
    directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java
    directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
    directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java
    directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java
    directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java
    directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java
    directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java
    directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
    directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java

Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java?rev=411557&r1=411556&r2=411557&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java
(original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java
Sun Jun  4 06:54:18 2006
@@ -30,6 +30,7 @@
 import org.apache.directory.shared.ldap.message.ManageDsaITControl;
 import org.apache.directory.shared.ldap.message.ReferralImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
@@ -117,7 +118,7 @@
                 && ( ( code == ResultCodeEnum.NOSUCHOBJECT ) || ( code == ResultCodeEnum.ALIASPROBLEM
)
                     || ( code == ResultCodeEnum.INVALIDDNSYNTAX ) || ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM
) ) )
             {
-                result.setMatchedDn( e.getResolvedName().toString() );
+                result.setMatchedDn( (LdapDN)e.getResolvedName() );
             }
 
             session.write( req.getResultResponse() );

Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java?rev=411557&r1=411556&r2=411557&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
(original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
Sun Jun  4 06:54:18 2006
@@ -32,8 +32,8 @@
 import org.apache.directory.shared.ldap.message.LdapResult;
 import org.apache.directory.shared.ldap.message.ManageDsaITControl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
-import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
 
@@ -45,7 +45,6 @@
  * A single reply handler for {@link org.apache.directory.shared.ldap.message.BindRequest}s.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
  */
 public class BindHandler implements MessageHandler
 {
@@ -69,14 +68,11 @@
             return;
         }
 
-        boolean emptyDn = StringTools.isEmpty( req.getName() );
-
         // clone the environment first then add the required security settings
-        String dn = ( emptyDn ? "" : req.getName() );
         byte[] creds = req.getCredentials();
 
         Hashtable cloned = ( Hashtable ) env.clone();
-        cloned.put( Context.SECURITY_PRINCIPAL, dn );
+        cloned.put( Context.SECURITY_PRINCIPAL, req.getName() );
         cloned.put( Context.SECURITY_CREDENTIALS, creds );
         cloned.put( Context.SECURITY_AUTHENTICATION, "simple" );
 
@@ -135,7 +131,7 @@
                 && ( ( code == ResultCodeEnum.NOSUCHOBJECT ) || ( code == ResultCodeEnum.ALIASPROBLEM
)
                     || ( code == ResultCodeEnum.INVALIDDNSYNTAX ) || ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM
) ) )
             {
-                result.setMatchedDn( e.getResolvedName().toString() );
+                result.setMatchedDn( (LdapDN)e.getResolvedName() );
             }
 
             result.setErrorMessage( msg );

Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java?rev=411557&r1=411556&r2=411557&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java
(original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java
Sun Jun  4 06:54:18 2006
@@ -31,7 +31,7 @@
 import org.apache.directory.shared.ldap.message.ManageDsaITControl;
 import org.apache.directory.shared.ldap.message.ReferralImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapName;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
@@ -61,6 +61,7 @@
         {
             LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null,
true );
             ServerLdapContext newCtx = ( ServerLdapContext ) ctx.lookup( "" );
+            
             if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
             {
                 newCtx.addToEnvironment( Context.REFERRAL, "ignore" );
@@ -71,8 +72,7 @@
             }
             newCtx.setRequestControls( ( Control[] ) req.getControls().values().toArray(
EMPTY_CONTROLS ) );
 
-            LdapName name = new LdapName( req.getName() );
-            if ( newCtx.compare( name, req.getAttributeId(), req.getAssertionValue() ) )
+            if ( newCtx.compare( req.getName(), req.getAttributeId(), req.getAssertionValue()
) )
             {
                 result.setResultCode( ResultCodeEnum.COMPARETRUE );
             }
@@ -87,13 +87,15 @@
             result.setReferral( refs );
             result.setResultCode( ResultCodeEnum.REFERRAL );
             result.setErrorMessage( "Encountered referral attempting to handle compare request."
);
-            /* coming up null causing a NPE */
-            // result.setMatchedDn( e.getResolvedName().toString() );
+
+            result.setMatchedDn( (LdapDN)e.getResolvedName() );
+            
             do
             {
                 refs.addLdapUrl( ( String ) e.getReferralInfo() );
             }
             while ( e.skipReferral() );
+            
             session.write( req.getResultResponse() );
             return;
         }
@@ -128,7 +130,7 @@
                     && ( ( code == ResultCodeEnum.NOSUCHOBJECT ) || ( code == ResultCodeEnum.ALIASPROBLEM
)
                         || ( code == ResultCodeEnum.INVALIDDNSYNTAX ) || ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM
) ) )
                 {
-                    result.setMatchedDn( ne.getResolvedName().toString() );
+                    result.setMatchedDn( (LdapDN)ne.getResolvedName() );
                 }
             }
 

Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java?rev=411557&r1=411556&r2=411557&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java
(original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java
Sun Jun  4 06:54:18 2006
@@ -30,6 +30,7 @@
 import org.apache.directory.shared.ldap.message.ManageDsaITControl;
 import org.apache.directory.shared.ldap.message.ReferralImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
@@ -110,7 +111,7 @@
                 && ( ( code == ResultCodeEnum.NOSUCHOBJECT ) || ( code == ResultCodeEnum.ALIASPROBLEM
)
                     || ( code == ResultCodeEnum.INVALIDDNSYNTAX ) || ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM
) ) )
             {
-                result.setMatchedDn( e.getResolvedName().toString() );
+                result.setMatchedDn( (LdapDN)e.getResolvedName() );
             }
 
             session.write( req.getResultResponse() );

Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java?rev=411557&r1=411556&r2=411557&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java
(original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java
Sun Jun  4 06:54:18 2006
@@ -30,9 +30,8 @@
 import org.apache.directory.shared.ldap.message.ModifyDnRequest;
 import org.apache.directory.shared.ldap.message.ReferralImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapName;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
-import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
 
@@ -62,7 +61,7 @@
             LOG.debug( "req.getName() == [" + req.getName() + "]" );
         }
 
-        if ( req.getName() == null || req.getName().length() == 0 )
+        if ( req.getName().isEmpty() )
         {
             // it is not allowed to modify the name of the Root DSE
             String msg = "Modify DN is not allowed on Root DSE.";
@@ -75,6 +74,7 @@
             try
             {
                 LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session,
null, true );
+                
                 if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
                 {
                     ctx.addToEnvironment( Context.REFERRAL, "ignore" );
@@ -83,23 +83,32 @@
                 {
                     ctx.addToEnvironment( Context.REFERRAL, "throw" );
                 }
+                
                 ctx.setRequestControls( ( Control[] ) req.getControls().values().toArray(
EMPTY_CONTROLS ) );
                 String deleteRDN = String.valueOf( req.getDeleteOldRdn() );
                 ctx.addToEnvironment( "java.naming.ldap.deleteRDN", deleteRDN );
 
                 if ( req.isMove() )
                 {
-                    LdapName oldDn = new LdapName( req.getName() );
-                    LdapName newDn = null;
+                    LdapDN oldDn = req.getName();
+                    LdapDN newDn = null;
 
-                    String newSuperior = req.getNewSuperior();
-                    if ( StringTools.isEmpty( newSuperior ) )
+                    LdapDN newSuperior = req.getNewSuperior();
+                    
+                    if ( newSuperior.isEmpty() )
                     {
-                        newDn = ( LdapName ) oldDn.getPrefix( 1 );
+                        if ( oldDn.isEmpty() )
+                        {
+                            newDn = oldDn;
+                        }
+                        else
+                        {
+                            newDn = (LdapDN)oldDn.getPrefix( oldDn.size() - 1 );
+                        }
                     }
                     else
                     {
-                        newDn = new LdapName( req.getNewSuperior() );
+                        newDn = newSuperior;
                     }
 
                     if ( req.getNewRdn() != null )
@@ -111,14 +120,15 @@
                         newDn.add( oldDn.getRdn() );
                     }
 
-                    ctx.rename( new LdapName( req.getName() ), newDn );
+                    ctx.rename( req.getName(), newDn );
                 }
                 else
                 {
-                    LdapName newDn = new LdapName( req.getName() );
+                    LdapDN newDn = req.getName();
+                    
                     newDn.remove( newDn.size() - 1 );
                     newDn.add( req.getNewRdn() );
-                    ctx.rename( new LdapName( req.getName() ), newDn );
+                    ctx.rename( req.getName(), newDn );
                 }
             }
             catch ( ReferralException e )
@@ -127,13 +137,14 @@
                 result.setReferral( refs );
                 result.setResultCode( ResultCodeEnum.REFERRAL );
                 result.setErrorMessage( "Encountered referral attempting to handle modifyDn
request." );
-                /* coming up null causing a NPE */
-                // result.setMatchedDn( e.getResolvedName().toString() );
+                result.setMatchedDn( (LdapDN)e.getResolvedName() );
+
                 do
                 {
                     refs.addLdapUrl( ( String ) e.getReferralInfo() );
                 }
                 while ( e.skipReferral() );
+                
                 session.write( req.getResultResponse() );
                 return;
             }
@@ -146,6 +157,7 @@
                 }
 
                 ResultCodeEnum code;
+                
                 if ( e instanceof LdapException )
                 {
                     code = ( ( LdapException ) e ).getResultCode();
@@ -157,11 +169,12 @@
 
                 result.setResultCode( code );
                 result.setErrorMessage( msg );
+                
                 if ( ( e.getResolvedName() != null )
                     && ( ( code == ResultCodeEnum.NOSUCHOBJECT ) || ( code == ResultCodeEnum.ALIASPROBLEM
)
                         || ( code == ResultCodeEnum.INVALIDDNSYNTAX ) || ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM
) ) )
                 {
-                    result.setMatchedDn( e.getResolvedName().toString() );
+                    result.setMatchedDn( (LdapDN)e.getResolvedName() );
                 }
 
                 session.write( req.getResultResponse() );

Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java?rev=411557&r1=411556&r2=411557&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java
(original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java
Sun Jun  4 06:54:18 2006
@@ -31,6 +31,7 @@
 import org.apache.directory.shared.ldap.message.ModifyRequest;
 import org.apache.directory.shared.ldap.message.ReferralImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
@@ -108,11 +109,12 @@
 
             result.setResultCode( code );
             result.setErrorMessage( msg );
+            
             if ( ( e.getResolvedName() != null )
                 && ( ( code == ResultCodeEnum.NOSUCHOBJECT ) || ( code == ResultCodeEnum.ALIASPROBLEM
)
                     || ( code == ResultCodeEnum.INVALIDDNSYNTAX ) || ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM
) ) )
             {
-                result.setMatchedDn( e.getResolvedName().toString() );
+                result.setMatchedDn( (LdapDN)e.getResolvedName() );
             }
 
             session.write( req.getResultResponse() );

Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java?rev=411557&r1=411556&r2=411557&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java
(original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java
Sun Jun  4 06:54:18 2006
@@ -16,6 +16,7 @@
 package org.apache.directory.server.ldap.support;
 
 
+import javax.naming.InvalidNameException;
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
 import javax.naming.event.NamespaceChangeListener;
@@ -37,6 +38,7 @@
 import org.apache.directory.shared.ldap.message.SearchRequest;
 import org.apache.directory.shared.ldap.message.SearchResponseEntry;
 import org.apache.directory.shared.ldap.message.SearchResponseEntryImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 
@@ -136,6 +138,7 @@
         }
 
         ResultCodeEnum code = null;
+        
         if ( evt.getException() instanceof LdapException )
         {
             code = ( ( LdapException ) evt.getException() ).getResultCode();
@@ -148,12 +151,14 @@
         LdapResult result = req.getResultResponse().getLdapResult();
         result.setResultCode( code );
         result.setErrorMessage( msg );
+        
         if ( ( evt.getException().getResolvedName() != null )
             && ( ( code == ResultCodeEnum.NOSUCHOBJECT ) || ( code == ResultCodeEnum.ALIASPROBLEM
)
                 || ( code == ResultCodeEnum.INVALIDDNSYNTAX ) || ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM
) ) )
         {
-            result.setMatchedDn( evt.getException().getResolvedName().toString() );
+            result.setMatchedDn( (LdapDN)evt.getException().getResolvedName() );
         }
+        
         session.write( req.getResultResponse() );
     }
 
@@ -200,50 +205,101 @@
             ecControl = new EntryChangeControl();
             respEntry.add( ecControl );
         }
+        
+        LdapDN newBinding = null;
+        LdapDN oldBinding = null;
+        
+        if ( evt.getNewBinding() != null )
+        {
+            try
+            {
+                newBinding = new LdapDN( evt.getNewBinding().getName() );
+            }
+            catch ( InvalidNameException ine )
+            {
+                newBinding = LdapDN.EMPTY_LDAPDN;
+            }
+        }
+
+        if ( evt.getOldBinding() != null )
+        {
+            try
+            {
+                oldBinding = new LdapDN( evt.getOldBinding().getName() );
+            }
+            catch ( InvalidNameException ine )
+            {
+                oldBinding = LdapDN.EMPTY_LDAPDN;
+            }
+        }
 
         switch ( evt.getType() )
         {
             case ( NamingEvent.OBJECT_ADDED  ):
                 if ( !control.isNotificationEnabled( ChangeType.ADD ) )
+                {
                     return;
-                respEntry.setObjectName( evt.getNewBinding().getName() );
+                }
+            
+                respEntry.setObjectName( newBinding );
                 respEntry.setAttributes( ( Attributes ) evt.getChangeInfo() );
+                
                 if ( ecControl != null )
                 {
                     ecControl.setChangeType( ChangeType.ADD );
                 }
+                
                 break;
+                
             case ( NamingEvent.OBJECT_CHANGED  ):
                 if ( !control.isNotificationEnabled( ChangeType.MODIFY ) )
+                {
                     return;
-                respEntry.setObjectName( evt.getOldBinding().getName() );
+                }
+            
+                respEntry.setObjectName( oldBinding );
                 respEntry.setAttributes( ( Attributes ) evt.getOldBinding().getObject() );
+
                 if ( ecControl != null )
                 {
                     ecControl.setChangeType( ChangeType.MODIFY );
                 }
+                
                 break;
+                
             case ( NamingEvent.OBJECT_REMOVED  ):
                 if ( !control.isNotificationEnabled( ChangeType.DELETE ) )
+                {
                     return;
-                respEntry.setObjectName( evt.getOldBinding().getName() );
+                }
+            
+                respEntry.setObjectName( oldBinding );
                 respEntry.setAttributes( ( Attributes ) evt.getOldBinding().getObject() );
+
                 if ( ecControl != null )
                 {
                     ecControl.setChangeType( ChangeType.DELETE );
                 }
+                
                 break;
+                
             case ( NamingEvent.OBJECT_RENAMED  ):
                 if ( !control.isNotificationEnabled( ChangeType.MODDN ) )
+                {
                     return;
-                respEntry.setObjectName( evt.getNewBinding().getName() );
+                }
+            
+                respEntry.setObjectName( newBinding );
                 respEntry.setAttributes( ( Attributes ) evt.getNewBinding().getObject() );
+
                 if ( ecControl != null )
                 {
                     ecControl.setChangeType( ChangeType.MODDN );
-                    ecControl.setPreviousDn( evt.getOldBinding().getName() );
+                    ecControl.setPreviousDn( oldBinding );
                 }
+                
                 break;
+
             default:
                 return;
         }

Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java?rev=411557&r1=411556&r2=411557&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
(original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
Sun Jun  4 06:54:18 2006
@@ -46,11 +46,12 @@
 import org.apache.directory.shared.ldap.message.ScopeEnum;
 import org.apache.directory.shared.ldap.message.SearchRequest;
 import org.apache.directory.shared.ldap.message.SearchResponseDone;
-import org.apache.directory.shared.ldap.name.LdapName;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ArrayUtils;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -96,7 +97,7 @@
      */
     private static boolean isRootDSESearch( SearchRequest req )
     {
-        boolean isBaseIsRoot = req.getBase().trim().equals( "" );
+        boolean isBaseIsRoot = req.getBase().isEmpty();
         boolean isBaseScope = req.getScope() == ScopeEnum.BASEOBJECT;
         boolean isRootDSEFilter = false;
         if ( req.getFilter() instanceof PresenceNode )
@@ -214,7 +215,7 @@
 
                 if ( !psearchControl.isChangesOnly() )
                 {
-                    list = ( ( ServerLdapContext ) ctx ).search( new LdapName( req.getBase()
), req.getFilter(),
+                    list = ( ( ServerLdapContext ) ctx ).search( req.getBase(), req.getFilter(),
                         controls );
                     if ( list instanceof AbandonListener )
                     {
@@ -267,7 +268,7 @@
              * Iterate through all search results building and sending back responses 
              * for each search result returned.  
              */
-            list = ( ( ServerLdapContext ) ctx ).search( new LdapName( req.getBase() ), req.getFilter(),
controls );
+            list = ( ( ServerLdapContext ) ctx ).search( req.getBase(), req.getFilter(),
controls );
             if ( list instanceof AbandonListener )
             {
                 req.addAbandonListener( ( AbandonListener ) list );
@@ -356,7 +357,7 @@
                 && ( ( code == ResultCodeEnum.NOSUCHOBJECT ) || ( code == ResultCodeEnum.ALIASPROBLEM
)
                     || ( code == ResultCodeEnum.INVALIDDNSYNTAX ) || ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM
) ) )
             {
-                result.setMatchedDn( e.getResolvedName().toString() );
+                result.setMatchedDn( (LdapDN)e.getResolvedName() );
             }
 
             Iterator it = Collections.singleton( req.getResultResponse() ).iterator();

Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java?rev=411557&r1=411556&r2=411557&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java
(original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java
Sun Jun  4 06:54:18 2006
@@ -19,6 +19,7 @@
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
+import javax.naming.InvalidNameException;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -38,6 +39,7 @@
 import org.apache.directory.shared.ldap.message.SearchResponseEntryImpl;
 import org.apache.directory.shared.ldap.message.SearchResponseReference;
 import org.apache.directory.shared.ldap.message.SearchResponseReferenceImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 
 import org.slf4j.Logger;
@@ -94,7 +96,16 @@
                     SearchResponseEntry respEntry;
                     respEntry = new SearchResponseEntryImpl( req.getMessageId() );
                     respEntry.setAttributes( result.getAttributes() );
-                    respEntry.setObjectName( result.getName() );
+                    try
+                    {
+                        respEntry.setObjectName( new LdapDN( result.getName() ) );
+                    }
+                    catch ( InvalidNameException ine )
+                    {
+                        log.error( "Invalid object name : " + result.getName(), ine);
+                        throw new RuntimeException( ine );
+                    }
+                    
                     prefetched = respEntry;
                 }
                 else
@@ -251,7 +262,17 @@
         {
             SearchResponseEntry respEntry = new SearchResponseEntryImpl( req.getMessageId()
);
             respEntry.setAttributes( result.getAttributes() );
-            respEntry.setObjectName( result.getName() );
+            
+            try
+            {
+                respEntry.setObjectName( new LdapDN( result.getName() ) );
+            }
+            catch ( InvalidNameException ine )
+            {
+                log.error( "Invalid object name : " + result.getName(), ine);
+                throw new RuntimeException( ine );
+            }
+            
             prefetched = respEntry;
         }
         else
@@ -367,6 +388,7 @@
     SearchResponseDone getResponse( SearchRequest req, Exception e )
     {
         String msg = "failed on search operation";
+        
         if ( log.isDebugEnabled() )
         {
             msg += ":\n" + req + ":\n" + ExceptionUtils.getStackTrace( e );
@@ -374,6 +396,7 @@
 
         SearchResponseDone resp = ( SearchResponseDone ) req.getResultResponse();
         ResultCodeEnum code = null;
+        
         if ( e instanceof LdapException )
         {
             code = ( ( LdapException ) e ).getResultCode();
@@ -389,13 +412,15 @@
         if ( e instanceof NamingException )
         {
             NamingException ne = ( NamingException ) e;
+            
             if ( ( ne.getResolvedName() != null )
                 && ( ( code == ResultCodeEnum.NOSUCHOBJECT ) || ( code == ResultCodeEnum.ALIASPROBLEM
)
                     || ( code == ResultCodeEnum.INVALIDDNSYNTAX ) || ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM
) ) )
             {
-                resp.getLdapResult().setMatchedDn( ne.getResolvedName().toString() );
+                resp.getLdapResult().setMatchedDn( (LdapDN)ne.getResolvedName() );
             }
         }
+        
         return resp;
     }
 }



Mime
View raw message