Package org.apache.directory.studio.schemaeditor.model

Examples of org.apache.directory.studio.schemaeditor.model.SchemaImpl


    /* (non-Javadoc)
     * @see org.eclipse.jface.wizard.Wizard#performFinish()
     */
    public boolean performFinish()
    {
        SchemaImpl schema = new SchemaImpl( page.getSchemaName() );
        schema.setProject( Activator.getDefault().getProjectsHandler().getOpenProject() );
        Activator.getDefault().getSchemaHandler().addSchema( schema );

        return true;
    }
View Full Code Here


        throws NamingException
    {
        monitor.subTask( name ); //$NON-NLS-1$

        // Creating the schema
        Schema schema = new SchemaImpl( name );

        // Looking for the nodes of the schema
        SearchControls constraintSearch = new SearchControls();
        constraintSearch.setSearchScope( SearchControls.SUBTREE_SCOPE );

        NamingEnumeration<SearchResult> answer = wrapper.search( "cn=" + name + ", ou=schema", "(objectclass=*)",
            constraintSearch, DEREF_ALIAS_METHOD, HANDLE_REFERALS_METHOD, null, monitor, null );
        if ( answer != null )
        {
            try
            {
                while ( answer.hasMore() )
                {
                    SearchResult searchResult = ( SearchResult ) answer.next();
                    switch ( getNodeType( searchResult ) )
                    {
                        case ATTRIBUTE_TYPE:
                            AttributeTypeImpl at = createAttributeType( searchResult );
                            at.setSchema( name );
                            at.setSchemaObject( schema );
                            schema.addAttributeType( at );
                            break;
                        case OBJECT_CLASS:
                            ObjectClassImpl oc = createObjectClass( searchResult );
                            oc.setSchema( name );
                            oc.setSchemaObject( schema );
                            schema.addObjectClass( oc );
                            break;
                        case MATCHING_RULE:
                            MatchingRuleImpl mr = createMatchingRule( searchResult );
                            mr.setSchema( name );
                            mr.setSchemaObject( schema );
                            schema.addMatchingRule( mr );
                            break;
                        case SYNTAX:
                            SyntaxImpl syntax = createSyntax( searchResult );
                            syntax.setSchema( name );
                            syntax.setSchemaObject( schema );
                            schema.addSyntax( syntax );
                            break;
                        default:
                            break;
                    }
                }
View Full Code Here

     *      the corresponding schema
     */
    public static Schema readSchema( Element element, String path ) throws XMLSchemaFileImportException
    {
        // Creating the schema with an empty name
        Schema schema = new SchemaImpl( null );

        // Name
        schema.setName( getSchemaName( element, path ) );

        // Attribute Types
        readAttributeTypes( element, schema );

        // Object Classes
View Full Code Here

        {
            targetSchema = targetSchemas.get( targetSchemaName );
        }
        else
        {
            targetSchema = new SchemaImpl( targetSchemaName );
            targetSchema.setProject( targetProject );
        }
        targetSchemas.put( targetSchemaName, targetSchema );
        return targetSchema;
    }
View Full Code Here

                    { 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 );
            schema.addObjectClass( oc );
        }

        return schema;
    }
View Full Code Here

    private static Schema getSchema( JNDIConnectionWrapper wrapper, SearchResult searchResult,
        StudioProgressMonitor monitor ) throws NamingException, ParseException
    {
        // Creating the schema
        Schema schema = new SchemaImpl( "schema" ); //$NON-NLS-1$

        Attribute attributeTypesAttribute = searchResult.getAttributes().get( "attributeTypes" );
        if ( attributeTypesAttribute != null )
        {
            NamingEnumeration<?> ne = attributeTypesAttribute.getAll();
            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() );
                    impl.setSyntaxOid( mrd.getSyntax() );
                    impl.setSchema( schema.getName() );
                    impl.setSchemaObject( schema );

                    schema.addMatchingRule( impl );
                }
            }
        }
        // if online: assume all received matching rules in attributes are valid -> create dummy matching rules if missing
        for ( AttributeTypeImpl at : schema.getAttributeTypes() )
        {
            String equalityName = at.getEqualityName();
            String orderingName = at.getOrderingName();
            String substrName = at.getSubstrName();
            checkMatchingRules( schema, equalityName, orderingName, substrName );
View Full Code Here

        throws NamingException
    {
        monitor.subTask( "Reading schema '" + name + "'" );

        // Creating the schema
        Schema schema = new SchemaImpl( name );

        // Looking for the nodes of the schema
        SearchControls constraintSearch = new SearchControls();
        constraintSearch.setSearchScope( SearchControls.SUBTREE_SCOPE );

        NamingEnumeration<SearchResult> answer = wrapper.search( "cn=" + name + ", ou=schema", "(objectclass=*)",
            constraintSearch, DEREF_ALIAS_METHOD, HANDLE_REFERALS_METHOD, null, monitor, null );
        if ( answer != null )
        {
            while ( answer.hasMoreElements() )
            {
                SearchResult searchResult = ( SearchResult ) answer.nextElement();
                switch ( getNodeType( searchResult ) )
                {
                    case ATTRIBUTE_TYPE:
                        AttributeTypeImpl at = createAttributeType( searchResult );
                        at.setSchema( name );
                        schema.addAttributeType( at );
                        break;
                    case OBJECT_CLASS:
                        ObjectClassImpl oc = createObjectClass( searchResult );
                        oc.setSchema( name );
                        schema.addObjectClass( oc );
                        break;
                    case MATCHING_RULE:
                        MatchingRuleImpl mr = createMatchingRule( searchResult );
                        mr.setSchema( name );
                        schema.addMatchingRule( mr );
                        break;
                    case SYNTAX:
                        SyntaxImpl syntax = createSyntax( searchResult );
                        syntax.setSchema( name );
                        schema.addSyntax( syntax );
                        break;
                    default:
                        break;
                }
            }
View Full Code Here

            throw new OpenLdapSchemaFileImportException( "The file '" + path + "' can not be read correctly." );
        }

        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 );
            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 );
            schema.addObjectClass( oc );
        }

        return schema;
    }
