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

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


     */
    public String getText( Object obj )
    {
        if ( obj instanceof LdapSyntax )
        {
            LdapSyntax syntax = ( LdapSyntax ) obj;

            // Getting description (and name for backward compatibility)
            String description = syntax.getDescription();
            String name = syntax.getName();

            if ( ( description != null ) || ( name != null ) )
            {
                StringBuilder sb = new StringBuilder();

                if ( description != null )
                {
                    // Using description
                    sb.append( description );
                }
                else
                {
                    // Using name (for backward compatibility)
                    sb.append( name );
                }

                sb.append( "  -  (" ); //$NON-NLS-1$
                sb.append( syntax.getOid() );
                sb.append( ")" ); //$NON-NLS-1$

                return sb.toString();
            }
            else
            {
                return NLS.bind(
                    Messages.getString( "ATESyntaxComboLabelProvider.None" ), new String[] { syntax.getOid() } ); //$NON-NLS-1$
            }
        }
        else if ( obj instanceof NonExistingSyntax )
        {
            return ( ( NonExistingSyntax ) obj ).getDisplayName();
View Full Code Here


            syntaxComboViewer.setSelection( new StructuredSelection( new NonExistingSyntax( NonExistingSyntax.NONE ) ),
                true );
        }
        else
        {
            LdapSyntax syntax = schemaHandler.getSyntax( syntaxOID );
            if ( syntax != null )
            {
                syntaxComboViewer.setSelection( new StructuredSelection( syntax ), true );
            }
            else
View Full Code Here

                    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() );
                        impl.setSyntaxOid( mrd.getSyntaxOid() );
                        impl.setSchemaName( schema.getSchemaName() );

                        schema.addMatchingRule( impl );
                    }
                    catch ( ParseException e )
                    {
View Full Code Here

     *      the schema
     * @throws XMLSchemaFileImportException
     */
    private static void readSyntax( Element element, Schema schema ) throws XMLSchemaFileImportException
    {
        LdapSyntax syntax = null;

        // OID
        Attribute oidAttribute = element.attribute( OID_TAG );
        if ( ( oidAttribute != null ) && ( !oidAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$
        {
            syntax = new LdapSyntax( oidAttribute.getValue() );
        }
        else
        {
            throw new XMLSchemaFileImportException( Messages.getString( "XMLSchemaFileImporter.InvalidSyntaxForOID" ) ); //$NON-NLS-1$
        }

        // Schema
        syntax.setSchemaName( schema.getSchemaName() );

        // Aliases
        Element aliasesElement = element.element( ALIASES_TAG );
        if ( aliasesElement != null )
        {
            List<String> aliases = new ArrayList<String>();
            for ( Iterator<?> i = aliasesElement.elementIterator( ALIAS_TAG ); i.hasNext(); )
            {
                Element aliasElement = ( Element ) i.next();
                aliases.add( aliasElement.getText() );
            }
            if ( aliases.size() >= 1 )
            {
                syntax.setNames( aliases.toArray( new String[0] ) );
            }
        }

        // Description
        Element descriptionElement = element.element( DESCRIPTION_TAG );
        if ( ( descriptionElement != null ) && ( !descriptionElement.getText().equals( "" ) ) ) //$NON-NLS-1$
        {
            syntax.setDescription( descriptionElement.getText() );
        }

        // Obsolete
        Attribute obsoleteAttribute = element.attribute( OBSOLETE_TAG );
        if ( ( obsoleteAttribute != null ) && ( !obsoleteAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$
        {
            syntax.setObsolete( readBoolean( obsoleteAttribute.getValue() ) );
        }

        // Human Readible
        Attribute humanReadibleAttribute = element.attribute( HUMAN_READABLE_TAG );
        if ( ( humanReadibleAttribute != null ) && ( !humanReadibleAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$
        {
            syntax.setHumanReadable( readBoolean( humanReadibleAttribute.getValue() ) );
        }

        // Adding the syntax to the schema
        schema.addSyntax( syntax );
    }
View Full Code Here

            return ( IValueEditor ) class2ValueEditors.get( syntaxValueEditorMap.get( Strings
                .toLowerCase( syntaxNumericOid ) ) );
        }

        // return default
        LdapSyntax lsd = schema.getLdapSyntaxDescription( syntaxNumericOid );
        if ( SchemaUtils.isBinary( lsd ) )
        {
            return defaultBinaryValueEditor;
        }
        else
View Full Code Here

                            MatchingRule mr = createMatchingRule( searchResult );
                            mr.setSchemaName( name );
                            schema.addMatchingRule( mr );
                            break;
                        case SYNTAX:
                            LdapSyntax syntax = createSyntax( searchResult );
                            syntax.setSchemaName( name );
                            schema.addSyntax( syntax );
                            break;
                        default:
                            break;
                    }
View Full Code Here

     * ObjectClass could be created
     * @throws NamingException
     */
    private static LdapSyntax createSyntax( SearchResult sr ) throws NamingException
    {
        LdapSyntax syntax = new LdapSyntax( getOid( sr ) );
        syntax.setNames( getNames( sr ) );
        syntax.setDescription( getDescription( sr ) );
        syntax.setObsolete( isObsolete( sr ) );
        syntax.setHumanReadable( isHumanReadable( sr ) );
        return syntax;
    }
View Full Code Here

            }
            objectClassesMap.put( oc.getOid(), oc );
        }
        else if ( object instanceof LdapSyntax )
        {
            LdapSyntax syntax = ( LdapSyntax ) object;
            syntaxesList.add( syntax );
            List<String> names = syntax.getNames();
            if ( names != null )
            {
                for ( String name : names )
                {
                    syntaxesMap.put( Strings.toLowerCase( name ), syntax );
                }
            }
            syntaxesMap.put( syntax.getOid(), syntax );
        }
    }
View Full Code Here

            }
            objectClassesMap.remove( oc.getOid() );
        }
        else if ( object instanceof LdapSyntax )
        {
            LdapSyntax syntax = ( LdapSyntax ) object;
            syntaxesList.remove( syntax );
            List<String> names = syntax.getNames();
            if ( names != null )
            {
                for ( String name : names )
                {
                    syntaxesMap.remove( Strings.toLowerCase( name ) );
                }
            }
            syntaxesMap.remove( syntax.getOid() );
        }
    }
View Full Code Here

        {
            public String getText( Object element )
            {
                if ( element instanceof LdapSyntax )
                {
                    LdapSyntax syntax = ( LdapSyntax ) element;

                    String name = syntax.getName();
                    if ( name != null )
                    {
                        return NLS
                            .bind(
                                Messages.getString( "NewAttributeTypeContentWizardPage.NameOID" ), new String[] { name, syntax.getOid() } ); //$NON-NLS-1$
                    }
                    else
                    {
                        return NLS
                            .bind(
                                Messages.getString( "NewAttributeTypeContentWizardPage.NoneOID" ), new String[] { syntax.getOid() } ); //$NON-NLS-1$
                    }
                }

                return super.getText( element );
            }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.schema.LdapSyntax

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.