// Create the set of candidates
for ( Value<?> ocValue : objectClass )
{
String ocName = ocValue.getString();
String ocOid = schemaManager.getObjectClassRegistry().getOidByName( ocName );
ObjectClass oc = ( ObjectClass ) schemaManager.getObjectClassRegistry().get( ocOid );
if ( oc.isStructural() )
{
candidates.add( oc );
}
}
}
catch ( Exception e )
{
e.printStackTrace();
throw e;
}
// Now find the parent OC
for ( Value<?> ocValue : objectClass )
{
String ocName = ocValue.getString();
String ocOid = schemaManager.getObjectClassRegistry().getOidByName( ocName );
ObjectClass oc = ( ObjectClass ) schemaManager.getObjectClassRegistry().get( ocOid );
for ( ObjectClass superior : oc.getSuperiors() )
{
if ( oc.isStructural() )
{
if ( candidates.contains( superior ) )
{
candidates.remove( superior );
}
}
}
}
// The remaining OC in the candidates set is the one we are looking for
ObjectClass result = candidates.toArray( new ObjectClass[]
{} )[0];
LOG.debug( "The top level object class is {}", result.getName() );
return result;
}