directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r683474 - /directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyDnHandler.java
Date Thu, 07 Aug 2008 02:14:17 GMT
Author: akarasulu
Date: Wed Aug  6 19:14:16 2008
New Revision: 683474

URL: http://svn.apache.org/viewvc?rev=683474&view=rev
Log:
added handling to better detect differences between move, rename and 
moveAndRename operations.

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

Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyDnHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyDnHandler.java?rev=683474&r1=683473&r2=683474&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyDnHandler.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewModifyDnHandler.java
Wed Aug  6 19:14:16 2008
@@ -76,7 +76,18 @@
         
         try
         {
-            if ( req.getNewRdn() != null )
+            LdapDN newRdn = new LdapDN( req.getNewRdn().toString() );
+            newRdn.normalize( session.getCoreSession().getDirectoryService()
+                .getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+            
+            LdapDN oldRdn = new LdapDN( req.getName().getRdn().toString() );
+            oldRdn.normalize( session.getCoreSession().getDirectoryService()
+                .getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+            
+            boolean rdnChanged = req.getNewRdn() != null && 
+                ! newRdn.getNormName().equals( oldRdn.getNormName() );
+            
+            if ( rdnChanged )
             {
                 if ( req.getNewSuperior() != null )
                 {
@@ -87,10 +98,19 @@
                     session.getCoreSession().rename( req );
                 }
             }
-            else
+            else if ( req.getNewSuperior() != null )
             {
+                req.setNewRdn( null );
                 session.getCoreSession().move( req );
             }
+            else
+            {
+                result.setErrorMessage( "Attempt to move entry onto itself." );
+                result.setResultCode( ResultCodeEnum.ENTRY_ALREADY_EXISTS );
+                result.setMatchedDn( req.getName() );
+                session.getIoSession().write( req.getResultResponse() );
+                return;
+            }
 
             result.setResultCode( ResultCodeEnum.SUCCESS );
             session.getIoSession().write( req.getResultResponse() );



Mime
View raw message