// 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 = getAdditionalIndexLdif(backendName);
LDIFImportConfig ldifImportConfig = null;
try
{
ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
LDIFReader reader = new LDIFReader(ldifImportConfig);
Entry indexEntry;
while ((indexEntry = reader.readEntry()) != null)
{
ArrayList<String> args = new ArrayList<String>();
args.add("create-local-db-index");
args.add("--backend-name");
args.add(backendName);
args.add("--type");
args.add("generic");
argsArray.add(args);
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<org.nasutekds.server.types.Attribute> odsAttrs =
indexEntry.getAttributes();
for (org.nasutekds.server.types.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);
if (attrName.equalsIgnoreCase("ds-cfg-attribute"))
{
args.add("--index-name");
AttributeValue value =
odsAttr.iterator().next();
args.add(value.getValue().toString());
}
else if (attrName.equalsIgnoreCase("ds-cfg-index-type"))
{
it = odsAttr.iterator();
while (it.hasNext())
{
args.add("--set");
args.add("index-type:"+it.next().getValue().toString());
}
}
}
args.addAll(getConnectionCommandLineArguments());
args.add(getNoPropertiesFileArgument());
args.add("--no-prompt");
dns.add(indexEntry.getDN().toString());
attributes.add(attrs);
}
StringBuilder sb = new StringBuilder();
for (List<String> args : argsArray)
{
sb.append(getEquivalentCommandLine(getCommandLinePath("dsconfig"),
getObfuscatedCommandLineArguments(args)));
sb.append("<br><br>");
}
final String cmdLines = sb.toString();
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
getProgressDialog().appendProgressHtml(Utilities.applyFont(
INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_CREATE_ADDITIONAL_INDEXES.get()+
"<br><br><b>"+cmdLines+"</b>",
ColorAndFontConstants.progressFont));
getProgressDialog().appendProgressHtml(
Utilities.getProgressWithPoints(
INFO_CTRL_PANEL_CREATING_ADDITIONAL_INDEXES_PROGRESS.get(),
ColorAndFontConstants.progressFont));
}
});
for (int i=0; i<dns.size(); i++)
{
ctx.createSubcontext(dns.get(i), attributes.get(i));
}
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
getProgressDialog().appendProgressHtml(
Utilities.getProgressDone(ColorAndFontConstants.progressFont)+
"<br><br>");
}
});
}
catch (Throwable t)
{
throw new OnlineUpdateException(
ERR_CTRL_PANEL_ERROR_UPDATING_CONFIGURATION.get(t.toString()), t);
}
finally
{
if (ldifImportConfig != null)
{
ldifImportConfig.close();
}
}
}