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

Examples of org.apache.directory.shared.ldap.schema.MatchingRule


                }


                public MatchingRule getEquality() throws NamingException
                {
                    return new MatchingRule()
                    {
                        private static final long serialVersionUID = 1L;

                        public Syntax getSyntax() throws NamingException
                        {
                            return null;
                        }

                        public Comparator getComparator() throws NamingException
                        {
                            return null;
                        }

                        public Normalizer getNormalizer() throws NamingException
                        {
                            return new Normalizer()
                            {
                                private static final long serialVersionUID = 1L;

                                public Value<?> normalize( Value<?> value ) throws NamingException
                                {
                                    return new ClientStringValue( StringTools.deepTrimToLower( value.getString() ) );
                                }
                               
                                public String normalize( String value ) throws NamingException
                                {
                                    return StringTools.deepTrimToLower( value );
                                }
                            };
                        }

                        public boolean isObsolete()
                        {
                            return false;
                        }

                        public String getOid()
                        {
                            return null;
                        }

                        public String[] getNamesRef()
                        {
                            return null;
                        }

                        public String getName()
                        {
                            return null;
                        }

                        public String getDescription()
                        {
                            return null;
                        }

                        public String getSchema()
                        {
                            return null;
                        }

                        public void setSchema( String schemaName )
                        {
                        }
                    };
                }


                public MatchingRule getOrdering() throws NamingException
                {
                    return null;
                }


                public MatchingRule getSubstr() throws NamingException
                {
                    return null;
                }


                public boolean isAncestorOf( AttributeType descendant ) throws NamingException
                {
                    return false;
                }


                public boolean isDescendantOf( AttributeType ancestor ) throws NamingException
                {
                    return false;
                }


                public boolean isObsolete()
                {
                    return false;
                }


                public String getOid()
                {
                    return String.valueOf( id.hashCode() );
                }


                public String[] getNamesRef()
                {
                    return new String[]
                        { id };
                }


                public String getName()
                {
                    return id;
                }


                public String getDescription()
                {
                    return id;
                }


                public String getSchema()
                {
                    return null;
                }


                public void setSchema( String schemaName )
                {
                }
            };
        }
        else
        {
            return new AttributeType()
            {
                private static final long serialVersionUID = 1L;

                public boolean isSingleValue()
                {
                    return false;
                }


                public boolean isCanUserModify()
                {
                    return true;
                }


                public boolean isCollective()
                {
                    return false;
                }


                public UsageEnum getUsage()
                {
                    return null;
                }


                public AttributeType getSuperior() throws NamingException
                {
                    return null;
                }


                public Syntax getSyntax() throws NamingException
                {
                    return new Syntax()
                    {

                        private static final long serialVersionUID = 1L;

                        public boolean isHumanReadable()
                        {
                            return true;
                        }

                        public SyntaxChecker getSyntaxChecker() throws NamingException
                        {
                            return null;
                        }

                        public boolean isObsolete()
                        {
                            return false;
                        }

                        public String getOid()
                        {
                            return null;
                        }

                        public String[] getNamesRef()
                        {
                            return null;
                        }

                        public String getName()
                        {
                            return null;
                        }

                        public String getDescription()
                        {
                            return null;
                        }

                        public String getSchema()
                        {
                            return null;
                        }

                        public void setSchema( String schemaName )
                        {
                        }
                    };
                }


                public int getLength()
                {
                    return 0;
                }


                public MatchingRule getEquality() throws NamingException
                {
                    return new MatchingRule()
                    {
                        private static final long serialVersionUID = 1L;

                        public Syntax getSyntax() throws NamingException
                        {
View Full Code Here


    @Test
    public void testModifyMatchingRuleWithModificationItems() throws Exception
    {
        testAddMatchingRule();
       
        MatchingRule mr = getMatchingRuleRegistry().lookup( OID );
        assertEquals( mr.getDescription(), DESCRIPTION0 );
        assertEquals( mr.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );

        LdapDN dn = getMatchingRuleContainer( "apachemeta" );
        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
       
        ModificationItem[] mods = new ModificationItem[2];
        Attribute attr = new BasicAttribute( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION1 );
        mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
        attr = new BasicAttribute( MetaSchemaConstants.M_SYNTAX_AT, SchemaConstants.DIRECTORY_STRING_SYNTAX );
        mods[1] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
        getSchemaContext( service ).modifyAttributes( dn, mods );

        assertTrue( "matchingRule OID should still be present",
            getMatchingRuleRegistry().hasMatchingRule( OID ) );
       
        assertEquals( "matchingRule schema should be set to apachemeta",
            getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );
       
        mr = getMatchingRuleRegistry().lookup( OID );
        assertEquals( mr.getDescription(), DESCRIPTION1 );
        assertEquals( mr.getSyntax().getOid(), SchemaConstants.DIRECTORY_STRING_SYNTAX );
    }
View Full Code Here

    @Test
    public void testModifyMatchingRuleWithAttributes() throws Exception
    {
        testAddMatchingRule();
       
        MatchingRule mr = getMatchingRuleRegistry().lookup( OID );
        assertEquals( mr.getDescription(), DESCRIPTION0 );
        assertEquals( mr.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );

        LdapDN dn = getMatchingRuleContainer( "apachemeta" );
        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
       
        Attributes mods = new BasicAttributes( true );
        mods.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION1 );
        mods.put( MetaSchemaConstants.M_SYNTAX_AT, SchemaConstants.DIRECTORY_STRING_SYNTAX );
        getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );

        assertTrue( "matchingRule OID should still be present",
            getMatchingRuleRegistry().hasMatchingRule( OID ) );
       
        assertEquals( "matchingRule schema should be set to apachemeta",
            getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );

        mr = getMatchingRuleRegistry().lookup( OID );
        assertEquals( mr.getDescription(), DESCRIPTION1 );
        assertEquals( mr.getSyntax().getOid(), SchemaConstants.DIRECTORY_STRING_SYNTAX );
    }
View Full Code Here

    @Ignore
    public void testModifyMatchingRuleWithModificationItems() throws Exception
    {
        testAddMatchingRuleToEnabledSchema();
       
        MatchingRule mr = schemaManager.getMatchingRuleRegistry().lookup( OID );
        assertEquals( mr.getDescription(), DESCRIPTION0 );
        assertEquals( mr.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );

        DN dn = getMatchingRuleContainer( "apachemeta" );
        dn.add( "m-oid" + "=" + OID );
       
        ModificationItem[] mods = new ModificationItem[2];
        Attribute attr = new BasicAttribute( "m-description", DESCRIPTION1 );
        mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
        attr = new BasicAttribute( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
        mods[1] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), mods );

        assertTrue( "matchingRule OID should still be present",
            schemaManager.getMatchingRuleRegistry().contains( OID ) );
       
        assertEquals( "matchingRule schema should be set to apachemeta",
            schemaManager.getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );
       
        mr = schemaManager.getMatchingRuleRegistry().lookup( OID );
        assertEquals( mr.getDescription(), DESCRIPTION1 );
        assertEquals( mr.getSyntax().getOid(), SchemaConstants.DIRECTORY_STRING_SYNTAX );
    }
View Full Code Here

    @Ignore
    public void testModifyMatchingRuleWithAttributes() throws Exception
    {
        testAddMatchingRuleToEnabledSchema();
       
        MatchingRule mr = schemaManager.getMatchingRuleRegistry().lookup( OID );
        assertEquals( mr.getDescription(), DESCRIPTION0 );
        assertEquals( mr.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );

        DN dn = getMatchingRuleContainer( "apachemeta" );
        dn.add( "m-oid" + "=" + OID );
       
        Attributes mods = new BasicAttributes( true );
        mods.put( "m-description", DESCRIPTION1 );
        mods.put( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );

        assertTrue( "matchingRule OID should still be present",
            schemaManager.getMatchingRuleRegistry().contains( OID ) );
       
        assertEquals( "matchingRule schema should be set to apachemeta",
            schemaManager.getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );

        mr = schemaManager.getMatchingRuleRegistry().lookup( OID );
        assertEquals( mr.getDescription(), DESCRIPTION1 );
        assertEquals( mr.getSyntax().getOid(), SchemaConstants.DIRECTORY_STRING_SYNTAX );
    }
View Full Code Here

     */
    private void initTables( SchemaManager schemaManager ) throws IOException
    {
        SerializableComparator<K> comp;

        MatchingRule mr = attribute.getEquality();

        if ( mr == null )
        {
            throw new IOException( I18n.err( I18n.ERR_574, attribute.getName() ) );
        }

        comp = new SerializableComparator<K>( mr.getOid() );

        /*
         * The forward key/value map stores attribute values to master table
         * primary keys.  A value for an attribute can occur several times in
         * different entries so the forward map can have more than one value.
View Full Code Here

                    continue;
                }
                AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( oid );

                // Check that the attributeType has an EQUALITY matchingRule
                MatchingRule mr = attributeType.getEquality();

                if ( mr != null )
                {
                    ( ( JdbmIndex ) index ).init( schemaManager, schemaManager.lookupAttributeTypeRegistry( oid ),
                        workingDirectory );
View Full Code Here

         * We prefer matching using the Normalizer and Comparator pair from
         * the ordering matchingRule if one is available.  It may very well
         * not be.  If so then we resort to using the Normalizer and
         * Comparator from the equality matchingRule as a last resort.
         */
        MatchingRule mr = type.getOrdering();

        if ( mr == null )
        {
            mr = type.getEquality();
        }

        if ( mr == null )
        {
            throw new IllegalStateException( I18n.err( I18n.ERR_717, node ) );
        }

        normalizer = mr.getNormalizer();
        ldapComparator = mr.getLdapComparator();
    }
View Full Code Here

        int pos = 0;

        for ( Value<?> value : attr )
        {
            MatchingRule matchingRule = null;

            try
            {
                matchingRule = matchingRuleParser.parseMatchingRuleDescription( value.getString() );
                matchingRule.setSpecification( value.getString() );
            }
            catch ( ParseException e )
            {
                LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_424,
                        value.getString() ) );
                iave.initCause( e );
                throw iave;
            }

            if ( !schemaManager.getLdapSyntaxRegistry().contains( matchingRule.getSyntaxOid() ) )
            {
                throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
                    I18n.err( I18n.ERR_425, matchingRule.getSyntaxOid() ) );
            }

            matchingRules[pos++] = matchingRule;
        }
View Full Code Here

    @Test
    public void testEvaluatorAttributeOrderingMatchingRule() throws Exception
    {
        LdapSyntax syntax = new BogusSyntax( 2 );

        MatchingRule mr = new MatchingRule( "1.1" );
        mr.setSyntax( syntax );
        mr.setLdapComparator( new StringComparator( "1.1" ) );

        AttributeType at = new AttributeType( SchemaConstants.ATTRIBUTE_TYPES_AT_OID + ".3000" );
        at.addName( "bogus" );
        at.setSchemaName( "other" );
        at.setSyntax( syntax );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.schema.MatchingRule

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.