From 866cc640d33ce92abbd907d35d4c1b62f2328959 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Fri, 17 Apr 2015 08:54:07 +0000
Subject: [PATCH] OPENDJ-1929 Create an IndexTypeDescriptor

---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java     |   10 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexTypeDescriptor.java |  267 ++++++++++++++++++++++++++++++++++++++
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java           |   10 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexDescriptor.java     |   13 +
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractIndexPanel.java         |   17 +-
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java      |   10 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewIndexPanel.java              |   17 +-
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/IndexPanel.java                 |   30 ++--
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexTableModel.java     |    3 
 9 files changed, 323 insertions(+), 54 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexDescriptor.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexDescriptor.java
index 361ea6b..22fb8be 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexDescriptor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexDescriptor.java
@@ -27,10 +27,10 @@
 
 package org.opends.guitools.controlpanel.datamodel;
 
+import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType;
 import org.opends.server.types.AttributeType;
 
 /**
@@ -42,7 +42,7 @@
 
   private static final String[] DATABASE_INDEXES = new String[] {"dn2id", "id2children", "id2subtree"};
 
-  private final SortedSet<IndexType> types = new TreeSet<IndexType>();
+  private final SortedSet<IndexTypeDescriptor> types = new TreeSet<IndexTypeDescriptor>();
   private final boolean isDatabaseIndex;
   private final int entryLimit;
   private final AttributeType attr;
@@ -64,7 +64,7 @@
    */
   public IndexDescriptor(String name, AttributeType attr,
       BackendDescriptor backend,
-      SortedSet<IndexType> types, int entryLimit)
+      Set<IndexTypeDescriptor> types, int entryLimit)
   {
     super(name, backend);
     this.attr = attr;
@@ -101,9 +101,9 @@
    *
    * @return the type of indexes (equality, substring, etc.).
    */
-  public SortedSet<IndexType> getTypes()
+  public SortedSet<IndexTypeDescriptor> getTypes()
   {
-    return new TreeSet<IndexType>(types);
+    return new TreeSet<IndexTypeDescriptor>(types);
   }
 
   /**
@@ -178,7 +178,7 @@
   protected void recalculateHashCode()
   {
     final StringBuilder sb = new StringBuilder();
-    for (final IndexType t : types)
+    for (final IndexTypeDescriptor t : types)
     {
       sb.append(t).append(",");
     }
@@ -188,4 +188,5 @@
     }
     hashCode = (getName()+sb+entryLimit).hashCode();
   }
+
 }
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexTableModel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexTableModel.java
index 8663ca7..0e7500c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexTableModel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexTableModel.java
@@ -30,7 +30,6 @@
 import static org.opends.messages.AdminToolMessages.*;
 
 import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType;
 
 /**
  * The table model for the indexes.  This is the table model used by the table
@@ -143,7 +142,7 @@
   private String getIndexTypeString(IndexDescriptor index)
   {
     StringBuilder sb = new StringBuilder();
-    for (IndexType type : index.getTypes())
+    for (IndexTypeDescriptor type : index.getTypes())
     {
       LocalizableMessage v;
       switch (type)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexTypeDescriptor.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexTypeDescriptor.java
new file mode 100644
index 0000000..03d170a
--- /dev/null
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexTypeDescriptor.java
@@ -0,0 +1,267 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2015 ForgeRock AS
+ */
+
+package org.opends.guitools.controlpanel.datamodel;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.opends.server.admin.std.meta.BackendIndexCfgDefn;
+import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn;
+
+/** Defines the set of values for the index type. */
+public enum IndexTypeDescriptor
+{
+  /**
+   * This index type is used to improve the efficiency of searches using
+   * approximate matching search filters.
+   */
+  APPROXIMATE("approximate"),
+
+  /**
+   * This index type is used to improve the efficiency of searches using
+   * equality search filters.
+   */
+  EQUALITY("equality"),
+
+  /**
+   * This index type is used to improve the efficiency of searches using
+   * extensible matching search filters.
+   */
+  EXTENSIBLE("extensible"),
+
+  /**
+   * This index type is used to improve the efficiency of searches using
+   * "greater than or equal to" or "less then or equal to" search filters.
+   */
+  ORDERING("ordering"),
+
+  /**
+   * This index type is used to improve the efficiency of searches using the
+   * presence search filters.
+   */
+  PRESENCE("presence"),
+
+  /**
+   * This index type is used to improve the efficiency of searches using
+   * substring search filters.
+   */
+  SUBSTRING("substring");
+
+  private final String name;
+
+  private IndexTypeDescriptor(final String name)
+  {
+    this.name = name;
+  }
+
+  @Override
+  public String toString()
+  {
+    return name;
+  }
+
+  /**
+   * Convert the index type to the equivalent
+   * {@code BackendIndexCfgDefn.IndexType}.
+   *
+   * @return The index type to the equivalent
+   *         {@code BackendIndexCfgDefn.IndexType}
+   */
+  public BackendIndexCfgDefn.IndexType toBackendIndexType()
+  {
+    switch (this)
+    {
+    case APPROXIMATE:
+      return BackendIndexCfgDefn.IndexType.APPROXIMATE;
+    case EQUALITY:
+      return BackendIndexCfgDefn.IndexType.EQUALITY;
+    case EXTENSIBLE:
+      return BackendIndexCfgDefn.IndexType.EXTENSIBLE;
+    case ORDERING:
+      return BackendIndexCfgDefn.IndexType.ORDERING;
+    case PRESENCE:
+      return BackendIndexCfgDefn.IndexType.PRESENCE;
+    case SUBSTRING:
+      return BackendIndexCfgDefn.IndexType.SUBSTRING;
+    default:
+      throw new IllegalArgumentException("No BackendIndexCfgDefn.IndexType corresponding to: " + this);
+    }
+  }
+
+  // FIXME: Remove once local-db backend will be pluggable.
+  /**
+   * Convert the index type to the equivalent
+   * {@code LocalDBIndexCfgDefn.IndexType}.
+   *
+   * @return The index type to the equivalent
+   *         {@code LocalDBIndexCfgDefn.IndexType}
+   */
+  public LocalDBIndexCfgDefn.IndexType toLocalDBIndexType()
+  {
+    switch (this)
+    {
+    case APPROXIMATE:
+      return LocalDBIndexCfgDefn.IndexType.APPROXIMATE;
+    case EQUALITY:
+      return LocalDBIndexCfgDefn.IndexType.EQUALITY;
+    case EXTENSIBLE:
+      return LocalDBIndexCfgDefn.IndexType.EXTENSIBLE;
+    case ORDERING:
+      return LocalDBIndexCfgDefn.IndexType.ORDERING;
+    case PRESENCE:
+      return LocalDBIndexCfgDefn.IndexType.PRESENCE;
+    case SUBSTRING:
+      return LocalDBIndexCfgDefn.IndexType.SUBSTRING;
+    default:
+      throw new IllegalArgumentException("No LocalDBIndexCfgDefn.IndexType corresponding to: " + this);
+    }
+  }
+
+  private static IndexTypeDescriptor fromBackendIndexType(final BackendIndexCfgDefn.IndexType indexType)
+  {
+    switch (indexType)
+    {
+    case APPROXIMATE:
+      return APPROXIMATE;
+    case EQUALITY:
+      return EQUALITY;
+    case EXTENSIBLE:
+      return EXTENSIBLE;
+    case ORDERING:
+      return ORDERING;
+    case PRESENCE:
+      return PRESENCE;
+    case SUBSTRING:
+      return SUBSTRING;
+    default:
+      throw new IllegalArgumentException("No IndexTypeDescriptor corresponding to: " + indexType);
+    }
+  }
+
+  // FIXME: Remove once local-db backend will be pluggable.
+  private static IndexTypeDescriptor fromLocalDBIndexType(final LocalDBIndexCfgDefn.IndexType indexType)
+  {
+    switch (indexType)
+    {
+    case APPROXIMATE:
+      return APPROXIMATE;
+    case EQUALITY:
+      return EQUALITY;
+    case EXTENSIBLE:
+      return EXTENSIBLE;
+    case ORDERING:
+      return ORDERING;
+    case PRESENCE:
+      return PRESENCE;
+    case SUBSTRING:
+      return SUBSTRING;
+    default:
+      throw new IllegalArgumentException("No IndexTypeDescriptor corresponding to: " + indexType);
+    }
+  }
+
+  /**
+   * Convert the provided {@code Set<BackendIndexCfgDefn.IndexType>} to a
+   * {@code Set<IndexTypeDescriptor>}.
+   *
+   * @param indexTypes
+   *          A set of {@code Set<BackendIndexCfgDefn.IndexType>}
+   * @return A set of {@code Set<IndexTypeDescriptor>} corresponding to the
+   *         provided {@code Set<BackendIndexCfgDefn.IndexType>}
+   */
+  public static Set<IndexTypeDescriptor> fromBackendIndexTypes(final Set<BackendIndexCfgDefn.IndexType> indexTypes)
+  {
+    final Set<IndexTypeDescriptor> indexTypeDescriptors = new LinkedHashSet<IndexTypeDescriptor>();
+    for (final BackendIndexCfgDefn.IndexType indexType : indexTypes)
+    {
+      indexTypeDescriptors.add(fromBackendIndexType(indexType));
+    }
+    return indexTypeDescriptors;
+  }
+
+  // FIXME: Remove once local-db backend will be pluggable.
+  /**
+   * Convert the provided {@code Set<LocalDBIndexCfgDefn.IndexType} to a
+   * {@code Set<IndexTypeDescriptor>}.
+   *
+   * @param indexTypes
+   *          A set of {@code Set<LocalDBIndexCfgDefn.IndexType>}
+   * @return A set of {@code Set<IndexTypeDescriptor>} corresponding to the
+   *         provided {@code Set<LocalDBIndexCfgDefn.IndexType>}
+   */
+  public static Set<IndexTypeDescriptor> fromLocalDBIndexTypes(final Set<LocalDBIndexCfgDefn.IndexType> indexTypes)
+  {
+    final Set<IndexTypeDescriptor> indexTypeDescriptors = new LinkedHashSet<IndexTypeDescriptor>();
+    for (final LocalDBIndexCfgDefn.IndexType indexType : indexTypes)
+    {
+      indexTypeDescriptors.add(fromLocalDBIndexType(indexType));
+    }
+    return indexTypeDescriptors;
+  }
+
+  /**
+   * Convert the provided {@code Set<IndexTypeDescriptor>} to a
+   * {@code Set<BackendIndexCfgDefn.IndexType>}.
+   *
+   * @param indexTypeDescriptors
+   *          A set of {@code Set<IndexTypeDescriptor>}
+   * @return A set of {@code Set<BackendIndexCfgDefn.IndexType>} corresponding
+   *         to the provided {@code Set<IndexTypeDescriptor>}
+   */
+  public static Set<BackendIndexCfgDefn.IndexType> toBackendIndexTypes(
+      final Set<IndexTypeDescriptor> indexTypeDescriptors)
+  {
+    final Set<BackendIndexCfgDefn.IndexType> indexTypes = new LinkedHashSet<BackendIndexCfgDefn.IndexType>();
+    for (final IndexTypeDescriptor indexTypeDescriptor : indexTypeDescriptors)
+    {
+      indexTypes.add(indexTypeDescriptor.toBackendIndexType());
+    }
+    return indexTypes;
+  }
+
+  // FIXME: Remove once local-db backend will be pluggable.
+  /**
+   * Convert the provided {@code Set<IndexTypeDescriptor>} to a
+   * {@code Set<LocalDBIndexCfgDefn.IndexType>}.
+   *
+   * @param indexTypeDescriptors
+   *          A set of {@code Set<IndexTypeDescriptor>}
+   * @return A set of {@code Set<LocalDBIndexCfgDefn.IndexType>} corresponding
+   *         to the provided {@code Set<IndexTypeDescriptor>}
+   */
+  public static Set<LocalDBIndexCfgDefn.IndexType> toLocalDBIndexTypes(
+      final Set<IndexTypeDescriptor> indexTypeDescriptors)
+  {
+    final Set<LocalDBIndexCfgDefn.IndexType> indexTypes = new LinkedHashSet<LocalDBIndexCfgDefn.IndexType>();
+    for (final IndexTypeDescriptor indexTypeDescriptor : indexTypeDescriptors)
+    {
+      indexTypes.add(indexTypeDescriptor.toLocalDBIndexType());
+    }
+    return indexTypes;
+  }
+
+}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractIndexPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractIndexPanel.java
index 7c40357..d50cbbc 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractIndexPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractIndexPanel.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2008-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
+ *      Portions Copyright 2014-2015 ForgeRock AS
  */
 
 
@@ -46,12 +46,12 @@
 import javax.swing.JPanel;
 import javax.swing.JTextField;
 
+import org.forgerock.i18n.LocalizableMessage;
+import org.opends.guitools.controlpanel.datamodel.IndexTypeDescriptor;
 import org.opends.guitools.controlpanel.ui.components.TitlePanel;
 import org.opends.guitools.controlpanel.ui.renderer.CustomListCellRenderer;
 import org.opends.guitools.controlpanel.util.Utilities;
-import org.forgerock.i18n.LocalizableMessage;
 import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn;
-import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType;
 import org.opends.server.types.AttributeType;
 
 /**
@@ -168,9 +168,10 @@
   /**
    * Array of index types that matches the array of checkboxes (types).
    */
-  protected IndexType[] configTypes = {IndexType.APPROXIMATE,
-      IndexType.EQUALITY, IndexType.ORDERING, IndexType.PRESENCE,
-      IndexType.SUBSTRING
+  protected IndexTypeDescriptor[] configTypes = {
+    IndexTypeDescriptor.APPROXIMATE, IndexTypeDescriptor.EQUALITY,
+    IndexTypeDescriptor.ORDERING, IndexTypeDescriptor.PRESENCE,
+    IndexTypeDescriptor.SUBSTRING
   };
 
   /**
@@ -374,9 +375,9 @@
    * @return a sorted set of indexes (that matches what the user selected
    * on the check boxes).
    */
-  protected SortedSet<IndexType> getTypes()
+  protected SortedSet<IndexTypeDescriptor> getTypes()
   {
-    SortedSet<IndexType> indexTypes = new TreeSet<IndexType>();
+    SortedSet<IndexTypeDescriptor> indexTypes = new TreeSet<IndexTypeDescriptor>();
     for (int i=0; i<types.length; i++)
     {
       if (types[i].isSelected())
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
index c4cdc7e..d958fa3 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
@@ -65,6 +65,7 @@
 import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
 import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement;
 import org.opends.guitools.controlpanel.datamodel.IndexDescriptor;
+import org.opends.guitools.controlpanel.datamodel.IndexTypeDescriptor;
 import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
 import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor;
 import org.opends.guitools.controlpanel.datamodel.VLVSortOrder;
@@ -75,7 +76,6 @@
 import org.opends.guitools.controlpanel.util.LowerCaseComparator;
 import org.opends.guitools.controlpanel.util.Utilities;
 import org.opends.server.admin.DefinedDefaultBehaviorProvider;
-import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType;
 import org.opends.server.admin.std.meta.LocalDBVLVIndexCfgDefn;
 import org.opends.server.admin.std.meta.LocalDBVLVIndexCfgDefn.Scope;
 import org.opends.server.protocols.ldap.LDAPFilter;
@@ -526,9 +526,9 @@
           { FilterType.EQUALITY, FilterType.SUBSTRING, FilterType.GREATER_OR_EQUAL, FilterType.LESS_OR_EQUAL,
             FilterType.PRESENT, FilterType.APPROXIMATE_MATCH, FilterType.EXTENSIBLE_MATCH };
 
-      IndexType[] indexTypes =
-          { IndexType.EQUALITY, IndexType.SUBSTRING, IndexType.ORDERING,
-            IndexType.ORDERING, IndexType.PRESENCE, IndexType.APPROXIMATE, null };
+      IndexTypeDescriptor[] indexTypes =
+          { IndexTypeDescriptor.EQUALITY, IndexTypeDescriptor.SUBSTRING, IndexTypeDescriptor.ORDERING,
+            IndexTypeDescriptor.ORDERING, IndexTypeDescriptor.PRESENCE, IndexTypeDescriptor.APPROXIMATE, null };
 
       LocalizableMessage[] indexTypeNames =
           { INFO_CTRL_PANEL_VLV_INDEX_EQUALITY_TYPE.get(), INFO_CTRL_PANEL_VLV_INDEX_SUBSTRING_TYPE.get(),
@@ -541,7 +541,7 @@
           IndexDescriptor index = getIndex(filter.getAttributeType());
           if (index != null)
           {
-            IndexType type = indexTypes[i];
+            IndexTypeDescriptor type = indexTypes[i];
             if (type != null && !index.getTypes().contains(type))
             {
               msgs.add(INFO_CTRL_PANEL_MUST_UPDATE_INDEX_DEFINITION_TYPE.get(filter.getAttributeType(),
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/IndexPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/IndexPanel.java
index 95db5c7..59a95e5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/IndexPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/IndexPanel.java
@@ -57,9 +57,12 @@
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.config.server.ConfigException;
 import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor;
 import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
 import org.opends.guitools.controlpanel.datamodel.IndexDescriptor;
+import org.opends.guitools.controlpanel.datamodel.IndexTypeDescriptor;
 import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
 import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
 import org.opends.guitools.controlpanel.event.ScrollPaneBorderListener;
@@ -68,15 +71,12 @@
 import org.opends.guitools.controlpanel.task.Task;
 import org.opends.guitools.controlpanel.util.ConfigReader;
 import org.opends.guitools.controlpanel.util.Utilities;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.opendj.config.server.ConfigException;
 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.LocalDBIndexCfgClient;
 import org.opends.server.admin.std.client.RootCfgClient;
-import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.types.AttributeType;
 import org.opends.server.types.DN;
@@ -409,7 +409,7 @@
     ordering.setSelected(false);
     substring.setSelected(false);
     presence.setSelected(false);
-    for (IndexType type : index.getTypes())
+    for (IndexTypeDescriptor type : index.getTypes())
     {
       switch(type)
       {
@@ -496,7 +496,7 @@
     private String backendName;
     private int entryLimitValue;
     private IndexDescriptor indexToModify;
-    private SortedSet<IndexType> indexTypes = new TreeSet<IndexType>();
+    private SortedSet<IndexTypeDescriptor> indexTypes = new TreeSet<IndexTypeDescriptor>();
     private IndexDescriptor modifiedIndex;
 
     /**
@@ -655,9 +655,9 @@
       lines.add("objectClass: top");
       lines.add("ds-cfg-attribute: " + attributeName);
       lines.add("ds-cfg-index-entry-limit: " + entryLimitValue);
-      for (IndexType type : indexTypes)
+      for (IndexTypeDescriptor type : indexTypes)
       {
-        lines.add("ds-cfg-index-type: " + type);
+        lines.add("ds-cfg-index-type: " + type.toLocalDBIndexType());
       }
 
       final StringBuilder sb = new StringBuilder();
@@ -725,7 +725,7 @@
       LocalDBIndexCfgClient index = backend.getLocalDBIndex(attributeName);
       if (!indexTypes.equals(indexToModify.getTypes()))
       {
-        index.setIndexType(indexTypes);
+        index.setIndexType(IndexTypeDescriptor.toLocalDBIndexTypes(indexTypes));
       }
       if (entryLimitValue != index.getIndexEntryLimit())
       {
@@ -811,8 +811,8 @@
       if (!indexTypes.equals(indexToModify.getTypes()))
       {
         // To add
-        Set<IndexType> toAdd = new TreeSet<IndexType>();
-        for (IndexType newType : indexTypes)
+        Set<IndexTypeDescriptor> toAdd = new TreeSet<IndexTypeDescriptor>();
+        for (IndexTypeDescriptor newType : indexTypes)
         {
           if (!indexToModify.getTypes().contains(newType))
           {
@@ -820,23 +820,23 @@
           }
         }
         // To delete
-        Set<IndexType> toDelete = new TreeSet<IndexType>();
-        for (IndexType oldType : indexToModify.getTypes())
+        Set<IndexTypeDescriptor> toDelete = new TreeSet<IndexTypeDescriptor>();
+        for (IndexTypeDescriptor oldType : indexToModify.getTypes())
         {
           if (!indexTypes.contains(oldType))
           {
             toDelete.add(oldType);
           }
         }
-        for (IndexType newType : toDelete)
+        for (IndexTypeDescriptor newType : toDelete)
         {
           args.add("--remove");
           args.add("index-type:" + newType);
         }
-        for (IndexType newType : toAdd)
+        for (IndexTypeDescriptor newType : toAdd)
         {
           args.add("--add");
-          args.add("index-type:" + newType);
+          args.add("index-type:" + newType.toLocalDBIndexType());
         }
       }
       if (entryLimitValue != indexToModify.getEntryLimit())
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewIndexPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
index 4614a16..a1c120f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
@@ -53,10 +53,13 @@
 import javax.swing.JCheckBox;
 import javax.swing.SwingUtilities;
 
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.ldap.ByteString;
 import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
 import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement;
 import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
 import org.opends.guitools.controlpanel.datamodel.IndexDescriptor;
+import org.opends.guitools.controlpanel.datamodel.IndexTypeDescriptor;
 import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
 import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
 import org.opends.guitools.controlpanel.task.OfflineUpdateException;
@@ -64,12 +67,9 @@
 import org.opends.guitools.controlpanel.task.Task;
 import org.opends.guitools.controlpanel.util.ConfigReader;
 import org.opends.guitools.controlpanel.util.Utilities;
-import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.types.Attribute;
 import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.ldap.ByteString;
 import org.opends.server.types.DN;
 import org.opends.server.types.Entry;
 import org.opends.server.types.LDIFImportConfig;
@@ -77,6 +77,7 @@
 import org.opends.server.types.Schema;
 import org.opends.server.util.LDIFReader;
 import org.opends.server.util.ServerConstants;
+
 import com.forgerock.opendj.cli.CommandBuilder;
 
 /**
@@ -382,7 +383,7 @@
     private Set<String> backendSet;
     private String attributeName;
     private int entryLimitValue;
-    private SortedSet<IndexType> indexTypes;
+    private SortedSet<IndexTypeDescriptor> indexTypes;
 
     /**
      * The constructor of the task.
@@ -533,9 +534,9 @@
       lines.add("objectClass: top");
       lines.add("ds-cfg-attribute: "+attributeName);
       lines.add("ds-cfg-index-entry-limit: "+entryLimitValue);
-      for (IndexType type : indexTypes)
+      for (IndexTypeDescriptor type : indexTypes)
       {
-        lines.add("ds-cfg-index-type: " + type);
+        lines.add("ds-cfg-index-type: " + type.toLocalDBIndexType());
       }
       StringBuilder sb = new StringBuilder();
       for (String line : lines)
@@ -713,10 +714,10 @@
       args.add("--index-name");
       args.add(attributeName);
 
-      for (IndexType type : indexTypes)
+      for (IndexTypeDescriptor type : indexTypes)
       {
         args.add("--set");
-        args.add("index-type:"+type);
+        args.add("index-type:"+type.toLocalDBIndexType());
       }
       args.add("--set");
       args.add("index-entry-limit:"+entryLimitValue);
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
index 77d117b..0adca9a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
@@ -60,6 +60,7 @@
 import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor;
 import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.datamodel.IndexDescriptor;
+import org.opends.guitools.controlpanel.datamodel.IndexTypeDescriptor;
 import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor;
 import org.opends.guitools.controlpanel.datamodel.VLVSortOrder;
 import org.opends.guitools.controlpanel.task.OnlineUpdateException;
@@ -91,7 +92,6 @@
 import org.opends.server.admin.std.client.RootDNUserCfgClient;
 import org.opends.server.admin.std.client.SNMPConnectionHandlerCfgClient;
 import org.opends.server.admin.std.client.TaskBackendCfgClient;
-import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType;
 import org.opends.server.config.ConfigConstants;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.tools.tasks.TaskEntry;
@@ -482,16 +482,16 @@
         LocalDBIndexCfgClient index = db.getLocalDBIndex(indexName);
         indexes.add(new IndexDescriptor(
             index.getAttribute().getNameOrOID(), index.getAttribute(),
-            null, index.getIndexType(), index.getIndexEntryLimit()));
+            null, IndexTypeDescriptor.fromLocalDBIndexTypes(index.getIndexType()), index.getIndexEntryLimit()));
       }
     }
     catch (OpenDsException oe)
     {
       errors.add(oe);
     }
-    indexes.add(new IndexDescriptor("dn2id", null, null, new TreeSet<IndexType>(), -1));
-    indexes.add(new IndexDescriptor("id2children", null, null, new TreeSet<IndexType>(), -1));
-    indexes.add(new IndexDescriptor("id2subtree", null, null, new TreeSet<IndexType>(), -1));
+    indexes.add(new IndexDescriptor("dn2id", null, null, new TreeSet<IndexTypeDescriptor>(), -1));
+    indexes.add(new IndexDescriptor("id2children", null, null, new TreeSet<IndexTypeDescriptor>(), -1));
+    indexes.add(new IndexDescriptor("id2subtree", null, null, new TreeSet<IndexTypeDescriptor>(), -1));
 
     try
     {
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
index 7009980..2baf4a7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
@@ -48,11 +48,11 @@
 import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor;
 import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
 import org.opends.guitools.controlpanel.datamodel.IndexDescriptor;
+import org.opends.guitools.controlpanel.datamodel.IndexTypeDescriptor;
 import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor;
 import org.opends.guitools.controlpanel.datamodel.VLVSortOrder;
 import org.opends.guitools.controlpanel.task.OfflineUpdateException;
 import org.opends.server.admin.server.ServerManagementContext;
-import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType;
 import org.opends.server.admin.std.server.AdministrationConnectorCfg;
 import org.opends.server.admin.std.server.BackendCfg;
 import org.opends.server.admin.std.server.BackupBackendCfg;
@@ -237,16 +237,16 @@
             {
               final LocalDBIndexCfg index = db.getLocalDBIndex(indexName);
               indexes.add(new IndexDescriptor(index.getAttribute().getNameOrOID(), index.getAttribute(), null,
-                  index.getIndexType(), index.getIndexEntryLimit()));
+                  IndexTypeDescriptor.fromLocalDBIndexTypes(index.getIndexType()), index.getIndexEntryLimit()));
             }
           }
           catch (final ConfigException ce)
           {
             errors.add(toConfigException(ce));
           }
-          indexes.add(new IndexDescriptor("dn2id", null, null, new TreeSet<IndexType>(), -1));
-          indexes.add(new IndexDescriptor("id2children", null, null, new TreeSet<IndexType>(), -1));
-          indexes.add(new IndexDescriptor("id2subtree", null, null, new TreeSet<IndexType>(), -1));
+          indexes.add(new IndexDescriptor("dn2id", null, null, new TreeSet<IndexTypeDescriptor>(), -1));
+          indexes.add(new IndexDescriptor("id2children", null, null, new TreeSet<IndexTypeDescriptor>(), -1));
+          indexes.add(new IndexDescriptor("id2subtree", null, null, new TreeSet<IndexTypeDescriptor>(), -1));
 
           try
           {

--
Gitblit v1.10.0