You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2008/03/31 20:48:04 UTC
svn commit: r643096 - in /directory/sandbox/akarasulu/bigbang/apacheds:
btree-base/src/main/java/org/apache/directory/server/xdbm/
jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
jdbm-store/src/test/java/org/apache/...
Author: kayyagari
Date: Mon Mar 31 11:47:46 2008
New Revision: 643096
URL: http://svn.apache.org/viewvc?rev=643096&view=rev
Log:
moved getIndices method impl from JdbmStore to StoreUtils and renamed as getAttributes
removed getIndices method from Store, JdbmStore
removed a test case based on getIndices method from JdbmStoreTest
Modified:
directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/xdbm/Store.java
directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
Modified: directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=643096&r1=643095&r2=643096&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/xdbm/Store.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/xdbm/Store.java Mon Mar 31 11:47:46 2008
@@ -327,17 +327,6 @@
String getProperty( String propertyName ) throws Exception;
- /**
- * This is primarily a convenience method used to extract all the indices
- * associated with an entry.
- *
- * @param id the id of the entry to get index information for
- * @return the index names and values as an Attributes object
- * @throws Exception if there are failures accessing the underlying store
- */
- Attributes getIndices( Long id ) throws Exception;
-
-
void modify( LdapDN dn, ModificationOperation modOp, ServerEntry mods ) throws Exception;
Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=643096&r1=643095&r2=643096&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Mon Mar 31 11:47:46 2008
@@ -43,7 +43,6 @@
import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
@@ -1230,96 +1229,6 @@
public String getProperty( String propertyName ) throws Exception
{
return master.getProperty( propertyName );
- }
-
-
- /**
- * This is primarily a convenience method used to extract all the indices
- * associated with an entry.
- *
- * @param id the id of the entry to get index information for
- * @return the index names and values as an Attributes object
- * @throws Exception if there are failures accessing the underlying store
- */
- public Attributes getIndices( Long id ) throws Exception
- {
- Attributes attributes = new AttributesImpl();
-
- // Get the distinguishedName to id mapping
- attributes.put( "_nDn", getEntryDn( id ) );
- attributes.put( "_upDn", getEntryUpdn( id ) );
- attributes.put( "_parent", getParentId( id ) );
-
- // Get all standard index attribute to value mappings
- for ( Index index : userIndices.values() )
- {
- Cursor<ForwardIndexEntry<Long,E>> list = index.reverseCursor();
- ForwardIndexEntry<Long,E> recordForward = new ForwardIndexEntry<Long,E>();
- recordForward.setId( id );
- list.before( recordForward );
-
- while ( list.next() )
- {
- IndexEntry<Long,E> rec = list.get();
- String val = rec.getValue().toString();
- String attrId = index.getAttribute().getName();
- Attribute attr = attributes.get( attrId );
-
- if ( attr == null )
- {
- attr = new AttributeImpl( attrId );
- }
-
- attr.add( val );
- attributes.put( attr );
- }
- }
-
- // Get all existance mappings for this id creating a special key
- // that looks like so 'existance[attribute]' and the value is set to id
- Cursor<IndexEntry<String,E>> list = existanceIdx.reverseCursor();
- ForwardIndexEntry<String,E> recordForward = new ForwardIndexEntry<String,E>();
- recordForward.setId( id );
- list.before( recordForward );
- StringBuffer val = new StringBuffer();
-
- while ( list.next() )
- {
- IndexEntry rec = list.get();
- val.append( "_existance[" );
- val.append( rec.getValue().toString() );
- val.append( "]" );
-
- String valStr = val.toString();
- Attribute attr = attributes.get( valStr );
-
- if ( attr == null )
- {
- attr = new AttributeImpl( valStr );
- }
-
- attr.add( rec.getId().toString() );
- attributes.put( attr );
- val.setLength( 0 );
- }
-
- // Get all parent child mappings for this entry as the parent using the
- // key 'child' with many entries following it.
- Cursor<IndexEntry<Long,E>> children = oneLevelIdx.forwardCursor();
- ForwardIndexEntry<Long,E> longRecordForward = new ForwardIndexEntry<Long,E>();
- recordForward.setId( id );
- children.before( longRecordForward );
-
- Attribute childAttr = new AttributeImpl( "_child" );
- attributes.put( childAttr );
-
- while ( children.next() )
- {
- IndexEntry<Long,E> rec = children.get();
- childAttr.add( rec.getId().toString() );
- }
-
- return attributes;
}
Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=643096&r1=643095&r2=643096&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Mon Mar 31 11:47:46 2008
@@ -299,18 +299,6 @@
@Test
- public void testGetIndicies() throws Exception
- {
- Attributes attrs = store.getIndices( 1L );
- assertNotNull( attrs );
- assertNotNull( attrs.get( "_nDn" ) );
- assertNotNull( attrs.get( "_upDn" ) );
- assertNotNull( attrs.get( "_parent" ) );
- LOG.debug( attrs.toString() );
- }
-
-
- @Test
public void testPersistentProperties() throws Exception
{
assertNull( store.getProperty( "foo" ) );
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java?rev=643096&r1=643095&r2=643096&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java Mon Mar 31 11:47:46 2008
@@ -20,11 +20,22 @@
package org.apache.directory.server.xdbm.tools;
+import java.util.Set;
+
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.entry.ServerEntryUtils;
import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.server.xdbm.ForwardIndexEntry;
+import org.apache.directory.server.xdbm.Index;
+import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -125,4 +136,96 @@
entry.add( "aliasedObjectName", "cn=Johnny Walker,ou=Sales,o=Good Times Co." );
store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
}
+
+
+ /**
+ * This is primarily a convenience method used to extract all the attributes
+ * associated with an entry.
+ *
+ * @param id the id of the entry to get index information for
+ * @return the index names and values as an Attributes object
+ * @throws Exception if there are failures accessing the underlying store
+ */
+ @SuppressWarnings("unchecked")
+ public Attributes getAttributes( Store store, Long id ) throws Exception
+ {
+ Attributes attributes = new AttributesImpl();
+
+ // Get the distinguishedName to id mapping
+ attributes.put( "_nDn", store.getEntryDn( id ) );
+ attributes.put( "_upDn", store.getEntryUpdn( id ) );
+ attributes.put( "_parent", store.getParentId( id ) );
+
+ // Get all standard index attribute to value mappings
+ for ( Index index : ( Set<Index> )store.getUserIndices() )
+ {
+ Cursor<ForwardIndexEntry> list = index.reverseCursor();
+ ForwardIndexEntry recordForward = new ForwardIndexEntry();
+ recordForward.setId( id );
+ list.before( recordForward );
+
+ while ( list.next() )
+ {
+ IndexEntry rec = list.get();
+ String val = rec.getValue().toString();
+ String attrId = index.getAttribute().getName();
+ Attribute attr = attributes.get( attrId );
+
+ if ( attr == null )
+ {
+ attr = new AttributeImpl( attrId );
+ }
+
+ attr.add( val );
+ attributes.put( attr );
+ }
+ }
+
+ // Get all existance mappings for this id creating a special key
+ // that looks like so 'existance[attribute]' and the value is set to id
+ Cursor<IndexEntry> list = store.getPresenceIndex().reverseCursor();
+ ForwardIndexEntry recordForward = new ForwardIndexEntry();
+ recordForward.setId( id );
+ list.before( recordForward );
+ StringBuffer val = new StringBuffer();
+
+ while ( list.next() )
+ {
+ IndexEntry rec = list.get();
+ val.append( "_existance[" );
+ val.append( rec.getValue().toString() );
+ val.append( "]" );
+
+ String valStr = val.toString();
+ Attribute attr = attributes.get( valStr );
+
+ if ( attr == null )
+ {
+ attr = new AttributeImpl( valStr );
+ }
+
+ attr.add( rec.getId().toString() );
+ attributes.put( attr );
+ val.setLength( 0 );
+ }
+
+ // Get all parent child mappings for this entry as the parent using the
+ // key 'child' with many entries following it.
+ Cursor<IndexEntry> children = store.getOneLevelIndex().forwardCursor();
+ ForwardIndexEntry longRecordForward = new ForwardIndexEntry();
+ recordForward.setId( id );
+ children.before( longRecordForward );
+
+ Attribute childAttr = new AttributeImpl( "_child" );
+ attributes.put( childAttr );
+
+ while ( children.next() )
+ {
+ IndexEntry rec = children.get();
+ childAttr.add( rec.getId().toString() );
+ }
+
+ return attributes;
+ }
+
}