Package org.apache.ldap.server

Examples of org.apache.ldap.server.ContextPartitionConfig


    public static ContextPartitionConfig getContextPartitionConfig( String id, Hashtable env )
            throws NamingException
    {
        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;
        }

        /*
 
View Full Code Here

TOP

Related Classes of org.apache.ldap.server.ContextPartitionConfig

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.