directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1142788 - in /directory/apacheds/trunk/xdbm-partition/src: main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java test/java/org/apache/directory/server/xdbm/StoreUtils.java
Date Mon, 04 Jul 2011 20:06:45 GMT
Author: elecharny
Date: Mon Jul  4 20:06:45 2011
New Revision: 1142788

URL: http://svn.apache.org/viewvc?rev=1142788&view=rev
Log:
o Simplified the ParentIdAndRdn.equals() method
o Removed the StoreUtils.getAttributes() method, it's not used

Modified:
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/StoreUtils.java

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java?rev=1142788&r1=1142787&r2=1142788&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
Mon Jul  4 20:06:45 2011
@@ -150,7 +150,31 @@ public class ParentIdAndRdn<ID extends C
             return false;
         }
 
-        return compareTo( ( ParentIdAndRdn<ID> ) obj ) == 0;
+        ParentIdAndRdn<ID> that = (ParentIdAndRdn<ID>) obj;
+        
+        if ( rdns == null )
+        {
+            return that.rdns == null;
+        }
+        else if ( that.rdns == null )
+        {
+            return false;
+        }
+        
+        if ( rdns.length != that.rdns.length )
+        {
+            return false;
+        }
+        
+        for ( int i = 0; i < rdns.length; i++ )
+        {
+            if ( !rdns[i].equals( that.rdns[i] ) )
+            {
+                return false;
+            }
+        }
+        
+        return true;
     }
 
     

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/StoreUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/StoreUtils.java?rev=1142788&r1=1142787&r2=1142788&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/StoreUtils.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/StoreUtils.java
Mon Jul  4 20:06:45 2011
@@ -24,11 +24,8 @@ import java.util.UUID;
 
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.csn.CsnFactory;
-import org.apache.directory.shared.ldap.model.cursor.Cursor;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
-import org.apache.directory.shared.ldap.model.entry.DefaultAttribute;
 import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.entry.Attribute;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 
@@ -170,100 +167,8 @@ public class StoreUtils
         entry.add( "aliasedObjectName", "cn=Johnny Walker,ou=Sales,o=Good Times Co." );
         injectEntryInStore( store, entry );
     }
-
-
-    /**
-     * This is primarily a convenience method used to extract all the attributes
-     * associated with an entry.
-     *
-     * @param store the store to get the attributes from
-     * @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 Entry getAttributes( Store<Object, Long> store, Long id ) throws Exception
-    {
-        Entry entry = new DefaultEntry();
-
-        // Get the distinguishedName to id mapping
-        entry.put( "_nDn", store.getEntryDn( id ).getNormName() );
-        entry.put( "_upDn", store.getEntryDn( id ).getName() );
-        entry.put( "_parent", Long.toString( store.getParentId( id ) ) );
-
-        // Get all standard index attribute to value mappings
-        for ( Index 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 = entry.get( attrId );
-
-                if ( attr == null )
-                {
-                    attr = new DefaultAttribute( attrId );
-                }
-
-                attr.add( val );
-                entry.put( attr );
-            }
-        }
-
-        // Get all existence mappings for this id creating a special key
-        // that looks like so 'existence[attribute]' and the value is set to id
-        IndexCursor<String, Object, Long> 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( "_existence[" );
-            val.append( rec.getValue().toString() );
-            val.append( "]" );
-
-            String valStr = val.toString();
-            Attribute attr = entry.get( valStr );
-
-            if ( attr == null )
-            {
-                attr = new DefaultAttribute( valStr );
-            }
-
-            attr.add( rec.getId().toString() );
-            entry.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.
-        IndexCursor<Long, Object, Long> children = store.getOneLevelIndex().forwardCursor();
-        ForwardIndexEntry longRecordForward = new ForwardIndexEntry();
-        recordForward.setId( id );
-        children.before( longRecordForward );
-
-        Attribute childAttr = new DefaultAttribute( "_child" );
-        entry.put( childAttr );
-
-        while ( children.next() )
-        {
-            IndexEntry rec = children.get();
-            childAttr.add( rec.getId().toString() );
-        }
-
-        return entry;
-    }
-
-
+    
+    
     /**
      * 
      * adds a given <i>ServerEntry</i> to the store after injecting entryCSN
and entryUUID operational



Mime
View raw message