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

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


            Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants(
                node.getAttribute() );

            while ( descendants.hasNext() )
            {
                AttributeType descendant = descendants.next();

                attr = ( ServerAttribute ) entry.get( descendant );

                if ( attr != null && evaluate( attr ) )
                {
View Full Code Here


                {
                    // Bypass some specific index for AttributeTypes like ObjectClass hich are already
                    // present in the SystemIndices
                    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 );
                    tmp.put( oid, index );
                }
                else
                {
                    LOG.error( I18n.err( I18n.ERR_4, attributeType.getName() ) );
                }
            }

            userIndices = tmp;
        }
View Full Code Here

                presenceIdx.add( modsOid, id );
            }
        }

        // add all the values in mods to the same attribute in the entry
        AttributeType type = schemaManager.lookupAttributeTypeRegistry( modsOid );

        for ( Value<?> value : mods )
        {
            entry.add( type, value );
        }
View Full Code Here

            {
                presenceIdx.drop( modsOid, id );
            }
        }

        AttributeType attrType = schemaManager.lookupAttributeTypeRegistry( modsOid );
        /*
         * If there are no attribute values in the modifications then this
         * implies the compelete removal of the attribute from the entry. Else
         * we remove individual attribute values from the entry in mods one
         * at a time.
View Full Code Here

        for ( AVA newAtav : newRdn )
        {
            String newNormType = newAtav.getNormType();
            Object newNormValue = newAtav.getNormValue().get();
            AttributeType newRdnAttrType = schemaManager.lookupAttributeTypeRegistry( newNormType );

            entry.add( newRdnAttrType, newAtav.getUpValue() );

            if ( hasUserIndexOn( newNormType ) )
            {
                Index<?, E, Long> index = getUserIndex( newNormType );
                ( ( JdbmIndex ) index ).add( newNormValue, id );

                // Make sure the altered entry shows the existence of the new attrib
                if ( !presenceIdx.forward( newNormType, id ) )
                {
                    presenceIdx.add( newNormType, id );
                }
            }
        }

        /*
         * H A N D L E   O L D   R D N
         * ====================================================================
         * If the old RDN is to be removed we need to get the attribute and
         * value for it.  Keep in mind the old RDN need not be based on the
         * same attr as the new one.  We remove the RDN value from the entry
         * and remove the value/id tuple from the index on the old RDN attr
         * if any.  We also test if the delete of the old RDN index tuple
         * removed all the attribute values of the old RDN using a reverse
         * lookup.  If so that means we blew away the last value of the old
         * RDN attribute.  In this case we need to remove the attrName/id
         * tuple from the presence index.
         *
         * We only remove an ATAV of the old RDN if it is not included in the
         * new RDN.
         */

        if ( deleteOldRdn )
        {
            RDN oldRdn = updn.getRdn();
            for ( AVA oldAtav : oldRdn )
            {
                // check if the new ATAV is part of the old RDN
                // if that is the case we do not remove the ATAV
                boolean mustRemove = true;
                for ( AVA newAtav : newRdn )
                {
                    if ( oldAtav.equals( newAtav ) )
                    {
                        mustRemove = false;
                        break;
                    }
                }

                if ( mustRemove )
                {
                    String oldNormType = oldAtav.getNormType();
                    String oldNormValue = oldAtav.getNormValue().getString();
                    AttributeType oldRdnAttrType = schemaManager.lookupAttributeTypeRegistry( oldNormType );
                    entry.remove( oldRdnAttrType, oldNormValue );

                    if ( hasUserIndexOn( oldNormType ) )
                    {
                        Index<?, E, Long> index = getUserIndex( oldNormType );
View Full Code Here

    @Ignore
    public void testModifyAttributeTypeWithModificationItems() throws Exception
    {
        testAddAttributeTypeToEnabledSchema();
       
        AttributeType at = service.getSchemaManager().lookupAttributeTypeRegistry( OID );
        assertEquals( at.getDescription(), DESCRIPTION0 );
        assertEquals( at.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );

        DN dn = getAttributeTypeContainer( "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, mods );

        assertTrue( "attributeType OID should still be present",
            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
       
        assertEquals( "attributeType schema should be set to apachemeta",
            service.getSchemaManager().getAttributeTypeRegistry().getSchemaName( OID ), "apachemeta" );
       
        at = service.getSchemaManager().lookupAttributeTypeRegistry( OID );
        assertEquals( at.getDescription(), DESCRIPTION1 );
        assertEquals( at.getSyntax().getOid(), SchemaConstants.DIRECTORY_STRING_SYNTAX );
    }
View Full Code Here

    @Ignore
    public void testModifyAttributeTypeWithAttributes() throws Exception
    {
        testAddAttributeTypeToEnabledSchema();
       
        AttributeType at = service.getSchemaManager().lookupAttributeTypeRegistry( OID );
        assertEquals( at.getDescription(), DESCRIPTION0 );
        assertEquals( at.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );

        DN dn = getAttributeTypeContainer( "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, DirContext.REPLACE_ATTRIBUTE, mods );

        assertTrue( "attributeType OID should still be present",
            service.getSchemaManager().getAttributeTypeRegistry().contains( OID ) );
       
        assertEquals( "attributeType schema should be set to apachemeta",
            service.getSchemaManager().getAttributeTypeRegistry().getSchemaName( OID ), "apachemeta" );

        at = service.getSchemaManager().lookupAttributeTypeRegistry( OID );
        assertEquals( at.getDescription(), DESCRIPTION1 );
        assertEquals( at.getSyntax().getOid(), SchemaConstants.DIRECTORY_STRING_SYNTAX );
    }
View Full Code Here

        // check first to see if it is present in the subschemaSubentry
        // -------------------------------------------------------------------

        Attributes attrs = getSubschemaSubentryAttributes();
        Attribute attrTypes = attrs.get( "attributeTypes" );
        AttributeType attributeType = null;
       
        for ( int ii = 0; ii < attrTypes.size(); ii++ )
        {
            String desc = ( String ) attrTypes.get( ii );
           
            if ( desc.indexOf( oid ) != -1 )
            {
                attributeType = ATTRIBUTE_TYPE_DESCRIPTION_SCHEMA_PARSER
                    .parseAttributeTypeDescription( desc );
                break;
            }
        }

        if ( isPresent )
        {
            assertNotNull( attributeType );
            assertEquals( oid, attributeType.getOid() );
        }
        else
        {
            assertNull( attributeType );
        }
View Full Code Here

    {
        // let's check and make sure the supplied indices are OK

        if ( ndnIdx == null )
        {
            AttributeType attributeType = schemaManager
                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_N_DN_AT_OID );
            ndnIdx = new AvlIndex<String, E>();
            ndnIdx.setAttributeId( ApacheSchemaConstants.APACHE_N_DN_AT_OID );
            ndnIdx.initialize( attributeType );
            systemIndices.put( ApacheSchemaConstants.APACHE_N_DN_AT_OID, ndnIdx );
        }

        if ( updnIdx == null )
        {
            AttributeType attributeType = schemaManager
                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_UP_DN_AT_OID );
            updnIdx = new AvlIndex<String, E>();
            updnIdx.setAttributeId( ApacheSchemaConstants.APACHE_UP_DN_AT_OID );
            updnIdx.initialize( attributeType );
            systemIndices.put( ApacheSchemaConstants.APACHE_UP_DN_AT_OID, updnIdx );
        }

        if ( existenceIdx == null )
        {
            AttributeType attributeType = schemaManager
                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID );
            existenceIdx = new AvlIndex<String, E>();
            existenceIdx.setAttributeId( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID );
            existenceIdx.initialize( attributeType );
            systemIndices.put( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID, existenceIdx );
        }

        if ( oneLevelIdx == null )
        {
            AttributeType attributeType = schemaManager
                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID );
            oneLevelIdx = new AvlIndex<Long, E>();
            oneLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID );
            oneLevelIdx.initialize( attributeType );
            systemIndices.put( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID, oneLevelIdx );
        }

        if ( oneAliasIdx == null )
        {
            AttributeType attributeType = schemaManager
                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID );
            oneAliasIdx = new AvlIndex<Long, E>();
            oneAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID );
            oneAliasIdx.initialize( attributeType );
            systemIndices.put( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID, oneAliasIdx );
        }

        if ( subAliasIdx == null )
        {
            AttributeType attributeType = schemaManager
                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID );
            subAliasIdx = new AvlIndex<Long, E>();
            subAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID );
            subAliasIdx.initialize( attributeType );
            systemIndices.put( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID, subAliasIdx );
        }

        if ( aliasIdx == null )
        {
            AttributeType attributeType = schemaManager
                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
            aliasIdx = new AvlIndex<String, E>();
            aliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
            aliasIdx.initialize( attributeType );
            systemIndices.put( ApacheSchemaConstants.APACHE_ALIAS_AT_OID, aliasIdx );
        }

        if ( subLevelIdx == null )
        {
            AttributeType attributeType = schemaManager
                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID );
            subLevelIdx = new AvlIndex<Long, E>();
            subLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID );
            subLevelIdx.initialize( attributeType );
            systemIndices.put( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID, subLevelIdx );
        }

        if ( entryCsnIdx == null )
        {
            AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_CSN_AT_OID );
            entryCsnIdx = new AvlIndex<String, E>();
            entryCsnIdx.setAttributeId( SchemaConstants.ENTRY_CSN_AT_OID );
            entryCsnIdx.initialize( attributeType );
            systemIndices.put( SchemaConstants.ENTRY_CSN_AT_OID, entryCsnIdx );
        }

        if ( entryUuidIdx == null )
        {
            AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_UUID_AT_OID );
            entryUuidIdx = new AvlIndex<String, E>();
            entryUuidIdx.setAttributeId( SchemaConstants.ENTRY_UUID_AT_OID );
            entryUuidIdx.initialize( attributeType );
            systemIndices.put( SchemaConstants.ENTRY_UUID_AT_OID, entryUuidIdx );
        }

        if ( objectClassIdx == null )
        {
            AttributeType attributeType = schemaManager
                .lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT_OID );
            objectClassIdx = new AvlIndex<String, E>();
            objectClassIdx.setAttributeId( SchemaConstants.OBJECT_CLASS_AT_OID );
            objectClassIdx.initialize( attributeType );
            systemIndices.put( SchemaConstants.OBJECT_CLASS_AT_OID, objectClassIdx );
View Full Code Here

            Map<String, AvlIndex<? extends Object, E>> tmp = new HashMap<String, AvlIndex<? extends Object, E>>();

            for ( AvlIndex<? extends Object, E> index : userIndices.values() )
            {
                String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() );
                AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( oid );

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

                if ( mr != null )
                {
                    index.initialize( schemaManager.lookupAttributeTypeRegistry( oid ) );
                    tmp.put( oid, index );
                }
                else
                {
                    LOG.error( I18n.err( I18n.ERR_4, attributeType.getName() ) );
                }
            }

            userIndices = tmp;
        }
View Full Code Here

TOP

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

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.