Java Code Examples for org.apache.directory.api.ldap.model.schema.AttributeType#getEquality()

The following examples show how to use org.apache.directory.api.ldap.model.schema.AttributeType#getEquality() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Registries.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Add the SchemaObjectReferences. This method does nothing, it's just
 * a catch all. The other methods will be called for each specific
 * schemaObject
 *
public void addCrossReferences( SchemaObject schemaObject )
{
    // Do nothing : it's a catch all method.
}


/**
 * Delete the AT references (using and usedBy) :
 * AT -> MR (for EQUALITY, ORDERING and SUBSTR)
 * AT -> S
 * AT -> AT
 * 
 * @param attributeType The AttributeType to remove
 */
public void delCrossReferences( AttributeType attributeType )
{
    if ( attributeType.getEquality() != null )
    {
        delReference( attributeType, attributeType.getEquality() );
    }

    if ( attributeType.getOrdering() != null )
    {
        delReference( attributeType, attributeType.getOrdering() );
    }

    if ( attributeType.getSubstring() != null )
    {
        delReference( attributeType, attributeType.getSubstring() );
    }

    if ( attributeType.getSyntax() != null )
    {
        delReference( attributeType, attributeType.getSyntax() );
    }

    if ( attributeType.getSuperior() != null )
    {
        delReference( attributeType, attributeType.getSuperior() );
    }
}
 
Example 2
Source File: DefaultAttributeTypeRegistry.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void addMappingFor( AttributeType attributeType ) throws LdapException
{
    MatchingRule equality = attributeType.getEquality();
    OidNormalizer oidNormalizer;
    String oid = attributeType.getOid();

    if ( equality == null )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.msg( I18n.MSG_13703_AT_WITHOUT_EQ_MR, 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( Strings.toLowerCaseAscii( name ), oidNormalizer );
    }
}
 
Example 3
Source File: ConcreteNameComponentNormalizer.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Object normalizeByName( AttributeType attributeType, String value ) throws LdapException
{
    MatchingRule mrule = attributeType.getEquality();
    Normalizer normalizer;
        
    if ( mrule == null )
    {
        return new NoOpNormalizer( attributeType.getOid() );
    }
    else
    {
        normalizer = attributeType.getEquality().getNormalizer();
    }

    if ( attributeType.getSyntax().isHumanReadable() )
    {
        return normalizer.normalize( value );
    }
    else
    {
        String unescaped = unescape( value );

        return normalizer.normalize( unescaped );
    }
}
 
Example 4
Source File: ConcreteNameComponentNormalizer.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Looks up the Normalizer to use for a name component using the attributeId
 * for the name component.  First the attribute is resolved, then its
 * equality matching rule is looked up.  The normalizer of that matching
 * rule is returned.
 *
 * @param id the name or oid of the attribute in the name component to
 * normalize the value of
 * @return the Normalizer to use for normalizing the value of the attribute
 * @throws LdapException if there are failures resolving the Normalizer
 */
private Normalizer lookup( String id ) throws LdapException
{
    AttributeType type = schemaManager.lookupAttributeTypeRegistry( id );
    MatchingRule mrule = type.getEquality();

    if ( mrule == null )
    {
        return new NoOpNormalizer( id );
    }

    return mrule.getNormalizer();
}
 
Example 5
Source File: AttributeTypeHelper.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * Inject the AttributeType into the Registries, updating the references to
 * other SchemaObject
 *
 * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR, SYNTAX),
 * an exception is thrown.
 * 
 * @param attributeType The AttributeType to add to the Registries
 * @param errorHandler Error handler
 * @param registries The Registries
 * @throws LdapException If the AttributeType is not valid
 */
public static void addToRegistries( AttributeType attributeType, SchemaErrorHandler errorHandler, Registries registries ) throws LdapException
{
    if ( registries != null )
    {
        try
        {
            attributeType.unlock();
            AttributeTypeRegistry attributeTypeRegistry = registries.getAttributeTypeRegistry();

            // The superior
            if ( !buildSuperior( attributeType, errorHandler, registries ) )
            {
                // We have had errors, let's stop here as we need a correct superior to continue
                return;
            }

            // The Syntax
            buildSyntax( attributeType, errorHandler, registries );

            // The EQUALITY matching rule
            buildEquality( attributeType, errorHandler, registries );

            // The ORDERING matching rule
            buildOrdering( attributeType, errorHandler, registries );

            // The SUBSTR matching rule
            buildSubstring( attributeType, errorHandler, registries );

            // Check the USAGE
            checkUsage( attributeType, errorHandler );

            // Check the COLLECTIVE element
            checkCollective( attributeType, errorHandler );

            // Inject the attributeType into the oid/normalizer map
            attributeTypeRegistry.addMappingFor( attributeType );

            // Register this AttributeType into the Descendant map
            attributeTypeRegistry.registerDescendants( attributeType, attributeType.getSuperior() );

            /**
             * Add the AT references (using and usedBy) :
             * AT -> MR (for EQUALITY, ORDERING and SUBSTR)
             * AT -> S
             * AT -> AT
             */
            if ( attributeType.getEquality() != null )
            {
                registries.addReference( attributeType, attributeType.getEquality() );
            }

            if ( attributeType.getOrdering() != null )
            {
                registries.addReference( attributeType, attributeType.getOrdering() );
            }

            if ( attributeType.getSubstring() != null )
            {
                registries.addReference( attributeType, attributeType.getSubstring() );
            }

            if ( attributeType.getSyntax() != null )
            {
                registries.addReference( attributeType, attributeType.getSyntax() );
            }

            if ( attributeType.getSuperior() != null )
            {
                registries.addReference( attributeType, attributeType.getSuperior() );
            }
        }
        finally
        {
            attributeType.lock();
        }
    }
}
 
Example 6
Source File: AttributeTypeHelper.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * Remove the AttributeType from the registries, updating the references to
 * other SchemaObject.
 *
 * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR, SYNTAX),
 * an exception is thrown.
 * 
 * @param attributeType The AttributeType to remove from the Registries
 * @param errorHandler Error handler
 * @param registries The Registries
 * @throws LdapException If the AttributeType is not valid
 */
public static void removeFromRegistries( AttributeType attributeType, SchemaErrorHandler errorHandler, Registries registries ) throws LdapException
{
    if ( registries != null )
    {
        AttributeTypeRegistry attributeTypeRegistry = registries.getAttributeTypeRegistry();

        // Remove the attributeType from the oid/normalizer map
        attributeTypeRegistry.removeMappingFor( attributeType );

        // Unregister this AttributeType into the Descendant map
        attributeTypeRegistry.unregisterDescendants( attributeType, attributeType.getSuperior() );

        /**
         * Remove the AT references (using and usedBy) :
         * AT -> MR (for EQUALITY, ORDERING and SUBSTR)
         * AT -> S
         * AT -> AT
         */
        if ( attributeType.getEquality() != null )
        {
            registries.delReference( attributeType, attributeType.getEquality() );
        }

        if ( attributeType.getOrdering() != null )
        {
            registries.delReference( attributeType, attributeType.getOrdering() );
        }

        if ( attributeType.getSubstring() != null )
        {
            registries.delReference( attributeType, attributeType.getSubstring() );
        }

        if ( attributeType.getSyntax() != null )
        {
            registries.delReference( attributeType, attributeType.getSyntax() );
        }

        if ( attributeType.getSuperior() != null )
        {
            registries.delReference( attributeType, attributeType.getSuperior() );
        }
    }
}