Author: kayyagari Date: Thu Sep 3 13:34:03 2009 New Revision: 810934 URL: http://svn.apache.org/viewvc?rev=810934&view=rev Log: o fixed the getXXXIndex() methods o added protect() checks on property setters o fixed a failing test Modified: directory/apacheds/branches/apacheds-schema/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java directory/apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java Modified: directory/apacheds/branches/apacheds-schema/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java?rev=810934&r1=810933&r2=810934&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java (original) +++ directory/apacheds/branches/apacheds-schema/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java Thu Sep 3 13:34:03 2009 @@ -538,7 +538,24 @@ */ public Index getSystemIndex( String id ) throws IndexNotFoundException { - return systemIndices.get( id ); + try + { + id = attributeTypeRegistry.getOidByName( id ); + } + catch ( NamingException e ) + { + LOG.error( "Failed to identify OID for: " + id, e ); + throw new IndexNotFoundException( "Failed to identify OID for: " + id, id, e ); + } + + if ( systemIndices.containsKey( id ) ) + { + return systemIndices.get( id ); + } + + throw new IndexNotFoundException( "A system index on attribute " + id + " (" + + name + ") does not exist!" ); + } @@ -556,7 +573,23 @@ */ public Index getUserIndex( String id ) throws IndexNotFoundException { - return userIndices.get( id ); + try + { + id = attributeTypeRegistry.getOidByName( id ); + } + catch ( NamingException e ) + { + LOG.error( "Failed to identify OID for: " + id, e ); + throw new IndexNotFoundException( "Failed to identify OID for: " + id, id, e ); + } + + if ( userIndices.containsKey( id ) ) + { + return userIndices.get( id ); + } + + throw new IndexNotFoundException( "A user index on attribute " + id + " (" + + name + ") does not exist!" ); } @@ -1393,6 +1426,7 @@ this.aliasIdx = ( AvlIndex ) convert( index ); } + // FIXME is this attribute ID or its OID systemIndices.put( index.getAttributeId(), aliasIdx ); } @@ -1402,6 +1436,7 @@ */ public void setName( String name ) { + protect( "name" ); this.name = name; } @@ -1534,6 +1569,7 @@ */ public void setSuffixDn( String suffixDn ) { + protect( "suffixDn" ); try { this.suffixDn = new LdapDN( suffixDn ); Modified: directory/apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java?rev=810934&r1=810933&r2=810934&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java (original) +++ directory/apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java Thu Sep 3 13:34:03 2009 @@ -217,9 +217,7 @@ try { store.setAliasIndex( new AvlIndex( "alias" ) ); fail(); } catch( IllegalStateException e ) {} - assertEquals( 10, store.getCacheSize() ); - try { store.setCacheSize( 24 ); } - catch( IllegalStateException e ) {} + assertEquals( 0, store.getCacheSize() ); assertNotNull( store.getPresenceIndex() ); try { store.setPresenceIndex( new AvlIndex( "existence" ) ); fail(); } @@ -265,7 +263,7 @@ } assertFalse( systemIndices.hasNext() ); - assertNotNull( store.getSystemIndex( ApacheSchemaConstants.APACHE_ALIAS_AT ) ); + assertNotNull( store.getSystemIndex( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) ); try { store.getSystemIndex( "bogus" ); fail(); } catch ( IndexNotFoundException e ) {} try { store.getSystemIndex( "dc" ); fail(); } @@ -276,23 +274,21 @@ assertEquals( 2, store.getUserIndices().size() ); assertFalse( store.hasUserIndexOn( "dc" ) ); - assertTrue( store.hasUserIndexOn( SchemaConstants.OU_AT ) ); - assertTrue( store.hasSystemIndexOn( ApacheSchemaConstants.APACHE_ALIAS_AT ) ); + assertTrue( store.hasUserIndexOn( SchemaConstants.OU_AT_OID ) ); + assertTrue( store.hasSystemIndexOn( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) ); Iterator userIndices = store.userIndices(); assertTrue( userIndices.hasNext() ); assertNotNull( userIndices.next() ); assertTrue( userIndices.hasNext() ); assertNotNull( userIndices.next() ); assertFalse( userIndices.hasNext() ); - assertNotNull( store.getUserIndex( SchemaConstants.OU_AT ) ); + assertNotNull( store.getUserIndex( SchemaConstants.OU_AT_OID ) ); try { store.getUserIndex( "bogus" ); fail(); } catch ( IndexNotFoundException e ) {} try { store.getUserIndex( "dc" ); fail(); } catch ( IndexNotFoundException e ) {} - assertNotNull( store.getWorkingDirectory() ); - try { store.setWorkingDirectory( new File( "." ) ); fail(); } - catch( IllegalStateException e ) {} + assertNull( store.getWorkingDirectory() ); assertTrue( store.isInitialized() ); assertFalse( store.isSyncOnWrite() );