directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 22103 - in incubator/directory/eve/branches/start: . src/java/org/apache/eve/jndi src/java/org/apache/eve/protocol
Date Fri, 25 Jun 2004 06:57:34 GMT
Author: akarasulu
Date: Thu Jun 24 23:57:33 2004
New Revision: 22103

Modified:
   incubator/directory/eve/branches/start/src/java/org/apache/eve/jndi/ContextHelper.java
   incubator/directory/eve/branches/start/src/java/org/apache/eve/protocol/ModifyDnHandler.java
   incubator/directory/eve/branches/start/todo.txt
Log:
implemented ModifyDn using the JNDI interface

Modified: incubator/directory/eve/branches/start/src/java/org/apache/eve/jndi/ContextHelper.java
==============================================================================
--- incubator/directory/eve/branches/start/src/java/org/apache/eve/jndi/ContextHelper.java
(original)
+++ incubator/directory/eve/branches/start/src/java/org/apache/eve/jndi/ContextHelper.java
Thu Jun 24 23:57:33 2004
@@ -314,9 +314,9 @@
         LdapEntry l_oldEntry = null ;
         Name l_oldDn = new LdapName() ;
         Name l_newDn = new LdapName() ;
-        l_oldDn.addAll( l_entry.getNormalizedDN() ) ;
+        l_oldDn.addAll( l_entry.getUnNormalizedDN() ) ;
         l_oldDn.addAll( a_oldRdn ) ;
-        l_newDn.addAll( l_entry.getNormalizedDN() ) ;
+        l_newDn.addAll( l_entry.getUnNormalizedDN() ) ;
         l_newDn.addAll( a_newRdn ) ;
 
         try
@@ -338,7 +338,15 @@
         {
             try
             {
-                l_nexus.modifyRdn( l_oldEntry, a_newRdn, true ) ;
+                String deleteRdn = (String) m_ctx.getEnvironment().get("java.naming.ldap.deleteRDN");
+                if ( deleteRdn != null )
+                {
+                    l_nexus.modifyRdn( l_oldEntry, a_newRdn, deleteRdn.equals("true") ) ;
+                }
+                else
+                {
+                    l_nexus.modifyRdn( l_oldEntry, a_newRdn, true ) ;
+                }
             }
             catch( BackendException e )
             {
@@ -427,8 +435,8 @@
         throws NamingException
     {
         UnifiedBackend l_nexus = JndiProviderModule.getInstance().getNexus() ;
-        rename( l_nexus.getNormalizedName( a_oldRdn ),
-            l_nexus.getNormalizedName( a_newRdn ) ) ;
+        rename( l_nexus.getName( a_oldRdn ),
+            l_nexus.getName( a_newRdn ) ) ;
     }
 
 

Modified: incubator/directory/eve/branches/start/src/java/org/apache/eve/protocol/ModifyDnHandler.java
==============================================================================
--- incubator/directory/eve/branches/start/src/java/org/apache/eve/protocol/ModifyDnHandler.java
(original)
+++ incubator/directory/eve/branches/start/src/java/org/apache/eve/protocol/ModifyDnHandler.java
Thu Jun 24 23:57:33 2004
@@ -10,11 +10,16 @@
 package org.apache.eve.protocol ;
 
 
-import org.apache.ldap.common.message.ResultResponse ;
-import org.apache.ldap.common.message.MessageTypeEnum ;
 import org.apache.ldap.common.NotImplementedException ;
-import org.apache.ldap.common.message.ModifyDnRequest ;
-import org.apache.ldap.common.message.SingleReplyRequest ;
+import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.common.message.*;
+import org.apache.avalon.framework.CascadingRuntimeException;
+import org.apache.eve.jndi.UnifiedLdapContext;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.Name;
+import javax.naming.ldap.LdapContext;
 
 
 /**
@@ -94,13 +99,55 @@
      * Handles a request that generates a sole response by returning the
      * response object back to the caller.
      *
-     * @param a_request the request to handle.
+     * @param request the request to handle.
      * @return the response to the request argument.
      * @throws ClassCastException if a_request is not a ModifyRequest
      */
-    public ResultResponse handle( SingleReplyRequest a_request )
+    public ResultResponse handle( SingleReplyRequest request )
     {
-        ModifyDnRequest l_request = ( ModifyDnRequest ) a_request ;
-        throw new NotImplementedException() ;
+        LdapContext ctx = null;
+        InitialContext initCtx = null;
+        ModifyDnRequest req = (ModifyDnRequest) request ;
+        ModifyDnResponseImpl resp = new ModifyDnResponseImpl(req.getMessageId());
+        LdapResultImpl result = new LdapResultImpl(resp);
+        resp.setLdapResult(result);
+
+        try {
+            initCtx = Utils.getInitialContext();
+        } catch (NamingException e) {
+            String msg = "initial context lookup failure";
+            m_module.getLogger().error(msg, e);
+            throw new CascadingRuntimeException(msg,e);
+        }
+
+        try {
+            LdapName dn = (LdapName) m_module.getNexus().getName(req.getName());
+            if( req.getNewSuperior() == null )
+            {
+                ctx = (LdapContext) initCtx.lookup(dn.getSuffix(1));
+
+                if ( !req.getDeleteOldRdn() )
+                {
+                    ctx.getEnvironment().put("java.naming.ldap.deleteRDN", "false");
+                }
+
+                ctx.rename(dn.getRdn(), req.getNewRdn());
+                result.setResultCode(ResultCodeEnum.SUCCESS);
+                result.setMatchedDn(req.getName());
+                return resp;
+            }
+
+
+            Name newRdn = (LdapName) m_module.getNexus().getName(req.getNewSuperior());
+            newRdn.addAll(m_module.getNexus().getName(req.getNewRdn()));
+            initCtx.rename(dn,newRdn);
+            result.setResultCode(ResultCodeEnum.SUCCESS);
+            result.setMatchedDn(req.getName());
+            return resp;
+        } catch (NamingException e) {
+            String msg = "could not lookup entry context for " + req.getName();
+            m_module.getLogger().error(msg, e);
+            throw new CascadingRuntimeException(msg,e);
+        }
     }
 }

Modified: incubator/directory/eve/branches/start/todo.txt
==============================================================================
--- incubator/directory/eve/branches/start/todo.txt	(original)
+++ incubator/directory/eve/branches/start/todo.txt	Thu Jun 24 23:57:33 2004
@@ -1,4 +1,5 @@
- o add check to build.xml for proper ant version
- o test it out
- o add modified phoenix download and install option to build
-
+ o fix search subtree scope bug: onelevel children not returned
+ o fix bug in modifyDn where children dn indices are mangled
+ o test modifyDn for a move operation
+ o implement extended request to fire up debug UI
+ o ANNOUNCE NOT IMPLEMENTED ABANDON REQUEST

Mime
View raw message