View Full Code Here

        throws NamingException
    {
        monitor.subTask( "Reading schema '" + name + "'" );

        // Creating the schema
        Schema schema = new SchemaImpl( name );

        // Looking for the nodes of the schema
        SearchControls constraintSearch = new SearchControls();
        constraintSearch.setSearchScope( SearchControls.SUBTREE_SCOPE );
        NamingEnumeration<SearchResult> answer = wrapper.search( "cn=" + name + ", ou=schema", "(objectclass=*)",
            constraintSearch, DEREF_ALIAS_METHOD, HANDLE_REFERALS_METHOD, null, monitor );
        if ( answer != null )
        {
            while ( answer.hasMoreElements() )
            {
                SearchResult searchResult = ( SearchResult ) answer.nextElement();
                switch ( getNodeType( searchResult ) )
                {
                    case ATTRIBUTE_TYPE:
                        AttributeTypeImpl at = createAttributeType( searchResult );
                        at.setSchema( name );
                        schema.addAttributeType( at );
                        break;
                    case OBJECT_CLASS:
                        ObjectClassImpl oc = createObjectClass( searchResult );
                        oc.setSchema( name );
                        schema.addObjectClass( oc );
                        break;
                    case MATCHING_RULE:
                        MatchingRuleImpl mr = createMatchingRule( searchResult );
                        mr.setSchema( name );
                        schema.addMatchingRule( mr );
                        break;
                    case SYNTAX:
                        SyntaxImpl syntax = createSyntax( searchResult );
                        syntax.setSchema( name );
                        schema.addSyntax( syntax );
                        break;
                    default:
                        break;
                }
            }
View Full Code Here

     *      the corresponding schema
     */
    public static Schema readSchema( Element element, String path ) throws XMLSchemaFileImportException
    {
        // Creating the schema with an empty name
        Schema schema = new SchemaImpl( null );

        // Name
        schema.setName( getSchemaName( element, path ) );

        // Attribute Types
        readAttributeTypes( element, schema );

        // Object Classes
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.schemaeditor.model.SchemaImpl

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.