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

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


     * @throws OpenLdapSchemaFileImportException
     *      if an error occurrs when importing the schema
     */
    public static Schema getSchema( InputStream inputStream, String path ) throws OpenLdapSchemaFileImportException
    {
        OpenLdapSchemaParser parser = null;
        try
        {
            parser = new OpenLdapSchemaParser();
        }
        catch ( IOException e )
        {
            throw new OpenLdapSchemaFileImportException( NLS.bind( Messages
                .getString( "OpenLdapSchemaFileImporter.NotReadCorrectly" ), new String[] { path } ), e ); //$NON-NLS-1$
        }

        try
        {
            parser.parse( inputStream );
        }
        catch ( IOException e )
        {
            throw new OpenLdapSchemaFileImportException( NLS.bind( Messages
                .getString( "OpenLdapSchemaFileImporter.NotReadCorrectly" ), new String[] { path } ), e ); //$NON-NLS-1$
        }
        catch ( ParseException e )
        {
            ExceptionMessage exceptionMessage = parseExceptionMessage( e.getMessage() );
            throw new OpenLdapSchemaFileImportException( NLS.bind( Messages
                .getString( "OpenLdapSchemaFileImporter.NotReadCorrectly" ), new String[] //$NON-NLS-1$
                { path } )
                + ( exceptionMessage == null ? "" : NLS.bind( Messages //$NON-NLS-1$
                    .getString( "OpenLdapSchemaFileImporter.ErrorMessage" ), new String[] //$NON-NLS-1$
                    { exceptionMessage.lineNumber, exceptionMessage.columnNumber, exceptionMessage.cause } ) ), e );
        }

        String schemaName = getNameFromPath( path );

        Schema schema = new SchemaImpl( schemaName );

        List<?> ats = parser.getAttributeTypes();
        for ( int i = 0; i < ats.size(); i++ )
        {
            AttributeTypeImpl at = convertAttributeType( ( AttributeTypeLiteral ) ats.get( i ) );
            at.setSchema( schemaName );
            at.setSchemaObject( schema );
            schema.addAttributeType( at );
        }

        List<?> ocs = parser.getObjectClassTypes();
        for ( int i = 0; i < ocs.size(); i++ )
        {
            ObjectClassImpl oc = convertObjectClass( ( ObjectClassLiteral ) ocs.get( i ) );
            oc.setSchema( schemaName );
            oc.setSchemaObject( schema );
View Full Code Here


            throw new NullPointerException( "the schema property must be set" );
        }

        String filePath = sourceDirectory + File.separator + schema.getSchemaName() + ".schema";
        InputStream in = new FileInputStream( filePath );
        OpenLdapSchemaParser parser = new OpenLdapSchemaParser();
        parser.parse( in );
        generateSchema( schema );
        generateAttributeTypes( parser, schema );
        generateObjectClasses( parser, schema );
        generateRest( schema );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.schema.parsers.OpenLdapSchemaParser

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.