Package org.apache.directory.api.ldap.codec.decorators

Examples of org.apache.directory.api.ldap.codec.decorators.AddRequestDecorator


            case ABANDON_REQUEST:
                decorator = new AbandonRequestDecorator( codec, ( AbandonRequest ) decoratedMessage );
                break;

            case ADD_REQUEST:
                decorator = new AddRequestDecorator( codec, ( AddRequest ) decoratedMessage );
                break;

            case ADD_RESPONSE:
                decorator = new AddResponseDecorator( codec, ( AddResponse ) decoratedMessage );
                break;
View Full Code Here


            case ABANDON_REQUEST:
                decorator = new AbandonRequestDecorator( codec, ( AbandonRequest ) decoratedMessage );
                break;

            case ADD_REQUEST:
                decorator = new AddRequestDecorator( codec, ( AddRequest ) decoratedMessage );
                break;

            case ADD_RESPONSE:
                decorator = new AddResponseDecorator( codec, ( AddResponse ) decoratedMessage );
                break;
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void action( LdapMessageContainer<AddRequestDecorator> container ) throws DecoderException
    {
        AddRequestDecorator addRequest = container.getMessage();

        TLV tlv = container.getCurrentTLV();

        // Store the entry. It can't be null
        if ( tlv.getLength() == 0 )
        {
            String msg = I18n.err( I18n.ERR_04085 );
            LOG.error( msg );

            AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );

            // I guess that trying to add an entry which Dn is empty is a naming violation...
            // Not 100% sure though ...
            throw new ResponseCarryingException( msg, response, ResultCodeEnum.NAMING_VIOLATION,
                Dn.EMPTY_DN, null );
        }
        else
        {
            Dn entryDn = null;
            byte[] dnBytes = tlv.getValue().getData();
            String dnStr = Strings.utf8ToString( dnBytes );

            try
            {
                entryDn = new Dn( dnStr );
            }
            catch ( LdapInvalidDnException ine )
            {
                String msg = "Invalid Dn given : " + dnStr + " (" + Strings.dumpBytes( dnBytes )
                    + ") is invalid";
                LOG.error( "{} : {}", msg, ine.getMessage() );

                AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );
                throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                    Dn.EMPTY_DN, ine );
            }

            addRequest.setEntryDn( entryDn );
        }

        LOG.debug( "Adding an entry with Dn : {}", addRequest.getEntry() );
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void action( LdapMessageContainer<AddRequestDecorator> container )
    {
        AddRequestDecorator addRequest = container.getMessage();

        TLV tlv = container.getCurrentTLV();

        // Store the value. It can't be null
        Object value = null;

        try
        {
            if ( tlv.getLength() == 0 )
            {
                addRequest.addAttributeValue( "" );
            }
            else
            {
                if ( container.isBinary( addRequest.getCurrentAttributeType() ) )
                {
                    value = tlv.getValue().getData();

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Adding value {}", Strings.dumpBytes( ( byte[] ) value ) );
                    }

                    addRequest.addAttributeValue( ( byte[] ) value );
                }
                else
                {
                    value = Strings.utf8ToString( tlv.getValue().getData() );

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Adding value {}" + value );
                    }

                    addRequest.addAttributeValue( ( String ) value );
                }
            }
        }
        catch ( LdapException le )
        {
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void action( LdapMessageContainer<AddRequestDecorator> container ) throws DecoderException
    {
        AddRequestDecorator addRequest = container.getMessage();

        TLV tlv = container.getCurrentTLV();

        // Store the type. It can't be null.
        if ( tlv.getLength() == 0 )
        {
            String msg = I18n.err( I18n.ERR_04086 );
            LOG.error( msg );

            AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );

            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                addRequest.getEntry().getDn(), null );
        }

        String type = Strings.utf8ToString( tlv.getValue().getData() );

        try
        {
            addRequest.addAttributeType( type );
        }
        catch ( LdapException ne )
        {
            String msg = I18n.err( I18n.ERR_04087 );
            LOG.error( msg );

            AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );
            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                addRequest.getEntry().getDn(), ne );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "Adding type {}", type );
View Full Code Here

    {
        // Now, we can allocate the AddRequest Object
        int messageId = container.getMessageId();
        AddRequest internalAddRequest = new AddRequestImpl();
        internalAddRequest.setMessageId( messageId );
        AddRequestDecorator addRequest = new AddRequestDecorator(
            container.getLdapCodecService(), internalAddRequest );
        container.setMessage( addRequest );

        // We will check that the request is not null
        TLV tlv = container.getCurrentTLV();
View Full Code Here

            case ABANDON_REQUEST:
                decorator = new AbandonRequestDecorator( codec, ( AbandonRequest ) decoratedMessage );
                break;

            case ADD_REQUEST:
                decorator = new AddRequestDecorator( codec, ( AddRequest ) decoratedMessage );
                break;

            case ADD_RESPONSE:
                decorator = new AddResponseDecorator( codec, ( AddResponse ) decoratedMessage );
                break;
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.codec.decorators.AddRequestDecorator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.