directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r678727 - /directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewAddHandler.java
Date Tue, 22 Jul 2008 12:06:29 GMT
Author: elecharny
Date: Tue Jul 22 05:06:29 2008
New Revision: 678727

URL: http://svn.apache.org/viewvc?rev=678727&view=rev
Log:
o Added the code which writes back the result when the add was successfull.
o Added some comment

Modified:
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewAddHandler.java

Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewAddHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewAddHandler.java?rev=678727&r1=678726&r2=678727&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewAddHandler.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewAddHandler.java
Tue Jul 22 05:06:29 2008
@@ -44,6 +44,7 @@
  */
 public class NewAddHandler extends LdapRequestHandler<AddRequest>
 {
+	/** The logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( NewAddHandler.class );
     
     
@@ -58,10 +59,22 @@
 
         try
         {
+        	// Call the underlying layer to inject the new entry 
             session.getCoreSession().add( request );
+
+            // If it succeeded, we should be here now, otherwise, we would have
+            // got an exception.
+            result.setResultCode( ResultCodeEnum.SUCCESS );
+            
+            // TODO : inject the responseControls here...
+            //request.getResultResponse().addAll( session.request.getControls().ResponseControls()
);
+            
+            // Write the AddResponse message
+            session.getIoSession().write( request.getResultResponse() );
         }
         catch( ReferralException e )
         {
+        	// We tried to add an entry into a referral. 
             ReferralImpl refs = new ReferralImpl();
             result.setReferral( refs );
             result.setResultCode( ResultCodeEnum.REFERRAL );
@@ -69,7 +82,7 @@
             
             if ( e.getResolvedName() != null )
             {
-                result.setMatchedDn( new LdapDN( e.getResolvedName().toString() ) );
+                result.setMatchedDn( new LdapDN( e.getResolvedName() ) );
             }
             
             do
@@ -78,10 +91,12 @@
             }
             while ( e.skipReferral() );
             
+            // Write back the response
             session.getIoSession().write( request.getResultResponse() );
         }
         catch ( Throwable t )
         {
+        	// We got an error. Get the resultCode.
             ResultCodeEnum resultCode = ResultCodeEnum.OTHER;
             
             if ( t instanceof LdapException )
@@ -96,14 +111,15 @@
             result.setResultCode( resultCode );
             
             String msg = session + "failed to add entry " + request.getEntry() + ": " + t.getMessage();
+            
             if ( LOG.isDebugEnabled() )
             {
                 msg += ":\n" + ExceptionUtils.getStackTrace( t );
             }
 
             result.setErrorMessage( msg );
-            result.setErrorMessage( msg );
 
+            // Add the matchedDN if necessary
             boolean setMatchedDn = 
                 resultCode == ResultCodeEnum.NO_SUCH_OBJECT             || 
                 resultCode == ResultCodeEnum.ALIAS_PROBLEM              ||
@@ -115,6 +131,7 @@
                 if ( t instanceof NamingException )
                 {
                     NamingException ne = ( NamingException ) t;
+                    
                     if ( ne.getResolvedName() != null )
                     {
                         result.setMatchedDn( ( LdapDN ) ne.getResolvedName() );
@@ -122,6 +139,7 @@
                 }
             }
 
+            // Write back the error response
             session.getIoSession().write( request.getResultResponse() );
         }
     }



Mime
View raw message