{
// Instead of adding indexes using management framework, use this approach
// so that we have to define the additional indexes only in the method
// getBackendLdif.
String ldif = getIndexLDIF();
LDIFImportConfig ldifImportConfig = null;
try
{
ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
LDIFReader reader = new LDIFReader(ldifImportConfig);
Entry indexEntry = reader.readEntry();
Attributes attrs = new BasicAttributes();
BasicAttribute oc = new BasicAttribute("objectClass");
Iterator<AttributeValue> it =
indexEntry.getObjectClassAttribute().iterator();
while (it.hasNext())
{
oc.add(it.next().getValue().toString());
}
attrs.put(oc);
List<Attribute> odsAttrs = indexEntry.getAttributes();
for (Attribute odsAttr : odsAttrs)
{
String attrName = odsAttr.getName();
BasicAttribute attr = new BasicAttribute(attrName);
it = odsAttr.iterator();
while (it.hasNext())
{
attr.add(it.next().getValue().toString());
}
attrs.put(attr);
}
final StringBuilder sb = new StringBuilder();
sb.append(getConfigCommandLineName());
Collection<String> args =
getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments());
for (String arg : args)
{
sb.append(" "+CommandBuilder.escapeValue(arg));
}
ctx.createSubcontext(indexEntry.getDN().toString(), attrs);
}
catch (Throwable t)
{
throw new OnlineUpdateException(
ERR_CTRL_PANEL_ERROR_UPDATING_CONFIGURATION.get(t.toString()), t);
}
finally
{
if (ldifImportConfig != null)
{
ldifImportConfig.close();
}
}
}