Examples of MutableAttributeType


Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     *
     * @throws Exception
     */
    public void testRemoveSubstringDifference() throws Exception
    {
        MutableAttributeType o1 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o1.setSubstringOid( "substrName" ); //$NON-NLS-1$
        AttributeType o2 = new AttributeType( "1.2.3.4" ); //$NON-NLS-1$

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );
View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     *
     * @throws Exception
     */
    public void testRemoveSuperiorATDifference() throws Exception
    {
        MutableAttributeType o1 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o1.setSuperiorOid( "superiorName" ); //$NON-NLS-1$
        AttributeType o2 = new AttributeType( "1.2.3.4" ); //$NON-NLS-1$

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );
View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     *
     * @throws Exception
     */
    public void testRemoveSyntaxDifference() throws Exception
    {
        MutableAttributeType o1 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o1.setSyntaxOid( "1.2.3.4.5" ); //$NON-NLS-1$
        AttributeType o2 = new AttributeType( "1.2.3.4" ); //$NON-NLS-1$

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );
View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     *
     * @throws Exception
     */
    public void testRemoveSyntaxLengthDifference() throws Exception
    {
        MutableAttributeType o1 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o1.setSyntaxLength( 1234 );
        AttributeType o2 = new AttributeType( "1.2.3.4" ); //$NON-NLS-1$

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );
View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     * AttributeTypeImpl could be created
     * @throws NamingException
     */
    private static AttributeType createAttributeType( SearchResult sr ) throws NamingException
    {
        MutableAttributeType at = new MutableAttributeType( getOid( sr ) );
        at.setNames( getNames( sr ) );
        at.setDescription( getDescription( sr ) );
        at.setObsolete( isObsolete( sr ) );
        at.setSuperiorOid( getSuperior( sr ) );
        at.setUsage( getUsage( sr ) );
        at.setSyntaxOid( getSyntax( sr ) );
        at.setSyntaxLength( getSyntaxLength( sr ) );
        at.setCollective( isCollective( sr ) );
        at.setSingleValued( isSingleValued( sr ) );
        at.setUserModifiable( isUserModifiable( sr ) );
        at.setEqualityOid( getEquality( sr ) );
        at.setOrderingOid( getOrdering( sr ) );
        at.setSubstringOid( getSubstring( sr ) );
        return at;
    }
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.schema.MutableAttributeType

    /* no protection*/
    //This will suppress PMD.AvoidUsingHardCodedIP warnings in this class
    @SuppressWarnings("PMD.AvoidUsingHardCodedIP")
    static AttributeType getCaseIgnoringAttributeNoNumbersType()
    {
        MutableAttributeType attributeType = new MutableAttributeType( "1.1.3.1" );
        LdapSyntax syntax = new LdapSyntax( "1.1.1.1", "", true );

        syntax.setSyntaxChecker( new SyntaxChecker( "1.1.2.1" )
        {
            public boolean isValidSyntax( Object value )
            {
                if ( !( value instanceof String ) )
                {
                    return false;
                }

                String strval = ( String ) value;

                for ( char c : strval.toCharArray() )
                {
                    if ( Character.isDigit( c ) )
                    {
                        return false;
                    }
                }
                return true;
            }
        } );

        MutableMatchingRule matchingRule = new MutableMatchingRule( "1.1.2.1" );
        matchingRule.setSyntax( syntax );

        matchingRule.setLdapComparator( new LdapComparator<String>( matchingRule.getOid() )
        {
            public int compare( String o1, String o2 )
            {
                return ( o1 == null ?
                    ( o2 == null ? 0 : -1 ) :
                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
            }


            int getValue( String val )
            {
                if ( val.equals( "LOW" ) )
                {
                    return 0;
                }
                else if ( val.equals( "MEDIUM" ) )
                {
                    return 1;
                }
                else if ( val.equals( "HIGH" ) )
                {
                    return 2;
                }

                throw new IllegalArgumentException( I18n.err( I18n.ERR_472 ) );
            }
        } );

        Normalizer normalizer = new Normalizer( "1.1.1" )
        {
            public Value<?> normalize( Value<?> value ) throws LdapException
            {
                if ( value.isHumanReadable() )
                {
                    return new StringValue( Strings.toLowerCase( value.getString() ) );
                }

                throw new IllegalStateException( I18n.err( I18n.ERR_473 ) );
            }


            public String normalize( String value ) throws LdapException
            {
                return Strings.toLowerCase( value );
            }
        };

        matchingRule.setNormalizer( normalizer );

        attributeType.setEquality( matchingRule );
        attributeType.setSyntax( syntax );

        return attributeType;
    }
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.schema.MutableAttributeType

    }


    /* no protection*/static AttributeType getIA5StringAttributeType()
    {
        MutableAttributeType attributeType = new MutableAttributeType( "1.1" );
        attributeType.addName( "1.1" );
        LdapSyntax syntax = new LdapSyntax( "1.1.1", "", true );

        syntax.setSyntaxChecker( new SyntaxChecker( "1.1.2" )
        {
            public boolean isValidSyntax( Object value )
            {
                return ( ( String ) value == null ) || ( ( ( String ) value ).length() < 7 );
            }
        } );

        MutableMatchingRule matchingRule = new MutableMatchingRule( "1.1.2" );
        matchingRule.setSyntax( syntax );

        matchingRule.setLdapComparator( new LdapComparator<String>( matchingRule.getOid() )
        {
            public int compare( String o1, String o2 )
            {
                return ( ( o1 == null ) ?
                    ( o2 == null ? 0 : -1 ) :
                    ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
            }
        } );

        matchingRule.setNormalizer( new DeepTrimToLowerNormalizer( matchingRule.getOid() ) );

        attributeType.setEquality( matchingRule );
        attributeType.setSyntax( syntax );

        return attributeType;
    }
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.schema.MutableAttributeType

    }


    /* No protection */static AttributeType getBytesAttributeType()
    {
        MutableAttributeType attributeType = new MutableAttributeType( "1.2" );
        LdapSyntax syntax = new LdapSyntax( "1.2.1", "", true );

        syntax.setSyntaxChecker( new SyntaxChecker( "1.2.1" )
        {
            public boolean isValidSyntax( Object value )
            {
                return ( value == null ) || ( ( ( byte[] ) value ).length < 5 );
            }
        } );

        MutableMatchingRule matchingRule = new MutableMatchingRule( "1.2.2" );
        matchingRule.setSyntax( syntax );

        matchingRule.setLdapComparator( new ByteArrayComparator( "1.2.2" ) );

        matchingRule.setNormalizer( new Normalizer( "1.1.1" )
        {
            public Value<?> normalize( Value<?> value ) throws LdapException
            {
                if ( !value.isHumanReadable() )
                {
                    byte[] val = value.getBytes();

                    // each byte will be changed to be > 0, and spaces will be trimmed
                    byte[] newVal = new byte[val.length];

                    int i = 0;

                    for ( byte b : val )
                    {
                        newVal[i++] = ( byte ) ( b & 0x007F );
                    }

                    return new BinaryValue( Strings.trim( newVal ) );
                }

                throw new IllegalStateException( I18n.err( I18n.ERR_474 ) );
            }


            public String normalize( String value ) throws LdapException
            {
                throw new IllegalStateException( I18n.err( I18n.ERR_474 ) );
            }
        } );

        attributeType.setEquality( matchingRule );
        attributeType.setSyntax( syntax );

        return attributeType;
    }
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.schema.MutableAttributeType

    @Test(expected = IllegalStateException.class)
    public void testEvaluatorAttributeNoMatchingRule() throws Exception
    {
        LdapSyntax syntax = new BogusSyntax( 1 );
        MutableAttributeType at = new MutableAttributeType( SchemaConstants.ATTRIBUTE_TYPES_AT_OID + ".2000" );
        at.addName( "bogus" );
        at.setSchemaName( "other" );
        at.setSyntax( syntax );

        assertTrue( schemaManager.add( syntax ) );
        assertTrue( schemaManager.add( at ) );

        try
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.schema.MutableAttributeType

        MutableMatchingRule mr = new MutableMatchingRule( "1.1" );
        mr.setSyntax( syntax );
        mr.setLdapComparator( new StringComparator( "1.1" ) );

        MutableAttributeType at = new MutableAttributeType( SchemaConstants.ATTRIBUTE_TYPES_AT_OID + ".3000" );
        at.addName( "bogus" );
        at.setSchemaName( "other" );
        at.setSyntax( syntax );
        at.setOrdering( mr );

        assertTrue( schemaManager.add( syntax ) );
        assertTrue( schemaManager.add( mr ) );
        assertTrue( schemaManager.add( at ) );

        SyntaxCheckerDescription desc = new SyntaxCheckerDescription( at.getSyntax().getOid() );
        desc.setDescription( "bogus" );
        desc.setFqcn( BogusSyntax.class.getName() );
        List<String> names = new ArrayList<String>();
        names.add( "bogus" );
        desc.setNames( names );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.