From 656ab2dd56a9464df6e907d75ca1e40c927e945f Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 15 Apr 2015 20:01:20 +0000
Subject: [PATCH] Code cleanup

---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java      |   52 +++++----
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java |  208 ++++++++++++++++-------------------------
 2 files changed, 108 insertions(+), 152 deletions(-)

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 38fd081..c4cdc7e 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
@@ -24,9 +24,9 @@
  *      Copyright 2008-2010 Sun Microsystems, Inc.
  *      Portions Copyright 2014-2015 ForgeRock AS
  */
-
 package org.opends.guitools.controlpanel.ui;
 
+import static org.opends.guitools.controlpanel.util.Utilities.*;
 import static org.opends.messages.AdminToolMessages.*;
 
 import java.awt.Component;
@@ -60,6 +60,7 @@
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
 
+import org.forgerock.i18n.LocalizableMessage;
 import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
 import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
 import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement;
@@ -73,10 +74,9 @@
 import org.opends.guitools.controlpanel.ui.renderer.VLVSortOrderRenderer;
 import org.opends.guitools.controlpanel.util.LowerCaseComparator;
 import org.opends.guitools.controlpanel.util.Utilities;
-import org.forgerock.i18n.LocalizableMessage;
 import org.opends.server.admin.DefinedDefaultBehaviorProvider;
-import org.opends.server.admin.std.meta.LocalDBVLVIndexCfgDefn;
 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;
 import org.opends.server.types.AttributeType;
@@ -92,126 +92,103 @@
  * Abstract class used to re-factor some code between the classes that are used
  * to edit/create a VLV index.
  */
-public abstract class AbstractVLVIndexPanel extends StatusGenericPanel
+abstract class AbstractVLVIndexPanel extends StatusGenericPanel
 {
   private static final long serialVersionUID = -82857384664911898L;
+
   /** Title panel. */
-  protected TitlePanel titlePanel = new TitlePanel(LocalizableMessage.EMPTY, LocalizableMessage.EMPTY);
-
+  protected final TitlePanel titlePanel = new TitlePanel(LocalizableMessage.EMPTY, LocalizableMessage.EMPTY);
   /** Name label. */
-  protected JLabel lName = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_NAME_LABEL.get());
-
+  private final JLabel lName = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_NAME_LABEL.get());
   /** Base DN label. */
-  protected JLabel lBaseDN = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_BASE_DN_LABEL.get());
-
+  private final JLabel lBaseDN = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_BASE_DN_LABEL.get());
   /** Search scope label. */
-  protected JLabel lSearchScope = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_SEARCH_SCOPE_LABEL.get());
-
+  private final JLabel lSearchScope = createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_SEARCH_SCOPE_LABEL.get());
   /** Search filter label. */
-  protected JLabel lFilter = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_FILTER_LABEL.get());
-
+  private final JLabel lFilter = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_FILTER_LABEL.get());
   /** Sort order label. */
-  protected JLabel lSortOrder = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_SORT_ORDER_LABEL.get());
-
+  private final JLabel lSortOrder = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_SORT_ORDER_LABEL.get());
   /** Backends label. */
-  protected JLabel lBackend = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_BACKEND_LABEL.get());
-
+  private final JLabel lBackend = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_BACKEND_LABEL.get());
   /** Max block size label. */
-  protected JLabel lMaxBlockSize = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_MAX_BLOCK_SIZE_LABEL.get());
+  private final JLabel lMaxBlockSize = createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_MAX_BLOCK_SIZE_LABEL.get());
+  /** Read-only name label. */
+  protected final JLabel readOnlyName = Utilities.createDefaultLabel();
+  /** Read-only backend name label. */
+  protected final JLabel backendName = Utilities.createDefaultLabel();
 
   /** Name text field. */
