directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r682579 - /directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyHandler.java
Date Tue, 05 Aug 2008 04:17:01 GMT
Author: akarasulu
Date: Mon Aug  4 21:16:59 2008
New Revision: 682579

URL: http://svn.apache.org/viewvc?rev=682579&view=rev
Log:
adding modify operation handling code for referrals: using SingleReplyRequestHandler base
class stripping out old crusty code

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

Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyHandler.java?rev=682579&r1=682578&r2=682579&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyHandler.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyHandler.java
Mon Aug  4 21:16:59 2008
@@ -20,17 +20,12 @@
 package org.apache.directory.server.newldap.handlers;
 
 
-import javax.naming.NamingException;
-import javax.naming.ReferralException;
-
+import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.newldap.LdapSession;
-import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.LdapResult;
 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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,16 +37,20 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 664302 $
  */
-public class NewModifyHandler extends LdapRequestHandler<ModifyRequest>
+public class NewModifyHandler extends SingleReplyRequestHandler<ModifyRequest>
 {
     private static final Logger LOG = LoggerFactory.getLogger( NewModifyHandler.class );
 
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
-    
-    public void handle( LdapSession session, ModifyRequest req ) throws Exception
+    /**
+     * @see SingleReplyRequestHandler#handleIgnoringReferrals(LdapSession, LdapDN, ClonedServerEntry,

+     * org.apache.directory.shared.ldap.message.SingleReplyRequest)
+     */
+    @Override
+    public void handleIgnoringReferrals( LdapSession session, LdapDN reqTargetDn, 
+        ClonedServerEntry entry, ModifyRequest req )
     {
+        LOG.debug( "Handling modify request while ignoring referrals: {}", req );
         LdapResult result = req.getResultResponse().getLdapResult();
 
         try
@@ -60,51 +59,9 @@
             result.setResultCode( ResultCodeEnum.SUCCESS );
             session.getIoSession().write( req.getResultResponse() );
         }
-        catch ( ReferralException e )
-        {
-            ReferralImpl refs = new ReferralImpl();
-            result.setReferral( refs );
-            result.setResultCode( ResultCodeEnum.REFERRAL );
-            result.setErrorMessage( "Encountered referral attempting to handle modify request."
);
-            /* coming up null causing a NPE */
-            // result.setMatchedDn( e.getResolvedName().toString() );
-            do
-            {
-                refs.addLdapUrl( ( String ) e.getReferralInfo() );
-            }
-            while ( e.skipReferral() );
-            session.getIoSession().write( req.getResultResponse() );
-        }
-        catch ( NamingException e )
+        catch ( Exception e )
         {
-            String msg = "failed to modify entry " + req.getName() + ": " + e.getMessage();
-
-            if ( IS_DEBUG )
-            {
-                msg += ":\n" + ExceptionUtils.getStackTrace( e );
-            }
-
-            ResultCodeEnum code;
-            if ( e instanceof LdapException )
-            {
-                code = ( ( LdapException ) e ).getResultCode();
-            }
-            else
-            {
-                code = ResultCodeEnum.getBestEstimate( e, req.getType() );
-            }
-
-            result.setResultCode( code );
-            result.setErrorMessage( msg );
-
-            if ( ( e.getResolvedName() != null )
-                && ( ( code == ResultCodeEnum.NO_SUCH_OBJECT ) || ( code == ResultCodeEnum.ALIAS_PROBLEM
)
-                    || ( code == ResultCodeEnum.INVALID_DN_SYNTAX ) || ( code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM
) ) )
-            {
-                result.setMatchedDn( (LdapDN)e.getResolvedName() );
-            }
-
-            session.getIoSession().write( req.getResultResponse() );
+            handleException( session, req, e );
         }
     }
 }
\ No newline at end of file



Mime
View raw message