Examples of AttributeTypeDescriptionSchemaParser


Examples of org.apache.directory.api.ldap.model.schema.parsers.AttributeTypeDescriptionSchemaParser

        setSchemaRecord( schemaRecord );
        setDn( new Dn( schemaRecord.getDnLine().getValueAsString() ) );

        ObjectClassDescriptionSchemaParser ocdPparser = new ObjectClassDescriptionSchemaParser();
        ocdPparser.setQuirksMode( true );
        AttributeTypeDescriptionSchemaParser atdParser = new AttributeTypeDescriptionSchemaParser();
        atdParser.setQuirksMode( true );
        LdapSyntaxDescriptionSchemaParser lsdParser = new LdapSyntaxDescriptionSchemaParser();
        lsdParser.setQuirksMode( true );
        MatchingRuleDescriptionSchemaParser mrdParser = new MatchingRuleDescriptionSchemaParser();
        mrdParser.setQuirksMode( true );
        MatchingRuleUseDescriptionSchemaParser mrudParser = new MatchingRuleUseDescriptionSchemaParser();
        mrudParser.setQuirksMode( true );

        LdifAttrValLine[] lines = schemaRecord.getAttrVals();
        for ( int i = 0; i < lines.length; i++ )
        {
            LdifAttrValLine line = lines[i];
            String attributeName = line.getUnfoldedAttributeDescription();
            String value = line.getValueAsString();
            List<String> ldifValues = new ArrayList<String>( 1 );
            ldifValues.add( value );

            try
            {
                if ( attributeName.equalsIgnoreCase( SchemaConstants.OBJECT_CLASSES_AT ) )
                {
                    MutableObjectClass ocd = ocdPparser.parseObjectClassDescription( value );
                    ocd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addObjectClass( ocd );
                }
                else if ( attributeName.equalsIgnoreCase( SchemaConstants.ATTRIBUTE_TYPES_AT ) )
                {
                    AttributeType atd = atdParser.parseAttributeTypeDescription( value );
                    atd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addAttributeType( atd );
                }
                else if ( attributeName.equalsIgnoreCase( SchemaConstants.LDAP_SYNTAXES_AT ) )
                {
View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.parsers.AttributeTypeDescriptionSchemaParser

                {
                    String value = ( String ) ne.nextElement();

                    try
                    {
                        AttributeTypeDescriptionSchemaParser parser = new AttributeTypeDescriptionSchemaParser();
                        parser.setQuirksMode( true );

                        AttributeType atd = parser.parseAttributeTypeDescription( value );

                        MutableAttributeType impl = new MutableAttributeType( atd.getOid() );
                        impl.setNames( atd.getNames().toArray( new String[0] ) );
                        impl.setDescription( atd.getDescription() );
                        impl.setSuperiorOid( atd.getSuperiorOid() );
                        impl.setUsage( atd.getUsage() );
                        impl.setSyntaxOid( atd.getSyntaxOid() );
                        impl.setSyntaxLength( atd.getSyntaxLength() );
                        impl.setObsolete( atd.isObsolete() );
                        impl.setCollective( atd.isCollective() );
                        impl.setSingleValued( atd.isSingleValued() );
                        impl.setUserModifiable( atd.isUserModifiable() );
                        impl.setEqualityOid( atd.getEqualityOid() );
                        impl.setOrderingOid( atd.getOrderingOid() );
                        impl.setSubstringOid( atd.getSubstringOid() );
                        impl.setSchemaName( schema.getSchemaName() );

                        // Active Directory hack
                        if ( impl.getSyntaxOid() != null && "OctetString".equalsIgnoreCase( impl.getSyntaxOid() ) ) //$NON-NLS-1$
                        {
                            impl.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.40" ); //$NON-NLS-1$
                        }

                        schema.addAttributeType( impl );
                    }
                    catch ( ParseException e )
                    {
                        // Logging the exception and incrementing the counter
                        PluginUtils.logError( "Unable to parse the attribute type.", e );
                        parseErrorCount++;
                    }
                }
            }
        }

        Attribute objectClassesAttribute = searchResult.getAttributes().get( "objectClasses" ); //$NON-NLS-1$
        if ( objectClassesAttribute != null )
        {
            NamingEnumeration<?> ne = objectClassesAttribute.getAll();
            if ( ne != null )
            {
                while ( ne.hasMoreElements() )
                {
                    String value = ( String ) ne.nextElement();

                    try
                    {
                        ObjectClassDescriptionSchemaParser parser = new ObjectClassDescriptionSchemaParser();
                        parser.setQuirksMode( true );
                        ObjectClass ocd = parser.parseObjectClassDescription( value );

                        MutableObjectClass impl = new MutableObjectClass( ocd.getOid() );
                        impl.setNames( ocd.getNames().toArray( new String[0] ) );
                        impl.setDescription( ocd.getDescription() );
                        impl.setSuperiorOids( ocd.getSuperiorOids() );
                        impl.setType( ocd.getType() );
                        impl.setObsolete( ocd.isObsolete() );
                        impl.setMustAttributeTypeOids( ocd.getMustAttributeTypeOids() );
                        impl.setMayAttributeTypeOids( ocd.getMayAttributeTypeOids() );
                        impl.setSchemaName( schema.getSchemaName() );

                        schema.addObjectClass( impl );
                    }
                    catch ( ParseException e )
                    {
                        // Logging the exception and incrementing the counter
                        PluginUtils.logError( "Unable to parse the object class.", e );
                        parseErrorCount++;
                    }
                }
            }
        }

        Attribute ldapSyntaxesAttribute = searchResult.getAttributes().get( "ldapSyntaxes" ); //$NON-NLS-1$
        if ( ldapSyntaxesAttribute != null )
        {
            NamingEnumeration<?> ne = ldapSyntaxesAttribute.getAll();
            if ( ne != null )
            {
                while ( ne.hasMoreElements() )
                {
                    String value = ( String ) ne.nextElement();

                    try
                    {
                        LdapSyntaxDescriptionSchemaParser parser = new LdapSyntaxDescriptionSchemaParser();
                        parser.setQuirksMode( true );
                        LdapSyntax lsd = parser.parseLdapSyntaxDescription( value );

                        LdapSyntax impl = new LdapSyntax( lsd.getOid() );
                        impl.setDescription( lsd.getDescription() );
                        impl.setNames( new String[]
                            { lsd.getDescription() } );
                        //impl.setObsolete( lsd.isObsolete() );
                        impl.setHumanReadable( true );
                        impl.setSchemaName( schema.getSchemaName() );

                        schema.addSyntax( impl );
                    }
                    catch ( ParseException e )
                    {
                        // Logging the exception and incrementing the counter
                        PluginUtils.logError( "Unable to parse the syntax.", e );
                        parseErrorCount++;
                    }
                }
            }
        }

        // if online: assume all received syntaxes in attributes are valid -> create dummy syntaxes if missing
        for ( AttributeType at : schema.getAttributeTypes() )
        {
            String syntaxOid = at.getSyntaxOid();
            if ( syntaxOid != null && schema.getSyntax( syntaxOid ) == null )
            {
                LdapSyntax impl = new LdapSyntax( syntaxOid );
                impl.setSchemaName( schema.getSchemaName() );
                String oidDescription = Utils.getOidDescription( syntaxOid );
                impl.setDescription( oidDescription != null ? oidDescription : "Dummy" ); //$NON-NLS-1$
                impl.setNames( new String[]
                    { impl.getDescription() } );
                schema.addSyntax( impl );
            }
        }

        Attribute matchingRulesAttribute = searchResult.getAttributes().get( "matchingRules" ); //$NON-NLS-1$
        if ( matchingRulesAttribute != null )
        {
            NamingEnumeration<?> ne = matchingRulesAttribute.getAll();
            if ( ne != null )
            {
                while ( ne.hasMoreElements() )
                {
                    String value = ( String ) ne.nextElement();

                    try
                    {
                        MatchingRuleDescriptionSchemaParser parser = new MatchingRuleDescriptionSchemaParser();
                        parser.setQuirksMode( true );
                        MatchingRule mrd = parser.parseMatchingRuleDescription( value );

                        MutableMatchingRule impl = new MutableMatchingRule( mrd.getOid() );
                        impl.setDescription( mrd.getDescription() );
                        impl.setNames( mrd.getNames().toArray( new String[0] ) );
                        impl.setObsolete( mrd.isObsolete() );
View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.parsers.AttributeTypeDescriptionSchemaParser


    @Before
    public void setUp() throws Exception
    {
        parser = new AttributeTypeDescriptionSchemaParser();
        parser.setParserMonitor( new ConsoleParserMonitor() );
    }
View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.parsers.AttributeTypeDescriptionSchemaParser


    private void testSubschemSubentryRendererAndParserRoundtrip( AttributeType original ) throws ParseException
    {
        String renderedOriginal = SchemaObjectRenderer.SUBSCHEMA_SUBENTRY_RENDERER.render( original );
        AttributeType parsed = new AttributeTypeDescriptionSchemaParser().parse( renderedOriginal );
        String renderedParsed = SchemaObjectRenderer.SUBSCHEMA_SUBENTRY_RENDERER.render( parsed );

        assertTrue( original.equals( parsed ) );
        assertTrue( renderedOriginal.equals( renderedParsed ) );
    }
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.schema.parsers.AttributeTypeDescriptionSchemaParser


    @Before
    public void setUp() throws Exception
    {
        parser = new AttributeTypeDescriptionSchemaParser();
        parser.setParserMonitor( new ConsoleParserMonitor() );
    }
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.schema.parsers.AttributeTypeDescriptionSchemaParser


    @Before
    public void setUp() throws Exception
    {
        parser = new AttributeTypeDescriptionSchemaParser();
        parser.setParserMonitor( new ConsoleParserMonitor() );
    }
View Full Code Here

Examples of org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescriptionSchemaParser

            if ( ne != null )
            {
                while ( ne.hasMoreElements() )
                {
                    String value = ( String ) ne.nextElement();
                    AttributeTypeDescriptionSchemaParser parser = new AttributeTypeDescriptionSchemaParser();
                    parser.setQuirksMode( true );
                    AttributeTypeDescription atd = parser.parseAttributeTypeDescription( value );

                    AttributeTypeImpl impl = new AttributeTypeImpl( atd.getNumericOid() );
                    impl.setOid( atd.getNumericOid() );
                    impl.setNames( atd.getNames().toArray( new String[0] ) );
                    impl.setDescription( atd.getDescription() );
                    impl.setSuperiorName( atd.getSuperType() );
                    impl.setUsage( atd.getUsage() );
                    impl.setSyntaxOid( atd.getSyntax() );
                    impl.setLength( atd.getSyntaxLength() );
                    impl.setObsolete( atd.isObsolete() );
                    impl.setCollective( atd.isCollective() );
                    impl.setSingleValue( atd.isSingleValued() );
                    impl.setCanUserModify( atd.isUserModifiable() );
                    impl.setEqualityName( atd.getEqualityMatchingRule() );
                    impl.setOrderingName( atd.getOrderingMatchingRule() );
                    impl.setSubstrName( atd.getSubstringsMatchingRule() );
                    impl.setSchema( schema.getName() );
                    impl.setSchemaObject( schema );

                    // Active Directory hack
                    if ( impl.getSyntaxOid() != null && "OctetString".equalsIgnoreCase( impl.getSyntaxOid() ) ) //$NON-NLS-1$
                    {
                        impl.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.40" );
                    }

                    schema.addAttributeType( impl );
                }
            }
        }

        Attribute objectClassesAttribute = searchResult.getAttributes().get( "objectClasses" );
        if ( objectClassesAttribute != null )
        {
            NamingEnumeration<?> ne = objectClassesAttribute.getAll();
            if ( ne != null )
            {
                while ( ne.hasMoreElements() )
                {
                    String value = ( String ) ne.nextElement();
                    ObjectClassDescriptionSchemaParser parser = new ObjectClassDescriptionSchemaParser();
                    parser.setQuirksMode( true );
                    ObjectClassDescription ocd = parser.parseObjectClassDescription( value );

                    ObjectClassImpl impl = new ObjectClassImpl( ocd.getNumericOid() );
                    impl.setOid( ocd.getNumericOid() );
                    impl.setNames( ocd.getNames().toArray( new String[0] ) );
                    impl.setDescription( ocd.getDescription() );
                    impl.setSuperClassesNames( ocd.getSuperiorObjectClasses().toArray( new String[0] ) );
                    impl.setType( ocd.getKind() );
                    impl.setObsolete( ocd.isObsolete() );
                    impl.setMustNamesList( ocd.getMustAttributeTypes().toArray( new String[0] ) );
                    impl.setMayNamesList( ocd.getMayAttributeTypes().toArray( new String[0] ) );
                    impl.setSchema( schema.getName() );
                    impl.setSchemaObject( schema );

                    schema.addObjectClass( impl );
                }
            }
        }

        Attribute ldapSyntaxesAttribute = searchResult.getAttributes().get( "ldapSyntaxes" );
        if ( ldapSyntaxesAttribute != null )
        {
            NamingEnumeration<?> ne = ldapSyntaxesAttribute.getAll();
            if ( ne != null )
            {
                while ( ne.hasMoreElements() )
                {
                    String value = ( String ) ne.nextElement();
                    LdapSyntaxDescriptionSchemaParser parser = new LdapSyntaxDescriptionSchemaParser();
                    parser.setQuirksMode( true );
                    LdapSyntaxDescription lsd = parser.parseLdapSyntaxDescription( value );

                    SyntaxImpl impl = new SyntaxImpl( lsd.getNumericOid() );
                    impl.setDescription( lsd.getDescription() );
                    impl.setNames( new String[]
                        { lsd.getDescription() } );
                    //impl.setObsolete( lsd.isObsolete() );
                    impl.setHumanReadable( true );
                    impl.setSchema( schema.getName() );
                    impl.setSchemaObject( schema );

                    schema.addSyntax( impl );
                }
            }
        }
        // if online: assume all received syntaxes in attributes are valid -> create dummy syntaxes if missing
        for ( AttributeTypeImpl at : schema.getAttributeTypes() )
        {
            String syntaxOid = at.getSyntaxOid();
            if ( syntaxOid != null && schema.getSyntax( syntaxOid ) == null )
            {
                SyntaxImpl impl = new SyntaxImpl( syntaxOid );
                impl.setSchema( schema.getName() );
                impl.setSchemaObject( schema );
                String oidDescription = Utils.getOidDescription( syntaxOid );
                impl.setDescription( oidDescription != null ? oidDescription : "Dummy" ); //$NON-NLS-1$
                impl.setNames( new String[]
                    { impl.getDescription() } );
                schema.addSyntax( impl );
            }
        }

        Attribute matchingRulesAttribute = searchResult.getAttributes().get( "matchingRules" );
        if ( matchingRulesAttribute != null )
        {
            NamingEnumeration<?> ne = matchingRulesAttribute.getAll();
            if ( ne != null )
            {
                while ( ne.hasMoreElements() )
                {
                    String value = ( String ) ne.nextElement();
                    MatchingRuleDescriptionSchemaParser parser = new MatchingRuleDescriptionSchemaParser();
                    parser.setQuirksMode( true );
                    MatchingRuleDescription mrd = parser.parseMatchingRuleDescription( value );

                    MatchingRuleImpl impl = new MatchingRuleImpl( mrd.getNumericOid() );
                    impl.setDescription( mrd.getDescription() );
                    impl.setNames( mrd.getNames().toArray( new String[0] ) );
                    impl.setObsolete( mrd.isObsolete() );
View Full Code Here

Examples of org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescriptionSchemaParser

        setSchemaRecord( schemaRecord );
        setDn( new LdapDN( schemaRecord.getDnLine().getValueAsString() ) );

        ObjectClassDescriptionSchemaParser ocdPparser = new ObjectClassDescriptionSchemaParser();
        ocdPparser.setQuirksMode( true );
        AttributeTypeDescriptionSchemaParser atdParser = new AttributeTypeDescriptionSchemaParser();
        atdParser.setQuirksMode( true );
        LdapSyntaxDescriptionSchemaParser lsdParser = new LdapSyntaxDescriptionSchemaParser();
        lsdParser.setQuirksMode( true );
        MatchingRuleDescriptionSchemaParser mrdParser = new MatchingRuleDescriptionSchemaParser();
        mrdParser.setQuirksMode( true );
        MatchingRuleUseDescriptionSchemaParser mrudParser = new MatchingRuleUseDescriptionSchemaParser();
        mrudParser.setQuirksMode( true );

        LdifAttrValLine[] lines = schemaRecord.getAttrVals();
        for ( int i = 0; i < lines.length; i++ )
        {
            LdifAttrValLine line = lines[i];
            String attributeName = line.getUnfoldedAttributeDescription();
            String value = line.getValueAsString();
            List<String> ldifValues = new ArrayList<String>( 1 );
            ldifValues.add( value );

            try
            {
                if ( attributeName.equalsIgnoreCase( SchemaConstants.OBJECT_CLASSES_AT ) )
                {
                    ObjectClassDescription ocd = ocdPparser.parseObjectClassDescription( value );
                    ocd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addObjectClassDescription( ocd );
                }
                else if ( attributeName.equalsIgnoreCase( SchemaConstants.ATTRIBUTE_TYPES_AT ) )
                {
                    AttributeTypeDescription atd = atdParser.parseAttributeTypeDescription( value );
                    atd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addAttributeTypeDescription( atd );
                }
                else if ( attributeName.equalsIgnoreCase( SchemaConstants.LDAP_SYNTAXES_AT ) )
                {
View Full Code Here

Examples of org.apache.directory.shared.ldap.schema.syntax.parser.AttributeTypeDescriptionSchemaParser

                    ocd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addObjectClassDescription( ocd );
                }
                else if ( attributeName.equalsIgnoreCase( Schema.SCHEMA_ATTRIBUTE_ATTRIBUTETYPES ) )
                {
                    AttributeTypeDescriptionSchemaParser parser = new AttributeTypeDescriptionSchemaParser();
                    parser.setQuirksMode( true );
                    AttributeTypeDescription atd = parser.parseAttributeTypeDescription( value );
                    atd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addAttributeTypeDescription( atd );
                }
                else if ( attributeName.equalsIgnoreCase( Schema.SCHEMA_ATTRIBUTE_LDAPSYNTAXES ) )
                {
                    LdapSyntaxDescriptionSchemaParser parser = new LdapSyntaxDescriptionSchemaParser();
                    parser.setQuirksMode( true );
                    LdapSyntaxDescription lsd = parser.parseLdapSyntaxDescription( value );
                    lsd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addLdapSyntaxDescription( lsd );
                }
                else if ( attributeName.equalsIgnoreCase( Schema.SCHEMA_ATTRIBUTE_MATCHINGRULES ) )
                {
                    MatchingRuleDescriptionSchemaParser parser = new MatchingRuleDescriptionSchemaParser();
                    parser.setQuirksMode( true );
                    MatchingRuleDescription mrd = parser.parseMatchingRuleDescription( value );
                    mrd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addMatchingRuleDescription( mrd );
                }
                else if ( attributeName.equalsIgnoreCase( Schema.SCHEMA_ATTRIBUTE_MATCHINGRULEUSE ) )
                {
                    MatchingRuleUseDescriptionSchemaParser parser = new MatchingRuleUseDescriptionSchemaParser();
                    parser.setQuirksMode( true );
                    MatchingRuleUseDescription mrud = parser.parseMatchingRuleUseDescription( value );
                    mrud.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addMatchingRuleUseDescription( mrud );
                }
                else if ( attributeName.equalsIgnoreCase( IAttribute.OPERATIONAL_ATTRIBUTE_CREATE_TIMESTAMP ) )
                {
View Full Code Here

Examples of org.apache.directory.shared.ldap.schema.syntax.parser.AttributeTypeDescriptionSchemaParser

                    ocd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addObjectClassDescription( ocd );
                }
                else if ( attributeName.equalsIgnoreCase( Schema.SCHEMA_ATTRIBUTE_ATTRIBUTETYPES ) )
                {
                    AttributeTypeDescriptionSchemaParser parser = new AttributeTypeDescriptionSchemaParser();
                    parser.setQuirksMode( true );
                    AttributeTypeDescription atd = parser.parseAttributeTypeDescription( value );
                    atd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addAttributeTypeDescription( atd );
                }
                else if ( attributeName.equalsIgnoreCase( Schema.SCHEMA_ATTRIBUTE_LDAPSYNTAXES ) )
                {
                    LdapSyntaxDescriptionSchemaParser parser = new LdapSyntaxDescriptionSchemaParser();
                    parser.setQuirksMode( true );
                    LdapSyntaxDescription lsd = parser.parseLdapSyntaxDescription( value );
                    lsd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addLdapSyntaxDescription( lsd );
                }
                else if ( attributeName.equalsIgnoreCase( Schema.SCHEMA_ATTRIBUTE_MATCHINGRULES ) )
                {
                    MatchingRuleDescriptionSchemaParser parser = new MatchingRuleDescriptionSchemaParser();
                    parser.setQuirksMode( true );
                    MatchingRuleDescription mrd = parser.parseMatchingRuleDescription( value );
                    mrd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addMatchingRuleDescription( mrd );
                }
                else if ( attributeName.equalsIgnoreCase( Schema.SCHEMA_ATTRIBUTE_MATCHINGRULEUSE ) )
                {
                    MatchingRuleUseDescriptionSchemaParser parser = new MatchingRuleUseDescriptionSchemaParser();
                    parser.setQuirksMode( true );
                    MatchingRuleUseDescription mrud = parser.parseMatchingRuleUseDescription( value );
                    mrud.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addMatchingRuleUseDescription( mrud );
                }
                else if ( attributeName.equalsIgnoreCase( IAttribute.OPERATIONAL_ATTRIBUTE_CREATE_TIMESTAMP ) )
                {
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.