-  protected JTextField name = Utilities.createMediumTextField();
-
-  /** Read-only name label. */
-  protected JLabel readOnlyName = Utilities.createDefaultLabel();
-
-  /** Read-only backend name label. */
-  protected JLabel backendName = Utilities.createDefaultLabel();
-
+  protected final JTextField name = Utilities.createMediumTextField();
   /** Base DNs combo box. */
-  protected JComboBox baseDNs = Utilities.createComboBox();
-
+  protected final JComboBox baseDNs = Utilities.createComboBox();
   /** Subtree text field. */
-  protected JTextField baseDN = Utilities.createLongTextField();
+  protected final JTextField baseDN = Utilities.createLongTextField();
 
   /** Base Object scope radio button. */
-  protected JRadioButton baseObject = Utilities.createRadioButton(INFO_CTRL_PANEL_VLV_INDEX_BASE_OBJECT_LABEL.get());
-
+  protected final JRadioButton baseObject = createRadioButton(INFO_CTRL_PANEL_VLV_INDEX_BASE_OBJECT_LABEL.get());
   /** Single Level scope radio button. */
-  protected JRadioButton singleLevel = Utilities.createRadioButton(INFO_CTRL_PANEL_VLV_INDEX_SINGLE_LEVEL_LABEL.get());
-
+  protected final JRadioButton singleLevel = createRadioButton(INFO_CTRL_PANEL_VLV_INDEX_SINGLE_LEVEL_LABEL.get());
   /** Subordinate subtree scope radio button. */
-  protected JRadioButton subordinateSubtree = Utilities
+  protected final JRadioButton subordinateSubtree = Utilities
       .createRadioButton(INFO_CTRL_PANEL_VLV_INDEX_SUBORDINATE_SUBTREE_LABEL.get());
-
   /** Whole subtree scope radio button. */
-  protected JRadioButton wholeSubtree = Utilities
+  protected final JRadioButton wholeSubtree = Utilities
       .createRadioButton(INFO_CTRL_PANEL_VLV_INDEX_WHOLE_SUBTREE_LABEL.get());
 
   /** Filter text field. */
-  protected JTextField filter = Utilities.createLongTextField();
-
+  protected final JTextField filter = Utilities.createLongTextField();
   /** Max block size text field. */
-  protected JTextField maxBlockSize = Utilities.createShortTextField();
-
+  protected final JTextField maxBlockSize = Utilities.createShortTextField();
   /** Attributes combo box. */
-  protected JComboBox attributes = Utilities.createComboBox();
+  protected final JComboBox attributes = Utilities.createComboBox();
 
   /** The list containing the sort order elements. */
-  protected JList sortOrder = new JList();
+  protected final JList sortOrder = new JList();
 
   /** The add button. */
-  protected JButton add = Utilities.createButton(INFO_CTRL_PANEL_VLV_INDEX_ADD_BUTTON_LABEL.get());
-
+  private final JButton add = Utilities.createButton(INFO_CTRL_PANEL_VLV_INDEX_ADD_BUTTON_LABEL.get());
   /** The move up button. */
-  protected JButton moveUp = Utilities.createButton(INFO_CTRL_PANEL_VLV_INDEX_MOVE_UP_BUTTON_LABEL.get());
-
+  private final JButton moveUp = Utilities.createButton(INFO_CTRL_PANEL_VLV_INDEX_MOVE_UP_BUTTON_LABEL.get());
   /** The move down button. */
-  protected JButton moveDown = Utilities.createButton(INFO_CTRL_PANEL_VLV_INDEX_MOVE_DOWN_BUTTON_LABEL.get());
-
+  private final JButton moveDown = Utilities.createButton(INFO_CTRL_PANEL_VLV_INDEX_MOVE_DOWN_BUTTON_LABEL.get());
   /** The remove button. */
-  protected JButton remove = Utilities.createButton(INFO_CTRL_PANEL_VLV_INDEX_REMOVE_BUTTON_LABEL.get());
+  protected final JButton remove = Utilities.createButton(INFO_CTRL_PANEL_VLV_INDEX_REMOVE_BUTTON_LABEL.get());
 
   /** Ascending order combo box. */
