Package org.apache.ldap.common.message

Examples of org.apache.ldap.common.message.LockableAttributesImpl


    }


    public Attributes getTestSubentry3()
    {
        Attributes subentry = new LockableAttributesImpl();
        Attribute objectClass = new LockableAttributeImpl( "objectClass" );
        objectClass.add( "top" );
        objectClass.add( "subentry" );
        objectClass.add( "collectiveAttributeSubentry" );
        subentry.put( objectClass );
        subentry.put( "c-st", "FL" );
        subentry.put( "subtreeSpecification", "{ base \"ou=configuration\" }" );
        subentry.put( "cn", "testsubentry3" );
        return subentry;
    }
View Full Code Here


        {
            entry = ( Attributes ) rec.getAttributes().clone();
        }
        else
        {
            entry = new LockableAttributesImpl();

            for ( int ii = 0; ii < attrIds.length; ii++ )
            {
                // there is no attribute by that name in the entry so we continue
                if ( null == rec.getAttributes().get( attrIds[ii] ) )
View Full Code Here

    {
        final StringBuffer buf = new StringBuffer();

        final ContextPartitionConfig config = new ContextPartitionConfig();

        final LockableAttributesImpl attrs = new LockableAttributesImpl();

        // --------------------------------------------------------------------
        // set id, empty attributes, and lookup the suffix for config
        // --------------------------------------------------------------------

        config.setId( id );

        config.setAttributes( attrs );

        buf.append( EnvKeys.SUFFIX ).append( id );

        String suffix = ( String ) env.getbuf.toString() );

        if ( suffix != null )
        {
            suffix = new LdapName( suffix ).toString();
        }

        config.setSuffix( suffix );

        // --------------------------------------------------------------------
        // set partition class
        // --------------------------------------------------------------------

        buf.setLength( 0 );

        buf.append( EnvKeys.PARTITION_CLASS ).append( id );

        String partitionClass = ( String ) env.getbuf.toString() );

        if ( partitionClass != null )
        {
            config.setPartitionClass( partitionClass );
        }

        // --------------------------------------------------------------------
        // set partition properties
        // --------------------------------------------------------------------

        buf.setLength( 0 );

        buf.append( EnvKeys.PARTITION_PROPERTIES ).append( id );

        String properties = ( String ) env.getbuf.toString() );

        if ( properties != null )
        {
            config.setProperties( properties );
        }

        // --------------------------------------------------------------------
        // extract index list and set the list of indices in config
        // --------------------------------------------------------------------

        buf.setLength( 0 );

        buf.append( EnvKeys.INDICES ).append( id );

        String indexList = ( ( String ) env.get( buf.toString() ) );

        if ( indexList == null || indexList.trim().length() == 0 )
        {
            config.setIndices( ArrayUtils.EMPTY_STRING_ARRAY );
        }
        else
        {
            indexList = StringTools.deepTrim( indexList );

            config.setIndices( indexList.split( " " ) );
        }

        // --------------------------------------------------------------------
        // extract attributes and values adding them to the config
        // --------------------------------------------------------------------

        buf.setLength( 0 );

        buf.append( EnvKeys.ATTRIBUTES ).append( id );

        /*
         * before going on to extract attributes check to see if the
         * attributes base plus id has an Attributes object set.  Users
         * can programatically use Attributes objects rather than
         * wrestle with individual key value pairs.
         */
        String keyBase = buf.toString();

        if ( env.containsKey( keyBase ) )
        {
            config.setAttributes( ( Attributes ) env.get( keyBase ) );

            return config;
        }

        /*
         * looks like the environment attributes were not set programatically
         * with an Attributes object for the base.  So we now add the extra
         * '.' and go on to try and detect all the keys and their attributes.
         */
        buf.append( "." );

        keyBase = buf.toString();

        for ( Enumeration list = env.keys(); list.hasMoreElements(); )
        {
            String attrKey = ( String ) list.nextElement();

            if ( attrKey.startsWith( keyBase ) )
            {
                LockableAttributeImpl attr = new LockableAttributeImpl( attrs, attrKey.substring( keyBase.length() ) ) ;

                String valueList = ( String ) env.get( attrKey );

                if ( valueList == null || valueList.trim().length() == 0 )
                {
                    // add the empty attribute
                    attrs.put( attr );

                    continue;
                }

                valueList = StringTools.deepTrim( valueList );

                String[] values = valueList.split( " " );

                for ( int ii = 0; ii < values.length; ii++ )
                {
                    attr.add( values[ii] );
                }

                attrs.put( attr );
            }
        }

        return config;
    }
