Package org.apache.directory.shared.ldap.model.schema

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


     */
    @Test
    public void testMay() throws ParseException
    {
        String value = null;
        DITContentRule ditContentRule = null;

        // no MAY
        value = "( 1.1 )";
        ditContentRule = parser.parseDITContentRuleDescription( value );
        assertEquals( 0, ditContentRule.getMayAttributeTypeOids().size() );

        // MAY simple numericoid
        value = "( 1.1 MAY 1.2.3 )";
        ditContentRule = parser.parseDITContentRuleDescription( value );
        assertEquals( 1, ditContentRule.getMayAttributeTypeOids().size() );
        assertEquals( "1.2.3", ditContentRule.getMayAttributeTypeOids().get( 0 ) );

        // MAY mulitple
        value = "(1.1 MAY (cn$sn       $11.22.33.44.55         $  objectClass   ))";
        ditContentRule = parser.parseDITContentRuleDescription( value );
        assertEquals( 4, ditContentRule.getMayAttributeTypeOids().size() );
        assertEquals( "cn", ditContentRule.getMayAttributeTypeOids().get( 0 ) );
        assertEquals( "sn", ditContentRule.getMayAttributeTypeOids().get( 1 ) );
        assertEquals( "11.22.33.44.55", ditContentRule.getMayAttributeTypeOids().get( 2 ) );
        assertEquals( "objectClass", ditContentRule.getMayAttributeTypeOids().get( 3 ) );

        if ( !parser.isQuirksMode() )
        {
            // invalid value
            value = "( 1.1 MAY ( c_n ) )";
View Full Code Here


     */
    @Test
    public void testNot() throws ParseException
    {
        String value = null;
        DITContentRule ditContentRule = null;

        // no NOT
        value = "( 1.1 )";
        ditContentRule = parser.parseDITContentRuleDescription( value );
        assertEquals( 0, ditContentRule.getNotAttributeTypeOids().size() );

        // NOT simple numericoid
        value = "( 1.1 NOT 1.2.3 )";
        ditContentRule = parser.parseDITContentRuleDescription( value );
        assertEquals( 1, ditContentRule.getNotAttributeTypeOids().size() );
        assertEquals( "1.2.3", ditContentRule.getNotAttributeTypeOids().get( 0 ) );

        // NOT mulitple
        value = "(1.1 NOT (cn\nsn\t$11.22.33.44.55         $  objectClass   ))";
        ditContentRule = parser.parseDITContentRuleDescription( value );
        assertEquals( 4, ditContentRule.getNotAttributeTypeOids().size() );
        assertEquals( "cn", ditContentRule.getNotAttributeTypeOids().get( 0 ) );
        assertEquals( "sn", ditContentRule.getNotAttributeTypeOids().get( 1 ) );
        assertEquals( "11.22.33.44.55", ditContentRule.getNotAttributeTypeOids().get( 2 ) );
        assertEquals( "objectClass", ditContentRule.getNotAttributeTypeOids().get( 3 ) );

        if ( !parser.isQuirksMode() )
        {
            // invalid value
            value = "( 1.1 NOT ( c_n ) )";
View Full Code Here

     */
    @Test
    public void testFull() throws ParseException
    {
        String value = null;
        DITContentRule ditContentRule = null;

        value = "( 1.2.3.4.5.6.7.8.9.0 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' 'test' ) DESC 'Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577' OBSOLETE AUX ( 2.3.4.5.6.7.8.9.0.1 $ abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 ) MUST ( 3.4.5.6.7.8.9.0.1.2 $ abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 ) MAY ( 4.5.6.7.8.9.0.1.2.3 $ abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 ) NOT ( 5.6.7.8.9.0.1.2.3.4 $ abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 ) X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )";
        ditContentRule = parser.parseDITContentRuleDescription( value );

        assertEquals( "1.2.3.4.5.6.7.8.9.0", ditContentRule.getOid() );
        assertEquals( 2, ditContentRule.getNames().size() );
        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", ditContentRule.getNames()
            .get( 0 ) );
        assertEquals( "test", ditContentRule.getNames().get( 1 ) );
        assertEquals( "Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577", ditContentRule.getDescription() );
        assertTrue( ditContentRule.isObsolete() );
        assertEquals( 2, ditContentRule.getAuxObjectClassOids().size() );
        assertEquals( "2.3.4.5.6.7.8.9.0.1", ditContentRule.getAuxObjectClassOids().get( 0 ) );
        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", ditContentRule
            .getAuxObjectClassOids().get( 1 ) );
        assertEquals( 2, ditContentRule.getMustAttributeTypeOids().size() );
        assertEquals( "3.4.5.6.7.8.9.0.1.2", ditContentRule.getMustAttributeTypeOids().get( 0 ) );
        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", ditContentRule
            .getMustAttributeTypeOids()
            .get( 1 ) );
        assertEquals( 2, ditContentRule.getMayAttributeTypeOids().size() );
        assertEquals( "4.5.6.7.8.9.0.1.2.3", ditContentRule.getMayAttributeTypeOids().get( 0 ) );
        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", ditContentRule
            .getMayAttributeTypeOids()
            .get( 1 ) );
        assertEquals( 2, ditContentRule.getNotAttributeTypeOids().size() );
        assertEquals( "5.6.7.8.9.0.1.2.3.4", ditContentRule.getNotAttributeTypeOids().get( 0 ) );
        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", ditContentRule
            .getNotAttributeTypeOids()
            .get( 1 ) );
        assertEquals( 2, ditContentRule.getExtensions().size() );
        assertNotNull( ditContentRule.getExtensions().get( "X-TEST-a" ) );
        assertEquals( 2, ditContentRule.getExtensions().get( "X-TEST-a" ).size() );
        assertEquals( "test1-1", ditContentRule.getExtensions().get( "X-TEST-a" ).get( 0 ) );
        assertEquals( "test1-2", ditContentRule.getExtensions().get( "X-TEST-a" ).get( 1 ) );
        assertNotNull( ditContentRule.getExtensions().get( "X-TEST-b" ) );
        assertEquals( 2, ditContentRule.getExtensions().get( "X-TEST-b" ).size() );
        assertEquals( "test2-1", ditContentRule.getExtensions().get( "X-TEST-b" ).get( 0 ) );
        assertEquals( "test2-2", ditContentRule.getExtensions().get( "X-TEST-b" ).get( 1 ) );
    }
