You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/07/13 01:28:24 UTC
svn commit: r963526 - in /directory/shared/trunk: ldap-aci/src/main/antlr/
ldap/src/main/java/org/apache/directory/shared/ldap/codec/
ldap/src/main/java/org/apache/directory/shared/ldap/filter/
ldap/src/main/java/org/apache/directory/shared/ldap/name/ ...
Author: elecharny
Date: Mon Jul 12 23:28:23 2010
New Revision: 963526
URL: http://svn.apache.org/viewvc?rev=963526&view=rev
Log:
o Made the Filter Schema aware
o Added the AttributeTypeRegistry.hadDescendant( AttributeType )/descendants( AttributeType ) methods for more convenient manpulation
o Fixed the tests accordingly
Modified:
directory/shared/trunk/ldap-aci/src/main/antlr/subtree-specification.g
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitorTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterCloneTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java
Modified: directory/shared/trunk/ldap-aci/src/main/antlr/subtree-specification.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-aci/src/main/antlr/subtree-specification.g?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap-aci/src/main/antlr/subtree-specification.g (original)
+++ directory/shared/trunk/ldap-aci/src/main/antlr/subtree-specification.g Mon Jul 12 23:28:23 2010
@@ -49,6 +49,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.StringValue;
import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.schema.AttributeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -96,6 +97,9 @@ options
/** The schemaManager */
private SchemaManager schemaManager;
+ /** The ObjectClass AT */
+ AttributeType OBJECT_CLASS_AT;
+
private ComponentsMonitor subtreeSpecificationComponentsMonitor = null;
@@ -106,6 +110,8 @@ options
public void init( SchemaManager schemaManager )
{
this.schemaManager = schemaManager;
+ OBJECT_CLASS_AT = schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT );
+
}
@@ -327,7 +333,7 @@ filter returns [ ExprNode filterExpr = n
log.debug( "entered filter()" );
}
:
- ( filterToken:FILTER { filterExpr=FilterParser.parse( filterToken.getText() ); } )
+ ( filterToken:FILTER { filterExpr=FilterParser.parse( schemaManager, filterToken.getText() ); } )
;
exception
catch [Exception e]
@@ -396,7 +402,7 @@ item returns [ LeafNode node ]
log.debug( "entered item()" );
node = null;
String oid = null;
- ObjectClass objectClass = null;
+ ObjectClass objectClass;
}
:
ID_item ( SP )* COLON ( SP )* oid=oid
@@ -411,7 +417,7 @@ item returns [ LeafNode node ]
// TODO : deal with such an exception
}
- node = new EqualityNode( SchemaConstants.OBJECT_CLASS_AT, new StringValue( oid ) );
+ node = new EqualityNode( OBJECT_CLASS_AT, new StringValue( oid ) );
}
;
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java Mon Jul 12 23:28:23 2010
@@ -108,6 +108,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.message.internal.InternalMessage;
import org.apache.directory.shared.ldap.message.internal.InternalReferral;
import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
import org.apache.directory.shared.ldap.util.LdapURL;
import org.apache.directory.shared.ldap.util.StringTools;
import org.slf4j.Logger;
@@ -473,14 +474,12 @@ public class LdapTransformer
break;
case LdapConstants.LESS_OR_EQUAL_FILTER:
- branch = new LessEqNode( ava.getAttributeDesc(),
- ava.getAssertionValue() );
+ branch = new LessEqNode( ava.getAttributeDesc(), ava.getAssertionValue() );
break;
case LdapConstants.APPROX_MATCH_FILTER:
- branch = new ApproximateNode( ava.getAttributeDesc(),
- ava.getAssertionValue() );
+ branch = new ApproximateNode( ava.getAttributeDesc(), ava.getAssertionValue() );
break;
}
@@ -520,14 +519,8 @@ public class LdapTransformer
{
// Transform Extensible Match Filter
ExtensibleMatchFilter filter = ( ExtensibleMatchFilter ) codecFilter;
- String attribute = null;
String matchingRule = null;
- if ( filter.getType() != null )
- {
- attribute = filter.getType();
- }
-
Value<?> value = filter.getMatchValue();
if ( filter.getMatchingRule() != null )
@@ -535,7 +528,7 @@ public class LdapTransformer
matchingRule = filter.getMatchingRule();
}
- branch = new ExtensibleNode( attribute, value, matchingRule, filter.isDnAttributes() );
+ branch = new ExtensibleNode( filter.getType(), value, matchingRule, filter.isDnAttributes() );
}
return branch;
@@ -555,7 +548,7 @@ public class LdapTransformer
* @param exprNode The filter to be transformed
* @return A Codec filter
*/
- public static Filter transformFilter( ExprNode exprNode )
+ public static Filter transformFilter( SchemaManager schemaManager, ExprNode exprNode )
{
if ( exprNode != null )
{
@@ -586,7 +579,7 @@ public class LdapTransformer
{
try
{
- ((ConnectorFilter)filter).addFilter( transformFilter( child ) );
+ ((ConnectorFilter)filter).addFilter( transformFilter( schemaManager, child ) );
}
catch ( DecoderException de )
{
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java Mon Jul 12 23:28:23 2010
@@ -42,6 +42,9 @@ public abstract class AbstractExprNode i
/** The node type */
protected final AssertionType assertionType;
+ /** A flag set to true if the Node is Schema aware */
+ protected boolean isSchemaAware;
+
/**
* Creates a node by setting abstract node type.
@@ -317,6 +320,18 @@ public abstract class AbstractExprNode i
return annotations;
}
+
+ /**
+ * Tells if this Node is Schema aware.
+ *
+ * @return true if the Node is SchemaAware
+ */
+ public boolean isSchemaAware()
+ {
+ return isSchemaAware;
+ }
+
+
/**
* Default implementation for this method : just throw an exception.
*
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java Mon Jul 12 23:28:23 2010
@@ -20,6 +20,7 @@
package org.apache.directory.shared.ldap.filter;
import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.AttributeType;
/**
* A simple assertion value node.
@@ -31,6 +32,18 @@ public class ApproximateNode<T> extends
/**
* Creates a new ApproximateNode object.
*
+ * @param attributeType the attribute type
+ * @param value the value to test for
+ */
+ public ApproximateNode( AttributeType attributeType, Value<T> value )
+ {
+ super( attributeType, value, AssertionType.APPROXIMATE );
+ }
+
+
+ /**
+ * Creates a new ApproximateNode object.
+ *
* @param attribute the attribute name
* @param value the value to test for
*/
@@ -48,7 +61,18 @@ public class ApproximateNode<T> extends
{
StringBuilder buf = new StringBuilder();
- buf.append( '(' ).append( getAttribute() ).append( "~=" ).append( getEscapedValue() );
+ buf.append( '(' );
+
+ if ( attributeType != null )
+ {
+ buf.append( attributeType.getName() );
+ }
+ else
+ {
+ buf.append( attribute );
+ }
+
+ buf.append( "~=" ).append( getEscapedValue() );
buf.append( super.toString() );
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java Mon Jul 12 23:28:23 2010
@@ -53,6 +53,8 @@ public abstract class AssertionNode exte
public AssertionNode( Assertion assertion )
{
this( assertion, "ASSERTION" );
+
+ isSchemaAware = true;
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNode.java Mon Jul 12 23:28:23 2010
@@ -55,6 +55,8 @@ public class BranchNode extends Abstract
{
this.children = childList;
}
+
+ isSchemaAware = true;
}
@@ -87,6 +89,7 @@ public class BranchNode extends Abstract
super( assertionType );
this.children = new ArrayList<ExprNode>( 2 );
+ isSchemaAware = true;
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java Mon Jul 12 23:28:23 2010
@@ -26,6 +26,8 @@ import java.util.List;
import java.util.Set;
import java.util.TreeSet;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+
/**
* Visitor which traverses a filter tree while normalizing the branch node
@@ -109,15 +111,14 @@ public class BranchNormalizedVisitor imp
* Normalizes a filter expression to a canonical representation while
* retaining logical meaning of the expression.
*
- * @param filter
- * the filter to normalize
+ * @param filter the filter to normalize
* @return the normalized version of the filter
* @throws java.text.ParseException
* if the filter is malformed
*/
- public static String getNormalizedFilter( String filter ) throws ParseException
+ public static String getNormalizedFilter( SchemaManager schemaManager, String filter ) throws ParseException
{
- ExprNode originalNode = FilterParser.parse( filter );
+ ExprNode originalNode = FilterParser.parse( schemaManager, filter );
return getNormalizedFilter( originalNode );
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java Mon Jul 12 23:28:23 2010
@@ -21,6 +21,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.AttributeType;
/**
@@ -33,24 +34,24 @@ public class EqualityNode<T> extends Sim
/**
* Creates a new Equality object.
*
- * @param attribute the attribute name
+ * @param attributeType the attributeType
* @param value the value to test for
*/
- public EqualityNode( String attribute, Value<T> value )
+ public EqualityNode( AttributeType attributeType, Value<T> value )
{
- super( attribute, value, AssertionType.EQUALITY );
+ super( attributeType, value, AssertionType.EQUALITY );
}
+
/**
* Creates a new Equality object.
*
* @param attribute the attribute name
* @param value the value to test for
- * @param assertionType The node's type
*/
- protected EqualityNode( String attribute, Value<T> value, AssertionType assertionType )
+ public EqualityNode( String attribute, Value<T> value )
{
- super( attribute, value, assertionType );
+ super( attribute, value, AssertionType.EQUALITY );
}
@@ -62,7 +63,18 @@ public class EqualityNode<T> extends Sim
{
StringBuilder buf = new StringBuilder();
- buf.append( '(' ).append( getAttribute() ).append( "=" ).append( getEscapedValue() );
+ buf.append( '(' );
+
+ if ( attributeType != null )
+ {
+ buf.append( attributeType.getName() );
+ }
+ else
+ {
+ buf.append( attribute );
+ }
+
+ buf.append( "=" ).append( getEscapedValue() );
buf.append( super.toString() );
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java Mon Jul 12 23:28:23 2010
@@ -56,6 +56,14 @@ public interface ExprNode extends Clonea
/**
+ * Tells if this Node is Schema aware.
+ *
+ * @return true if the Node is SchemaAware
+ */
+ boolean isSchemaAware();
+
+
+ /**
* Gets the assertion type of this node. Make it possible to use switch
* statements on the node type.
*
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java Mon Jul 12 23:28:23 2010
@@ -21,6 +21,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.AttributeType;
/**
@@ -43,6 +44,19 @@ public class ExtensibleNode extends Leaf
/**
* Creates a new emptyExtensibleNode object.
*
+ * @param attributeType the attributeType associated with this node
+ */
+ public ExtensibleNode( AttributeType attributeType )
+ {
+ super( attributeType, AssertionType.EXTENSIBLE );
+
+ dnAttributes = false;
+ }
+
+
+ /**
+ * Creates a new emptyExtensibleNode object.
+ *
* @param attribute the attribute associated with this node
*/
public ExtensibleNode( String attribute )
@@ -52,6 +66,27 @@ public class ExtensibleNode extends Leaf
dnAttributes = false;
}
+
+ /**
+ * Creates a new ExtensibleNode object.
+ *
+ * @param attributeType the attributeType used for the extensible assertion
+ * @param value the value to match for
+ * @param matchingRuleId the OID of the matching rule
+ * @param dnAttributes the dn attributes
+ */
+ public ExtensibleNode( AttributeType attributeType, Value<?> value, String matchingRuleId, boolean dnAttributes )
+ {
+ super( attributeType, AssertionType.EXTENSIBLE );
+
+ this.value = value;
+ this.matchingRuleId = matchingRuleId;
+ this.dnAttributes = dnAttributes;
+ }
+
+
+
+
/**
* Creates a new ExtensibleNode object.
*
@@ -68,7 +103,8 @@ public class ExtensibleNode extends Leaf
this.matchingRuleId = matchingRuleId;
this.dnAttributes = dnAttributes;
}
-
+
+
/**
* Makes a full clone in new memory space of the current node and children
*
@@ -183,6 +219,7 @@ public class ExtensibleNode extends Leaf
return false;
}
ExtensibleNode that = ( ExtensibleNode ) obj;
+
if ( dnAttributes != that.dnAttributes )
{
return false;
@@ -195,6 +232,7 @@ public class ExtensibleNode extends Leaf
{
return false;
}
+
return super.equals( obj );
}
@@ -225,7 +263,17 @@ public class ExtensibleNode extends Leaf
{
StringBuilder buf = new StringBuilder();
- buf.append( '(' ).append( getAttribute() );
+ buf.append( '(' );
+
+ if ( attributeType != null )
+ {
+ buf.append( attributeType.getName() );
+ }
+ else
+ {
+ buf.append( attribute );
+ }
+
buf.append( "-" );
buf.append( dnAttributes );
buf.append( "-EXTENSIBLE-" );
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java Mon Jul 12 23:28:23 2010
@@ -25,6 +25,8 @@ import java.text.ParseException;
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.entry.BinaryValue;
import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
import org.apache.directory.shared.ldap.util.AttributeUtils;
import org.apache.directory.shared.ldap.util.Position;
import org.apache.directory.shared.ldap.util.StringTools;
@@ -52,11 +54,20 @@ public class FilterParser
* / ( [":dn"] ':' oid ":=" assertionvalue )
* matchingrule = ":" oid
*/
- private static ExprNode parseExtensible( String attr, String filter, Position pos ) throws ParseException
+ private static ExprNode parseExtensible( SchemaManager schemaManager, String attribute, String filter, Position pos ) throws LdapException, ParseException
{
- ExtensibleNode node = new ExtensibleNode( attr );
+ ExtensibleNode node = null;
+
+ if ( schemaManager != null )
+ {
+ node = new ExtensibleNode( schemaManager.lookupAttributeTypeRegistry( attribute ) );
+ }
+ else
+ {
+ node = new ExtensibleNode( attribute );
+ }
- if ( attr != null )
+ if ( attribute != null )
{
// First check if we have a ":dn"
if ( StringTools.areEquals( filter, pos.start, "dn" ) )
@@ -276,13 +287,22 @@ public class FilterParser
/**
* Parse a substring
*/
- private static ExprNode parseSubstring( String attr, Value<?> initial, String filter, Position pos )
- throws ParseException
+ private static ExprNode parseSubstring( SchemaManager schemaManager, String attribute, Value<?> initial, String filter, Position pos )
+ throws ParseException, LdapException
{
if ( StringTools.isCharASCII( filter, pos.start, '*' ) )
{
// We have found a '*' : this is a substring
- SubstringNode node = new SubstringNode( attr );
+ SubstringNode node = null;
+
+ if ( schemaManager != null )
+ {
+ node = new SubstringNode( schemaManager.lookupAttributeTypeRegistry( attribute ) );
+ }
+ else
+ {
+ node = new SubstringNode( attribute );
+ }
if ( initial != null && !initial.isNull() )
{
@@ -359,13 +379,13 @@ public class FilterParser
* We have also to consider the difference between a substring and the
* equality node : this last node does not contain a '*'
*
- * @param attr
+ * @param attributeType
* @param filter
* @param pos
* @return
*/
- private static ExprNode parsePresenceEqOrSubstring( String attr, String filter, Position pos )
- throws ParseException
+ private static ExprNode parsePresenceEqOrSubstring( SchemaManager schemaManager, String attribute, String filter, Position pos )
+ throws ParseException, LdapException
{
if ( StringTools.isCharASCII( filter, pos.start, '*' ) )
{
@@ -375,20 +395,34 @@ public class FilterParser
if ( StringTools.isCharASCII( filter, pos.start, ')' ) )
{
// This is a present node
- return new PresenceNode( attr );
+ if ( schemaManager != null )
+ {
+ return new PresenceNode( schemaManager.lookupAttributeTypeRegistry( attribute ) );
+ }
+ else
+ {
+ return new PresenceNode( attribute );
+ }
}
else
{
// Definitively a substring with no initial or an error
// Push back the '*' on the string
pos.start--;
- return parseSubstring( attr, null, filter, pos );
+ return parseSubstring( schemaManager, attribute, null, filter, pos );
}
}
else if ( StringTools.isCharASCII( filter, pos.start, ')' ) )
{
// An empty equality Node
- return new EqualityNode( attr, new BinaryValue() );
+ if ( schemaManager != null )
+ {
+ return new EqualityNode( schemaManager.lookupAttributeTypeRegistry( attribute ), new BinaryValue() );
+ }
+ else
+ {
+ return new EqualityNode( attribute, new BinaryValue() );
+ }
}
else
{
@@ -399,10 +433,17 @@ public class FilterParser
if ( StringTools.isCharASCII( filter, pos.start, ')' ) )
{
// This is an equality node
- return new EqualityNode( attr, value );
+ if ( schemaManager != null )
+ {
+ return new EqualityNode( schemaManager.lookupAttributeTypeRegistry( attribute ), value );
+ }
+ else
+ {
+ return new EqualityNode( attribute, value );
+ }
}
- return parseSubstring( attr, value, filter, pos );
+ return parseSubstring( schemaManager, attribute, value, filter, pos );
}
}
@@ -420,10 +461,11 @@ public class FilterParser
*
* An item starts with an attribute or a colon.
*/
- private static ExprNode parseItem( String filter, Position pos, char c ) throws ParseException
+ private static ExprNode parseItem( SchemaManager schemaManager, String filter, Position pos, char c )
+ throws ParseException, LdapException
{
LeafNode node = null;
- String attr = null;
+ String attribute = null;
if ( c == '\0' )
{
@@ -433,13 +475,13 @@ public class FilterParser
if ( c == ':' )
{
// If we have a colon, then the item is an extensible one
- return parseExtensible( null, filter, pos );
+ return parseExtensible( schemaManager, null, filter, pos );
}
else
{
// We must have an attribute
- attr = AttributeUtils.parseAttribute( filter, pos, true );
-
+ attribute = AttributeUtils.parseAttribute( filter, pos, true );
+
// Now, we may have a present, substring, simple or an extensible
c = StringTools.charAt( filter, pos.start );
@@ -448,7 +490,7 @@ public class FilterParser
case '=':
// It can be a presence, an equal or a substring
pos.start++;
- return parsePresenceEqOrSubstring( attr, filter, pos );
+ return parsePresenceEqOrSubstring( schemaManager, attribute, filter, pos );
case '~':
// Approximate node
@@ -463,7 +505,16 @@ public class FilterParser
pos.start++;
// Parse the value and create the node
- node = new ApproximateNode( attr, parseAssertionValue( filter, pos ) );
+ if ( schemaManager == null )
+ {
+ node = new ApproximateNode( attribute, parseAssertionValue( filter, pos ) );
+ }
+ else
+ {
+ node = new ApproximateNode( schemaManager.lookupAttributeTypeRegistry( attribute ),
+ parseAssertionValue( filter, pos ) );
+ }
+
return node;
case '>':
@@ -479,7 +530,15 @@ public class FilterParser
pos.start++;
// Parse the value and create the node
- node = new GreaterEqNode( attr, parseAssertionValue( filter, pos ) );
+ if ( schemaManager == null )
+ {
+ node = new GreaterEqNode( attribute, parseAssertionValue( filter, pos ) );
+ }
+ else
+ {
+ node = new GreaterEqNode( schemaManager.lookupAttributeTypeRegistry( attribute ),
+ parseAssertionValue( filter, pos ) );
+ }
return node;
case '<':
@@ -495,13 +554,22 @@ public class FilterParser
pos.start++;
// Parse the value and create the node
- node = new LessEqNode( attr, parseAssertionValue( filter, pos ) );
+ if ( schemaManager == null )
+ {
+ node = new LessEqNode( attribute, parseAssertionValue( filter, pos ) );
+ }
+ else
+ {
+ node = new LessEqNode( schemaManager.lookupAttributeTypeRegistry( attribute ), parseAssertionValue( filter, pos ) );
+
+ }
+
return node;
case ':':
// An extensible node
pos.start++;
- return parseExtensible( attr, filter, pos );
+ return parseExtensible( schemaManager, attribute, filter, pos );
default:
// This is an error
@@ -521,18 +589,19 @@ public class FilterParser
*
* @return
*/
- private static ExprNode parseBranchNode( ExprNode node, String filter, Position pos ) throws ParseException
+ private static ExprNode parseBranchNode( SchemaManager schemaManager, ExprNode node, String filter, Position pos )
+ throws ParseException, LdapException
{
BranchNode bNode = ( BranchNode ) node;
// We must have at least one filter
- ExprNode child = parseFilterInternal( filter, pos );
+ ExprNode child = parseFilterInternal( schemaManager, filter, pos );
// Add the child to the node children
bNode.addNode( child );
// Now, iterate recusively though all the remaining filters, if any
- while ( ( child = parseFilterInternal( filter, pos ) ) != null )
+ while ( ( child = parseFilterInternal( schemaManager, filter, pos ) ) != null )
{
// Add the child to the node children
bNode.addNode( child );
@@ -556,7 +625,8 @@ public class FilterParser
* / ( [dnattrs]
* matchingrule COLON EQUALS assertionvalue )
*/
- private static ExprNode parseFilterComp( String filter, Position pos ) throws ParseException
+ private static ExprNode parseFilterComp( SchemaManager schemaManager, String filter, Position pos )
+ throws ParseException, LdapException
{
ExprNode node = null;
@@ -573,26 +643,26 @@ public class FilterParser
// This is a AND node
pos.start++;
node = new AndNode();
- parseBranchNode( node, filter, pos );
+ parseBranchNode( schemaManager, node, filter, pos );
break;
case '|':
// This is an OR node
pos.start++;
node = new OrNode();
- parseBranchNode( node, filter, pos );
+ parseBranchNode( schemaManager, node, filter, pos );
break;
case '!':
// This is a NOT node
pos.start++;
node = new NotNode();
- parseBranchNode( node, filter, pos );
+ parseBranchNode( schemaManager, node, filter, pos );
break;
default:
// This is an item
- node = parseItem( filter, pos, c );
+ node = parseItem( schemaManager, filter, pos, c );
break;
}
@@ -605,7 +675,8 @@ public class FilterParser
* Pasre the grammar rule :
* filter ::= '(' filterComp ')'
*/
- private static ExprNode parseFilterInternal( String filter, Position pos ) throws ParseException
+ private static ExprNode parseFilterInternal( SchemaManager schemaManager, String filter, Position pos )
+ throws ParseException, LdapException
{
// Check for the left '('
if ( !StringTools.isCharASCII( filter, pos.start, '(' ) )
@@ -624,7 +695,7 @@ public class FilterParser
pos.start++;
// parse the filter component
- ExprNode node = parseFilterComp( filter, pos );
+ ExprNode node = parseFilterComp( schemaManager, filter, pos );
if ( node == null )
{
@@ -648,6 +719,15 @@ public class FilterParser
*/
public static ExprNode parse( String filter ) throws ParseException
{
+ return parse( null, filter );
+ }
+
+
+ /**
+ * @see FilterParser#parse(String)
+ */
+ public static ExprNode parse( SchemaManager schemaManager, String filter ) throws ParseException
+ {
// The filter must not be null. This is a defensive test
if ( StringTools.isEmpty( filter ) )
{
@@ -659,14 +739,21 @@ public class FilterParser
pos.end = 0;
pos.length = filter.length();
- return parseFilterInternal( filter, pos );
+ try
+ {
+ return parseFilterInternal( schemaManager, filter, pos );
+ }
+ catch ( LdapException le )
+ {
+ throw new ParseException( le.getMessage(), pos.start );
+ }
}
/**
* @see FilterParser#parse(String)
*/
- public static ExprNode parse( String filter, Position pos ) throws ParseException
+ public static ExprNode parse( SchemaManager schemaManager, String filter, Position pos ) throws ParseException
{
// The filter must not be null. This is a defensive test
if ( StringTools.isEmpty( filter ) )
@@ -678,7 +765,14 @@ public class FilterParser
pos.end = 0;
pos.length = filter.length();
- return parseFilterInternal( filter, pos );
+ try
+ {
+ return parseFilterInternal( schemaManager, filter, pos );
+ }
+ catch ( LdapException le )
+ {
+ throw new ParseException( le.getMessage(), pos.start );
+ }
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java Mon Jul 12 23:28:23 2010
@@ -21,6 +21,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.AttributeType;
/**
@@ -33,6 +34,18 @@ public class GreaterEqNode<T> extends Si
/**
* Creates a new GreaterOrEqual object.
*
+ * @param attributeType the attributeType
+ * @param value the value to test for
+ */
+ public GreaterEqNode( AttributeType attributeType, Value<T> value )
+ {
+ super( attributeType, value, AssertionType.GREATEREQ );
+ }
+
+
+ /**
+ * Creates a new GreaterOrEqual object.
+ *
* @param attribute the attribute name
* @param value the value to test for
*/
@@ -41,6 +54,7 @@ public class GreaterEqNode<T> extends Si
super( attribute, value, AssertionType.GREATEREQ );
}
+
/**
* @see Object#toString()
* @return A string representing the AndNode
@@ -49,7 +63,18 @@ public class GreaterEqNode<T> extends Si
{
StringBuilder buf = new StringBuilder();
- buf.append( '(' ).append( getAttribute() ).append( ">=" ).append( getEscapedValue() );
+ buf.append( '(' );
+
+ if ( attributeType != null )
+ {
+ buf.append( attributeType.getName() );
+ }
+ else
+ {
+ buf.append( attribute );
+ }
+
+ buf.append( ">=" ).append( getEscapedValue() );
buf.append( super.toString() );
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java Mon Jul 12 23:28:23 2010
@@ -19,6 +19,8 @@
*/
package org.apache.directory.shared.ldap.filter;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+
/**
* Abstract base class for leaf nodes within the expression filter tree.
@@ -27,22 +29,47 @@ package org.apache.directory.shared.ldap
*/
public class LeafNode extends AbstractExprNode
{
+ /** attributeType on which this leaf is based */
+ protected AttributeType attributeType;
+
/** attribute on which this leaf is based */
- private String attribute;
+ protected String attribute;
/**
* Creates a leaf node.
*
- * @param attribute the attribute this node is based on
+ * @param attributeType the attribute this node is based on
+ * @param assertionType the type of this leaf node
+ */
+ protected LeafNode( AttributeType attributeType, AssertionType assertionType )
+ {
+ super( assertionType );
+ this.attributeType = attributeType;
+
+ if ( attributeType != null )
+ {
+ this.attribute = attributeType.getName();
+ isSchemaAware = true;
+ }
+ }
+
+
+ /**
+ * Creates a leaf node.
+ *
+ * @param attributeType the attribute this node is based on
* @param assertionType the type of this leaf node
*/
protected LeafNode( String attribute, AssertionType assertionType )
{
super( assertionType );
+ this.attributeType = null;
this.attribute = attribute;
+ isSchemaAware = false;
}
+
/**
* Gets whether this node is a leaf - the answer is always true here.
*
@@ -55,6 +82,17 @@ public class LeafNode extends AbstractEx
/**
+ * Gets the attributeType this leaf node is based on.
+ *
+ * @return the attributeType asserted
+ */
+ public final AttributeType getAttributeType()
+ {
+ return attributeType;
+ }
+
+
+ /**
* Gets the attribute this leaf node is based on.
*
* @return the attribute asserted
@@ -66,6 +104,23 @@ public class LeafNode extends AbstractEx
/**
+ * Sets the attributeType this leaf node is based on.
+ *
+ * @param attributeType the attributeType that is asserted by this filter node
+ */
+ public void setAttributeType( AttributeType attributeType )
+ {
+ this.attributeType = attributeType;
+
+ if ( attributeType != null )
+ {
+ attribute = attributeType.getName();
+ isSchemaAware = true;
+ }
+ }
+
+
+ /**
* Sets the attribute this leaf node is based on.
*
* @param attribute the attribute that is asserted by this filter node
@@ -73,6 +128,7 @@ public class LeafNode extends AbstractEx
public void setAttribute( String attribute )
{
this.attribute = attribute;
+ isSchemaAware = false;
}
@@ -105,7 +161,15 @@ public class LeafNode extends AbstractEx
int h = 37;
h = h*17 + super.hashCode();
- h = h*17 + attribute.hashCode();
+
+ if ( attributeType != null )
+ {
+ h = h*17 + attributeType.hashCode();
+ }
+ else
+ {
+ h = h*17 + attribute.hashCode();
+ }
return h;
}
@@ -127,13 +191,21 @@ public class LeafNode extends AbstractEx
{
return false;
}
+
+ LeafNode otherNode = (LeafNode)other;
- //noinspection SimplifiableIfStatement
if ( other.getClass() != this.getClass() )
{
return false;
}
- return attribute.equals( ( ( LeafNode ) other ).getAttribute() );
+ if ( attributeType != null )
+ {
+ return attributeType.equals( otherNode.getAttributeType() );
+ }
+ else
+ {
+ return attribute.equalsIgnoreCase( otherNode.getAttribute() );
+ }
}
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java Mon Jul 12 23:28:23 2010
@@ -21,6 +21,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.AttributeType;
/**
@@ -33,6 +34,18 @@ public class LessEqNode<T> extends Simpl
/**
* Creates a new LessEqNode object.
*
+ * @param attributeType the attributeType
+ * @param value the value to test for
+ */
+ public LessEqNode( AttributeType attributeType, Value<T> value )
+ {
+ super( attributeType, value, AssertionType.LESSEQ );
+ }
+
+
+ /**
+ * Creates a new LessEqNode object.
+ *
* @param attribute the attribute name
* @param value the value to test for
*/
@@ -41,6 +54,7 @@ public class LessEqNode<T> extends Simpl
super( attribute, value, AssertionType.LESSEQ );
}
+
/**
* @see Object#toString()
* @return A string representing the AndNode
@@ -49,7 +63,18 @@ public class LessEqNode<T> extends Simpl
{
StringBuilder buf = new StringBuilder();
- buf.append( '(' ).append( getAttribute() ).append( "<=" ).append( getEscapedValue() );
+ buf.append( '(' );
+
+ if ( attributeType != null )
+ {
+ buf.append( attributeType.getName() );
+ }
+ else
+ {
+ buf.append( attribute );
+ }
+
+ buf.append( "<=" ).append( getEscapedValue() );
buf.append( super.toString() );
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java Mon Jul 12 23:28:23 2010
@@ -19,6 +19,8 @@
*/
package org.apache.directory.shared.ldap.filter;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+
/**
* Filter expression tree node representing a filter attribute value assertion
@@ -31,6 +33,17 @@ public final class PresenceNode extends
/**
* Creates a PresenceNode object based on an attribute.
*
+ * @param attributeType the attributeType to assert the presence of
+ */
+ public PresenceNode( AttributeType attributeType )
+ {
+ super( attributeType, AssertionType.PRESENCE );
+ }
+
+
+ /**
+ * Creates a PresenceNode object based on an attribute.
+ *
* @param attribute the attribute to assert the presence of
*/
public PresenceNode( String attribute )
@@ -47,7 +60,18 @@ public final class PresenceNode extends
{
StringBuilder buf = new StringBuilder();
- buf.append( '(' ).append( getAttribute() ).append( "=*" );
+ buf.append( '(' );
+
+ if ( attributeType != null )
+ {
+ buf.append( attributeType.getName() );
+ }
+ else
+ {
+ buf.append( attribute );
+ }
+
+ buf.append( "=*" );
buf.append( super.toString() );
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java Mon Jul 12 23:28:23 2010
@@ -55,6 +55,7 @@ public class ScopeNode extends AbstractE
this.scope = scope;
this.baseDn = baseDn;
this.aliasDerefAliases = aliasDerefAliases;
+ isSchemaAware = true;
}
/**
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java Mon Jul 12 23:28:23 2010
@@ -23,6 +23,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.AttributeType;
/**
@@ -59,6 +60,20 @@ public abstract class SimpleNode<T> exte
/**
+ * Creates a new SimpleNode object.
+ *
+ * @param attribute the attribute name
+ * @param value the value to test for
+ * @param assertionType the type of assertion represented by this ExprNode
+ */
+ protected SimpleNode( AttributeType attributeType, Value<T> value, AssertionType assertionType )
+ {
+ super( attributeType, assertionType );
+ this.value = value;
+ }
+
+
+ /**
* Makes a full clone in new memory space of the current node and children
*/
@Override
@@ -134,12 +149,21 @@ public abstract class SimpleNode<T> exte
*/
public StringBuilder printRefinementToBuffer( StringBuilder buf )
{
- if ( ( getAttribute() == null ) ||
- !( SchemaConstants.OBJECT_CLASS_AT.equalsIgnoreCase( getAttribute() ) ||
- SchemaConstants.OBJECT_CLASS_AT_OID.equalsIgnoreCase( getAttribute() ) )
- )
+ if ( isSchemaAware )
+ {
+ if ( !attributeType.getOid().equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
+ {
+ throw new UnsupportedOperationException( I18n.err( I18n.ERR_04162, attribute ) );
+ }
+ }
+ else
{
- throw new UnsupportedOperationException( I18n.err( I18n.ERR_04162, getAttribute() ) );
+ if ( ( attribute == null ) ||
+ !( SchemaConstants.OBJECT_CLASS_AT.equalsIgnoreCase( attribute ) ||
+ SchemaConstants.OBJECT_CLASS_AT_OID.equalsIgnoreCase( attribute ) ) )
+ {
+ throw new UnsupportedOperationException( I18n.err( I18n.ERR_04162, attribute ) );
+ }
}
buf.append( "item: " ).append( value );
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java Mon Jul 12 23:28:23 2010
@@ -26,6 +26,8 @@ import java.util.regex.Pattern;
import org.apache.directory.shared.ldap.entry.StringValue;
import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.Normalizer;
import org.apache.directory.shared.ldap.util.StringTools;
@@ -50,6 +52,24 @@ public class SubstringNode extends LeafN
* Creates a new SubstringNode object with only one wildcard and no internal
* any fragments between wildcards.
*
+ * @param attributeType the name of the attributeType to substring assert
+ * @param initialPattern the initial fragment
+ * @param finalPattern the final fragment
+ */
+ public SubstringNode( AttributeType attributeType, String initialPattern, String finalPattern )
+ {
+ super( attributeType, AssertionType.SUBSTRING );
+
+ anyPattern = new ArrayList<String>( 2 );
+ this.finalPattern = finalPattern;
+ this.initialPattern = initialPattern;
+ }
+
+
+ /**
+ * Creates a new SubstringNode object with only one wildcard and no internal
+ * any fragments between wildcards.
+ *
* @param attribute the name of the attribute to substring assert
* @param initialPattern the initial fragment
* @param finalPattern the final fragment
@@ -65,33 +85,28 @@ public class SubstringNode extends LeafN
/**
- * Clone the Node
+ * Creates a new SubstringNode object without any value
+ *
+ * @param attribute the name of the attribute to substring assert
*/
- @Override public ExprNode clone()
+ public SubstringNode( AttributeType attribute )
{
- ExprNode clone = (ExprNode)super.clone();
-
- if ( anyPattern != null )
- {
- ((SubstringNode)clone).anyPattern = new ArrayList<String>();
-
- for ( String any:anyPattern )
- {
- ((SubstringNode)clone).anyPattern.add( any );
- }
- }
-
- return clone;
+ super( attribute, AssertionType.SUBSTRING );
+
+ anyPattern = new ArrayList<String>( 2 );
+ this.finalPattern = null;
+ this.initialPattern = null;
}
+
/**
* Creates a new SubstringNode object without any value
*
- * @param attribute the name of the attribute to substring assert
+ * @param attributeType the attributeType to substring assert
*/
- public SubstringNode( String attribute )
+ public SubstringNode( String attributeType )
{
- super( attribute, AssertionType.SUBSTRING );
+ super( attributeType, AssertionType.SUBSTRING );
anyPattern = new ArrayList<String>( 2 );
this.finalPattern = null;
@@ -104,6 +119,25 @@ public class SubstringNode extends LeafN
* list.
*
* @param anyPattern list of internal fragments between wildcards
+ * @param attributeType the attributeType to substring assert
+ * @param initialPattern the initial fragment
+ * @param finalPattern the final fragment
+ */
+ public SubstringNode( List<String> anyPattern, AttributeType attributeType, String initialPattern, String finalPattern )
+ {
+ super( attributeType, AssertionType.SUBSTRING );
+
+ this.anyPattern = anyPattern;
+ this.finalPattern = finalPattern;
+ this.initialPattern = initialPattern;
+ }
+
+
+ /**
+ * Creates a new SubstringNode object more than one wildcard and an any
+ * list.
+ *
+ * @param anyPattern list of internal fragments between wildcards
* @param attribute the name of the attribute to substring assert
* @param initialPattern the initial fragment
* @param finalPattern the final fragment
@@ -117,6 +151,27 @@ public class SubstringNode extends LeafN
this.initialPattern = initialPattern;
}
+
+ /**
+ * Clone the Node
+ */
+ @Override public ExprNode clone()
+ {
+ ExprNode clone = (ExprNode)super.clone();
+
+ if ( anyPattern != null )
+ {
+ ((SubstringNode)clone).anyPattern = new ArrayList<String>();
+
+ for ( String any:anyPattern )
+ {
+ ((SubstringNode)clone).anyPattern.add( any );
+ }
+ }
+
+ return clone;
+ }
+
/**
* Gets the initial fragment.
@@ -128,6 +183,7 @@ public class SubstringNode extends LeafN
return initialPattern;
}
+
/**
* Set the initial pattern
* @param initialPattern The initial pattern
@@ -137,6 +193,7 @@ public class SubstringNode extends LeafN
this.initialPattern = initialPattern;
}
+
/**
* Gets the final fragment or suffix.
*
@@ -263,6 +320,7 @@ public class SubstringNode extends LeafN
return false;
}
SubstringNode that = ( SubstringNode ) obj;
+
if ( initialPattern == null )
{
if ( that.initialPattern != null )
@@ -277,6 +335,7 @@ public class SubstringNode extends LeafN
return false;
}
}
+
if ( finalPattern == null )
{
if ( that.finalPattern != null )
@@ -291,6 +350,7 @@ public class SubstringNode extends LeafN
return false;
}
}
+
return super.equals( obj );
}
@@ -329,7 +389,19 @@ public class SubstringNode extends LeafN
{
StringBuilder buf = new StringBuilder();
- buf.append( '(' ).append( getAttribute() ).append( '=' );
+ buf.append( '(' );
+
+ if ( attributeType != null )
+ {
+ buf.append( attributeType.getName() );
+ }
+ else
+ {
+ buf.append( attribute );
+ }
+
+
+ buf.append( '=' );
if ( null != initialPattern )
{
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java Mon Jul 12 23:28:23 2010
@@ -661,12 +661,7 @@ public class DN implements Cloneable, Se
*/
public boolean isChildOf( DN dn )
{
- if ( dn == null )
- {
- return true;
- }
-
- if ( dn.size() == 0 )
+ if ( ( dn == null ) || dn.isRootDSE() )
{
return true;
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java Mon Jul 12 23:28:23 2010
@@ -57,6 +57,18 @@ public interface AttributeTypeRegistry e
/**
+ * Quick lookup to see if an attribute has descendants.
+ *
+ * @param ancestor the attributeType we are looking for
+ * @return an Iterator over the AttributeTypes which have the ancestor
+ * within their superior chain to the top
+ * @throws LdapException if the ancestor attributeType cannot be
+ * discerned from the ancestorId supplied
+ */
+ boolean hasDescendants( AttributeType ancestor ) throws LdapException;
+
+
+ /**
* Get's an iterator over the set of descendant attributeTypes for
* some ancestor's name alias or their OID.
*
@@ -70,6 +82,19 @@ public interface AttributeTypeRegistry e
/**
+ * Get's an iterator over the set of descendant attributeTypes for
+ * some ancestor's name alias or their OID.
+ *
+ * @param ancestor the AttributeType we are looking for
+ * @return an Iterator over the AttributeTypes which have the ancestor
+ * within their superior chain to the top
+ * @throws LdapException if the ancestor attributeType cannot be
+ * discerned from the ancestorId supplied
+ */
+ Iterator<AttributeType> descendants( AttributeType ancestor ) throws LdapException;
+
+
+ /**
* Store the AttributeType into a map associating an AttributeType to its
* descendants.
*
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java Mon Jul 12 23:28:23 2010
@@ -97,6 +97,17 @@ public class DefaultAttributeTypeRegistr
/**
* {@inheritDoc}
*/
+ public boolean hasDescendants( AttributeType ancestor ) throws LdapException
+ {
+ String oid = ancestor.getOid();
+ Set<AttributeType> descendants = oidToDescendantSet.get( oid );
+ return ( descendants != null ) && !descendants.isEmpty();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
@SuppressWarnings("unchecked")
public Iterator<AttributeType> descendants( String ancestorId ) throws LdapException
{
@@ -122,6 +133,24 @@ public class DefaultAttributeTypeRegistr
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("unchecked")
+ public Iterator<AttributeType> descendants( AttributeType ancestor ) throws LdapException
+ {
+ String oid = ancestor.getOid();
+ Set<AttributeType> descendants = oidToDescendantSet.get( oid );
+
+ if ( descendants == null )
+ {
+ return Collections.EMPTY_SET.iterator();
+ }
+
+ return descendants.iterator();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
public void registerDescendants( AttributeType attributeType, AttributeType ancestor ) throws LdapException
{
// add this attribute to descendant list of other attributes in superior chain
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java Mon Jul 12 23:28:23 2010
@@ -77,6 +77,15 @@ public class ImmutableAttributeTypeRegis
/**
* {@inheritDoc}
*/
+ public boolean hasDescendants( AttributeType ancestor ) throws LdapException
+ {
+ return immutableAttributeTypeRegistry.hasDescendants( ancestor );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
public Iterator<AttributeType> descendants( String ancestorId ) throws LdapException
{
return immutableAttributeTypeRegistry.descendants( ancestorId );
@@ -86,6 +95,15 @@ public class ImmutableAttributeTypeRegis
/**
* {@inheritDoc}
*/
+ public Iterator<AttributeType> descendants( AttributeType ancestor ) throws LdapException
+ {
+ return immutableAttributeTypeRegistry.descendants( ancestor );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
public void register( AttributeType attributeType ) throws LdapException
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04275 ) );
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java Mon Jul 12 23:28:23 2010
@@ -908,7 +908,7 @@ public class LdapURL
try
{
filter = decode( new String( chars, pos, end - pos ) );
- FilterParser.parse( filter );
+ FilterParser.parse( null, filter );
}
catch ( URIException ue )
{
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitorTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitorTest.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitorTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitorTest.java Mon Jul 12 23:28:23 2010
@@ -20,17 +20,15 @@
package org.apache.directory.shared.ldap.filter;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import org.apache.directory.junit.tools.Concurrent;
import org.apache.directory.junit.tools.ConcurrentJunitRunner;
-import org.apache.directory.shared.ldap.filter.BranchNormalizedVisitor;
-import org.apache.directory.shared.ldap.filter.ExprNode;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
/**
* Tests the BranchNormalizedVisitor.
@@ -120,9 +118,9 @@ public class BranchNormalizedVisitorTest
String filter2 = "(&(a=A)(|(c=C)(b=B)))";
- String normalizedFilter1 = BranchNormalizedVisitor.getNormalizedFilter( filter1 );
+ String normalizedFilter1 = BranchNormalizedVisitor.getNormalizedFilter( null, filter1 );
- String normalizedFilter2 = BranchNormalizedVisitor.getNormalizedFilter( filter2 );
+ String normalizedFilter2 = BranchNormalizedVisitor.getNormalizedFilter( null, filter2 );
assertEquals( normalizedFilter1, normalizedFilter2 );
}
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterCloneTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterCloneTest.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterCloneTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterCloneTest.java Mon Jul 12 23:28:23 2010
@@ -46,7 +46,7 @@ public class FilterCloneTest
@Test
public void testItemFilter() throws ParseException
{
- SimpleNode node = ( SimpleNode ) FilterParser.parse( "(ou~=people)" );
+ SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(ou~=people)" );
// just check that it doesnt throw for now
node = (SimpleNode)node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -58,7 +58,7 @@ public class FilterCloneTest
@Test
public void testAndFilter() throws ParseException
{
- BranchNode node = ( BranchNode ) FilterParser.parse( "(&(ou~=people)(age>=30))" );
+ BranchNode node = ( BranchNode ) FilterParser.parse( null, "(&(ou~=people)(age>=30))" );
// just check that it doesnt throw for now
node = (BranchNode) node.clone();
assertEquals( 2, node.getChildren().size() );
@@ -69,7 +69,7 @@ public class FilterCloneTest
@Test
public void testAndFilterOneChildOnly() throws ParseException
{
- BranchNode node = ( BranchNode ) FilterParser.parse( "(&(ou~=people))" );
+ BranchNode node = ( BranchNode ) FilterParser.parse( null, "(&(ou~=people))" );
// just check that it doesnt throw for now
node = (BranchNode)node.clone();
assertEquals( 1, node.getChildren().size() );
@@ -80,7 +80,7 @@ public class FilterCloneTest
@Test
public void testOrFilter() throws ParseException
{
- BranchNode node = ( BranchNode ) FilterParser.parse( "(|(ou~=people)(age>=30))" );
+ BranchNode node = ( BranchNode ) FilterParser.parse( null, "(|(ou~=people)(age>=30))" );
// just check that it doesnt throw for now
node = (BranchNode)node.clone();
assertEquals( 2, node.getChildren().size() );
@@ -91,7 +91,7 @@ public class FilterCloneTest
@Test
public void testOrFilterOneChildOnly() throws ParseException
{
- BranchNode node = ( BranchNode ) FilterParser.parse( "(|(age>=30))" );
+ BranchNode node = ( BranchNode ) FilterParser.parse( null, "(|(age>=30))" );
// just check that it doesnt throw for now
node = (BranchNode) node.clone();
assertEquals( 1, node.getChildren().size() );
@@ -102,7 +102,7 @@ public class FilterCloneTest
@Test
public void testNotFilter() throws ParseException
{
- BranchNode node = ( BranchNode ) FilterParser.parse( "(!(&(ou~= people)(age>=30)))" );
+ BranchNode node = ( BranchNode ) FilterParser.parse( null, "(!(&(ou~= people)(age>=30)))" );
// just check that it doesnt throw for now
node = (BranchNode)node.clone();
assertEquals( 1, node.getChildren().size() );
@@ -114,7 +114,7 @@ public class FilterCloneTest
@Test
public void testOptionAndEscapesFilter() throws ParseException
{
- SimpleNode node = ( SimpleNode ) FilterParser.parse( "(ou;lang-de>=\\23\\42asdl fkajsd)" );
+ SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(ou;lang-de>=\\23\\42asdl fkajsd)" );
// just check that it doesnt throw for now
node = (SimpleNode)node.clone();
assertEquals( "ou;lang-de", node.getAttribute() );
@@ -126,7 +126,7 @@ public class FilterCloneTest
@Test
public void testOptionsAndEscapesFilter() throws ParseException
{
- SimpleNode node = ( SimpleNode ) FilterParser.parse( "(ou;lang-de;version-124>=\\23\\42asdl fkajsd)" );
+ SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(ou;lang-de;version-124>=\\23\\42asdl fkajsd)" );
// just check that it doesnt throw for now
node = (SimpleNode)node.clone();
assertEquals( "ou;lang-de;version-124", node.getAttribute() );
@@ -138,7 +138,7 @@ public class FilterCloneTest
@Test
public void testNumericoidOptionsAndEscapesFilter() throws ParseException
{
- SimpleNode node = ( SimpleNode ) FilterParser.parse( "(1.3.4.2;lang-de;version-124>=\\23\\42asdl fkajsd)" );
+ SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(1.3.4.2;lang-de;version-124>=\\23\\42asdl fkajsd)" );
// just check that it doesnt throw for now
node = (SimpleNode)node.clone();
assertEquals( "1.3.4.2;lang-de;version-124", node.getAttribute() );
@@ -149,7 +149,7 @@ public class FilterCloneTest
@Test
public void testPresentFilter() throws ParseException
{
- PresenceNode node = ( PresenceNode ) FilterParser.parse( "(ou=*)" );
+ PresenceNode node = ( PresenceNode ) FilterParser.parse( null, "(ou=*)" );
// just check that it doesnt throw for now
node = (PresenceNode) node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -160,7 +160,7 @@ public class FilterCloneTest
@Test
public void testNumericoidPresentFilter() throws ParseException
{
- PresenceNode node = ( PresenceNode ) FilterParser.parse( "(1.2.3.4=*)" );
+ PresenceNode node = ( PresenceNode ) FilterParser.parse( null, "(1.2.3.4=*)" );
// just check that it doesnt throw for now
node = ( PresenceNode )node.clone();
assertEquals( "1.2.3.4", node.getAttribute() );
@@ -172,7 +172,7 @@ public class FilterCloneTest
@Test
public void testEqualsFilter() throws ParseException
{
- SimpleNode node = ( SimpleNode ) FilterParser.parse( "(ou=people)" );
+ SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(ou=people)" );
// just check that it doesnt throw for now
node = ( SimpleNode) node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -185,7 +185,7 @@ public class FilterCloneTest
@Test
public void testEqualsWithForwardSlashFilter() throws ParseException
{
- SimpleNode node = ( SimpleNode ) FilterParser.parse( "(ou=people/in/my/company)" );
+ SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(ou=people/in/my/company)" );
// just check that it doesnt throw for now
node = (SimpleNode) node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -197,7 +197,7 @@ public class FilterCloneTest
@Test
public void testExtensibleFilterForm1() throws ParseException
{
- ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( "(ou:dn:stupidMatch:=dummyAssertion\\23\\2A)" );
+ ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, "(ou:dn:stupidMatch:=dummyAssertion\\23\\2A)" );
// just check that it doesnt throw for now
node = ( ExtensibleNode ) node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -211,7 +211,7 @@ public class FilterCloneTest
@Test
public void testExtensibleFilterForm1WithNumericOid() throws ParseException
{
- ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( "(1.2.3.4:dn:1.3434.23.2:=dummyAssertion\\23\\2A)" );
+ ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, "(1.2.3.4:dn:1.3434.23.2:=dummyAssertion\\23\\2A)" );
// just check that it doesnt throw for now
node = ( ExtensibleNode )node.clone();
assertEquals( "1.2.3.4", node.getAttribute() );
@@ -225,7 +225,7 @@ public class FilterCloneTest
@Test
public void testExtensibleFilterForm1NoDnAttr() throws ParseException
{
- ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( "(ou:stupidMatch:=dummyAssertion\\23\\2A)" );
+ ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, "(ou:stupidMatch:=dummyAssertion\\23\\2A)" );
// just check that it doesnt throw for now
node = ( ExtensibleNode ) node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -240,7 +240,7 @@ public class FilterCloneTest
@Test
public void testExtensibleFilterForm1NoAttrNoMatchingRule() throws ParseException
{
- ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( "(ou:=dummyAssertion\\23\\2A)" );
+ ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, "(ou:=dummyAssertion\\23\\2A)" );
// just check that it doesnt throw for now
node = (ExtensibleNode) node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -254,7 +254,7 @@ public class FilterCloneTest
@Test
public void testExtensibleFilterForm2() throws ParseException
{
- ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( "(:dn:stupidMatch:=dummyAssertion\\23\\2A)" );
+ ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, "(:dn:stupidMatch:=dummyAssertion\\23\\2A)" );
// just check that it doesnt throw for now
node = ( ExtensibleNode ) node.clone();
assertEquals( null, node.getAttribute() );
@@ -268,7 +268,7 @@ public class FilterCloneTest
@Test
public void testExtensibleFilterForm2WithNumericOid() throws ParseException
{
- ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( "(:dn:1.3434.23.2:=dummyAssertion\\23\\2A)" );
+ ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, "(:dn:1.3434.23.2:=dummyAssertion\\23\\2A)" );
assertEquals( null, node.getAttribute() );
assertEquals( "dummyAssertion#*", node.getValue().getString() );
assertEquals( "1.3434.23.2", node.getMatchingRuleId() );
@@ -280,7 +280,7 @@ public class FilterCloneTest
@Test
public void testExtensibleFilterForm2NoDnAttr() throws ParseException
{
- ExtensibleNode node1 = ( ExtensibleNode ) FilterParser.parse( "(:stupidMatch:=dummyAssertion\\23\\2A)" );
+ ExtensibleNode node1 = ( ExtensibleNode ) FilterParser.parse( null, "(:stupidMatch:=dummyAssertion\\23\\2A)" );
// just check that it doesnt throw for now
ExtensibleNode node = ( ExtensibleNode )node1.clone();
assertEquals( null, node.getAttribute() );
@@ -294,7 +294,7 @@ public class FilterCloneTest
@Test
public void testExtensibleFilterForm2NoDnAttrWithNumericOidNoAttr() throws ParseException
{
- ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( "(:1.3434.23.2:=dummyAssertion\\23\\2A)" );
+ ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, "(:1.3434.23.2:=dummyAssertion\\23\\2A)" );
// just check that it doesnt throw for now
node = ( ExtensibleNode) node.clone();
assertEquals( null, node.getAttribute() );
@@ -308,7 +308,7 @@ public class FilterCloneTest
@Test
public void testSubstringNoAnyNoFinal() throws ParseException
{
- SubstringNode node = ( SubstringNode ) FilterParser.parse( "(ou=foo*)" );
+ SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=foo*)" );
// just check that it doesnt throw for now
node = ( SubstringNode ) node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -323,7 +323,7 @@ public class FilterCloneTest
@Test
public void testSubstringNoAny() throws ParseException
{
- SubstringNode node = ( SubstringNode ) FilterParser.parse( "(ou=foo*bar)" );
+ SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=foo*bar)" );
// just check that it doesnt throw for now
node = ( SubstringNode ) node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -338,7 +338,7 @@ public class FilterCloneTest
@Test
public void testSubstringNoAnyNoIni() throws ParseException
{
- SubstringNode node = ( SubstringNode ) FilterParser.parse( "(ou=*bar)" );
+ SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=*bar)" );
// just check that it doesnt throw for now
node = ( SubstringNode )node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -353,7 +353,7 @@ public class FilterCloneTest
@Test
public void testSubstringOneAny() throws ParseException
{
- SubstringNode node = ( SubstringNode ) FilterParser.parse( "(ou=foo*guy*bar)" );
+ SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=foo*guy*bar)" );
// just check that it doesnt throw for now
node = ( SubstringNode )node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -369,7 +369,7 @@ public class FilterCloneTest
@Test
public void testSubstringManyAny() throws ParseException
{
- SubstringNode node = ( SubstringNode ) FilterParser.parse( "(ou=a*b*c*d*e*f)" );
+ SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=a*b*c*d*e*f)" );
// just check that it doesnt throw for now
node = ( SubstringNode )node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -388,7 +388,7 @@ public class FilterCloneTest
@Test
public void testSubstringNoIniManyAny() throws ParseException
{
- SubstringNode node = ( SubstringNode ) FilterParser.parse( "(ou=*b*c*d*e*f)" );
+ SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=*b*c*d*e*f)" );
// just check that it doesnt throw for now
node = ( SubstringNode )node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -407,7 +407,7 @@ public class FilterCloneTest
@Test
public void testSubstringManyAnyNoFinal() throws ParseException
{
- SubstringNode node = ( SubstringNode ) FilterParser.parse( "(ou=a*b*c*d*e*)" );
+ SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=a*b*c*d*e*)" );
// just check that it doesnt throw for now
node = ( SubstringNode )node.clone();
assertEquals( "ou", node.getAttribute() );
@@ -426,7 +426,7 @@ public class FilterCloneTest
@Test
public void testSubstringNoIniManyAnyNoFinal() throws ParseException
{
- SubstringNode node = ( SubstringNode ) FilterParser.parse( "(ou=*b*c*d*e*)" );
+ SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=*b*c*d*e*)" );
// just check that it doesnt throw for now
node = ( SubstringNode ) node.clone();
@@ -446,7 +446,7 @@ public class FilterCloneTest
@Test
public void testSubstringNoAnyDoubleSpaceStar() throws ParseException
{
- SubstringNode node = ( SubstringNode ) FilterParser.parse( "(ou=foo* *bar)" );
+ SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=foo* *bar)" );
// just check that it doesnt throw for now
node = ( SubstringNode )node.clone();
@@ -463,7 +463,7 @@ public class FilterCloneTest
@Test
public void testSubstringAnyDoubleSpaceStar() throws ParseException
{
- SubstringNode node = ( SubstringNode ) FilterParser.parse( "(ou=foo* a *bar)" );
+ SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=foo* a *bar)" );
// just check that it doesnt throw for now
node = ( SubstringNode ) node.clone();
@@ -485,7 +485,7 @@ public class FilterCloneTest
@Test
public void testSubstringStarAnyStar() throws ParseException
{
- SubstringNode node = ( SubstringNode ) FilterParser.parse( "(ou=*foo*)" );
+ SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=*foo*)" );
// just check that it doesnt throw for now
node = ( SubstringNode )node.clone();
@@ -502,7 +502,7 @@ public class FilterCloneTest
@Test
public void testEqualsFilterNullValue() throws ParseException
{
- SimpleNode node = ( SimpleNode ) FilterParser.parse( "(ou=)" );
+ SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(ou=)" );
// just check that it doesnt throw for now
node = ( SimpleNode )node.clone();
@@ -519,7 +519,7 @@ public class FilterCloneTest
@Test
public void testEqualsFilterWithPoundInValue() throws ParseException
{
- SimpleNode node = ( SimpleNode ) FilterParser.parse( "(uid=#f1)" );
+ SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(uid=#f1)" );
// just check that it doesnt throw for now
node = ( SimpleNode ) node.clone();
assertEquals( "uid", node.getAttribute() );
@@ -531,7 +531,7 @@ public class FilterCloneTest
@Test
public void testLargeBusyFilter() throws ParseException
{
- ExprNode node1 = FilterParser.parse( "(&(|(2.5.4.3=h*)(2.5.4.4=h*)(2.16.840.1.113730.3.1.241=h*)(2.5.4.42=h*))(!(objectClass=computer))(|(objectClass=person)(objectClass=group)(objectClass=organizationalUnit)(objectClass=domain))(!(&(userAccountControl:1.2.840.113556.1.4.803:=2))))" );
+ ExprNode node1 = FilterParser.parse( null, "(&(|(2.5.4.3=h*)(2.5.4.4=h*)(2.16.840.1.113730.3.1.241=h*)(2.5.4.42=h*))(!(objectClass=computer))(|(objectClass=person)(objectClass=group)(objectClass=organizationalUnit)(objectClass=domain))(!(&(userAccountControl:1.2.840.113556.1.4.803:=2))))" );
// just check that it doesnt throw for now
ExprNode node = node1.clone();
assertTrue(node instanceof AndNode);
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java?rev=963526&r1=963525&r2=963526&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java Mon Jul 12 23:28:23 2010
@@ -917,7 +917,7 @@ public class FilterParserTest
{
try
{
- BranchNode node = ( BranchNode ) FilterParser.parse("(&(objectClass=nisNetgroup)(|(nisNetGroupTriple=a*a)(nisNetGroupTriple=\\28*,acc1,*\\29)))");
+ BranchNode node = ( BranchNode ) FilterParser.parse( "(&(objectClass=nisNetgroup)(|(nisNetGroupTriple=a*a)(nisNetGroupTriple=\\28*,acc1,*\\29)))");
assertEquals( 2, node.getChildren().size() );
assertTrue( node instanceof AndNode );