/** * Remove the AttributeType normalizer from the OidNormalizer map */ public void removeMappingFor( AttributeType attributeType ) throws LdapException { if ( attributeType == null ) { return; } oidNormalizerMap.remove( attributeType.getOid() ); // We also have to remove all the short names for this attribute for ( String name : attributeType.getNames() ) { oidNormalizerMap.remove( name.toLowerCase() ); } }
/** * Efficient server side means to perform a lookup of an attribute * within an entry. Simple lookups by name may fail if the user provided * the attribute identifier in any way other than the common alias for * the attribute. We need to check for all aliases and the OID. * * @param type the attributeType containing the OID and aliases we need * @param entry the entry with user provided attribute IDENTIFIERS * @return the attribute if it is present * @throws NamingException if there are failures while accessing the * attributes object */ public static Attribute getAttribute( AttributeType type, Attributes entry ) throws NamingException { Attribute attr = entry.get( type.getOid() ); if ( attr == null ) { String[] aliases = type.getNames(); for ( int ii = 0; ii < aliases.length; ii++ ) { attr = entry.get( aliases[ii] ); if ( attr != null ) { return attr; } } } return attr; }
for ( String name : attributeType.getNames() )
public Map getNormalizerMapping() throws NamingException { if ( mapping == null ) { Map bootstrapMapping = bootstrap.getNormalizerMapping(); mapping = new HashMap( ( byOid.size() << 1 ) + bootstrapMapping.size() ); mapping.putAll( bootstrapMapping ); for ( Iterator ii = byOid.values().iterator(); ii.hasNext(); /**/ ) { AttributeType type = ( AttributeType ) ii.next(); OidNormalizer oidNormalizer = new OidNormalizer( type.getOid(), type.getEquality().getNormalizer() ); mapping.put( type.getOid(), oidNormalizer ); String[] aliases = type.getNames(); for ( int jj = 0; jj < aliases.length; jj++ ) { mapping.put( aliases[jj], oidNormalizer ); mapping.put( aliases[jj].toLowerCase(), oidNormalizer ); } } } return Collections.unmodifiableMap( mapping ); }
String[] aliases = type.getNames(); for ( int jj = 0; jj < aliases.length; jj++ )
public static Attribute removeAttribute( AttributeType type, Attributes entry ) throws NamingException { Attribute attr = entry.get( type.getOid() ); if ( attr == null ) { String[] aliases = type.getNames(); for ( int ii = 0; ii < aliases.length; ii++ ) { attr = entry.get( aliases[ii] ); if ( attr != null ) { return entry.remove( attr.getID() ); } } } if ( attr == null ) { return null; } return entry.remove( attr.getID() ); } }
for ( String name:attributeType.getNames() )
/** * Correctly removes an attribute from an entry using it's attributeType information. * * @param type the attributeType of the attribute to remove * @param entry the entry to remove the attribute from * @return the Attribute that is removed */ public static Attribute removeAttribute( AttributeType type, Attributes entry ) { Attribute attr = entry.get( type.getOid() ); if ( attr == null ) { List<String> aliases = type.getNames(); for ( String alias : aliases ) { attr = entry.get( alias ); if ( attr != null ) { return entry.remove( attr.getID() ); } } } if ( attr == null ) { return null; } return entry.remove( attr.getID() ); }
public void register( String schema, AttributeType attributeType ) throws NamingException { if ( byOid.containsKey( attributeType.getOid() ) ) { NamingException e = new NamingException( "attributeType w/ OID " + attributeType.getOid() + " has already been registered!" ); monitor.registerFailed( attributeType, e ); throw e; } String[] names = attributeType.getNames(); for ( int ii = 0; ii < names.length; ii++ ) { oidRegistry.register( names[ii], attributeType.getOid() ); } registerDescendants( attributeType ); oidToSchema.put( attributeType.getOid(), schema ); byOid.put( attributeType.getOid(), attributeType ); monitor.registered( attributeType ); }
String[] names = attributeType.getNames(); for ( int ii = 0; ii < names.length; ii++ ) OidNormalizer oidNormalizer = new OidNormalizer( attributeType.getOid(), normalizer ); mapping.put( attributeType.getOid(), oidNormalizer ); String[] aliases = attributeType.getNames(); for ( int jj = 0; jj < aliases.length; jj++ )
/** * {@inheritDoc} */ public void addMappingFor( AttributeType attributeType ) throws LdapException { MatchingRule equality = attributeType.getEquality(); OidNormalizer oidNormalizer; String oid = attributeType.getOid(); if ( equality == null ) { LOG.debug( "Attribute {} does not have an EQUALITY MatchingRule : using NoopNormalizer", attributeType .getName() ); oidNormalizer = new OidNormalizer( oid, new NoOpNormalizer( attributeType.getOid() ) ); } else { oidNormalizer = new OidNormalizer( oid, equality.getNormalizer() ); } oidNormalizerMap.put( oid, oidNormalizer ); // Also inject the attributeType's short names in the map for ( String name : attributeType.getNames() ) { oidNormalizerMap.put( name.toLowerCase(), oidNormalizer ); } }
String[] names = type.getNames(); for ( int ii = 0; ii < names.length; ii++ )
List<String> names = at.getNames();
for ( String atName:attributeType.getNames() )