From ee5d05f4843a959cd76804318a9ab1f49653770c Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 17 Nov 2008 13:32:09 +0000
Subject: [PATCH] Fix for issue 3589 (Control Panel : error raised at new vlv index creation).
---
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java | 3 +
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java | 103 ++++++++++++++++++++++-----------------------------
2 files changed, 47 insertions(+), 59 deletions(-)
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java
index aff231c..7e4c854 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java
@@ -1367,7 +1367,8 @@
public void run()
{
getProgressDialog().appendProgressHtml(
- Utilities.getProgressDone(ColorAndFontConstants.progressFont));
+ Utilities.getProgressDone(ColorAndFontConstants.progressFont)+
+ "<br><br>");
}
});
}
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java
index 26764ef..ee93e09 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java
@@ -36,14 +36,9 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
-
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
import javax.naming.ldap.InitialLdapContext;
import javax.swing.SwingUtilities;
@@ -53,15 +48,19 @@
import org.opends.guitools.controlpanel.datamodel.VLVSortOrder;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.task.OfflineUpdateException;
-import org.opends.guitools.controlpanel.task.OnlineUpdateException;
import org.opends.guitools.controlpanel.task.Task;
import org.opends.guitools.controlpanel.util.ConfigReader;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.Message;
+import org.opends.server.admin.client.ManagementContext;
+import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
+import org.opends.server.admin.client.ldap.LDAPManagementContext;
+import org.opends.server.admin.std.client.LocalDBBackendCfgClient;
+import org.opends.server.admin.std.client.LocalDBVLVIndexCfgClient;
+import org.opends.server.admin.std.client.RootCfgClient;
+import org.opends.server.admin.std.meta.LocalDBVLVIndexCfgDefn;
import org.opends.server.admin.std.meta.LocalDBVLVIndexCfgDefn.Scope;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.Attribute;
-import org.opends.server.types.AttributeValue;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
@@ -352,7 +351,30 @@
LDIFImportConfig ldifImportConfig = null;
try
{
- ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
+ String topEntryDN =
+ "cn=VLV Index,"+Utilities.getRDNString("ds-cfg-backend-id",
+ backendName.getText())+",cn=Backends,cn=config";
+ boolean topEntryExists =
+ DirectoryServer.getConfigHandler().entryExists(
+ DN.decode(topEntryDN));
+
+ if (!topEntryExists)
+ {
+ String completeLDIF =
+ Utilities.makeLdif(
+ "dn: "+topEntryDN,
+ "objectClass: top",
+ "objectClass: ds-cfg-branch",
+ "cn: VLV Index", "") + ldif;
+ ldifImportConfig =
+ new LDIFImportConfig(new StringReader(completeLDIF));
+ }
+ else
+ {
+ ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
+ }
+
+
LDIFReader reader = new LDIFReader(ldifImportConfig);
Entry backendConfigEntry;
while ((backendConfigEntry = reader.readEntry()) != null)
@@ -378,53 +400,21 @@
private void createIndex(InitialLdapContext ctx) throws OpenDsException
{
- // Instead of adding indexes using management framework, use this approach
- // so that we have to define the additional indexes only in the method
- // getBackendLdif.
- LDIFImportConfig ldifImportConfig = null;
- try
- {
- ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
- LDIFReader reader = new LDIFReader(ldifImportConfig);
- Entry indexEntry = reader.readEntry();
- Attributes attrs = new BasicAttributes();
+ ManagementContext mCtx = LDAPManagementContext.createFromContext(
+ JNDIDirContextAdaptor.adapt(ctx));
+ RootCfgClient root = mCtx.getRootConfiguration();
+ LocalDBBackendCfgClient backend =
+ (LocalDBBackendCfgClient)root.getBackend(backendName.getText());
+ LocalDBVLVIndexCfgDefn provider = LocalDBVLVIndexCfgDefn.getInstance();
+ LocalDBVLVIndexCfgClient index =
+ backend.createLocalDBVLVIndex(provider, name.getText(), null);
- BasicAttribute oc = new BasicAttribute("objectClass");
- Iterator<AttributeValue> it =
- indexEntry.getObjectClassAttribute().iterator();
- while (it.hasNext())
- {
- oc.add(it.next().getStringValue());
- }
- 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().getStringValue());
- }
- attrs.put(attr);
- }
-
- 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();
- }
- }
+ index.setFilter(filter.getText().trim());
+ index.setSortOrder(getSortOrderStringValue(getSortOrder()));
+ index.setBaseDN(DN.decode(getBaseDN()));
+ index.setScope(getScope());
+ index.setMaxBlockSize(Integer.parseInt(maxBlockSize.getText().trim()));
+ index.commit();
}
/**
@@ -524,9 +514,6 @@
args.add("--set");
args.add("sort-order:"+sortOrderStringValue);
- args.add("--index-filter");
- args.add(filterValue);
-
args.addAll(getConnectionCommandLineArguments());
args.add("--no-prompt");
return args;
--
Gitblit v1.10.0