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.get( buf.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.get( buf.toString() );
if ( partitionClass != null )
{
config.setPartitionClass( partitionClass );
}
// --------------------------------------------------------------------
// set partition properties
// --------------------------------------------------------------------
buf.setLength( 0 );
buf.append( EnvKeys.PARTITION_PROPERTIES ).append( id );
String properties = ( String ) env.get( buf.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;
}
/*