directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r664452 - in /directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers: DefaultModifyHandler.java ModifyHandler.java NewModifyHandler.java
Date Sun, 08 Jun 2008 05:52:59 GMT
Author: akarasulu
Date: Sat Jun  7 22:52:59 2008
New Revision: 664452

URL: http://svn.apache.org/viewvc?rev=664452&view=rev
Log:
adding new ModifyRequest handler while removing old ones

Added:
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyHandler.java
Removed:
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/DefaultModifyHandler.java
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/ModifyHandler.java

Added: 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=664452&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyHandler.java
(added)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyHandler.java
Sat Jun  7 22:52:59 2008
@@ -0,0 +1,110 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.newldap.handlers;
+
+
+import javax.naming.NamingException;
+import javax.naming.ReferralException;
+
+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;
+
+
+/**
+ * A single reply handler for {@link ModifyRequest}s.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 664302 $
+ */
+public class NewModifyHandler extends LdapRequestHandler<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
+    {
+        LdapResult result = req.getResultResponse().getLdapResult();
+
+        try
+        {
+            session.getCoreSession().modify( req );
+            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 )
+        {
+            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() );
+        }
+    }
+}
\ No newline at end of file



Mime
View raw message