You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/06/09 19:16:49 UTC
svn commit: r953084 -
/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
Author: elecharny
Date: Wed Jun 9 17:16:49 2010
New Revision: 953084
URL: http://svn.apache.org/viewvc?rev=953084&view=rev
Log:
Removed a helper method, using a DN isChildOf() method instead
Modified:
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java?rev=953084&r1=953083&r2=953084&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java Wed Jun 9 17:16:49 2010
@@ -44,7 +44,6 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.DN;
-import org.apache.directory.shared.ldap.name.RDN;
/**
@@ -336,7 +335,11 @@ public abstract class AbstractXdbmPartit
public final void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException
{
- checkIsValidMove( moveAndRenameContext.getDn(), moveAndRenameContext.getParent() );
+ if ( moveAndRenameContext.getParent().isChildOf( moveAndRenameContext.getDn() ) )
+ {
+ throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
+ "cannot place an entry below itself" );
+ }
try
{
@@ -352,11 +355,15 @@ public abstract class AbstractXdbmPartit
public final void move( MoveOperationContext moveContext ) throws LdapException
{
- checkIsValidMove( moveContext.getDn(), moveContext.getNewSuperior() );
+ if ( moveContext.getNewSuperior().isChildOf( moveContext.getDn() ) )
+ {
+ throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
+ "cannot place an entry below itself" );
+ }
try
{
- store.move( moveContext.getDn(), moveContext.getNewSuperior() );
+ store.move( moveContext.getDn(), moveContext.getNewSuperior() ); //, moveContext.getEntry().getClonedEntry() );
}
catch ( Exception e )
{
@@ -365,49 +372,6 @@ public abstract class AbstractXdbmPartit
}
- /**
- *
- * checks whether the moving of given entry is valid
- *
- * @param oldChildDn the entry's DN to be moved
- * @param newParentDn new parent entry's DN
- * @throws Exception
- */
- private void checkIsValidMove( DN oldChildDn, DN newParentDn ) throws LdapException
- {
- boolean invalid = false;
-
- DN newParentDNClone = ( DN ) newParentDn.clone();
- newParentDNClone.remove( newParentDNClone.size() - 1 );
-
- if ( newParentDn.size() >= oldChildDn.size() )
- {
- for ( int i = 0; i < oldChildDn.size(); i++ )
- {
- RDN nameRdn = oldChildDn.getRdn( i );
- RDN ldapRdn = newParentDn.getRdn( i );
-
- if ( nameRdn.compareTo( ldapRdn ) == 0 )
- {
- invalid = true;
- }
- else
- {
- invalid = false;
- break;
- }
- }
- }
-
- if ( invalid )
- {
- throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
- "cannot place an entry below itself" );
- }
-
- }
-
-
public final void bind( DN bindDn, byte[] credentials, List<String> mechanisms, String saslAuthId )
throws LdapException
{