View Full Code Here

        }

        // DITContentRule
        try
        {
            DITContentRule ditContentRule = ditContentRuleRegistry.lookup( name );

            if ( ditContentRule != null )
            {
                return ditContentRule.getOid();
            }
        }
        catch ( LdapException ne )
        {
            // Fall down to the next registry
View Full Code Here

        int pos = 0;

        for ( Value<?> value : attr )
        {
            DITContentRule ditContentRule = null;

            try
            {
                ditContentRule = ditContentRuleParser.parseDITContentRuleDescription( value.getString() );
                ditContentRule.setSpecification( value.getString() );
            }
            catch ( ParseException e )
            {
                LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_427,
                        value.getString() ) );
View Full Code Here

        {
            String desc = value.getString();

            try
            {
                DitContentRule ditContentRule = DCR_DESCR_SCHEMA_PARSER.parseDITContentRuleDescription( desc );

                updateSchemas( ditContentRule );
            }
            catch ( ParseException pe )
            {
View Full Code Here

            {
                SchemaObject schemaObject = schemaObjectWrapper.get();

                if ( schemaObject instanceof DitContentRule )
                {
                    DitContentRule ditContentRule = ( DitContentRule ) schemaObject;

                    Entry ditContentRuleEntry = factory.convert( ditContentRule, schema, null );

                    ditContentRuleEntries.add( ditContentRuleEntry );
                }
View Full Code Here

        }

        // DitContentRule
        try
        {
            DitContentRule ditContentRule = ditContentRuleRegistry.lookup( name );

            if ( ditContentRule != null )
            {
                return ditContentRule.getOid();
            }
        }
        catch ( LdapException ne )
        {
            // Fall down to the next registry
View Full Code Here

        int pos = 0;

        for ( Value<?> value : attr )
        {
            DitContentRule ditContentRule = null;

            try
            {
                ditContentRule = ditContentRuleParser.parseDITContentRuleDescription( value.getString() );
                ditContentRule.setSpecification( value.getString() );
            }
            catch ( ParseException e )
            {
                LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException(
                    ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_427,
View Full Code Here

        {
            String desc = value.getString();

            try
            {
                DitContentRule ditContentRule = DCR_DESCR_SCHEMA_PARSER.parseDITContentRuleDescription( desc );

                updateSchemas( ditContentRule );
            }
            catch ( ParseException pe )
            {
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.schema.DitContentRule

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.