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

Examples of org.apache.directory.shared.ldap.codec.decorators.SearchResultEntryDecorator


            case SEARCH_RESULT_DONE:
                decorator = new SearchResultDoneDecorator( codec, ( SearchResultDone ) decoratedMessage );
                break;
               
            case SEARCH_RESULT_ENTRY:
                decorator = new SearchResultEntryDecorator( codec, ( SearchResultEntry ) decoratedMessage );
                break;
               
            case SEARCH_RESULT_REFERENCE:
                decorator = new SearchResultReferenceDecorator( codec, ( SearchResultReference ) decoratedMessage );
                break;
View Full Code Here


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

        TLV tlv = container.getCurrentTLV();

        // Store the value
        Object value = null;

        if ( tlv.getLength() == 0 )
        {
            searchResultEntry.addAttributeValue( "" );

            LOG.debug( "The attribute value is null" );
        }
        else
        {
            if ( container.isBinary( searchResultEntry.getCurrentAttribute().getId() ) )
            {
                value = tlv.getValue().getData();

                if ( IS_DEBUG )
                {
                    LOG.debug( "Attribute value {}", Strings.dumpBytes((byte[]) value) );
                }
            }
            else
            {
                value = Strings.utf8ToString(tlv.getValue().getData());

                LOG.debug( "Attribute value {}", value );
            }

            searchResultEntry.addAttributeValue( value );
        }

        // We can have an END transition
        container.setGrammarEndAllowed( true );
    }
