Author: elecharny Date: Tue Jul 5 09:26:41 2011 New Revision: 1142939 URL: http://svn.apache.org/viewvc?rev=1142939&view=rev Log: o Factorised the Store.destroy() method into a common method in the AbstractStore class o Removed the useless rename/move methods which take no Entry parameter in Store Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.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/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=1142939&r1=1142938&r2=1142939&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original) +++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Tue Jul 5 09:26:41 2011 @@ -180,50 +180,27 @@ public class JdbmStore extends Abstra /** - * Close the partition : we have to close all the userIndices and the master table. - * - * @throws Exception lazily thrown on any closer failures to avoid leaving - * open files + * {@inheritDoc} */ public synchronized void destroy() throws Exception { - LOG.debug( "destroy() called on store for {}", this.suffixDn ); + MultiException errors = new MultiException( I18n.err( I18n.ERR_577 ) ); if ( !initialized ) { return; } - - List> array = new ArrayList>(); - array.addAll( userIndices.values() ); - array.addAll( systemIndices.values() ); - MultiException errors = new MultiException( I18n.err( I18n.ERR_577 ) ); - - for ( Index index : array ) - { - try - { - index.close(); - LOG.debug( "Closed {} index for {} partition.", index.getAttributeId(), suffixDn ); - } - catch ( Throwable t ) - { - LOG.error( I18n.err( I18n.ERR_124 ), t ); - errors.addThrowable( t ); - } - } - + try { - master.close(); - LOG.debug( I18n.err( I18n.ERR_125, suffixDn ) ); + super.destroy(); } - catch ( Throwable t ) + catch ( Exception e ) { - LOG.error( I18n.err( I18n.ERR_126 ), t ); - errors.addThrowable( t ); + errors.addThrowable( e ); } + // This is specific to the JDBM store : close the record manager try { recMan.close(); @@ -239,8 +216,6 @@ public class JdbmStore extends Abstra { throw errors; } - - initialized = false; } 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=1142939&r1=1142938&r2=1142939&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 Tue Jul 5 09:26:41 2011 @@ -713,7 +713,7 @@ public class JdbmStoreTest Rdn rdn = new Rdn( "sn=James" ); - store.rename( dn, rdn, true ); + store.rename( dn, rdn, true, null ); } @@ -732,7 +732,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( schemaManager, "sn=Ja\\+es,ou=Engineering,o=Good Times Co." ); Long id = store.getEntryId( dn2 ); 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=1142939&r1=1142938&r2=1142939&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 Tue Jul 5 09:26:41 2011 @@ -374,7 +374,7 @@ public abstract class AbstractXdbmPartit } else { - store.rename( oldDn, newRdn, deleteOldRdn ); + store.rename( oldDn, newRdn, deleteOldRdn, 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=1142939&r1=1142938&r2=1142939&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 Tue Jul 5 09:26:41 2011 @@ -54,6 +54,7 @@ import org.apache.directory.shared.ldap. import org.apache.directory.shared.ldap.model.schema.AttributeType; import org.apache.directory.shared.ldap.model.schema.MatchingRule; import org.apache.directory.shared.ldap.model.schema.SchemaManager; +import org.apache.directory.shared.util.exception.MultiException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -154,8 +155,8 @@ public abstract class AbstractStore index : userIndices.values() ) + { + try + { + index.close(); + LOG.debug( "Closed {} user index for {} partition.", index.getAttributeId(), suffixDn ); + } + catch ( Throwable t ) + { + LOG.error( I18n.err( I18n.ERR_124 ), t ); + errors.addThrowable( t ); + } + } + + for ( Index index : systemIndices.values() ) + { + try + { + index.close(); + LOG.debug( "Closed {} system index for {} partition.", index.getAttributeId(), suffixDn ); + } + catch ( Throwable t ) + { + LOG.error( I18n.err( I18n.ERR_124 ), t ); + errors.addThrowable( t ); + } + } + + try + { + master.close(); + LOG.debug( I18n.err( I18n.ERR_125, suffixDn ) ); + } + catch ( Throwable t ) + { + LOG.error( I18n.err( I18n.ERR_126 ), t ); + errors.addThrowable( t ); + } + + if ( errors.size() > 0 ) + { + throw errors; + } + } } Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=1142939&r1=1142938&r2=1142939&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java Tue Jul 5 09:26:41 2011 @@ -33,6 +33,7 @@ import org.apache.directory.shared.ldap. import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.entry.Modification; import org.apache.directory.shared.ldap.model.entry.ModificationOperation; +import org.apache.directory.shared.ldap.model.exception.LdapException; import org.apache.directory.shared.ldap.model.name.Dn; import org.apache.directory.shared.ldap.model.name.Rdn; import org.apache.directory.shared.ldap.model.schema.AttributeType; @@ -91,29 +92,21 @@ public interface Store SYS_INDEX_OIDS = Collections.unmodifiableSet( new HashSet( Arrays .asList( SYS_INDEX_OID_ARRAY ) ) ); @@ -214,12 +207,12 @@ public interface StoreMove an entry from one place to the other. The Rdn remains unchanged, - * the parent Dn changes

