{
ids = EMPTY_STRING_ARRAY;
}
Set set = new HashSet();
LockableAttributesImpl attrs = new LockableAttributesImpl();
LockableAttributeImpl attr = null;
for ( int ii = 0; ii < ids.length; ii++ )
{
set.add( ids[ii].toLowerCase() );
}
// Check whether the set contains a plus, and use it below to include all
// operational attributes. Due to RFC 3673, and issue DIREVE-228 in JIRA
boolean returnAllOperationalAttributes = set.contains( "+" );
if ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 ( returnAllOperationalAttributes || 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 );
}
// timeestamps are hacks for now until the schema is actually updateable these
// use the servers startup time stamp for both modify and create timestamps
if ( returnAllOperationalAttributes || set.contains( "createtimestamp" ) )
{
attr = new LockableAttributeImpl( attrs, "createTimestamp" );
attr.add( startUpTimeStamp );
attrs.put( attr );
}
if ( returnAllOperationalAttributes || set.contains( "modifytimestamp" ) )
{
attr = new LockableAttributeImpl( attrs, "modifyTimestamp" );
attr.add( startUpTimeStamp );
attrs.put( attr );
}
if ( returnAllOperationalAttributes || set.contains( "creatorsname" ) )
{
attr = new LockableAttributeImpl( attrs, "creatorsName" );
attr.add( ContextPartitionNexus.ADMIN_PRINCIPAL );
attrs.put( attr );
}
if ( returnAllOperationalAttributes || set.contains( "modifiersname" ) )
{
attr = new LockableAttributeImpl( attrs, "modifiersName" );
attr.add( ContextPartitionNexus.ADMIN_PRINCIPAL );
attrs.put( attr );
}
int minSetSize = 0;
if ( set.contains( "+" ) )
{
minSetSize++;
}
if ( set.contains( "*" ) )
{
minSetSize++;
}
if ( set.contains( "ref" ) )
{
minSetSize++;
}
// add the objectClass attribute
if ( set.contains( "*" ) || set.contains( "objectclass" ) || set.size() == minSetSize )
{
attr = new LockableAttributeImpl( attrs, "objectClass" );
attr.add( "top" );
attr.add( "subschema" );
attrs.put( attr );
}
// add the cn attribute as required for the RDN
if ( set.contains( "*" ) || set.contains( "cn" ) || set.contains( "commonname" ) || set.size() == minSetSize )
{
attrs.put( "cn", "schema" );
}
return attrs;
}