-  protected JComboBox ascendingOrder = Utilities.createComboBox();
+  private final JComboBox ascendingOrder = Utilities.createComboBox();
 
   /** Combo box containing the sort order. */
   protected DefaultListModel sortOrderModel;
 
   /** The list of labels. */
-  protected JLabel[] labels = { lName, lBaseDN, lSearchScope, lFilter, lSortOrder, lBackend, lMaxBlockSize };
+  private final JLabel[] labels = { lName, lBaseDN, lSearchScope, lFilter, lSortOrder, lBackend, lMaxBlockSize };
 
   /**
    * The relative component that must be used to center the parent dialog of
    * this panel.
    */
-  protected Component relativeComponent;
+  private final Component relativeComponent;
 
   /** Other base DN message. */
   protected final LocalizableMessage OTHER_BASE_DN = INFO_CTRL_PANEL_VLV_OTHER_BASE_DN_LABEL.get();
-
   /** Ascending message. */
-  protected final LocalizableMessage ASCENDING = INFO_CTRL_PANEL_VLV_ASCENDING_LABEL.get();
-
+  private final LocalizableMessage ASCENDING = INFO_CTRL_PANEL_VLV_ASCENDING_LABEL.get();
   /** Descending message. */
-  protected final LocalizableMessage DESCENDING = INFO_CTRL_PANEL_VLV_DESCENDING_LABEL.get();
+  private final LocalizableMessage DESCENDING = INFO_CTRL_PANEL_VLV_DESCENDING_LABEL.get();
 
   /** Custom attributes message. */
-  protected LocalizableMessage CUSTOM_ATTRIBUTES = INFO_CTRL_PANEL_CUSTOM_ATTRIBUTES_LABEL.get();
-
+  private final LocalizableMessage CUSTOM_ATTRIBUTES = INFO_CTRL_PANEL_CUSTOM_ATTRIBUTES_LABEL.get();
   /** Standard attributes message. */
-  protected LocalizableMessage STANDARD_ATTRIBUTES = INFO_CTRL_PANEL_STANDARD_ATTRIBUTES_LABEL.get();
+  private final LocalizableMessage STANDARD_ATTRIBUTES = INFO_CTRL_PANEL_STANDARD_ATTRIBUTES_LABEL.get();
 
   /** The list of standard attribute names. */
-  protected TreeSet<String> standardAttrNames = new TreeSet<String>(new LowerCaseComparator());
-
+  private final TreeSet<String> standardAttrNames = new TreeSet<String>(new LowerCaseComparator());
   /** The list of configuration attribute names. */
-  protected TreeSet<String> configurationAttrNames = new TreeSet<String>(new LowerCaseComparator());
-
+  private final TreeSet<String> configurationAttrNames = new TreeSet<String>(new LowerCaseComparator());
   /** The list of custom attribute names. */
-  protected TreeSet<String> customAttrNames = new TreeSet<String>(new LowerCaseComparator());
+  private final TreeSet<String> customAttrNames = new TreeSet<String>(new LowerCaseComparator());
 
-  private int defaultVLVEntryLimitValue;
+  private final int defaultVLVEntryLimitValue;
   {
     DefinedDefaultBehaviorProvider<Integer> provider =
         (DefinedDefaultBehaviorProvider<Integer>) LocalDBVLVIndexCfgDefn.getInstance()
@@ -220,14 +197,12 @@
   }
 
   /** Minimum value for max block size. */
-  protected final int MIN_MAX_BLOCK_SIZE = LocalDBVLVIndexCfgDefn.getInstance().getMaxBlockSizePropertyDefinition()
+  private final int MIN_MAX_BLOCK_SIZE = LocalDBVLVIndexCfgDefn.getInstance().getMaxBlockSizePropertyDefinition()
       .getLowerLimit();
-
   /** Maximum value for max block size. */
-  protected final int MAX_MAX_BLOCK_SIZE = 2147483647;
-
+  private final int MAX_MAX_BLOCK_SIZE = 2147483647;
   /** Default value for max block size. */