View Full Code Here

            LdapConstants.SEARCH_RESULT_ENTRY_TAG, new GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>( "Init SearchResultEntry" )
            {
                public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container )
                {
                    // Now, we can allocate the SearchResultEntry Object
                    SearchResultEntryDecorator searchResultEntry = new SearchResultEntryDecorator(
                        container.getLdapCodecService(), new SearchResultEntryImpl( container.getMessageId() ) );
                    container.setMessage( searchResultEntry );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from SearchResultEntry Message to ObjectName
        // --------------------------------------------------------------------------------------------
        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
        // objectName LDAPDN,
        // ...
        //
        // Store the object name.
        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.SEARCH_RESULT_ENTRY_STATE, LdapStatesEnum.OBJECT_NAME_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<SearchResultEntryDecorator>>( "Store search result entry object name Value" )
            {
                public void action( LdapMessageContainer<SearchResultEntryDecorator> container ) throws DecoderException
                {
                    SearchResultEntryDecorator searchResultEntry = container.getMessage();

                    TLV tlv = container.getCurrentTLV();

                    Dn objectName = Dn.EMPTY_DN;

                    // Store the value.
                    if ( tlv.getLength() == 0 )
                    {
                        searchResultEntry.setObjectName( objectName );
                    }
                    else
                    {
                        byte[] dnBytes = tlv.getValue().getData();
                        String dnStr = Strings.utf8ToString(dnBytes);

                        try
                        {
                            objectName = new Dn( dnStr );
                        }
                        catch ( LdapInvalidDnException ine )
                        {
                            // This is for the client side. We will never decode LdapResult on the server
                            String msg = "The Dn " + Strings.dumpBytes(dnBytes) + "is invalid : "
                                + ine.getMessage();
                            LOG.error( "{} : {}", msg, ine.getMessage() );
                            throw new DecoderException( msg, ine );
                        }

                        searchResultEntry.setObjectName( objectName );
                    }

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Search Result Entry Dn found : {}", searchResultEntry.getObjectName() );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from ObjectName to AttributesSR
        // --------------------------------------------------------------------------------------------
        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
        // ...
        // attributes PartialAttributeList }
        //
        // PartialAttributeList ::= *SEQUENCE* OF SEQUENCE {
        // ...
        //
        // We may have no attributes. Just allows the grammar to end
        super.transitions[LdapStatesEnum.OBJECT_NAME_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.OBJECT_NAME_STATE, LdapStatesEnum.ATTRIBUTES_SR_STATE, UniversalTag.SEQUENCE.getValue(),
            new GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>( "Pop and end allowed" )
            {
                public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
                {
                    container.setGrammarEndAllowed( true );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from AttributesSR to PartialAttributesList
        // --------------------------------------------------------------------------------------------
        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
        // ...
        // attributes PartialAttributeList }
        //
        // PartialAttributeList ::= SEQUENCE OF *SEQUENCE* {
        // ...
        //
        // nothing to do
        super.transitions[LdapStatesEnum.ATTRIBUTES_SR_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTES_SR_STATE, LdapStatesEnum.PARTIAL_ATTRIBUTES_LIST_STATE,
            UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from AttributesSR to Controls
        // --------------------------------------------------------------------------------------------
        //     searchResultEntry SearchResultEntry,
        //     ... },
        // controls   [0] Controls OPTIONAL }
        //
        // Initialize the controls
        super.transitions[LdapStatesEnum.ATTRIBUTES_SR_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTES_SR_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from PartialAttributesList to typeSR
        // --------------------------------------------------------------------------------------------
        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
        // ...
        // attributes PartialAttributeList }
        //
        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
        //     type  AttributeDescription,
        //     ...
        //
        // Store the attribute's name.
        super.transitions[LdapStatesEnum.PARTIAL_ATTRIBUTES_LIST_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.PARTIAL_ATTRIBUTES_LIST_STATE, LdapStatesEnum.TYPE_SR_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<SearchResultEntryDecorator>>( "Store search result entry object name Value" )
            {
                public void action( LdapMessageContainer<SearchResultEntryDecorator> container ) throws DecoderException
                {
                    SearchResultEntryDecorator searchResultEntry = container.getMessage();

                    TLV tlv = container.getCurrentTLV();

                    String type = "";

                    // Store the name
                    if ( tlv.getLength() == 0 )
                    {
                        // The type can't be null
                        String msg = I18n.err( I18n.ERR_04081 );
                        LOG.error( msg );
                        throw new DecoderException( msg );
                    }
                    else
                    {
                        type = getType(tlv.getValue().getData());

                        try
                        {
                            searchResultEntry.addAttribute( type );
                        }
                        catch ( LdapException ine )
                        {
                            // This is for the client side. We will never decode LdapResult on the server
                            String msg = "The Attribute type " + type + "is invalid : " + ine.getMessage();
View Full Code Here

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

        TLV tlv = container.getCurrentTLV();

        String type = "";

        // Store the type
        if ( tlv.getLength() == 0 )
        {
            // The type can't be null
            String msg = I18n.err( I18n.ERR_04081 );
            LOG.error( msg );
            throw new DecoderException( msg );
        }
        else
        {
            type = Strings.utf8ToString( tlv.getValue().getData() );

            try
            {
                searchResultEntry.addAttribute( type );
            }
            catch ( LdapException ine )
            {
                // This is for the client side. We will never decode LdapResult on the server
                String msg = "The Attribute type " + type + "is invalid : " + ine.getMessage();
View Full Code Here

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

        TLV tlv = container.getCurrentTLV();

        Dn objectName = Dn.EMPTY_DN;

        // Store the value.
        if ( tlv.getLength() == 0 )
        {
            searchResultEntry.setObjectName( objectName );
        }
        else
        {
            byte[] dnBytes = tlv.getValue().getData();
            String dnStr = Strings.utf8ToString(dnBytes);

            try
            {
                objectName = new Dn( dnStr );
            }
            catch ( LdapInvalidDnException ine )
            {
                // This is for the client side. We will never decode LdapResult on the server
                String msg = "The Dn " + Strings.dumpBytes(dnBytes) + "is invalid : "
                    + ine.getMessage();
                LOG.error( "{} : {}", msg, ine.getMessage() );
                throw new DecoderException( msg, ine );
            }

            searchResultEntry.setObjectName( objectName );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "Search Result Entry Dn found : {}", searchResultEntry.getObjectName() );
        }
    }
View Full Code Here

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

        TLV tlv = container.getCurrentTLV();

        // Store the value
        Object value = null;

        try
        {
            if ( tlv.getLength() == 0 )
            {
                searchResultEntry.addAttributeValue( "" );
   
                LOG.debug( "The attribute value is null" );
            }
            else
            {
                if ( container.isBinary( searchResultEntry.getCurrentAttribute().getId() ) )
                {
                    value = tlv.getValue().getData();
   
                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Attribute value {}", Strings.dumpBytes((byte[]) value) );
                    }
                }
                else
                {
                    value = Strings.utf8ToString(tlv.getValue().getData());
   
                    LOG.debug( "Attribute value {}", value );
                }
   
                searchResultEntry.addAttributeValue( value );
            }
        }
        catch ( LdapException le )
        {
            // Just swallow the exception, it can't occur here
View Full Code Here

            case SEARCH_RESULT_DONE:
                decorator = new SearchResultDoneDecorator( codec, ( SearchResultDone ) decoratedMessage );
                break;
               
            case SEARCH_RESULT_ENTRY:
                decorator = new SearchResultEntryDecorator( codec, ( SearchResultEntry ) decoratedMessage );
                break;
               
            case SEARCH_RESULT_REFERENCE:
                decorator = new SearchResultReferenceDecorator( codec, ( SearchResultReference ) decoratedMessage );
                break;
View Full Code Here

            case SEARCH_RESULT_DONE:
                decorator = new SearchResultDoneDecorator( codec, ( SearchResultDone ) decoratedMessage );
                break;

            case SEARCH_RESULT_ENTRY:
                decorator = new SearchResultEntryDecorator( codec, ( SearchResultEntry ) decoratedMessage );
                break;

            case SEARCH_RESULT_REFERENCE:
                decorator = new SearchResultReferenceDecorator( codec, ( SearchResultReference ) decoratedMessage );
                break;
View Full Code Here

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

        TLV tlv = container.getCurrentTLV();

        String type = "";

        // Store the type
        if ( tlv.getLength() == 0 )
        {
            // The type can't be null
            String msg = I18n.err( I18n.ERR_04081 );
            LOG.error( msg );
            throw new DecoderException( msg );
        }
        else
        {
            type = Strings.utf8ToString( tlv.getValue().getData() );

            try
            {
                searchResultEntry.addAttribute( type );
            }
            catch ( LdapException ine )
            {
                // This is for the client side. We will never decode LdapResult on the server
                String msg = "The Attribute type " + type + "is invalid : " + ine.getMessage();
View Full Code Here

     * {@inheritDoc}
     */
    public void action( LdapMessageContainer<SearchResultEntryDecorator> container )
    {
        // Now, we can allocate the SearchResultEntry Object
        SearchResultEntryDecorator searchResultEntry = new SearchResultEntryDecorator(
            container.getLdapCodecService(), new SearchResultEntryImpl( container.getMessageId() ) );
        container.setMessage( searchResultEntry );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.codec.decorators.SearchResultEntryDecorator

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.