You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2008/05/10 22:19:41 UTC
svn commit: r655151 [2/3] - in /directory/sandbox/akarasulu/bigbang:
apacheds/btree-base/src/main/java/org/apache/directory/server/xdbm/
apacheds/core-entry/src/main/java/org/apache/directory/server/core/entry/
apacheds/jdbm-store/src/main/java/org/apa...
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java Sat May 10 13:19:40 2008
@@ -21,18 +21,17 @@
import org.apache.directory.shared.ldap.filter.LessEqNode;
-import org.apache.directory.shared.ldap.util.AttributeUtils;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.MatchingRule;
import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.Store;
import org.apache.directory.server.xdbm.Index;
import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerAttribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.Attribute;
-import javax.naming.NamingEnumeration;
import java.util.Iterator;
import java.util.Comparator;
@@ -44,18 +43,18 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class LessEqEvaluator implements Evaluator<LessEqNode, Attributes>
+public class LessEqEvaluator implements Evaluator<LessEqNode, ServerEntry>
{
private final LessEqNode node;
- private final Store<Attributes> db;
+ private final Store<ServerEntry> db;
private final Registries registries;
private final AttributeType type;
private final Normalizer normalizer;
private final Comparator comparator;
- private final Index<Object,Attributes> idx;
+ private final Index<Object,ServerEntry> idx;
- public LessEqEvaluator( LessEqNode node, Store<Attributes> db, Registries registries )
+ public LessEqEvaluator( LessEqNode node, Store<ServerEntry> db, Registries registries )
throws Exception
{
this.db = db;
@@ -121,14 +120,14 @@
}
- public boolean evaluate( IndexEntry<?,Attributes> indexEntry ) throws Exception
+ public boolean evaluate( IndexEntry<?,ServerEntry> indexEntry ) throws Exception
{
if ( idx != null )
{
return idx.reverseLessOrEq( indexEntry.getId(), node.getValue() );
}
- Attributes entry = indexEntry.getObject();
+ ServerEntry entry = indexEntry.getObject();
// resuscitate the entry if it has not been and set entry in IndexEntry
if ( null == entry )
@@ -138,10 +137,10 @@
}
// get the attribute
- Attribute attr = AttributeUtils.getAttribute( entry, type );
+ ServerAttribute attr = ( ServerAttribute ) entry.get( type );
// if the attribute does not exist just return false
- if ( attr != null && evaluate( ( IndexEntry<Object,Attributes> ) indexEntry, attr ) )
+ if ( attr != null && evaluate( ( IndexEntry<Object,ServerEntry> ) indexEntry, attr ) )
{
return true;
}
@@ -161,9 +160,9 @@
{
AttributeType descendant = descendants.next();
- attr = AttributeUtils.getAttribute( entry, descendant );
+ attr = ( ServerAttribute ) entry.get( descendant );
- if ( attr != null && evaluate( ( IndexEntry<Object,Attributes> ) indexEntry, attr ) )
+ if ( attr != null && evaluate( ( IndexEntry<Object,ServerEntry> ) indexEntry, attr ) )
{
return true;
}
@@ -175,7 +174,9 @@
}
- private boolean evaluate( IndexEntry<Object,Attributes> indexEntry, Attribute attribute ) throws Exception
+ // TODO - determine if comaparator and index entry should have the Value
+ // wrapper or the raw normalized value
+ private boolean evaluate( IndexEntry<Object,ServerEntry> indexEntry, ServerAttribute attribute ) throws Exception
{
/*
* Cycle through the attribute values testing normalized version
@@ -183,18 +184,13 @@
* normalizer. The test uses the comparator obtained from the
* appropriate matching rule to perform the check.
*/
- NamingEnumeration values = attribute.getAll();
-
- while ( values.hasMore() )
+ for ( Value value : attribute )
{
- Object value = normalizer.normalize( values.next() );
+ value.normalize( normalizer );
- // Once match is found cleanup and return true
- //noinspection unchecked
- if ( comparator.compare( value, node.getValue() ) <= 0 )
+ if ( comparator.compare( value.getNormalizedValue(), node.getValue().getNormalizedValue() ) <= 0 )
{
- indexEntry.setValue( value );
- values.close();
+ indexEntry.setValue( value.getNormalizedValue() );
return true;
}
}
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java Sat May 10 13:19:40 2008
@@ -25,10 +25,9 @@
import org.apache.directory.server.core.cursor.AbstractCursor;
import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
+import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.shared.ldap.filter.ExprNode;
-import javax.naming.directory.Attributes;
-
/**
* A Cursor returning candidates satisfying a logical negation expression.
@@ -36,17 +35,17 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $$Rev$$
*/
-public class NotCursor extends AbstractCursor<IndexEntry<?, Attributes>>
+public class NotCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
{
private static final String UNSUPPORTED_MSG =
"NotCursors are not ordered and do not support positioning by element.";
- private final Cursor<IndexEntry<String,Attributes>> ndnCursor;
- private final Evaluator<? extends ExprNode, Attributes> childEvaluator;
+ private final Cursor<IndexEntry<String,ServerEntry>> ndnCursor;
+ private final Evaluator<? extends ExprNode, ServerEntry> childEvaluator;
private boolean available = false;
- public NotCursor( Store<Attributes> db,
- Evaluator<? extends ExprNode, Attributes> childEvaluator ) throws Exception
+ public NotCursor( Store<ServerEntry> db,
+ Evaluator<? extends ExprNode, ServerEntry> childEvaluator ) throws Exception
{
this.childEvaluator = childEvaluator;
this.ndnCursor = db.getNdnIndex().forwardCursor();
@@ -59,13 +58,13 @@
}
- public void before( IndexEntry<?, Attributes> element ) throws Exception
+ public void before( IndexEntry<?, ServerEntry> element ) throws Exception
{
throw new UnsupportedOperationException( UNSUPPORTED_MSG );
}
- public void after( IndexEntry<?, Attributes> element ) throws Exception
+ public void after( IndexEntry<?, ServerEntry> element ) throws Exception
{
throw new UnsupportedOperationException( UNSUPPORTED_MSG );
}
@@ -103,7 +102,7 @@
{
while ( ndnCursor.previous() )
{
- IndexEntry<?,Attributes> candidate = ndnCursor.get();
+ IndexEntry<?,ServerEntry> candidate = ndnCursor.get();
if ( ! childEvaluator.evaluate( candidate ) )
{
return available = true;
@@ -118,7 +117,7 @@
{
while ( ndnCursor.next() )
{
- IndexEntry<?,Attributes> candidate = ndnCursor.get();
+ IndexEntry<?,ServerEntry> candidate = ndnCursor.get();
if ( ! childEvaluator.evaluate( candidate ) )
{
return available = true;
@@ -129,7 +128,7 @@
}
- public IndexEntry<?, Attributes> get() throws Exception
+ public IndexEntry<?, ServerEntry> get() throws Exception
{
if ( available )
{
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java Sat May 10 13:19:40 2008
@@ -23,8 +23,7 @@
import org.apache.directory.shared.ldap.filter.NotNode;
import org.apache.directory.shared.ldap.filter.ExprNode;
import org.apache.directory.server.xdbm.IndexEntry;
-
-import javax.naming.directory.Attributes;
+import org.apache.directory.server.core.entry.ServerEntry;
/**
@@ -33,20 +32,20 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $$Rev$$
*/
-public class NotEvaluator implements Evaluator<NotNode, Attributes>
+public class NotEvaluator implements Evaluator<NotNode, ServerEntry>
{
private final NotNode node;
- private final Evaluator<? extends ExprNode,Attributes> childEvaluator;
+ private final Evaluator<? extends ExprNode,ServerEntry> childEvaluator;
- public NotEvaluator( NotNode node, Evaluator<? extends ExprNode, Attributes> childEvaluator )
+ public NotEvaluator( NotNode node, Evaluator<? extends ExprNode, ServerEntry> childEvaluator )
{
this.node = node;
this.childEvaluator = childEvaluator;
}
- public boolean evaluate( IndexEntry<?, Attributes> indexEntry ) throws Exception
+ public boolean evaluate( IndexEntry<?, ServerEntry> indexEntry ) throws Exception
{
return ! childEvaluator.evaluate( indexEntry );
}
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java Sat May 10 13:19:40 2008
@@ -23,11 +23,10 @@
import org.apache.directory.server.core.cursor.AbstractCursor;
import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
+import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.Store;
-import javax.naming.directory.Attributes;
-
/**
* A Cursor over entries satisfying one level scope constraints with alias
@@ -36,26 +35,26 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class OneLevelScopeCursor extends AbstractCursor<IndexEntry<?, Attributes>>
+public class OneLevelScopeCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
{
/** Error message for unsupported operations */
private static final String UNSUPPORTED_MSG =
"Scope Cursors are not ordered and do not support positioning by element.";
/** The entry database/store */
- private final Store<Attributes> db;
+ private final Store<ServerEntry> db;
/** A onelevel ScopeNode Evaluator */
private final OneLevelScopeEvaluator evaluator;
/** A Cursor over the entries in the scope of the search base */
- private final Cursor<IndexEntry<Long,Attributes>> scopeCursor;
+ private final Cursor<IndexEntry<Long,ServerEntry>> scopeCursor;
/** A Cursor over entries brought into scope by alias dereferencing */
- private final Cursor<IndexEntry<Long,Attributes>> dereferencedCursor;
+ private final Cursor<IndexEntry<Long,ServerEntry>> dereferencedCursor;
/** Currently active Cursor: we switch between two cursors */
- private Cursor<IndexEntry<Long,Attributes>> cursor;
+ private Cursor<IndexEntry<Long,ServerEntry>> cursor;
/** Whether or not this Cursor is positioned so an entry is available */
private boolean available = false;
@@ -68,7 +67,7 @@
* @param evaluator an IndexEntry (candidate) evaluator
* @throws Exception on db access failures
*/
- public OneLevelScopeCursor( Store<Attributes> db, OneLevelScopeEvaluator evaluator ) throws Exception
+ public OneLevelScopeCursor( Store<ServerEntry> db, OneLevelScopeEvaluator evaluator ) throws Exception
{
this.db = db;
this.evaluator = evaluator;
@@ -91,13 +90,13 @@
}
- public void before( IndexEntry<?, Attributes> element ) throws Exception
+ public void before( IndexEntry<?, ServerEntry> element ) throws Exception
{
throw new UnsupportedOperationException( UNSUPPORTED_MSG );
}
- public void after( IndexEntry<?, Attributes> element ) throws Exception
+ public void after( IndexEntry<?, ServerEntry> element ) throws Exception
{
throw new UnsupportedOperationException( UNSUPPORTED_MSG );
}
@@ -268,7 +267,7 @@
}
- public IndexEntry<Long, Attributes> get() throws Exception
+ public IndexEntry<Long, ServerEntry> get() throws Exception
{
if ( available )
{
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java Sat May 10 13:19:40 2008
@@ -23,7 +23,9 @@
import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.cursor.AbstractCursor;
import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
+import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.shared.ldap.filter.ExprNode;
import java.util.*;
@@ -34,19 +36,19 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $$Rev$$
*/
-public class OrCursor<Attributes> extends AbstractCursor<IndexEntry<?,Attributes>>
+public class OrCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
{
private static final String UNSUPPORTED_MSG =
"OrCursors are not ordered and do not support positioning by element.";
- private final List<Cursor<IndexEntry<?,Attributes>>> cursors;
- private final List<Evaluator> evaluators;
+ private final List<Cursor<IndexEntry<?,ServerEntry>>> cursors;
+ private final List<Evaluator<? extends ExprNode,ServerEntry>> evaluators;
private final List<Set<Long>> blacklists;
private int cursorIndex = -1;
private boolean available = false;
// TODO - do same evaluator fail fast optimization that we do in AndCursor
- public OrCursor( List<Cursor<IndexEntry<?,Attributes>>> cursors, List<Evaluator> evaluators )
+ public OrCursor( List<Cursor<IndexEntry<?, ServerEntry>>> cursors, List<Evaluator<? extends ExprNode,ServerEntry>> evaluators )
{
if ( cursors.size() <= 1 )
{
@@ -72,13 +74,13 @@
}
- public void before( IndexEntry<?, Attributes> element ) throws Exception
+ public void before( IndexEntry<?, ServerEntry> element ) throws Exception
{
throw new UnsupportedOperationException( UNSUPPORTED_MSG );
}
- public void after( IndexEntry<?, Attributes> element ) throws Exception
+ public void after( IndexEntry<?, ServerEntry> element ) throws Exception
{
throw new UnsupportedOperationException( UNSUPPORTED_MSG );
}
@@ -127,7 +129,7 @@
* @param indexEntry the index entry to blacklist
* @throws Exception if there are problems accessing underlying db
*/
- private void blackListIfDuplicate( IndexEntry<?,Attributes> indexEntry ) throws Exception
+ private void blackListIfDuplicate( IndexEntry<?, ServerEntry> indexEntry ) throws Exception
{
for ( int ii = 0; ii < evaluators.size(); ii++ )
{
@@ -149,7 +151,7 @@
{
while ( cursors.get( cursorIndex ).previous() )
{
- IndexEntry<?,Attributes> candidate = cursors.get( cursorIndex ).get();
+ IndexEntry<?,ServerEntry> candidate = cursors.get( cursorIndex ).get();
if ( ! isBlackListed( candidate.getId() ) )
{
blackListIfDuplicate( candidate );
@@ -164,7 +166,7 @@
while ( cursors.get( cursorIndex ).previous() )
{
- IndexEntry<?,Attributes> candidate = cursors.get( cursorIndex ).get();
+ IndexEntry<?,ServerEntry> candidate = cursors.get( cursorIndex ).get();
if ( ! isBlackListed( candidate.getId() ) )
{
blackListIfDuplicate( candidate );
@@ -181,7 +183,7 @@
{
while ( cursors.get( cursorIndex ).next() )
{
- IndexEntry<?,Attributes> candidate = cursors.get( cursorIndex ).get();
+ IndexEntry<?,ServerEntry> candidate = cursors.get( cursorIndex ).get();
if ( ! isBlackListed( candidate.getId() ) )
{
blackListIfDuplicate( candidate );
@@ -196,7 +198,7 @@
while ( cursors.get( cursorIndex ).next() )
{
- IndexEntry<?,Attributes> candidate = cursors.get( cursorIndex ).get();
+ IndexEntry<?,ServerEntry> candidate = cursors.get( cursorIndex ).get();
if ( ! isBlackListed( candidate.getId() ) )
{
blackListIfDuplicate( candidate );
@@ -209,7 +211,7 @@
}
- public IndexEntry<?, Attributes> get() throws Exception
+ public IndexEntry<?, ServerEntry> get() throws Exception
{
if ( available )
{
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java Sat May 10 13:19:40 2008
@@ -23,8 +23,8 @@
import org.apache.directory.shared.ldap.filter.OrNode;
import org.apache.directory.shared.ldap.filter.ExprNode;
import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
-import javax.naming.directory.Attributes;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
@@ -37,14 +37,14 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $$Rev$$
*/
-public class OrEvaluator implements Evaluator<OrNode,Attributes>
+public class OrEvaluator implements Evaluator<OrNode, ServerEntry>
{
- private final List<Evaluator<? extends ExprNode, Attributes>> evaluators;
+ private final List<Evaluator<? extends ExprNode, ServerEntry>> evaluators;
private final OrNode node;
- public OrEvaluator( OrNode node, List<Evaluator<? extends ExprNode, Attributes>> evaluators )
+ public OrEvaluator( OrNode node, List<Evaluator<? extends ExprNode, ServerEntry>> evaluators )
{
this.node = node;
this.evaluators = optimize( evaluators );
@@ -62,15 +62,15 @@
* @param unoptimized the unoptimized list of Evaluators
* @return optimized Evaluator list with decreasing scan count ordering
*/
- private List<Evaluator<? extends ExprNode,Attributes>>
- optimize( List<Evaluator<? extends ExprNode, Attributes>> unoptimized )
+ private List<Evaluator<? extends ExprNode,ServerEntry>>
+ optimize( List<Evaluator<? extends ExprNode, ServerEntry>> unoptimized )
{
- List<Evaluator<? extends ExprNode, Attributes>> optimized =
- new ArrayList<Evaluator<? extends ExprNode, Attributes>>( unoptimized.size() );
+ List<Evaluator<? extends ExprNode, ServerEntry>> optimized =
+ new ArrayList<Evaluator<? extends ExprNode, ServerEntry>>( unoptimized.size() );
optimized.addAll( unoptimized );
- Collections.sort( optimized, new Comparator<Evaluator<? extends ExprNode,Attributes>>()
+ Collections.sort( optimized, new Comparator<Evaluator<? extends ExprNode,ServerEntry>>()
{
- public int compare( Evaluator<? extends ExprNode, Attributes> e1, Evaluator<? extends ExprNode, Attributes> e2 )
+ public int compare( Evaluator<? extends ExprNode, ServerEntry> e1, Evaluator<? extends ExprNode, ServerEntry> e2 )
{
int scanCount1 = ( Integer ) e1.getExpression().get( "count" );
int scanCount2 = ( Integer ) e2.getExpression().get( "count" );
@@ -99,9 +99,9 @@
}
- public boolean evaluate( IndexEntry<?, Attributes> indexEntry ) throws Exception
+ public boolean evaluate( IndexEntry<?, ServerEntry> indexEntry ) throws Exception
{
- for ( Evaluator<?,Attributes> evaluator : evaluators )
+ for ( Evaluator<?,ServerEntry> evaluator : evaluators )
{
if ( evaluator.evaluate( indexEntry ) )
{
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java Sat May 10 13:19:40 2008
@@ -25,10 +25,9 @@
import org.apache.directory.server.core.cursor.AbstractCursor;
import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
+import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.shared.ldap.schema.AttributeType;
-import javax.naming.directory.Attributes;
-
/**
* A returning candidates satisfying an attribute presence expression.
@@ -36,17 +35,17 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $$Rev$$
*/
-public class PresenceCursor extends AbstractCursor<IndexEntry<?, Attributes>>
+public class PresenceCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
{
private static final String UNSUPPORTED_MSG =
"PresenceCursors do not support positioning by element without a user index on the presence attribute.";
- private final Cursor<IndexEntry<String,Attributes>> ndnCursor;
- private final Cursor<IndexEntry<String,Attributes>> presenceCursor;
+ private final Cursor<IndexEntry<String,ServerEntry>> ndnCursor;
+ private final Cursor<IndexEntry<String,ServerEntry>> presenceCursor;
private final PresenceEvaluator presenceEvaluator;
private boolean available = false;
- public PresenceCursor( Store<Attributes> db, PresenceEvaluator presenceEvaluator ) throws Exception
+ public PresenceCursor( Store<ServerEntry> db, PresenceEvaluator presenceEvaluator ) throws Exception
{
this.presenceEvaluator = presenceEvaluator;
AttributeType type = presenceEvaluator.getAttributeType();
@@ -75,12 +74,12 @@
}
- public void before( IndexEntry<?, Attributes> element ) throws Exception
+ public void before( IndexEntry<?, ServerEntry> element ) throws Exception
{
if ( presenceCursor != null )
{
//noinspection unchecked
- presenceCursor.before( ( IndexEntry<String,Attributes> ) element );
+ presenceCursor.before( ( IndexEntry<String,ServerEntry> ) element );
return;
}
@@ -88,12 +87,12 @@
}
- public void after( IndexEntry<?, Attributes> element ) throws Exception
+ public void after( IndexEntry<?, ServerEntry> element ) throws Exception
{
if ( presenceCursor != null )
{
//noinspection unchecked
- presenceCursor.after( ( IndexEntry<String,Attributes> ) element );
+ presenceCursor.after( ( IndexEntry<String,ServerEntry> ) element );
return;
}
@@ -160,7 +159,7 @@
while ( ndnCursor.previous() )
{
- IndexEntry<?,Attributes> candidate = ndnCursor.get();
+ IndexEntry<?,ServerEntry> candidate = ndnCursor.get();
if ( presenceEvaluator.evaluate( candidate ) )
{
return available = true;
@@ -180,7 +179,7 @@
while ( ndnCursor.next() )
{
- IndexEntry<?,Attributes> candidate = ndnCursor.get();
+ IndexEntry<?,ServerEntry> candidate = ndnCursor.get();
if ( presenceEvaluator.evaluate( candidate ) )
{
return available = true;
@@ -191,7 +190,7 @@
}
- public IndexEntry<String, Attributes> get() throws Exception
+ public IndexEntry<String, ServerEntry> get() throws Exception
{
if ( presenceCursor != null )
{
@@ -210,7 +209,7 @@
* value to be the value of the attribute in question. So we will
* set that accordingly here.
*/
- IndexEntry<String, Attributes> indexEntry = ndnCursor.get();
+ IndexEntry<String, ServerEntry> indexEntry = ndnCursor.get();
indexEntry.setValue( presenceEvaluator.getAttributeType().getOid() );
return indexEntry;
}
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java Sat May 10 13:19:40 2008
@@ -21,15 +21,14 @@
import org.apache.directory.shared.ldap.filter.PresenceNode;
-import org.apache.directory.shared.ldap.util.AttributeUtils;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.Store;
import org.apache.directory.server.xdbm.Index;
import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerAttribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.Attribute;
import java.util.Iterator;
@@ -40,16 +39,16 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class PresenceEvaluator implements Evaluator<PresenceNode, Attributes>
+public class PresenceEvaluator implements Evaluator<PresenceNode, ServerEntry>
{
private final PresenceNode node;
- private final Store<Attributes> db;
+ private final Store<ServerEntry> db;
private final Registries registries;
private final AttributeType type;
- private final Index<String,Attributes> idx;
+ private final Index<String,ServerEntry> idx;
- public PresenceEvaluator( PresenceNode node, Store<Attributes> db, Registries registries )
+ public PresenceEvaluator( PresenceNode node, Store<ServerEntry> db, Registries registries )
throws Exception
{
this.db = db;
@@ -80,14 +79,16 @@
}
- public boolean evaluate( IndexEntry<?,Attributes> indexEntry ) throws Exception
+ // TODO - determine if comaparator and index entry should have the Value
+ // wrapper or the raw normalized value
+ public boolean evaluate( IndexEntry<?,ServerEntry> indexEntry ) throws Exception
{
if ( idx != null )
{
return idx.forward( type.getOid(), indexEntry.getId() );
}
- Attributes entry = indexEntry.getObject();
+ ServerEntry entry = indexEntry.getObject();
// resuscitate the entry if it has not been and set entry in IndexEntry
if ( null == entry )
@@ -97,7 +98,7 @@
}
// get the attribute
- Attribute attr = AttributeUtils.getAttribute( entry, type );
+ ServerAttribute attr = ( ServerAttribute ) entry.get( type );
// if the attribute exists just return true
if ( attr != null )
@@ -120,7 +121,7 @@
{
AttributeType descendant = descendants.next();
- attr = AttributeUtils.getAttribute( entry, descendant );
+ attr = ( ServerAttribute ) entry.get( descendant );
if ( attr != null )
{
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java Sat May 10 13:19:40 2008
@@ -23,12 +23,11 @@
import org.apache.directory.server.core.cursor.AbstractCursor;
import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
+import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.Store;
import org.apache.directory.server.xdbm.ForwardIndexEntry;
-import javax.naming.directory.Attributes;
-
/**
* A Cursor traversing candidates matching a Substring assertion expression.
@@ -36,19 +35,19 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class SubstringCursor extends AbstractCursor<IndexEntry<?, Attributes>>
+public class SubstringCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
{
private static final String UNSUPPORTED_MSG =
"SubstringCursors may not be ordered and do not support positioning by element.";
private final boolean hasIndex;
- private final Cursor<IndexEntry<String,Attributes>> wrapped;
+ private final Cursor<IndexEntry<String,ServerEntry>> wrapped;
private final SubstringEvaluator evaluator;
- private final ForwardIndexEntry<String,Attributes> indexEntry =
- new ForwardIndexEntry<String,Attributes>();
+ private final ForwardIndexEntry<String,ServerEntry> indexEntry =
+ new ForwardIndexEntry<String,ServerEntry>();
private boolean available = false;
- public SubstringCursor( Store<Attributes> db,
+ public SubstringCursor( Store<ServerEntry> db,
final SubstringEvaluator substringEvaluator ) throws Exception
{
evaluator = substringEvaluator;
@@ -83,13 +82,13 @@
}
- public void before( IndexEntry<?, Attributes> element ) throws Exception
+ public void before( IndexEntry<?, ServerEntry> element ) throws Exception
{
throw new UnsupportedOperationException( UNSUPPORTED_MSG );
}
- public void after( IndexEntry<?, Attributes> element ) throws Exception
+ public void after( IndexEntry<?, ServerEntry> element ) throws Exception
{
throw new UnsupportedOperationException( UNSUPPORTED_MSG );
}
@@ -99,7 +98,7 @@
{
if ( evaluator.getExpression().getInitial() != null && hasIndex )
{
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( evaluator.getExpression().getInitial() );
wrapped.before( indexEntry );
}
@@ -138,7 +137,7 @@
}
- private boolean evaluateCandidate( IndexEntry<String,Attributes> indexEntry ) throws Exception
+ private boolean evaluateCandidate( IndexEntry<String,ServerEntry> indexEntry ) throws Exception
{
if ( hasIndex )
{
@@ -162,7 +161,7 @@
{
while ( wrapped.previous() )
{
- IndexEntry<String,Attributes> entry = wrapped.get();
+ IndexEntry<String,ServerEntry> entry = wrapped.get();
if ( evaluateCandidate( entry ) )
{
available = true;
@@ -182,7 +181,7 @@
{
while ( wrapped.next() )
{
- IndexEntry<String,Attributes> entry = wrapped.get();
+ IndexEntry<String,ServerEntry> entry = wrapped.get();
if ( evaluateCandidate( entry ) )
{
available = true;
@@ -198,7 +197,7 @@
}
- public IndexEntry<?, Attributes> get() throws Exception
+ public IndexEntry<?, ServerEntry> get() throws Exception
{
if ( available )
{
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java Sat May 10 13:19:40 2008
@@ -23,21 +23,19 @@
import java.util.Iterator;
import java.util.regex.Pattern;
-import javax.naming.NamingEnumeration;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-
import org.apache.directory.server.schema.registries.Registries;
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.server.core.cursor.Cursor;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerAttribute;
import org.apache.directory.shared.ldap.filter.SubstringNode;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.MatchingRule;
import org.apache.directory.shared.ldap.schema.Normalizer;
import org.apache.directory.shared.ldap.schema.NoOpNormalizer;
-import org.apache.directory.shared.ldap.util.AttributeUtils;
+import org.apache.directory.shared.ldap.entry.Value;
/**
@@ -46,10 +44,10 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class SubstringEvaluator implements Evaluator<SubstringNode,Attributes>
+public class SubstringEvaluator implements Evaluator<SubstringNode, ServerEntry>
{
/** Database used while evaluating candidates */
- private final Store<Attributes> db;
+ private final Store<ServerEntry> db;
/** Oid Registry used to translate attributeIds to OIDs */
private final Registries registries;
@@ -64,7 +62,7 @@
private final Normalizer normalizer;
- private final Index<String,Attributes> idx;
+ private final Index<String,ServerEntry> idx;
/**
@@ -75,7 +73,7 @@
* @param registries the set of registries
* @throws Exception if there are failures accessing resources and the db
*/
- public SubstringEvaluator( SubstringNode node, Store<Attributes> db, Registries registries ) throws Exception
+ public SubstringEvaluator( SubstringNode node, Store<ServerEntry> db, Registries registries ) throws Exception
{
this.db = db;
this.node = node;
@@ -115,16 +113,13 @@
}
- /**
- * @see Evaluator#evaluate(IndexEntry)
- */
- public boolean evaluate( IndexEntry<?,Attributes> indexEntry ) throws Exception
+ public boolean evaluate( IndexEntry<?,ServerEntry> indexEntry ) throws Exception
{
if ( idx == null )
{
//noinspection unchecked
- return evaluateWithoutIndex( ( IndexEntry<String,Attributes> ) indexEntry );
+ return evaluateWithoutIndex( ( IndexEntry<String,ServerEntry> ) indexEntry );
}
else
{
@@ -145,7 +140,7 @@
}
- private boolean evaluateWithIndex( IndexEntry<?,Attributes> indexEntry ) throws Exception
+ private boolean evaluateWithIndex( IndexEntry<?,ServerEntry> indexEntry ) throws Exception
{
/*
* Note that this is using the reverse half of the index giving a
@@ -153,7 +148,7 @@
* Otherwise we would have to scan the entire index if there were
* no reverse lookups.
*/
- Cursor<IndexEntry<String,Attributes>> entries = idx.reverseCursor( indexEntry.getId() );
+ Cursor<IndexEntry<String,ServerEntry>> entries = idx.reverseCursor( indexEntry.getId() );
// cycle through the attribute values testing for a match
while ( entries.next() )
@@ -173,9 +168,11 @@
}
- private boolean evaluateWithoutIndex( IndexEntry<String,Attributes> indexEntry ) throws Exception
+ // TODO - determine if comaparator and index entry should have the Value
+ // wrapper or the raw normalized value
+ private boolean evaluateWithoutIndex( IndexEntry<String,ServerEntry> indexEntry ) throws Exception
{
- Attributes entry = indexEntry.getObject();
+ ServerEntry entry = indexEntry.getObject();
// resuscitate the entry if it has not been and set entry in IndexEntry
if ( null == entry )
@@ -185,31 +182,27 @@
}
// get the attribute
- Attribute attr = AttributeUtils.getAttribute( entry, type );
+ ServerAttribute attr = ( ServerAttribute ) entry.get( type );
- // if the attribute does not exist just return false
+ // if the attribute exists and the pattern matches return true
if ( attr != null )
{
-
/*
* Cycle through the attribute values testing normalized version
* obtained from using the substring matching rule's normalizer.
* The test uses the comparator obtained from the appropriate
* substring matching rule.
*/
- NamingEnumeration values = attr.getAll();
-
- while ( values.hasMore() )
+ for ( Value value : attr )
{
- String value = ( String ) normalizer.normalize( values.next() );
+ value.normalize( normalizer );
+ String strValue = ( String ) value.getNormalizedValue();
// Once match is found cleanup and return true
- if ( regex.matcher( value ).matches() )
+ if ( regex.matcher( strValue ).matches() )
{
// before returning we set the normalized value
- indexEntry.setValue( value );
-
- values.close();
+ indexEntry.setValue( strValue );
return true;
}
}
@@ -232,26 +225,28 @@
{
AttributeType descendant = descendants.next();
- attr = AttributeUtils.getAttribute( entry, descendant );
+ attr = ( ServerAttribute ) entry.get( descendant );
if ( null != attr )
{
+
+
/*
* Cycle through the attribute values testing normalized version
* obtained from using the substring matching rule's normalizer.
* The test uses the comparator obtained from the appropriate
* substring matching rule.
*/
- NamingEnumeration values = attr.getAll();
-
- while ( values.hasMore() )
+ for ( Value value : attr )
{
- String value = ( String ) normalizer.normalize( values.next() );
+ value.normalize( normalizer );
+ String strValue = ( String ) value.getNormalizedValue();
// Once match is found cleanup and return true
- if ( regex.matcher( value ).matches() )
+ if ( regex.matcher( strValue ).matches() )
{
- values.close();
+ // before returning we set the normalized value
+ indexEntry.setValue( strValue );
return true;
}
}
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java Sat May 10 13:19:40 2008
@@ -23,11 +23,10 @@
import org.apache.directory.server.core.cursor.AbstractCursor;
import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
+import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.Store;
-import javax.naming.directory.Attributes;
-
/**
* A Cursor over entries satisfying scope constraints with alias dereferencing
@@ -36,25 +35,25 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class SubtreeScopeCursor extends AbstractCursor<IndexEntry<?, Attributes>>
+public class SubtreeScopeCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
{
private static final String UNSUPPORTED_MSG =
"Scope Cursors are not ordered and do not support positioning by element.";
/** The Entry database/store */
- private final Store<Attributes> db;
+ private final Store<ServerEntry> db;
/** A ScopeNode Evaluator */
private final SubtreeScopeEvaluator evaluator;
/** A Cursor over the entries in the scope of the search base */
- private final Cursor<IndexEntry<Long,Attributes>> scopeCursor;
+ private final Cursor<IndexEntry<Long,ServerEntry>> scopeCursor;
/** A Cursor over entries brought into scope by alias dereferencing */
- private final Cursor<IndexEntry<Long,Attributes>> dereferencedCursor;
+ private final Cursor<IndexEntry<Long,ServerEntry>> dereferencedCursor;
/** Currently active Cursor: we switch between two cursors */
- private Cursor<IndexEntry<Long,Attributes>> cursor;
+ private Cursor<IndexEntry<Long,ServerEntry>> cursor;
/** Whether or not this Cursor is positioned so an entry is available */
private boolean available = false;
@@ -67,7 +66,7 @@
* @param evaluator an IndexEntry (candidate) evaluator
* @throws Exception on db access failures
*/
- public SubtreeScopeCursor( Store<Attributes> db, SubtreeScopeEvaluator evaluator ) throws Exception
+ public SubtreeScopeCursor( Store<ServerEntry> db, SubtreeScopeEvaluator evaluator ) throws Exception
{
this.db = db;
this.evaluator = evaluator;
@@ -90,13 +89,13 @@
}
- public void before( IndexEntry<?, Attributes> element ) throws Exception
+ public void before( IndexEntry<?, ServerEntry> element ) throws Exception
{
throw new UnsupportedOperationException( UNSUPPORTED_MSG );
}
- public void after( IndexEntry<?, Attributes> element ) throws Exception
+ public void after( IndexEntry<?, ServerEntry> element ) throws Exception
{
throw new UnsupportedOperationException( UNSUPPORTED_MSG );
}
@@ -266,7 +265,7 @@
}
- public IndexEntry<Long, Attributes> get() throws Exception
+ public IndexEntry<Long, ServerEntry> get() throws Exception
{
if ( available )
{
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java Sat May 10 13:19:40 2008
@@ -19,21 +19,21 @@
*/
package org.apache.directory.server.xdbm.search.impl;
+
import static org.junit.Assert.*;
import java.io.File;
-import java.util.ArrayList;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
-
-import javax.naming.directory.Attributes;
+import java.util.List;
+import java.util.ArrayList;
import org.apache.commons.io.FileUtils;
-import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
+import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
+import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.schema.SerializableComparator;
import org.apache.directory.server.schema.bootstrap.ApacheSchema;
import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
@@ -48,8 +48,8 @@
import org.apache.directory.server.schema.registries.OidRegistry;
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.server.xdbm.ForwardIndexEntry;
-import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.tools.StoreUtils;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.filter.AndNode;
@@ -61,6 +61,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
*
* Test class for AndCursor.
@@ -73,7 +74,7 @@
private static final Logger LOG = LoggerFactory.getLogger( AndCursorTest.class.getSimpleName() );
File wkdir;
- Store<Attributes> store;
+ Store<ServerEntry> store;
Registries registries = null;
AttributeTypeRegistry attributeRegistry;
EvaluatorBuilder evaluatorBuilder;
@@ -111,7 +112,7 @@
wkdir.mkdirs();
// initialize the store
- store = new JdbmStore<Attributes>();
+ store = new JdbmStore<ServerEntry>();
store.setName( "example" );
store.setCacheSize( 10 );
store.setWorkingDirectory( wkdir );
@@ -153,7 +154,7 @@
ExprNode exprNode = FilterParser.parse( filter );
- Cursor<IndexEntry<?,Attributes>> cursor = cursorBuilder.build( exprNode );
+ Cursor<IndexEntry<?,ServerEntry>> cursor = cursorBuilder.build( exprNode );
cursor.beforeFirst();
@@ -185,12 +186,12 @@
{
AndNode andNode = new AndNode();
- List<Evaluator<? extends ExprNode,Attributes>> evaluators = new ArrayList<Evaluator<? extends ExprNode,Attributes>>();
- Evaluator<? extends ExprNode, Attributes> eval;
+ List<Evaluator<? extends ExprNode,ServerEntry>> evaluators = new ArrayList<Evaluator<? extends ExprNode,ServerEntry>>();
+ Evaluator<? extends ExprNode, ServerEntry> eval;
ExprNode exprNode = new SubstringNode( "cn", "J*", null );
eval = new SubstringEvaluator( ( SubstringNode ) exprNode, store, registries );
- Cursor<IndexEntry<?,Attributes>> wrapped = new SubstringCursor( store, ( SubstringEvaluator ) eval );
+ Cursor<IndexEntry<?,ServerEntry>> wrapped = new SubstringCursor( store, ( SubstringEvaluator ) eval );
/* adding this results in NPE adding Presence evaluator not
Substring evaluator but adding Substring cursor as wrapped cursor */
@@ -204,7 +205,7 @@
andNode.addNode( exprNode );
- Cursor<IndexEntry<?,Attributes>> cursor = ( Cursor<IndexEntry<?,Attributes>> ) new AndCursor( wrapped, evaluators ); //cursorBuilder.build( andNode );
+ Cursor<IndexEntry<?,ServerEntry>> cursor = new AndCursor( wrapped, evaluators ); //cursorBuilder.build( andNode );
cursor.beforeFirst();
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java Sat May 10 13:19:40 2008
@@ -31,10 +31,12 @@
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerStringValue;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.filter.GreaterEqNode;
import org.apache.directory.shared.ldap.schema.*;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
@@ -44,7 +46,6 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-import javax.naming.directory.Attributes;
import javax.naming.NamingException;
import java.io.File;
import java.util.Set;
@@ -66,7 +67,7 @@
File wkdir;
- Store<Attributes> store;
+ Store<ServerEntry> store;
Registries registries = null;
AttributeTypeRegistry attributeRegistry;
@@ -103,7 +104,7 @@
wkdir.mkdirs();
// initialize the store
- store = new JdbmStore<Attributes>();
+ store = new JdbmStore<ServerEntry>();
store.setName( "example" );
store.setCacheSize( 10 );
store.setWorkingDirectory( wkdir );
@@ -139,7 +140,8 @@
@Test
public void testCursorIndexed() throws Exception
{
- GreaterEqNode node = new GreaterEqNode( SchemaConstants.POSTALCODE_AT_OID, "3" );
+ AttributeType at = attributeRegistry.lookup( SchemaConstants.POSTALCODE_AT_OID );
+ GreaterEqNode node = new GreaterEqNode( SchemaConstants.POSTALCODE_AT_OID, new ServerStringValue( at, "3" ) );
GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, registries );
GreaterEqCursor cursor = new GreaterEqCursor( store, evaluator );
assertNotNull( cursor );
@@ -277,7 +279,7 @@
// ---------- test before() ----------
cursor = new GreaterEqCursor( store, evaluator );
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "5" );
assertFalse( cursor.available() );
@@ -300,7 +302,7 @@
assertTrue( cursor.isClosed() );
cursor = new GreaterEqCursor( store, evaluator );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "7" );
cursor.before( indexEntry );
assertFalse( cursor.available() );
@@ -310,7 +312,7 @@
cursor.close();
cursor = new GreaterEqCursor( store, evaluator );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "3" );
cursor.before( indexEntry );
assertFalse( cursor.available() );
@@ -322,7 +324,7 @@
// ---------- test after() ----------
cursor = new GreaterEqCursor( store, evaluator );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "4" );
assertFalse( cursor.available() );
@@ -345,7 +347,7 @@
assertTrue( cursor.isClosed() );
cursor = new GreaterEqCursor( store, evaluator );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "7" );
cursor.after( indexEntry );
assertFalse( cursor.available() );
@@ -355,7 +357,7 @@
cursor.close();
cursor = new GreaterEqCursor( store, evaluator );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "3" );
cursor.after( indexEntry );
assertFalse( cursor.available() );
@@ -369,7 +371,8 @@
@Test
public void testCursorNotIndexed() throws Exception
{
- GreaterEqNode node = new GreaterEqNode( SchemaConstants.POSTOFFICEBOX_AT_OID, "3" );
+ AttributeType at = attributeRegistry.lookup( SchemaConstants.POSTOFFICEBOX_AT_OID );
+ GreaterEqNode node = new GreaterEqNode( SchemaConstants.POSTOFFICEBOX_AT_OID, new ServerStringValue( at, "3" ) );
GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, registries );
GreaterEqCursor cursor = new GreaterEqCursor( store, evaluator );
assertNotNull( cursor );
@@ -502,7 +505,7 @@
// ---------- test before() ----------
cursor = new GreaterEqCursor( store, evaluator );
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "2" );
try { cursor.before( indexEntry ); fail( "Should never get here." );}
catch ( UnsupportedOperationException e ) {}
@@ -510,7 +513,7 @@
// ---------- test after() ----------
cursor = new GreaterEqCursor( store, evaluator );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "2" );
try { cursor.after( indexEntry ); fail( "Should never get here." );}
catch ( UnsupportedOperationException e ) {}
@@ -525,9 +528,10 @@
@Test
public void testEvaluatorIndexed() throws Exception
{
- GreaterEqNode node = new GreaterEqNode( SchemaConstants.POSTALCODE_AT_OID, "3" );
+ AttributeType at = attributeRegistry.lookup( SchemaConstants.POSTALCODE_AT_OID );
+ GreaterEqNode node = new GreaterEqNode( SchemaConstants.POSTALCODE_AT_OID, new ServerStringValue( at, "3" ) );
GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, registries );
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String,ServerEntry>();
assertEquals( node, evaluator.getExpression() );
assertEquals( SchemaConstants.POSTALCODE_AT_OID, evaluator.getAttributeType().getOid() );
assertNotNull( evaluator.getNormalizer() );
@@ -536,31 +540,31 @@
indexEntry.setId( 1L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 4L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 5L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 6L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 7L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 8L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 9L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 10L );
assertFalse( evaluator.evaluate( indexEntry ) );
}
@@ -569,9 +573,10 @@
@Test
public void testEvaluatorWithDescendantValue() throws Exception
{
- GreaterEqNode node = new GreaterEqNode( SchemaConstants.STREET_AT_OID, "2" );
+ AttributeType at = attributeRegistry.lookup( SchemaConstants.STREET_AT_OID );
+ GreaterEqNode node = new GreaterEqNode( SchemaConstants.STREET_AT_OID, new ServerStringValue( at, "2" ) );
GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, registries );
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String,ServerEntry>();
assertEquals( node, evaluator.getExpression() );
assertEquals( SchemaConstants.STREET_AT_OID, evaluator.getAttributeType().getOid() );
assertNotNull( evaluator.getNormalizer() );
@@ -579,10 +584,11 @@
LdapDN dn = new LdapDN( "cn=jane doe,o=good times co." );
dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
- AttributesImpl attrs = new AttributesImpl( "objectClass", "person", true );
- attrs.put( "c-street", "3" );
- attrs.put( "cn", "jane doe" );
- attrs.put( "sn", "doe" );
+ ServerEntry attrs = new DefaultServerEntry( registries, dn );
+ attrs.add( "objectClass", "person" );
+ attrs.add( "c-street", "3" );
+ attrs.add( "cn", "jane doe" );
+ attrs.add( "sn", "doe" );
store.add( dn, attrs );
indexEntry.setId( 12L );
@@ -593,9 +599,11 @@
@Test
public void testEvaluatorWithoutDescendants() throws Exception
{
- GreaterEqNode node = new GreaterEqNode( SchemaConstants.C_POSTALCODE_AT_OID, "2" );
+ AttributeType at = attributeRegistry.lookup( SchemaConstants.C_POSTALCODE_AT_OID );
+ GreaterEqNode node = new GreaterEqNode( SchemaConstants.C_POSTALCODE_AT_OID, new ServerStringValue( at, "2" ) );
+
GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, registries );
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String,ServerEntry>();
assertEquals( node, evaluator.getExpression() );
assertEquals( SchemaConstants.C_POSTALCODE_AT_OID, evaluator.getAttributeType().getOid() );
assertNotNull( evaluator.getNormalizer() );
@@ -609,9 +617,11 @@
@Test
public void testEvaluatorNotIndexed() throws Exception
{
- GreaterEqNode node = new GreaterEqNode( SchemaConstants.POSTOFFICEBOX_AT_OID, "3" );
+ AttributeType at = attributeRegistry.lookup( SchemaConstants.POSTOFFICEBOX_AT_OID );
+ GreaterEqNode node = new GreaterEqNode( SchemaConstants.POSTOFFICEBOX_AT_OID, new ServerStringValue( at, "3" ) );
+
GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, registries );
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String, ServerEntry>();
assertEquals( node, evaluator.getExpression() );
assertEquals( SchemaConstants.POSTOFFICEBOX_AT_OID, evaluator.getAttributeType().getOid() );
assertNotNull( evaluator.getNormalizer() );
@@ -620,31 +630,31 @@
indexEntry.setId( 1L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 4L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 5L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 6L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 7L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 8L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 9L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 10L );
assertFalse( evaluator.evaluate( indexEntry ) );
}
@@ -769,7 +779,8 @@
}
};
registries.getAttributeTypeRegistry().register( at );
- GreaterEqNode node = new GreaterEqNode( at.getOid(), "3" );
+
+ GreaterEqNode node = new GreaterEqNode( at.getOid(), new ServerStringValue( at, "3" ) );
new GreaterEqEvaluator( node, store, registries );
registries.getAttributeTypeRegistry().unregister( at.getOid() );
}
@@ -954,7 +965,8 @@
}
};
registries.getAttributeTypeRegistry().register( at );
- GreaterEqNode node = new GreaterEqNode( at.getOid(), "3" );
+
+ GreaterEqNode node = new GreaterEqNode( at.getOid(), new ServerStringValue( at, "3" ) );
new GreaterEqEvaluator( node, store, registries );
registries.getAttributeTypeRegistry().unregister( at.getOid() );
}
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java Sat May 10 13:19:40 2008
@@ -31,10 +31,12 @@
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerStringValue;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.filter.LessEqNode;
import org.apache.directory.shared.ldap.schema.*;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
@@ -44,8 +46,6 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-import javax.naming.directory.Attributes;
-import javax.naming.NamingException;
import java.io.File;
import java.util.Set;
import java.util.HashSet;
@@ -53,6 +53,8 @@
import jdbm.helper.StringComparator;
+import javax.naming.NamingException;
+
/**
* Tests the LessEqEvaluator and LessEqCursor classes for correct operation.
@@ -66,7 +68,7 @@
File wkdir;
- Store<Attributes> store;
+ Store<ServerEntry> store;
Registries registries = null;
AttributeTypeRegistry attributeRegistry;
@@ -103,7 +105,7 @@
wkdir.mkdirs();
// initialize the store
- store = new JdbmStore<Attributes>();
+ store = new JdbmStore<ServerEntry>();
store.setName( "example" );
store.setCacheSize( 10 );
store.setWorkingDirectory( wkdir );
@@ -139,7 +141,8 @@
@Test
public void testCursorIndexed() throws Exception
{
- LessEqNode node = new LessEqNode( SchemaConstants.POSTALCODE_AT_OID, "3" );
+ AttributeType at = attributeRegistry.lookup( SchemaConstants.POSTALCODE_AT_OID );
+ LessEqNode node = new LessEqNode( SchemaConstants.POSTALCODE_AT_OID, new ServerStringValue( at, "3" ) );
LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
LessEqCursor cursor = new LessEqCursor( store, evaluator );
assertNotNull( cursor );
@@ -297,7 +300,7 @@
// ---------- test before() ----------
cursor = new LessEqCursor( store, evaluator );
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "2" );
assertFalse( cursor.available() );
@@ -320,7 +323,7 @@
assertTrue( cursor.isClosed() );
cursor = new LessEqCursor( store, evaluator );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "7" );
cursor.before( indexEntry );
assertFalse( cursor.available() );
@@ -330,7 +333,7 @@
cursor.close();
cursor = new LessEqCursor( store, evaluator );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "3" );
cursor.before( indexEntry );
assertFalse( cursor.available() );
@@ -342,7 +345,7 @@
// ---------- test after() ----------
cursor = new LessEqCursor( store, evaluator );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "1" );
assertFalse( cursor.available() );
@@ -365,7 +368,7 @@
assertTrue( cursor.isClosed() );
cursor = new LessEqCursor( store, evaluator );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "7" );
cursor.after( indexEntry );
assertFalse( cursor.available() );
@@ -375,7 +378,7 @@
cursor.close();
cursor = new LessEqCursor( store, evaluator );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "3" );
cursor.after( indexEntry );
assertFalse( cursor.available() );
@@ -389,7 +392,8 @@
@Test
public void testCursorNotIndexed() throws Exception
{
- LessEqNode node = new LessEqNode( SchemaConstants.POSTOFFICEBOX_AT_OID, "3" );
+ AttributeType at = attributeRegistry.lookup( SchemaConstants.POSTOFFICEBOX_AT_OID );
+ LessEqNode node = new LessEqNode( SchemaConstants.POSTOFFICEBOX_AT_OID, new ServerStringValue( at, "3" ) );
LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
LessEqCursor cursor = new LessEqCursor( store, evaluator );
assertNotNull( cursor );
@@ -542,7 +546,7 @@
// ---------- test before() ----------
cursor = new LessEqCursor( store, evaluator );
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "2" );
try { cursor.before( indexEntry ); fail( "Should never get here." );}
catch ( UnsupportedOperationException e ) {}
@@ -550,7 +554,7 @@
// ---------- test after() ----------
cursor = new LessEqCursor( store, evaluator );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setValue( "2" );
try { cursor.after( indexEntry ); fail( "Should never get here." );}
catch ( UnsupportedOperationException e ) {}
@@ -565,9 +569,11 @@
@Test
public void testEvaluatorIndexed() throws Exception
{
- LessEqNode node = new LessEqNode( SchemaConstants.POSTALCODE_AT_OID, "3" );
+ AttributeType at = attributeRegistry.lookup( SchemaConstants.POSTALCODE_AT_OID );
+ LessEqNode node = new LessEqNode( SchemaConstants.POSTALCODE_AT_OID, new ServerStringValue( at, "3" ) );
+
LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String,ServerEntry>();
assertEquals( node, evaluator.getExpression() );
assertEquals( SchemaConstants.POSTALCODE_AT_OID, evaluator.getAttributeType().getOid() );
assertNotNull( evaluator.getNormalizer() );
@@ -576,31 +582,31 @@
indexEntry.setId( 1L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 4L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 5L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 6L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 7L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 8L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 9L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 10L );
assertFalse( evaluator.evaluate( indexEntry ) );
}
@@ -609,9 +615,11 @@
@Test
public void testEvaluatorWithDescendantValue() throws Exception
{
- LessEqNode node = new LessEqNode( SchemaConstants.STREET_AT_OID, "2" );
+ AttributeType at = attributeRegistry.lookup( SchemaConstants.STREET_AT_OID );
+ LessEqNode node = new LessEqNode( SchemaConstants.STREET_AT_OID, new ServerStringValue( at, "2" ) );
+
LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String,ServerEntry>();
assertEquals( node, evaluator.getExpression() );
assertEquals( SchemaConstants.STREET_AT_OID, evaluator.getAttributeType().getOid() );
assertNotNull( evaluator.getNormalizer() );
@@ -619,10 +627,11 @@
LdapDN dn = new LdapDN( "cn=jane doe,o=good times co." );
dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
- AttributesImpl attrs = new AttributesImpl( "objectClass", "person", true );
- attrs.put( "c-street", "1" );
- attrs.put( "cn", "jane doe" );
- attrs.put( "sn", "doe" );
+ ServerEntry attrs = new DefaultServerEntry( registries, dn );
+ attrs.add( "objectClass", "person" );
+ attrs.add( "c-street", "1" );
+ attrs.add( "cn", "jane doe" );
+ attrs.add( "sn", "doe" );
store.add( dn, attrs );
indexEntry.setId( 12L );
@@ -633,9 +642,11 @@
@Test
public void testEvaluatorWithoutDescendants() throws Exception
{
- LessEqNode node = new LessEqNode( SchemaConstants.C_POSTALCODE_AT_OID, "2" );
+ AttributeType at = attributeRegistry.lookup( SchemaConstants.C_POSTALCODE_AT_OID );
+ LessEqNode node = new LessEqNode( SchemaConstants.C_POSTALCODE_AT_OID, new ServerStringValue( at, "2" ) );
+
LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String,ServerEntry>();
assertEquals( node, evaluator.getExpression() );
assertEquals( SchemaConstants.C_POSTALCODE_AT_OID, evaluator.getAttributeType().getOid() );
assertNotNull( evaluator.getNormalizer() );
@@ -649,9 +660,11 @@
@Test
public void testEvaluatorNotIndexed() throws Exception
{
- LessEqNode node = new LessEqNode( SchemaConstants.POSTOFFICEBOX_AT_OID, "3" );
+ AttributeType at = attributeRegistry.lookup( SchemaConstants.POSTOFFICEBOX_AT_OID );
+ LessEqNode node = new LessEqNode( SchemaConstants.POSTOFFICEBOX_AT_OID, new ServerStringValue( at, "3" ) );
+
LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
- ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+ ForwardIndexEntry<String,ServerEntry> indexEntry = new ForwardIndexEntry<String,ServerEntry>();
assertEquals( node, evaluator.getExpression() );
assertEquals( SchemaConstants.POSTOFFICEBOX_AT_OID, evaluator.getAttributeType().getOid() );
assertNotNull( evaluator.getNormalizer() );
@@ -660,31 +673,31 @@
indexEntry.setId( 1L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 4L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 5L );
assertTrue( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 6L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 7L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 8L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 9L );
assertFalse( evaluator.evaluate( indexEntry ) );
- indexEntry = new ForwardIndexEntry<String,Attributes>();
+ indexEntry = new ForwardIndexEntry<String,ServerEntry>();
indexEntry.setId( 10L );
assertFalse( evaluator.evaluate( indexEntry ) );
}
@@ -809,7 +822,9 @@
}
};
registries.getAttributeTypeRegistry().register( at );
- LessEqNode node = new LessEqNode( at.getOid(), "3" );
+
+ LessEqNode node = new LessEqNode( at.getOid(), new ServerStringValue( at, "3" ) );
+
new LessEqEvaluator( node, store, registries );
registries.getAttributeTypeRegistry().unregister( at.getOid() );
}
@@ -994,7 +1009,8 @@
}
};
registries.getAttributeTypeRegistry().register( at );
- LessEqNode node = new LessEqNode( at.getOid(), "3" );
+
+ LessEqNode node = new LessEqNode( at.getOid(), new ServerStringValue( at, "3" ) );
new LessEqEvaluator( node, store, registries );
registries.getAttributeTypeRegistry().unregister( at.getOid() );
}
Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java?rev=655151&r1=655150&r2=655151&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java Sat May 10 13:19:40 2008
@@ -19,19 +19,19 @@
*/
package org.apache.directory.server.xdbm.search.impl;
+
import static org.junit.Assert.*;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
-import javax.naming.directory.Attributes;
-
import org.apache.commons.io.FileUtils;
import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
+import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.schema.SerializableComparator;
import org.apache.directory.server.schema.bootstrap.ApacheSchema;
import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
@@ -54,11 +54,11 @@
import org.apache.directory.shared.ldap.filter.FilterParser;
import org.apache.directory.shared.ldap.filter.NotNode;
import org.apache.directory.shared.ldap.filter.SubstringNode;
-import org.apache.directory.shared.ldap.name.LdapDN;
import org.junit.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
*
* Test cases for NotCursor.
@@ -71,7 +71,7 @@
private static final Logger LOG = LoggerFactory.getLogger( NotCursorTest.class.getSimpleName() );
File wkdir;
- Store<Attributes> store;
+ Store<ServerEntry> store;
Registries registries = null;
AttributeTypeRegistry attributeRegistry;
EvaluatorBuilder evaluatorBuilder;
@@ -109,7 +109,7 @@
wkdir.mkdirs();
// initialize the store
- store = new JdbmStore<Attributes>();
+ store = new JdbmStore<ServerEntry>();
store.setName( "example" );
store.setCacheSize( 10 );
store.setWorkingDirectory( wkdir );
@@ -151,7 +151,7 @@
ExprNode exprNode = FilterParser.parse( filter );
- Cursor<IndexEntry<?,Attributes>> cursor = cursorBuilder.build( exprNode );
+ Cursor<IndexEntry<?, ServerEntry>> cursor = cursorBuilder.build( exprNode );
assertFalse( cursor.available() );
@@ -196,10 +196,10 @@
NotNode notNode = new NotNode();
ExprNode exprNode = new SubstringNode( "cn", "J", null );
- Evaluator<? extends ExprNode, Attributes> eval = new SubstringEvaluator( ( SubstringNode ) exprNode, store, registries );
+ Evaluator<? extends ExprNode, ServerEntry> eval = new SubstringEvaluator( ( SubstringNode ) exprNode, store, registries );
notNode.addNode( exprNode );
- Cursor<IndexEntry<?,Attributes>> cursor = ( Cursor<IndexEntry<?,Attributes>> ) new NotCursor( store, eval ); //cursorBuilder.build( andNode );
+ Cursor<IndexEntry<?,ServerEntry>> cursor = new NotCursor( store, eval ); //cursorBuilder.build( andNode );
assertTrue( cursor.next() );
assertTrue( cursor.available() );