View Full Code Here

                if ( ids != null && ids.length > 0 )
                {
                    boolean doSwap = true;

                    Attributes askedFor = new LockableAttributesImpl();

                    for ( int ii = 0; ii < ids.length; ii++ )
                    {
                        if ( ids[ii].trim().equals( "*" ) )
                        {
                            doSwap = false;

                            break;
                        }

                        if ( attrs.get( ids[ii] ) != null )
                        {
                            askedFor.put( attrs.get( ids[ii] ) );
                        }
                    }

                    if ( doSwap )
                    {
View Full Code Here

     */
    public Attributes lookup( Name dn, String[] attrIds throws NamingException
    {
        if ( dn.size() == 0 )
        {
            LockableAttributes retval = new LockableAttributesImpl();

            NamingEnumeration list = rootDSE.getIDs();

            while ( list.hasMore() )
            {
                String id = ( String ) list.next();

                Attribute attr = rootDSE.get( id );

                retval.put( ( Attribute ) attr.clone() );
            }

            retval.setLocked( true );

            return retval;
        }

        ContextPartition backend = getBackend( dn );
View Full Code Here

     *
     * @param name the name of the new ServerPreferences node.
     */
    private void setUpNode( String name ) throws NamingException
    {
        Attributes attrs = new LockableAttributesImpl();

        Attribute attr = new LockableAttributeImpl( ( Lockable ) attrs, "objectClass" );

        attr.add( "top" );

        attr.add( "prefNode" );

        attr.add( "extensibleObject" );

        attrs.put( attr );

        attr = new LockableAttributeImpl( ( Lockable ) attrs, "prefNodeName" );

        attr.add( name );

        attrs.put( attr );

        LdapContext parent = ( ( ServerSystemPreferences ) parent() ).getLdapContext();

        parent.bind( "prefNodeName=" + name, null, attrs );

View Full Code Here

        // add the root entry for the system root context if it does not exist
        Attributes attributes = db.getSuffixEntry() ;
        if ( null == attributes )
        {
            attributes = new LockableAttributesImpl() ;
            attributes.put( "objectClass", "top" ) ;
            attributes.put( "objectClass", "organizationalUnit" ) ;
            attributes.put( "creatorsName", ADMIN_PRINCIPAL ) ;
            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() ) ;
            attributes.put( NamespaceTools.getRdnAttribute( SUFFIX ),
View Full Code Here

    private Attributes getSubschemaEntry( String[] ids ) throws NamingException
    {
        if ( ids == null )
        {
            return new LockableAttributesImpl();
        }

        HashSet set = new HashSet( ids.length );
        LockableAttributesImpl attrs = new LockableAttributesImpl();
        LockableAttributeImpl attr = null;

        for ( int ii = 0; ii < ids.length; ii++ )
        {
            set.add( ids[ii].toLowerCase() );
        }


        if ( set.contains( "objectclasses" ) )
        {
            attr = new LockableAttributeImpl( attrs, "objectClasses" );
            Iterator list = globalRegistries.getObjectClassRegistry().list();
            while ( list.hasNext() )
            {
                ObjectClass oc = ( ObjectClass ) list.next();
                attr.add( SchemaUtils.render( oc ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "attributetypes" ) )
        {
            attr = new LockableAttributeImpl( attrs, "attributeTypes" );
            Iterator list = globalRegistries.getAttributeTypeRegistry().list();
            while ( list.hasNext() )
            {
                AttributeType at = ( AttributeType ) list.next();
                attr.add( SchemaUtils.render( at ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "matchingrules" ) )
        {
            attr = new LockableAttributeImpl( attrs, "matchingRules" );
            Iterator list = globalRegistries.getMatchingRuleRegistry().list();
            while ( list.hasNext() )
            {
                MatchingRule mr = ( MatchingRule ) list.next();
                attr.add( SchemaUtils.render( mr ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "matchingruleuse" ) )
        {
            attr = new LockableAttributeImpl( attrs, "matchingRuleUse" );
            Iterator list = globalRegistries.getMatchingRuleUseRegistry().list();
            while ( list.hasNext() )
            {
                MatchingRuleUse mru = ( MatchingRuleUse ) list.next();
                attr.add( SchemaUtils.render( mru ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "ldapsyntaxes" ) )
        {
            attr = new LockableAttributeImpl( attrs, "ldapSyntaxes" );
            Iterator list = globalRegistries.getSyntaxRegistry().list();
            while ( list.hasNext() )
            {
                Syntax syntax = ( Syntax ) list.next();
                attr.add( SchemaUtils.render( syntax ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "ditcontentrules" ) )
        {
            attr = new LockableAttributeImpl( attrs, "dITContentRules" );
            Iterator list = globalRegistries.getDitContentRuleRegistry().list();
            while ( list.hasNext() )
            {
                DITContentRule dcr = ( DITContentRule ) list.next();
                attr.add( SchemaUtils.render( dcr ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "ditstructurerules" ) )
        {
            attr = new LockableAttributeImpl( attrs, "dITStructureRules" );
            Iterator list = globalRegistries.getDitStructureRuleRegistry().list();
            while ( list.hasNext() )
            {
                DITStructureRule dsr = ( DITStructureRule ) list.next();
                attr.add( SchemaUtils.render( dsr ).toString() );
            }
            attrs.put( attr );
        }

        if ( set.contains( "nameforms" ) )
        {
            attr = new LockableAttributeImpl( attrs, "nameForms" );
            Iterator list = globalRegistries.getNameFormRegistry().list();
            while ( list.hasNext() )
            {
                NameForm nf = ( NameForm ) list.next();
                attr.add( SchemaUtils.render( nf ).toString() );
            }
            attrs.put( attr );
        }

        // add the objectClass attribute
        attr = new LockableAttributeImpl( attrs, "objectClass" );
        attr.add( "top" );
        attr.add( "subschema" );
        attrs.put( attr );

        // add the cn attribute as required for the RDN
        attrs.put( "cn", "schema" );

        return attrs;
    }
View Full Code Here

    public AbstractCoreTest()
    {
        list = new ArrayList();

        Attributes attributes = new LockableAttributesImpl();

        LdifParserImpl parser = new LdifParserImpl();

        try
        {
View Full Code Here

        {
            LdifIterator iterator = new LdifIterator( in );

            while ( iterator.hasNext() )
            {
                Attributes attributes = new LockableAttributesImpl();

                String ldif = ( String ) iterator.next();

                parser.parse( attributes, ldif );

                Name dn = new LdapName( ( String ) attributes.remove( "dn" ).get() );

                dn.remove( 0 );

                ctx.createSubcontext( dn, attributes );
            }
View Full Code Here

TOP

Related Classes of org.apache.ldap.common.message.LockableAttributesImpl

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.