-  protected final int DEFAULT_MAX_BLOCK_SIZE = defaultVLVEntryLimitValue;
+  private final int DEFAULT_MAX_BLOCK_SIZE = defaultVLVEntryLimitValue;
 
   /**
    * Constructor.
@@ -240,7 +215,6 @@
    */
   protected AbstractVLVIndexPanel(String backendID, Component relativeComponent)
   {
-    super();
     if (backendID != null)
     {
       backendName.setText(backendID);
@@ -395,18 +369,7 @@
         for (AttributeType attr : schema.getAttributeTypes().values())
         {
           String name = attr.getPrimaryName();
-          boolean defined = false;
-          ListModel model = sortOrder.getModel();
-          for (int i = 0; i < model.getSize(); i++)
-          {
-            VLVSortOrder s = (VLVSortOrder) model.getElementAt(i);
-            if (name.equalsIgnoreCase(s.getAttributeName()))
-            {
-              defined = true;
-              break;
-            }
-          }
-          if (!defined)
+          if (!isDefined(name))
           {
             if (Utilities.isStandard(attr))
             {
@@ -439,15 +402,6 @@
           newElements.add(new CategorizedComboBoxElement(attrName, CategorizedComboBoxElement.Type.REGULAR));
         }
       }
-      // Ignore configuration attr names
-      /*
-       * if (configurationAttrNames.size() > 0) { newElements.add(new
-       * CategorizedComboBoxDescriptor( "Configuration Attributes",
-       * CategorizedComboBoxDescriptor.Type.CATEGORY)); for (String attrName :
-       * configurationAttrNames) { newElements.add(new
-       * CategorizedComboBoxDescriptor( attrName,
-       * CategorizedComboBoxDescriptor.Type.REGULAR)); } }
-       */
       DefaultComboBoxModel model = (DefaultComboBoxModel) attributes.getModel();
       updateComboBoxModel(newElements, model);
     }
@@ -461,6 +415,7 @@
 
     SwingUtilities.invokeLater(new Runnable()
     {
+      @Override
       public void run()
       {
         if (getButtonType() == GenericDialog.ButtonType.OK)
@@ -484,6 +439,20 @@
     return !error[0];
   }
 
+  private boolean isDefined(String name)
+  {
+    ListModel model = sortOrder.getModel();
+    for (int i = 0; i < model.getSize(); i++)
+    {
+      VLVSortOrder s = (VLVSortOrder) model.getElementAt(i);
+      if (name.equalsIgnoreCase(s.getAttributeName()))
+      {
+        return true;
+      }
+    }
+    return false;
+  }
+
   /**
    * Returns <CODE>true</CODE> if the user accepts to continue creating the VLV
    * index even if no indexes are created for the provided filter for the VLV
@@ -499,7 +468,6 @@
    */
   protected boolean checkIndexRequired()
   {
-    boolean confirm = true;
     String f = filter.getText().trim();
     try
     {
@@ -513,17 +481,16 @@
         {
           sb.append("<br>-").append(msg);
         }
-        confirm =
-            displayConfirmationDialog(INFO_CTRL_PANEL_VLV_INDEXES_NOT_DEFINED_CONFIRMATION_TITLE.get(),
+        return displayConfirmationDialog(INFO_CTRL_PANEL_VLV_INDEXES_NOT_DEFINED_CONFIRMATION_TITLE.get(),
                 INFO_CTRL_PANEL_VLV_INDEXES_NOT_DEFINED_CONFIRMATION_MSG.get(getBackend().getBackendID(), sb));
       }
+      return true;
     }
     catch (Throwable t)
     {
       // Bug
       throw new RuntimeException("Unexpected error: " + t, t);
     }
-    return confirm;
   }
 
   /**
@@ -608,7 +575,6 @@
    */
   private IndexDescriptor getIndex(String indexName)
   {
-    IndexDescriptor index = null;
     BackendDescriptor backend = getBackend();
     if (backend != null)
     {
@@ -616,12 +582,11 @@
       {
         if (i.getName().equalsIgnoreCase(indexName))
         {
-          index = i;
-          break;
+          return i;
         }
       }
     }
-    return index;
+    return null;
   }
 
   /**
@@ -759,19 +724,16 @@
    *
    * @return the backend for the index.
    */
-  protected BackendDescriptor getBackend()
+  private BackendDescriptor getBackend()
   {
-    //  Check that the index does not exist
-    BackendDescriptor backend = null;
     for (BackendDescriptor b : getInfo().getServerDescriptor().getBackends())
     {
       if (b.getBackendID().equalsIgnoreCase(backendName.getText()))
       {
-        backend = b;
-        break;
+        return b;
       }
     }
-    return backend;
+    return null;
   }
 
   /**
@@ -786,14 +748,7 @@
     {
       selectedItem = baseDN.getText().trim();
     }
-    if (selectedItem != null)
-    {
-      return selectedItem.toString();
-    }
-    else
-    {
-      return null;
-    }
+    return selectedItem != null ? selectedItem.toString() : null;
   }
 
   /**
@@ -801,19 +756,10 @@
    *
    * @return the selected attribute.
    */
-  protected String getSelectedAttribute()
+  private String getSelectedAttribute()
   {
-    String attrName;
     CategorizedComboBoxElement o = (CategorizedComboBoxElement) attributes.getSelectedItem();
-    if (o != null)
-    {
-      attrName = o.getValue().toString();
-    }
-    else
-    {
-      attrName = null;
-    }
-    return attrName;
+    return o != null ? o.getValue().toString() : null;
   }
 
   /**
@@ -905,6 +851,7 @@
     baseDNs.addItemListener(listener);
     baseDNs.addItemListener(new ItemListener()
     {
+      @Override
       public void itemStateChanged(ItemEvent ev)
       {
         baseDN.setEnabled(OTHER_BASE_DN.equals(baseDNs.getSelectedItem()));
@@ -986,6 +933,7 @@
 
     final ListSelectionListener listListener = new ListSelectionListener()
     {
+      @Override
       public void valueChanged(ListSelectionEvent ev)
       {
         int[] indexes = sortOrder.getSelectedIndices();
@@ -1013,6 +961,7 @@
 
     add.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent ev)
       {
         String attr = getSelectedAttribute();
@@ -1057,6 +1006,7 @@
     });
     moveUp.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent ev)
       {
         int[] indexes = sortOrder.getSelectedIndices();
@@ -1075,6 +1025,7 @@
     });
     moveDown.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent ev)
       {
         int[] indexes = sortOrder.getSelectedIndices();
@@ -1093,6 +1044,7 @@
     });
     remove.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent ev)
       {
         int[] indexes = sortOrder.getSelectedIndices();
@@ -1100,9 +1052,9 @@
         synchronized (standardAttrNames)
         {
           DefaultComboBoxModel model = (DefaultComboBoxModel) attributes.getModel();
-          for (int i = 0; i < indexes.length; i++)
+          for (int index : indexes)
           {
-            VLVSortOrder sortOrder = (VLVSortOrder) sortOrderModel.getElementAt(indexes[i]);
+            VLVSortOrder sortOrder = (VLVSortOrder) sortOrderModel.getElementAt(index);
             String attrName = sortOrder.getAttributeName();
             boolean isCustom = customAttrNames.contains(attrName);
             boolean dealingWithCustom = true;
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java
index c291c49..7a541fd 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java
@@ -24,7 +24,6 @@
  *      Copyright 2008-2009 Sun Microsystems, Inc.
  *      Portions Copyright 2014-2015 ForgeRock AS
  */
-
 package org.opends.guitools.controlpanel.ui;
 
 import static org.opends.guitools.controlpanel.util.Utilities.*;
@@ -64,6 +63,7 @@
 import org.opends.server.admin.std.meta.LocalDBVLVIndexCfgDefn.Scope;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
 import org.opends.server.types.Entry;
 import org.opends.server.types.LDIFImportConfig;
 import org.opends.server.types.OpenDsException;
@@ -72,7 +72,7 @@
 /**
  * Panel that appears when the user defines a new VLV index.
  */
-public class NewVLVIndexPanel extends AbstractVLVIndexPanel
+class NewVLVIndexPanel extends AbstractVLVIndexPanel
 {
   private static final long serialVersionUID = 1554866540747530939L;
 
@@ -85,7 +85,7 @@
    *          the component relative to which the dialog containing this panel
    *          will be centered.
    */
-  public NewVLVIndexPanel(String backendName, Component relativeComponent)
+  NewVLVIndexPanel(String backendName, Component relativeComponent)
   {
     super(backendName, relativeComponent);
     createBasicLayout(this, new GridBagConstraints(), false);
@@ -121,7 +121,7 @@
    * @param backend
    *          the backend where the index will be created.
    */
-  public void update(BackendDescriptor backend)
+  void update(BackendDescriptor backend)
   {
     updateBaseDNCombo(backend);
     backendName.setText(backend.getBackendID());
@@ -161,7 +161,7 @@
   }
 
   /** The task in charge of creating the VLV index. */
-  protected class NewVLVIndexTask extends Task
+  private class NewVLVIndexTask extends Task
   {
     private final Set<String> backendSet;
     private final String indexName;
@@ -183,7 +183,7 @@
      * @param dlg
      *          the progress dialog that shows the progress of the task.
      */
-    public NewVLVIndexTask(ControlPanelInfo info, ProgressDialog dlg)
+    private NewVLVIndexTask(ControlPanelInfo info, ProgressDialog dlg)
     {
       super(info, dlg);
       backendSet = new HashSet<String>();
@@ -220,7 +220,6 @@
     @Override
     public boolean canLaunch(Task taskToBeLaunched, Collection<LocalizableMessage> incompatibilityReasons)
     {
-      boolean canLaunch = true;
       if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
       {
         // All the operations are incompatible if they apply to this
@@ -231,10 +230,10 @@
         if (backends.size() > 0)
         {
           incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched));
-          canLaunch = false;
+          return false;
         }
       }
-      return canLaunch;
+      return true;
     }
 
     private void updateConfiguration() throws OpenDsException
@@ -311,21 +310,7 @@
       LDIFImportConfig ldifImportConfig = null;
       try
       {
-        final String topEntryDN =
-            "cn=VLV Index," + getRDNString("ds-cfg-backend-id", backendName.getText()) + ",cn=Backends,cn=config";
-        final boolean topEntryExists = DirectoryServer.getConfigHandler().entryExists(DN.valueOf(topEntryDN));
-
-        if (!topEntryExists)
-        {
-          final String completeLDIF =
-              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));
-        }
+        ldifImportConfig = new LDIFImportConfig(new StringReader(getLDIF()));
 
         final LDIFReader reader = new LDIFReader(ldifImportConfig);
         Entry backendConfigEntry;
@@ -348,6 +333,25 @@
       }
     }
 
+    private String getLDIF() throws DirectoryException
+    {
+      final String topEntryDN =
+          "cn=VLV Index," + getRDNString("ds-cfg-backend-id", backendName.getText()) + ",cn=Backends,cn=config";
+      final boolean topEntryExists = DirectoryServer.getConfigHandler().entryExists(DN.valueOf(topEntryDN));
+
+      if (!topEntryExists)
+      {
+        return makeLdif(
+            "dn: " + topEntryDN,
+            "objectClass: top",
+            "objectClass: ds-cfg-branch",
+            "cn: VLV Index",
+            "")
+            + ldif;
+      }
+      return ldif;
+    }
+
     private void createIndex(InitialLdapContext ctx) throws OpenDsException
     {
       final ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(ctx));

--
Gitblit v1.10.0