/** * Gets the worst case scan count for all entries that satisfy the equality * assertion in the SimpleNode argument. * * @param node the node to get a scan count for * @return the worst case * @throws NamingException if there is an error accessing an index */ private BigInteger getEqualityScan( SimpleNode node ) throws NamingException { if ( db.hasUserIndexOn( node.getAttribute() ) ) { Index idx = db.getUserIndex( node.getAttribute() ); return BigInteger.valueOf( idx.count( node.getValue() ) ); } // count for non-indexed attribute is unknown so we presume da worst return MAX; }
static ExprNode getReferralFilter() { return new SimpleNode( OBJCLASS_ATTR, REFERRAL_OC, LeafNode.EQUALITY ); }
/** * Makes a full clone in new memory space of the current node and children * * @return the clone */ @Override public ExprNode clone() { return super.clone(); }
if ( node.getAssertionType() != LeafNode.EQUALITY ) throw new NamingException( "Unrecognized assertion type for refinement node: " + node.getAssertionType() ); if ( !node.getAttribute().equalsIgnoreCase( "objectclass" ) ) throw new NamingException( "Refinement leaf node attribute was " + node.getAttribute() ); if ( AttributeUtils.containsValueCaseIgnore( objectClasses, node.getValue() ) ) if ( node.getValue() instanceof String ) value = ( String ) node.getValue(); else if ( node.getValue() instanceof byte[] ) value = "#" + StringTools.toHexString( ( byte[] ) node.getValue() ); value = node.getValue().toString();
if ( !ncn.isDefined( snode.getAttribute() ) ) normalized = snode.getValue(); else if ( Character.isDigit( snode.getAttribute().charAt( 0 ) ) ) if ( snode.getValue() instanceof String ) normalized = ncn.normalizeByOid( snode.getAttribute(), ( String ) snode.getValue() ); else if ( snode.getValue() instanceof byte [] ) normalized = ncn.normalizeByOid( snode.getAttribute(), ( byte[] ) snode.getValue() ); normalized = ncn.normalizeByOid( snode.getAttribute(), snode.getValue().toString() ); if ( snode.getValue() instanceof String ) normalized = ncn.normalizeByName( snode.getAttribute(), ( String ) snode.getValue() ); else if ( snode.getValue() instanceof byte [] ) normalized = ncn.normalizeByName( snode.getAttribute(), ( byte[] ) snode.getValue() ); normalized = ncn.normalizeByName( snode.getAttribute(), snode.getValue().toString() ); snode.setAttribute( registry.getOid( snode.getAttribute() ) ); log.error( "Failed to normalize filter node attribute: " + snode.getAttribute(), e );
case( LeafNode.LESSEQ ): SimpleNode simpleNode = ( SimpleNode ) leaf; if ( simpleNode.getValue() instanceof String ) newLeaf = new SimpleNode( descendant.getOid(), ( String ) simpleNode.getValue(), simpleNode.getAssertionType() ); else if ( simpleNode.getValue() instanceof byte[] ) newLeaf = new SimpleNode( descendant.getOid(), ( byte[] ) simpleNode.getValue(), simpleNode.getAssertionType() ); newLeaf = new SimpleNode( descendant.getOid(), simpleNode.getValue().toString(), simpleNode.getAssertionType() );
/** * @see ExprNode#printRefinementToBuffer(StringBuilder) * @return The buffer in which the refinement has been appended * @throws UnsupportedOperationException if this node isn't a part of a refinement. */ public StringBuilder printRefinementToBuffer( StringBuilder buf ) { if ( getAttribute() == null || !SchemaConstants.OBJECT_CLASS_AT.equalsIgnoreCase( getAttribute() ) ) { throw new UnsupportedOperationException( I18n.err( I18n.ERR_04162, getAttribute() ) ); } buf.append( "item: " ).append( value ); return buf; }
/** * @see Object#toString() * @return A string representing the AndNode */ public String toString() { StringBuilder buf = new StringBuilder(); buf.append( '(' ).append( getAttribute() ).append( ">=" ).append( getEscapedValue() ); buf.append( super.toString() ); buf.append( ')' ); return buf.toString(); } }
/** * Pretty prints this expression node along with annotation information. * * TODO - perhaps this belong in some utility class? * * @param buf the buffer to print into * @return the same buf argument returned for call chaining */ public StringBuilder printToBuffer( StringBuilder buf ) { if ( ( null != getAnnotations() ) && getAnnotations().containsKey( "count" ) ) { buf.append( ":[" ); buf.append( getAnnotations().get( "count" ).toString() ); buf.append( "] " ); } buf.append( ')' ); return buf; }
String objectClass = null; if ( node.getValue() instanceof String ) objectClass = ( String ) node.getValue(); objectClass = node.getValue().toString(); if ( node.getAttribute().equalsIgnoreCase( "2.5.4.0" ) && ( "top".equalsIgnoreCase( objectClassOid ) || "subschema".equalsIgnoreCase( objectClassOid ) ) && ( node.getAssertionType() == SimpleNode.EQUALITY ) )
case( LeafNode.LESSEQ ): SimpleNode simpleNode = ( SimpleNode ) leaf; if ( simpleNode.getValue() instanceof String ) newLeaf = new SimpleNode( descendant.getOid(), ( String ) simpleNode.getValue(), simpleNode.getAssertionType() ); else if ( simpleNode.getValue() instanceof byte[] ) newLeaf = new SimpleNode( descendant.getOid(), ( byte[] ) simpleNode.getValue(), simpleNode.getAssertionType() ); newLeaf = new SimpleNode( descendant.getOid(), simpleNode.getValue().toString(), simpleNode.getAssertionType() );
/** * @see Object#toString() * @return A string representing the AndNode */ public String toString() { StringBuilder buf = new StringBuilder(); buf.append( '(' ).append( getAttribute() ).append( "~=" ).append( getEscapedValue() ); buf.append( super.toString() ); buf.append( ')' ); return buf.toString(); } }
/** * Gets a scan count of the nodes that satisfy the greater or less than test * specified by the node. * * @param node the greater or less than node to get a count for * @param isGreaterThan if true test is for >=, otherwise <= * @return the scan count of all nodes satisfying the AVA * @throws NamingException if there is an error accessing an index */ private BigInteger getGreaterLessScan( SimpleNode node, boolean isGreaterThan ) throws NamingException { if ( db.hasUserIndexOn( node.getAttribute() ) ) { Index idx = db.getUserIndex( node.getAttribute() ); int count = idx.count( node.getValue(), isGreaterThan ); return BigInteger.valueOf( count ); } // count for non-indexed attribute is unknown so we presume da worst return MAX; }
private void initialize() throws NamingException { // search all naming contexts for access control subentenries // generate ACITuple Arrays for each subentry // add that subentry to the hash Iterator suffixes = nexus.listSuffixes(); while ( suffixes.hasNext() ) { String suffix = ( String ) suffixes.next(); LdapDN baseDn = parseNormalized( suffix ); ExprNode filter = new SimpleNode( OC_ATTR, ACSUBENTRY_OC, SimpleNode.EQUALITY ); SearchControls ctls = new SearchControls(); ctls.setSearchScope( SearchControls.SUBTREE_SCOPE ); NamingEnumeration results = nexus.search( baseDn, env, filter, ctls ); while ( results.hasMore() ) { SearchResult result = ( SearchResult ) results.next(); String subentryDn = result.getName(); Attribute aci = result.getAttributes().get( ACI_ATTR ); if ( aci == null ) { log.warn( "Found accessControlSubentry '" + subentryDn + "' without any " + ACI_ATTR ); continue; } LdapDN normName = parseNormalized( subentryDn ); subentryAdded( subentryDn, normName, result.getAttributes() ); } results.close(); } }
/** * Return a cloned node */ @Override public ExprNode clone() { return super.clone(); }
/** * @see Object#toString() * @return A string representing the AndNode */ public String toString() { StringBuilder buf = new StringBuilder(); buf.append( '(' ).append( getAttribute() ).append( "=" ).append( getEscapedValue() ); buf.append( super.toString() ); buf.append( ')' ); return buf.toString(); } }
/** * Returns an enumeration over candidates that satisfy a simple equality * attribute value assertion. * * @param node the equality AVA node * @return an enumeration over the index records matching the AVA * @throws NamingException if there is a failure while accessing the db */ private NamingEnumeration enumEquality( final SimpleNode node ) throws NamingException { if ( db.hasUserIndexOn( node.getAttribute() ) ) { Index idx = db.getUserIndex( node.getAttribute() ); return idx.listIndices( node.getValue() ); } return nonIndexedScan( node ); }
filter.addNode( new SimpleNode( OC_ATTR, GROUPOFNAMES_OC, SimpleNode.EQUALITY ) ); filter.addNode( new SimpleNode( OC_ATTR, GROUPOFUNIQUENAMES_OC, SimpleNode.EQUALITY ) );
/** * Makes a full clone in new memory space of the current node and children * * @return the clone */ @Override public ExprNode clone() { return super.clone(); }
/** * @see Object#toString() * @return A string representing the AndNode */ public String toString() { StringBuilder buf = new StringBuilder(); buf.append( '(' ).append( getAttribute() ).append( "<=" ).append( getEscapedValue() ); buf.append( super.toString() ); buf.append( ')' ); return buf.toString(); } }