Package org.apache.directory.api.ldap.model.message.controls

Examples of org.apache.directory.api.ldap.model.message.controls.SortKey


            request.removeControl( ctrl );
        }

        PROVIDER_LOG
            .debug( "Adding sort control to sort the entries by entryDn attribute to preserve order of insertion" );
        SortKey sk = new SortKey( SchemaConstants.ENTRY_DN_AT );
        // matchingrule for "entryDn"
        sk.setMatchingRuleId( "2.5.13.1" );
        sk.setReverseOrder( true );

        ctrl = new SortRequestControlImpl();
        ctrl.addSortKey( sk );

        request.addControl( ctrl );
View Full Code Here


        req.setScope( SearchScope.SUBTREE );
        req.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
        // the ENTRY_DN_AT must be in the attribute list, otherwise sorting fails
        req.addAttributes( SchemaConstants.ENTRY_DN_AT );

        SortKey sk = new SortKey( SchemaConstants.ENTRY_DN_AT, "2.5.13.1" );
        SortRequest ctrl = new SortRequestControlImpl();
        ctrl.addSortKey( sk );
        req.addControl( ctrl );

        OperationManager operationManager = directoryService.getOperationManager();
View Full Code Here

            req.setScope( SearchScope.SUBTREE );
            req.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
            // the ENTRY_DN_AT must be in the attribute list, otherwise sorting fails
            req.addAttributes( SchemaConstants.ENTRY_DN_AT );

            SortKey sk = new SortKey( SchemaConstants.ENTRY_DN_AT, "2.5.13.1" );

            SortRequest ctrl = new SortRequestControlImpl();
            ctrl.addSortKey( sk );
            req.addControl( ctrl );
View Full Code Here

            ldapResult.setDiagnosticMessage( "Cannot sort results based on more than one attribute" );
            resp.setSortResult( SortResultCode.UNWILLINGTOPERFORM );
            return resp;
        }

        SortKey sk = keys.get( 0 );

        AttributeType at = schemaManager.getAttributeType( sk.getAttributeTypeDesc() );

        if ( at == null )
        {
            ldapResult.setDiagnosticMessage( "No attribute with the name " + sk.getAttributeTypeDesc()
                + " exists in the server's schema" );
            resp.setSortResult( SortResultCode.NOSUCHATTRIBUTE );
            resp.setAttributeName( sk.getAttributeTypeDesc() );
            return resp;
        }

        String mrOid = sk.getMatchingRuleId();

        if ( mrOid != null )
        {
            MatchingRule mr = at.getOrdering();

            if ( mr != null )
            {
                if ( !mrOid.equals( mr.getOid() ) )
                {
                    ldapResult.setDiagnosticMessage( "Given matchingrule " + mrOid
                        + " is not applicable for the attribute " + sk.getAttributeTypeDesc() );
                    resp.setSortResult( SortResultCode.INAPPROPRIATEMATCHING );
                    resp.setAttributeName( sk.getAttributeTypeDesc() );
                    return resp;
                }
            }

            try
            {
                schemaManager.lookupComparatorRegistry( mrOid );
            }
            catch ( LdapException e )
            {
                ldapResult.setDiagnosticMessage( "Given matchingrule " + mrOid + " is not supported" );
                resp.setSortResult( SortResultCode.INAPPROPRIATEMATCHING );
                resp.setAttributeName( sk.getAttributeTypeDesc() );
                return resp;
            }
        }
        else
        {
            MatchingRule mr = at.getOrdering();

            if ( mr == null )
            {
                mr = at.getEquality();
            }

            ldapResult.setDiagnosticMessage( "Matchingrule is required for sorting by the attribute "
                + sk.getAttributeTypeDesc() );
            resp.setSortResult( SortResultCode.INAPPROPRIATEMATCHING );
            resp.setAttributeName( sk.getAttributeTypeDesc() );

            if ( mr == null )
            {
                return resp;
            }
View Full Code Here

            unsortedEntries.beforeFirst();

            return unsortedEntries;
        }

        SortKey sk = control.getSortKeys().get( 0 );

        AttributeType at = schemaManager.getAttributeType( sk.getAttributeTypeDesc() );

        SortedEntryComparator comparator = new SortedEntryComparator( at, sk.getMatchingRuleId(), sk.isReverseOrder(),
            schemaManager );

        SortedEntrySerializer keySerializer = new SortedEntrySerializer( comparator );

        PersistedBTreeConfiguration<Entry, String> config = new PersistedBTreeConfiguration<Entry, String>();
View Full Code Here

        // let the tests also test for DIRSERVER-1953
        req.addAttributes( SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
        req.addAttributes( SchemaConstants.ENTRY_DN_AT );
       
        // tests may overwrite the fields of the below SortKey instance
        sk = new SortKey( "entryDn" );
        ctrl = new SortRequestControlImpl();
        ctrl.addSortKey( sk );
        req.addControl( ctrl );
    }
View Full Code Here

                if ( IS_DEBUG )
                {
                    LOG.debug( "AttributeTypeDesc = " + atDesc );
                }
               
                SortKey sk = new SortKey( atDesc );
                container.setCurrentKey( sk );
                container.getControl().addSortKey( sk );
            }

        };
View Full Code Here

        List<SortKey> lst = getSortKeys();

        for ( int i = 0; i < lst.size(); i++ )
        {
            SortKey sk = lst.get( i );
            int skLen = sortKeyLenList.get( i );

            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( skLen ) );

            BerValue.encode( buffer, sk.getAttributeTypeDesc() );

            if ( sk.getMatchingRuleId() != null )
            {
                BerValue.encode( buffer, sk.getMatchingRuleId() );
            }

            BerValue.encode( buffer, sk.isReverseOrder() );
        }

        return buffer;
    }
View Full Code Here

        SortRequestDecorator decorator = new SortRequestDecorator( codec );
        SortRequestControl control = ( SortRequestControl ) decorator.decode( buffer.array() );
       
        assertEquals( 1, control.getSortKeys().size() );
       
        SortKey sk = control.getSortKeys().get( 0 );
        assertEquals( "cn", sk.getAttributeTypeDesc() );
        assertEquals( "oid", sk.getMatchingRuleId() );
        assertFalse( sk.isReverseOrder() );
       
        ByteBuffer encoded = ByteBuffer.allocate( buffer.capacity() );
        decorator.computeLength();
        decorator.encode( encoded );
        assertTrue( Arrays.equals( buffer.array(), encoded.array() ) );
View Full Code Here

        SortRequestDecorator decorator = new SortRequestDecorator( codec );
        SortRequestControl control = ( SortRequestControl ) decorator.decode( buffer.array() );
       
        assertEquals( 2, control.getSortKeys().size() );
       
        SortKey sk = control.getSortKeys().get( 0 );
        assertEquals( "cn", sk.getAttributeTypeDesc() );
        assertEquals( "oid", sk.getMatchingRuleId() );
        assertFalse( sk.isReverseOrder() );
       
        sk = control.getSortKeys().get( 1 );
        assertEquals( "sn", sk.getAttributeTypeDesc() );
        assertEquals( "iod", sk.getMatchingRuleId() );
        assertTrue( sk.isReverseOrder() );
       
        ByteBuffer encoded = ByteBuffer.allocate( buffer.capacity() );
        decorator.computeLength();
        decorator.encode( encoded );
        assertTrue( Arrays.equals( buffer.array(), encoded.array() ) );
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.message.controls.SortKey

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.