- *

We have to update some of the index when moving an entry. Assuming - * that the target destination does not exist, the following index must - * be updated :

- *
    - *
  • oneLevel index
  • - *
  • subLevel index
  • - *
- *

If the moved entry is an alias, then we also have to update the - * following index :

- *
    - *
  • oneAlias index
  • - *
  • subAlias index
  • - *
- *

The Alias index is not updated, as the entry ID won't change.

- *

We have a few check we must do before moving the entry : - *

    - *
  • The destination must not exist - *
  • The moved entry must exist (this has already been checked) - *
  • The moved entry must not inherit from a referral (already checked) - *
- * - * @param oldDn The previous entry Dn - * @param newSuperior The new superior Dn - * @param newDn The new Dn * @param entry The entry to move * @throws Exception If the move failed */ Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java?rev=1142939&r1=1142938&r2=1142939&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java Tue Jul 5 09:26:41 2011 @@ -46,32 +46,6 @@ public class AvlStore extends Abstrac /** static logger */ private static final Logger LOG = LoggerFactory.getLogger( AvlStore.class ); - - /** - * {@inheritDoc} - */ - public void destroy() throws Exception - { - // don't reset initialized flag - initialized = false; - - if ( master != null ) - { - master.close(); - } - - for ( Index idx : systemIndices.values() ) - { - idx.close(); - } - - for ( Index idx : userIndices.values() ) - { - idx.close(); - } - } - - /** * {@inheritDoc} * TODO why this and initRegistries on Store interface ??? @@ -173,5 +147,4 @@ public class AvlStore extends Abstrac { return 0L; } - } Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java?rev=1142939&r1=1142938&r2=1142939&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java Tue Jul 5 09:26:41 2011 @@ -388,7 +388,7 @@ public class AbstractStoreTest // move Dn newSuperior = new Dn( schemaManager, "o=Good Times Co." ); Dn newDn = new Dn( schemaManager, "cn=user,o=Good Times Co." ); - store.move( dn, newSuperior, newDn ); + store.move( dn, newSuperior, newDn, null ); entry = verifyParentId( newDn ); // move and rename Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java?rev=1142939&r1=1142938&r2=1142939&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java Tue Jul 5 09:26:41 2011 @@ -614,7 +614,7 @@ public class AvlStoreTest Rdn rdn = new Rdn( "sn=James" ); - store.rename( dn, rdn, true ); + store.rename( dn, rdn, true, null ); } @@ -633,7 +633,7 @@ public class AvlStoreTest Rdn rdn = new Rdn( "sn=Ja\\+es" ); - store.rename( dn, rdn, true ); + store.rename( dn, rdn, true, null ); Dn dn2 = new Dn( schemaManager, "sn=Ja\\+es,ou=Engineering,o=Good Times Co." ); Long id = store.getEntryId( dn2 );