Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 44417 invoked from network); 7 Jun 2010 18:01:29 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Jun 2010 18:01:29 -0000 Received: (qmail 9701 invoked by uid 500); 7 Jun 2010 18:01:29 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 9651 invoked by uid 500); 7 Jun 2010 18:01:29 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 9644 invoked by uid 99); 7 Jun 2010 18:01:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Jun 2010 18:01:29 +0000 X-ASF-Spam-Status: No, hits=-1522.1 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Jun 2010 18:01:27 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3C47423889ED; Mon, 7 Jun 2010 18:01:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r952354 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/interceptor/ core/src/main/java/org/apache/directory/server/core/event/ core/src/main/java/org/apache/directory/server/core/exception/ core/src/... Date: Mon, 07 Jun 2010 18:01:06 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100607180107.3C47423889ED@eris.apache.org> Author: elecharny Date: Mon Jun 7 18:01:05 2010 New Revision: 952354 URL: http://svn.apache.org/viewvc?rev=952354&view=rev Log: o Modify the eagerlyPopulateFields to throw a LdapNoSuchObjectException if the entry does not exist o Removed spurious lookups for the rename operation o Removed a check for existence in the Exception interceptor, the check is already done in the eagerlyPopulateFields o Removed some useless normalizations o The MODIFIERS_NAME_AT and MODIFY_TIMESTAMP_AT operational attributes are now added directly into the renamed entry, in order to guarantee that the modification is atomic o The modifications are applied to the read entrain the SchemaInterceptor, instead of being done by the store o The Store API rename method now takes a forth parameter : the modified entry Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java?rev=952354&r1=952353&r2=952354&view=diff ============================================================================== --- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java (original) +++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java Mon Jun 7 18:01:05 2010 @@ -51,8 +51,10 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.partition.PartitionNexus; import org.apache.directory.server.i18n.I18n; import org.apache.directory.shared.ldap.constants.SchemaConstants; +import org.apache.directory.shared.ldap.entry.DefaultEntry; import org.apache.directory.shared.ldap.entry.Entry; import org.apache.directory.shared.ldap.exception.LdapException; +import org.apache.directory.shared.ldap.exception.LdapNoSuchObjectException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -554,7 +556,7 @@ public class InterceptorChain */ // This will suppress PMD.EmptyCatchBlock warnings in this method @SuppressWarnings("PMD.EmptyCatchBlock") - private void eagerlyPopulateFields( OperationContext opContext ) + private void eagerlyPopulateFields( OperationContext opContext ) throws LdapException { // If the entry field is not set for ops other than add for example // then we set the entry but don't freak if we fail to do so since it @@ -562,17 +564,30 @@ public class InterceptorChain if ( opContext.getEntry() == null ) { - try + // We have to use the admin session here, otherwise we may have + // trouble reading the entry due to insufficient access rights + CoreSession adminSession = opContext.getSession().getDirectoryService().getAdminSession(); + + Entry foundEntry = adminSession.lookup( opContext.getDn(), + SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES_ARRAY ); + + if ( foundEntry != null ) { - // We have to use the admin session here, otherwise we may have - // trouble reading the entry due to insufficient access rights - CoreSession adminSession = opContext.getSession().getDirectoryService().getAdminSession(); - opContext.setEntry( ( ClonedServerEntry ) adminSession.lookup( opContext.getDn(), - SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES_ARRAY ) ); + if ( foundEntry instanceof DefaultEntry ) + { + opContext.setEntry( new ClonedServerEntry( foundEntry ) ); + } + else + { + opContext.setEntry( (ClonedServerEntry)foundEntry ); + } } - catch ( Exception e ) + else { - // might not exist + // This is an error : we *must* have an entry if we want to be able to rename. + LdapNoSuchObjectException ldnfe = new LdapNoSuchObjectException( I18n.err( I18n.ERR_256, opContext.getDn() ) ); + + throw ldnfe; } } } Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java?rev=952354&r1=952353&r2=952354&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java Mon Jun 7 18:01:05 2010 @@ -212,7 +212,7 @@ public class EventInterceptor extends Ba public void rename( NextInterceptor next, RenameOperationContext opContext ) throws LdapException { - Entry oriEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS ); + Entry oriEntry = opContext.getEntry().getOriginalEntry(); List selecting = getSelectingRegistrations( opContext.getDn(), oriEntry ); next.rename( opContext ); Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=952354&r1=952353&r2=952354&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java Mon Jun 7 18:01:05 2010 @@ -354,17 +354,6 @@ public class ExceptionInterceptor extend subschemSubentryDn, subschemSubentryDn ) ); } - // Check to see if the renamed entry exists - if ( opContext.getEntry() == null ) - { - // This is a nonsense : we can't rename an entry which does not exist - // on the server - LdapNoSuchObjectException ldnfe; - ldnfe = new LdapNoSuchObjectException( I18n.err( I18n.ERR_256, dn.getName() ) ); - //ldnfe.setResolvedName( new DN( dn.getName() ) ); - throw ldnfe; - } - // check to see if target entry exists DN newDn = opContext.getNewDn(); Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java?rev=952354&r1=952353&r2=952354&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java Mon Jun 7 18:01:05 2010 @@ -152,10 +152,19 @@ public class NormalizationInterceptor ex */ public void rename( NextInterceptor nextInterceptor, RenameOperationContext opContext ) throws LdapException { - // Normalize the new RDN and the DN + // Normalize the new RDN and the DN if needed + + if ( !opContext.getDn().isNormalized() ) + { + opContext.getDn().normalize( schemaManager.getNormalizerMapping() ); + } + opContext.getNewRdn().normalize( schemaManager.getNormalizerMapping() ); - opContext.getDn().normalize( schemaManager.getNormalizerMapping() ); - opContext.getNewDn().normalize( schemaManager.getNormalizerMapping() ); + + if ( !opContext.getNewDn().isNormalized() ) + { + opContext.getNewDn().normalize( schemaManager.getNormalizerMapping() ); + } // Push to the next interceptor nextInterceptor.rename( opContext ); Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java?rev=952354&r1=952353&r2=952354&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java Mon Jun 7 18:01:05 2010 @@ -319,22 +319,11 @@ public class OperationalAttributeInterce public void rename( NextInterceptor nextInterceptor, RenameOperationContext opContext ) throws LdapException { - nextInterceptor.rename( opContext ); - - DN newDn = opContext.getNewDn(); - - // add operational attributes after call in case the operation fails - Entry serverEntry = new DefaultEntry( schemaManager, newDn ); - serverEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() ); - serverEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime() ); + Entry entry = ((ClonedServerEntry)opContext.getEntry() ).getClonedEntry(); + entry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() ); + entry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime() ); - List items = ModifyOperationContext.createModItems( serverEntry, - ModificationOperation.REPLACE_ATTRIBUTE ); - - ModifyOperationContext newModify = new ModifyOperationContext( opContext.getSession(), newDn, items ); - newModify.setEntry( opContext.getAlteredEntry() ); - - service.getPartitionNexus().modify( newModify ); + nextInterceptor.rename( opContext ); } Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=952354&r1=952353&r2=952354&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java Mon Jun 7 18:01:05 2010 @@ -948,7 +948,7 @@ public class SchemaInterceptor extends B DN oldDn = opContext.getDn(); RDN newRdn = opContext.getNewRdn(); boolean deleteOldRn = opContext.getDelOldDn(); - Entry entry = ( Entry ) opContext.getEntry().getClonedEntry(); + Entry entry = opContext.getEntry().getClonedEntry(); /* * Note: This is only a consistency checks, to the ensure that all @@ -958,7 +958,6 @@ public class SchemaInterceptor extends B */ if ( deleteOldRn ) { - Entry tmpEntry = ( Entry ) entry.clone(); RDN oldRDN = oldDn.getRdn(); // Delete the old RDN means we remove some attributes and values. @@ -967,24 +966,9 @@ public class SchemaInterceptor extends B for ( AVA atav : oldRDN ) { AttributeType type = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() ); - tmpEntry.remove( type, atav.getUpValue() ); + entry.remove( type, atav.getUpValue() ); } - for ( AVA atav : newRdn ) - { - AttributeType type = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() ); - - if ( !tmpEntry.contains( type, atav.getNormValue() ) ) - { - tmpEntry.add( new DefaultEntryAttribute( type, atav.getUpValue() ) ); - } - } - - // Substitute the RDN and check if the new entry is correct - tmpEntry.setDn( opContext.getNewDn() ); - - check( opContext.getNewDn(), tmpEntry ); - // Check that no operational attributes are removed for ( AVA atav : oldRDN ) { @@ -996,6 +980,21 @@ public class SchemaInterceptor extends B } } } + + for ( AVA atav : newRdn ) + { + AttributeType type = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() ); + + if ( !entry.contains( type, atav.getNormValue() ) ) + { + entry.add( new DefaultEntryAttribute( type, atav.getUpValue() ) ); + } + } + + // Substitute the RDN and check if the new entry is correct + entry.setDn( opContext.getNewDn() ); + + check( opContext.getNewDn(), entry ); next.rename( opContext ); } Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=952354&r1=952353&r2=952354&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Mon Jun 7 18:01:05 2010 @@ -789,7 +789,7 @@ public class SubentryInterceptor extends { DN name = opContext.getDn(); - Entry entry = ( Entry ) opContext.getEntry().getClonedEntry(); + Entry entry = opContext.getEntry().getClonedEntry(); EntryAttribute objectClasses = entry.get( objectClassType ); Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java?rev=952354&r1=952353&r2=952354&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java Mon Jun 7 18:01:05 2010 @@ -373,7 +373,7 @@ public class TriggerInterceptor extends } // Gather supplementary data. - Entry renamedEntry = ( Entry ) renameContext.getEntry().getClonedEntry(); + Entry renamedEntry = renameContext.getEntry().getClonedEntry(); // @TODO : To be completely reviewed !!! DN oldRDN = new DN( name.getRdn().getName() ); Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=952354&r1=952353&r2=952354&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original) +++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Mon Jun 7 18:01:05 2010 @@ -698,7 +698,7 @@ public class JdbmStoreTest RDN rdn = new RDN( "sn=James" ); - store.rename( dn, rdn, true ); + store.rename( dn, rdn, true, null ); } @@ -718,7 +718,7 @@ public class JdbmStoreTest RDN rdn = new RDN( "sn=Ja\\+es" ); - store.rename( dn, rdn, true ); + store.rename( dn, rdn, true, null ); DN dn2 = new DN( "sn=Ja\\+es,ou=Engineering,o=Good Times Co." ); dn2.normalize( schemaManager.getNormalizerMapping() ); 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=952354&r1=952353&r2=952354&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 Mon Jun 7 18:01:05 2010 @@ -318,7 +318,14 @@ public abstract class AbstractXdbmPartit { try { - store.rename( renameContext.getDn(), renameContext.getNewRdn(), renameContext.getDelOldDn() ); + if ( renameContext.getEntry() != null ) + { + store.rename( renameContext.getDn(), renameContext.getNewRdn(), renameContext.getDelOldDn(), renameContext.getEntry().getClonedEntry() ); + } + else + { + store.rename( renameContext.getDn(), renameContext.getNewRdn(), renameContext.getDelOldDn(), null ); + } } catch ( Exception e ) { Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=952354&r1=952353&r2=952354&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java Mon Jun 7 18:01:05 2010 @@ -1069,10 +1069,17 @@ public abstract class AbstractStore