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

The following examples show how to use org.apache.directory.api.ldap.model.schema.AttributeType#getName() . 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: DefaultEntry.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Get the UpId if it is null.
 *
 * @param upId The ID
 * @param attributeType The AttributeType to retrieve
 * @return the retrieved ID
 */
private String getUpId( String upId, AttributeType attributeType )
{
    String normUpId = Strings.trim( upId );

    if ( attributeType == null )
    {
        if ( Strings.isEmpty( normUpId ) )
        {
            String message = I18n.err( I18n.ERR_13226_CANNOT_ADD_ATTRIBUTE_NO_ID );
            LOG.error( message );
            throw new IllegalArgumentException( message );
        }

        return upId;
    }
    else if ( Strings.isEmpty( normUpId ) )
    {
        String id = attributeType.getName();

        if ( Strings.isEmpty( id ) )
        {
            id = attributeType.getOid();
        }

        return id;
    }
    else
    {
        return upId;
    }
}
 
Example 2
Source File: LeafNode.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a leaf node.
 * 
 * @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();
    }
    else
    {
        throw new NullPointerException( I18n.err( I18n.ERR_13302_CANNOT_CREATE_NODE_NULL_ATTR ) );
    }
}
 
Example 3
Source File: LeafNode.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 4
Source File: DefaultEntry.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * Get the UpId if it is null.
 * 
 * @param upId The ID
 */
private String getUpId( String upId, AttributeType attributeType )
{
    String normUpId = Strings.trim( upId );

    if ( ( attributeType == null ) )
    {
        if ( Strings.isEmpty( normUpId ) )
        {
            String message = I18n.err( I18n.ERR_04458 );
            LOG.error( message );
            throw new IllegalArgumentException( message );
        }

        return upId;
    }
    else if ( Strings.isEmpty( normUpId ) )
    {
        String id = attributeType.getName();

        if ( Strings.isEmpty( id ) )
        {
            id = attributeType.getOid();
        }

        return id;
    }
    else
    {
        return upId;
    }
}
 
Example 5
Source File: ServerEntryUtils.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * Convert a ServerAttribute into a BasicAttribute. The Dn is lost
 * during this conversion, as the Attributes object does not store
 * this element.
 *
 * @return An instance of a AttributesImpl() object
 */
public static javax.naming.directory.Attribute toBasicAttribute( Attribute entryAttribute )
{
    AttributeType attributeType = entryAttribute.getAttributeType();

    javax.naming.directory.Attribute attribute = new BasicAttribute( attributeType.getName() );

    for ( Value<?> value : entryAttribute )
    {
        attribute.add( value.getValue() );
    }

    return attribute;
}
 
Example 6
Source File: DefaultEntry.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * Get the UpId if it is null.
 * 
 * @param upId The ID
 */
private String getUpId( String upId, AttributeType attributeType )
{
    String normUpId = Strings.trim( upId );

    if ( ( attributeType == null ) )
    {
        if ( Strings.isEmpty( normUpId ) )
        {
            String message = I18n.err( I18n.ERR_04458 );
            LOG.error( message );
            throw new IllegalArgumentException( message );
        }

        return upId;
    }
    else if ( Strings.isEmpty( normUpId ) )
    {
        String id = attributeType.getName();

        if ( Strings.isEmpty( id ) )
        {
            id = attributeType.getOid();
        }

        return id;
    }
    else
    {
        return upId;
    }
}
 
Example 7
Source File: ServerEntryUtils.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * Convert a ServerAttribute into a BasicAttribute. The Dn is lost
 * during this conversion, as the Attributes object does not store
 * this element.
 *
 * @return An instance of a AttributesImpl() object
 */
public static javax.naming.directory.Attribute toBasicAttribute( Attribute entryAttribute )
{
    AttributeType attributeType = entryAttribute.getAttributeType();

    javax.naming.directory.Attribute attribute = new BasicAttribute( attributeType.getName() );

    for ( Value<?> value : entryAttribute )
    {
        attribute.add( value.getValue() );
    }

    return attribute;
}
 
Example 8
Source File: DefaultAttribute.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
private void setUpIdInternal( String upId, String newId, AttributeType attributeType )
{
    if ( attributeType == null )
    {
        if ( this.attributeType == null )
        {
            this.upId = upId;
            this.id = newId;

            // Compute the hashCode
            rehash();

            return;
        }
        else
        {
            if ( areCompatible( newId, this.attributeType ) )
            {
                this.upId = upId;
                this.id = this.attributeType.getOid();

                // Compute the hashCode
                rehash();

                return;
            }
            else
            {
                return;
            }
        }
    }

    if ( Strings.isEmpty( newId ) )
    {
        this.attributeType = attributeType;
        this.upId = attributeType.getName();
        this.id = attributeType.getOid();

        // Compute the hashCode
        rehash();

        return;
    }

    if ( areCompatible( newId, attributeType ) )
    {
        this.upId = upId;
        this.id = attributeType.getOid();
        this.attributeType = attributeType;

        // Compute the hashCode
        rehash();

        return;
    }

    throw new IllegalArgumentException( I18n.err( I18n.ERR_13244_ID_AT_NOT_COMPATIBLE, id, attributeType.getName() ) );
}
 
Example 9
Source File: DefaultAttribute.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void apply( AttributeType attributeType ) throws LdapInvalidAttributeValueException
{
    if ( attributeType == null )
    {
        throw new IllegalArgumentException( I18n.err( I18n.ERR_13245_AT_PARAMETER_NULL ) );
    }

    this.attributeType = attributeType;
    this.id = attributeType.getOid();

    if ( Strings.isEmpty( this.upId ) )
    {
        this.upId = attributeType.getName();
    }
    else
    {
        if ( !areCompatible( this.upId, attributeType ) )
        {
            this.upId = attributeType.getName();
        }
    }

    if ( values != null )
    {
        Set<Value> newValues = new LinkedHashSet<>( values.size() );

        for ( Value value : values )
        {
            if ( value.isSchemaAware() )
            {
                newValues.add( value );
            }
            else
            {
                if ( value.isHumanReadable() )
                {
                    newValues.add( new Value( attributeType, value.getString() ) );
                }
                else
                {
                    newValues.add( new Value( attributeType, value.getBytes() ) );
                }
            }
        }

        values = newValues;
    }

    isHR = attributeType.getSyntax().isHumanReadable();

    // Compute the hashCode
    rehash();
}