From 88071fbf6d8d1fff45bfd1b895c0a9250ac6d097 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Wed, 22 Apr 2015 09:16:38 +0000
Subject: [PATCH] OPENDJ-1934 Code cleanup
---
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractIndexPanel.java | 281 ++++++++++++-------------------
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewIndexPanel.java | 226 ++++++++++--------------
2 files changed, 204 insertions(+), 303 deletions(-)
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 d50cbbc..ae4d3fd 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
@@ -25,7 +25,6 @@
* Portions Copyright 2014-2015 ForgeRock AS
*/
-
package org.opends.guitools.controlpanel.ui;
import static org.opends.messages.AdminToolMessages.*;
@@ -57,158 +56,97 @@
/**
* Abstract class used to refactor some code between the classes that are used
* to edit/create an index.
- *
*/
-public abstract class AbstractIndexPanel extends StatusGenericPanel
+abstract class AbstractIndexPanel extends StatusGenericPanel
{
private static final long serialVersionUID = 4465529396749593707L;
- /**
- * Title panel.
- */
- protected TitlePanel titlePanel = new TitlePanel(LocalizableMessage.EMPTY,
- LocalizableMessage.EMPTY);
- /**
- * Attributes combo box.
- */
- protected JComboBox attributes = Utilities.createComboBox();
- /**
- * Name of the index label.
- */
- protected JLabel name = Utilities.createDefaultLabel();
- /**
- * Backends label.
- */
- protected JLabel lBackend = Utilities.createPrimaryLabel(
- INFO_CTRL_PANEL_BACKEND_LABEL.get());
- /**
- * Read-only backend name label.
- */
- protected JLabel backendName = Utilities.createDefaultLabel();
- /**
- * Label for attribute.
- */
- protected JLabel lAttribute =
- Utilities.createPrimaryLabel(INFO_CTRL_PANEL_ATTRIBUTE_LABEL.get());
- /**
- * Label for entry limit.
- */
- protected JLabel lEntryLimit =
- Utilities.createPrimaryLabel(INFO_CTRL_PANEL_ENTRY_LIMIT_LABEL.get());
- /**
- * Entry limit text field.
- */
- protected JTextField entryLimit = Utilities.createShortTextField();
- /**
- * Label for type.
- */
- protected JLabel lType =
- Utilities.createPrimaryLabel(INFO_CTRL_PANEL_INDEX_TYPE_LABEL.get());
- /**
- * Approximate index type check box.
- */
- protected JCheckBox approximate =
- Utilities.createCheckBox(INFO_CTRL_PANEL_APPROXIMATE_LABEL.get());
- /**
- * Equality index type check box.
- */
- protected JCheckBox equality =
- Utilities.createCheckBox(INFO_CTRL_PANEL_EQUALITY_LABEL.get());
- /**
- * Ordering index type check box.
- */
- protected JCheckBox ordering =
- Utilities.createCheckBox(INFO_CTRL_PANEL_ORDERING_LABEL.get());
- /**
- * Presence index type check box.
- */
- protected JCheckBox presence =
- Utilities.createCheckBox(INFO_CTRL_PANEL_PRESENCE_LABEL.get());
- /**
- * Substring index type check box.
- */
- protected JCheckBox substring =
- Utilities.createCheckBox(INFO_CTRL_PANEL_SUBSTRING_LABEL.get());
- /**
- * Delete index button.
- */
- protected JButton deleteIndex =
- Utilities.createButton(INFO_CTRL_PANEL_DELETE_INDEX_LABEL.get());
- /**
- * Save changes button.
- */
- protected JButton saveChanges =
- Utilities.createButton(INFO_CTRL_PANEL_SAVE_CHANGES_LABEL.get());
- /**
- * Label containing some warning information (such as the fact that the index
- * cannot be edited).
- */
- protected JLabel warning = Utilities.createDefaultLabel();
- /**
- * Panel containing all the index types.
- */
- protected JPanel typesPanel = new JPanel(new GridBagLayout());
- /**
- * LocalizableMessage to be displayed to indicate that an index is not configurable.
- */
- protected LocalizableMessage NON_CONFIGURABLE_INDEX =
- INFO_CTRL_PANEL_NON_CONFIGURABLE_INDEX_LABEL.get();
+ /** Custom attributes message. */
+ static LocalizableMessage CUSTOM_ATTRIBUTES = INFO_CTRL_PANEL_CUSTOM_ATTRIBUTES_LABEL.get();
- /**
- * LocalizableMessage to be displayed to indicate that an index has been modified.
- */
- protected LocalizableMessage INDEX_MODIFIED = INFO_CTRL_PANEL_INDEX_MODIFIED_LABEL.get();
+ /** Standard attributes message. */
+ static LocalizableMessage STANDARD_ATTRIBUTES = INFO_CTRL_PANEL_STANDARD_ATTRIBUTES_LABEL.get();
- /**
- * Array of checkboxes.
- */
- protected JCheckBox[] types = {approximate, equality, ordering, presence,
- substring};
+ /** Minimum value for entry limit. */
+ static final int MIN_ENTRY_LIMIT =
+ LocalDBIndexCfgDefn.getInstance().getIndexEntryLimitPropertyDefinition().getLowerLimit();
- /**
- * Array of index types that matches the array of checkboxes (types).
- */
- protected IndexTypeDescriptor[] configTypes = {
- IndexTypeDescriptor.APPROXIMATE, IndexTypeDescriptor.EQUALITY,
- IndexTypeDescriptor.ORDERING, IndexTypeDescriptor.PRESENCE,
- IndexTypeDescriptor.SUBSTRING
- };
+ /** Maximum value for entry limit. */
+ static final int MAX_ENTRY_LIMIT =
+ LocalDBIndexCfgDefn.getInstance().getIndexEntryLimitPropertyDefinition().getUpperLimit();
- /**
- * Custom attributes message.
- */
- protected LocalizableMessage CUSTOM_ATTRIBUTES =
- INFO_CTRL_PANEL_CUSTOM_ATTRIBUTES_LABEL.get();
- /**
- * Standard attributes message.
- */
- protected LocalizableMessage STANDARD_ATTRIBUTES =
- INFO_CTRL_PANEL_STANDARD_ATTRIBUTES_LABEL.get();
+ /** LocalizableMessage to be displayed to indicate that an index is not configurable. */
+ static LocalizableMessage NON_CONFIGURABLE_INDEX = INFO_CTRL_PANEL_NON_CONFIGURABLE_INDEX_LABEL.get();
- /**
- * Minimum value for entry limit.
- */
- protected final int MIN_ENTRY_LIMIT =
- LocalDBIndexCfgDefn.getInstance().getIndexEntryLimitPropertyDefinition().
- getLowerLimit();
- /**
- * Maximum value for entry limit.
- */
- protected final int MAX_ENTRY_LIMIT =
- LocalDBIndexCfgDefn.getInstance().getIndexEntryLimitPropertyDefinition().
- getUpperLimit();
+ /** LocalizableMessage to be displayed to indicate that an index has been modified. */
+ static LocalizableMessage INDEX_MODIFIED = INFO_CTRL_PANEL_INDEX_MODIFIED_LABEL.get();
- /**
- * Default value for entry limit.
- */
- protected final int DEFAULT_ENTRY_LIMIT = 4000;
+ /** Default value for entry limit. */
+ static final int DEFAULT_ENTRY_LIMIT = 4000;
+
+ TitlePanel titlePanel = new TitlePanel(LocalizableMessage.EMPTY, LocalizableMessage.EMPTY);
+
+ /** Attributes combo box. */
+ JComboBox attributes = Utilities.createComboBox();
+
+ /** Name of the index label. */
+ JLabel name = Utilities.createDefaultLabel();
+
+ /** Backends label. */
+ JLabel lBackend = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_BACKEND_LABEL.get());
+
+ /** Read-only backend name label. */
+ JLabel backendName = Utilities.createDefaultLabel();
+
+ JLabel lAttribute = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_ATTRIBUTE_LABEL.get());
+
+ JLabel lEntryLimit = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_ENTRY_LIMIT_LABEL.get());
+
+ JTextField entryLimit = Utilities.createShortTextField();
+
+ JLabel lType = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_INDEX_TYPE_LABEL.get());
+
+ /** Approximate index type check box. */
+ JCheckBox approximate = Utilities.createCheckBox(INFO_CTRL_PANEL_APPROXIMATE_LABEL.get());
+
+ /** Equality index type check box. */
+ JCheckBox equality = Utilities.createCheckBox(INFO_CTRL_PANEL_EQUALITY_LABEL.get());
+
+ /** Ordering index type check box. */
+ JCheckBox ordering = Utilities.createCheckBox(INFO_CTRL_PANEL_ORDERING_LABEL.get());
+
+ /** Presence index type check box. */
+ JCheckBox presence = Utilities.createCheckBox(INFO_CTRL_PANEL_PRESENCE_LABEL.get());
+
+ /** Substring index type check box. */
+ JCheckBox substring = Utilities.createCheckBox(INFO_CTRL_PANEL_SUBSTRING_LABEL.get());
+
+ JButton deleteIndex = Utilities.createButton(INFO_CTRL_PANEL_DELETE_INDEX_LABEL.get());
+
+ JButton saveChanges = Utilities.createButton(INFO_CTRL_PANEL_SAVE_CHANGES_LABEL.get());
+
+ /** Label containing some warning information (such as the fact that the index cannot be edited). */
+ JLabel warning = Utilities.createDefaultLabel();
+
+ /** Panel containing all the index types. */
+ JPanel typesPanel = new JPanel(new GridBagLayout());
+
+ /** Array of checkboxes. */
+ JCheckBox[] types = { approximate, equality, ordering, presence, substring };
+
+ /** Array of index types that matches the array of checkboxes (types). */
+ IndexTypeDescriptor[] configTypes = { IndexTypeDescriptor.APPROXIMATE, IndexTypeDescriptor.EQUALITY,
+ IndexTypeDescriptor.ORDERING, IndexTypeDescriptor.PRESENCE,
+ IndexTypeDescriptor.SUBSTRING };
/**
* Repopulates the contents of the panel with the provided attribute type. It
* will check the checkboxes for which the attribute has a matching rule.
- * @param attr the attribute.
+ *
+ * @param attr
+ * the attribute.
*/
- protected void repopulateTypesPanel(AttributeType attr)
+ void repopulateTypesPanel(final AttributeType attr)
{
typesPanel.removeAll();
GridBagConstraints gbc = new GridBagConstraints();
@@ -222,19 +160,19 @@
{
typesPanel.add(approximate, gbc);
gbc.insets.top = 10;
- gbc.gridy ++;
+ gbc.gridy++;
}
if (attr.getEqualityMatchingRule() != null)
{
typesPanel.add(equality, gbc);
gbc.insets.top = 10;
- gbc.gridy ++;
+ gbc.gridy++;
}
if (attr.getOrderingMatchingRule() != null)
{
typesPanel.add(ordering, gbc);
gbc.insets.top = 10;
- gbc.gridy ++;
+ gbc.gridy++;
}
typesPanel.add(presence, gbc);
gbc.gridx = 1;
@@ -242,7 +180,7 @@
typesPanel.add(Box.createHorizontalGlue(), gbc);
gbc.weightx = 0.0;
gbc.gridx = 0;
- gbc.gridy ++;
+ gbc.gridy++;
gbc.insets.top = 10;
if (attr.getSubstringMatchingRule() != null)
{
@@ -255,12 +193,15 @@
/**
* Creates the basic layout of the panel.
- * @param c the container of the layout.
- * @param gbc the grid bag constraints to be used.
- * @param nameReadOnly whether the panel is read-only or not.
+ *
+ * @param c
+ * the container of the layout.
+ * @param gbc
+ * the grid bag constraints to be used.
+ * @param nameReadOnly
+ * whether the panel is read-only or not.
*/
- protected void createBasicLayout(Container c, GridBagConstraints gbc,
- boolean nameReadOnly)
+ void createBasicLayout(final Container c, final GridBagConstraints gbc, final boolean nameReadOnly)
{
gbc.gridx = 0;
gbc.gridy = 0;
@@ -269,7 +210,7 @@
if (nameReadOnly)
{
- gbc.gridy ++;
+ gbc.gridy++;
titlePanel.setTitle(INFO_CTRL_PANEL_INDEX_DETAILS_LABEL.get());
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.WEST;
@@ -289,7 +230,7 @@
}
gbc.gridwidth = 1;
- gbc.gridy ++;
+ gbc.gridy++;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets.left = 0;
@@ -309,7 +250,7 @@
c.add(name, gbc);
}
gbc.insets.top = 10;
- gbc.gridy ++;
+ gbc.gridy++;
gbc.insets.left = 0;
gbc.gridx = 0;
c.add(lBackend, gbc);
@@ -317,7 +258,7 @@
gbc.gridx = 1;
c.add(backendName, gbc);
- gbc.gridy ++;
+ gbc.gridy++;
gbc.insets.left = 0;
gbc.gridx = 0;
c.add(lEntryLimit, gbc);
@@ -335,10 +276,9 @@
gbc2.weightx = 1.0;
p.add(Box.createHorizontalGlue(), gbc2);
-
gbc.gridx = 0;
gbc.insets.left = 0;
- gbc.gridy ++;
+ gbc.gridy++;
gbc.weightx = 0.0;
gbc.weightx = 0.0;
gbc.anchor = GridBagConstraints.NORTHWEST;
@@ -348,13 +288,13 @@
gbc.anchor = GridBagConstraints.WEST;
gbc.insets.left = 10;
gbc.weightx = 1.0;
- JCheckBox[] types = {approximate, equality, ordering, presence, substring};
+ JCheckBox[] types = { approximate, equality, ordering, presence, substring };
typesPanel.setOpaque(false);
c.add(typesPanel, gbc);
- gbc.gridy ++;
+ gbc.gridy++;
gbc2 = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
- for (int i=0; i<types.length; i++)
+ for (int i = 0; i < types.length; i++)
{
types[i].setOpaque(false);
typesPanel.add(types[i], gbc2);
@@ -370,15 +310,16 @@
}
/**
- * Returns a sorted set of index types (that matches what the user selected
- * on the check boxes).
- * @return a sorted set of indexes (that matches what the user selected
- * on the check boxes).
+ * Returns a sorted set of index types (that matches what the user selected on
+ * the check boxes).
+ *
+ * @return a sorted set of indexes (that matches what the user selected on the
+ * check boxes).
*/
- protected SortedSet<IndexTypeDescriptor> getTypes()
+ SortedSet<IndexTypeDescriptor> getTypes()
{
SortedSet<IndexTypeDescriptor> indexTypes = new TreeSet<IndexTypeDescriptor>();
- for (int i=0; i<types.length; i++)
+ for (int i = 0; i < types.length; i++)
{
if (types[i].isSelected())
{
@@ -391,12 +332,13 @@
/**
* Returns a list of error message with the problems encountered in the data
* provided by the user.
+ *
* @return a list of error message with the problems encountered in the data
- * provided by the user.
+ * provided by the user.
*/
- protected List<LocalizableMessage> getErrors()
+ List<LocalizableMessage> getErrors()
{
- ArrayList<LocalizableMessage> errors = new ArrayList<LocalizableMessage>();
+ List<LocalizableMessage> errors = new ArrayList<LocalizableMessage>();
setPrimaryValid(lEntryLimit);
setPrimaryValid(lType);
@@ -405,18 +347,15 @@
try
{
int n = Integer.parseInt(newEntryLimit);
- if ((n < MIN_ENTRY_LIMIT) ||
- (n > MAX_ENTRY_LIMIT))
+ if (n < MIN_ENTRY_LIMIT || n > MAX_ENTRY_LIMIT)
{
- errors.add(ERR_CTRL_PANEL_INVALID_ENTRY_LIMIT_LABEL.get(
- MIN_ENTRY_LIMIT, MAX_ENTRY_LIMIT));
+ errors.add(ERR_CTRL_PANEL_INVALID_ENTRY_LIMIT_LABEL.get(MIN_ENTRY_LIMIT, MAX_ENTRY_LIMIT));
setPrimaryInvalid(lEntryLimit);
}
}
catch (Throwable t)
{
- errors.add(ERR_CTRL_PANEL_INVALID_ENTRY_LIMIT_LABEL.get(
- MIN_ENTRY_LIMIT, MAX_ENTRY_LIMIT));
+ errors.add(ERR_CTRL_PANEL_INVALID_ENTRY_LIMIT_LABEL.get(MIN_ENTRY_LIMIT, MAX_ENTRY_LIMIT));
setPrimaryInvalid(lEntryLimit);
}
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 0ddc06b..da526cf 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
@@ -87,7 +87,7 @@
{
private static final long serialVersionUID = -3516011638125862137L;
- private Component relativeComponent;
+ private final Component relativeComponent;
private Schema schema;
@@ -95,11 +95,14 @@
/**
* Constructor of the panel.
- * @param backendName the backend where the index will be created.
- * @param relativeComponent the component relative to which the dialog
- * containing this panel will be centered.
+ *
+ * @param backendName
+ * the backend where the index will be created.
+ * @param relativeComponent
+ * the component relative to which the dialog containing this panel
+ * will be centered.
*/
- public NewIndexPanel(String backendName, Component relativeComponent)
+ public NewIndexPanel(final String backendName, final Component relativeComponent)
{
super();
this.backendName.setText(backendName);
@@ -107,13 +110,13 @@
createLayout();
}
- /** {@inheritDoc} */
+ @Override
public LocalizableMessage getTitle()
{
return INFO_CTRL_PANEL_NEW_INDEX_TITLE.get();
}
- /** {@inheritDoc} */
+ @Override
public Component getPreferredFocusComponent()
{
return attributes;
@@ -121,29 +124,30 @@
/**
* Updates the contents of the panel with the provided backend.
- * @param backend the backend where the index will be created.
+ *
+ * @param backend
+ * the backend where the index will be created.
*/
- public void update(BackendDescriptor backend)
+ public void update(final BackendDescriptor backend)
{
backendName.setText(backend.getBackendID());
}
- /** {@inheritDoc} */
- public void configurationChanged(ConfigurationChangeEvent ev)
+ @Override
+ public void configurationChanged(final ConfigurationChangeEvent ev)
{
final ServerDescriptor desc = ev.getNewDescriptor();
Schema s = desc.getSchema();
- final boolean[] repack = {false};
- final boolean[] error = {false};
+ final boolean[] repack = { false };
+ final boolean[] error = { false };
if (s != null)
{
schema = s;
repack[0] = attributes.getItemCount() == 0;
- LinkedHashSet<CategorizedComboBoxElement> newElements =
- new LinkedHashSet<CategorizedComboBoxElement>();
+ LinkedHashSet<CategorizedComboBoxElement> newElements = new LinkedHashSet<CategorizedComboBoxElement>();
-// Check that the index does not exist
+ // Check that the index does not exist
BackendDescriptor backend = null;
for (BackendDescriptor b : getInfo().getServerDescriptor().getBackends())
{
@@ -190,45 +194,34 @@
}
if (!customAttrNames.isEmpty())
{
- newElements.add(new CategorizedComboBoxElement(
- CUSTOM_ATTRIBUTES,
- CategorizedComboBoxElement.Type.CATEGORY));
+ newElements.add(new CategorizedComboBoxElement(CUSTOM_ATTRIBUTES, CategorizedComboBoxElement.Type.CATEGORY));
for (String attrName : customAttrNames)
{
- newElements.add(new CategorizedComboBoxElement(
- attrName,
- CategorizedComboBoxElement.Type.REGULAR));
+ newElements.add(new CategorizedComboBoxElement(attrName, CategorizedComboBoxElement.Type.REGULAR));
}
}
if (!standardAttrNames.isEmpty())
{
- newElements.add(new CategorizedComboBoxElement(
- STANDARD_ATTRIBUTES,
- CategorizedComboBoxElement.Type.CATEGORY));
+ newElements.add(new CategorizedComboBoxElement(STANDARD_ATTRIBUTES, CategorizedComboBoxElement.Type.CATEGORY));
for (String attrName : standardAttrNames)
{
- newElements.add(new CategorizedComboBoxElement(
- attrName,
- CategorizedComboBoxElement.Type.REGULAR));
+ newElements.add(new CategorizedComboBoxElement(attrName, CategorizedComboBoxElement.Type.REGULAR));
}
}
- DefaultComboBoxModel model =
- (DefaultComboBoxModel)attributes.getModel();
+ DefaultComboBoxModel model = (DefaultComboBoxModel) attributes.getModel();
updateComboBoxModel(newElements, model);
}
else
{
- updateErrorPane(errorPane,
- ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_SUMMARY.get(),
- ColorAndFontConstants.errorTitleFont,
- ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_DETAILS.get(),
- ColorAndFontConstants.defaultFont);
+ updateErrorPane(errorPane, ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_SUMMARY.get(), ColorAndFontConstants.errorTitleFont,
+ ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_DETAILS.get(), ColorAndFontConstants.defaultFont);
repack[0] = true;
error[0] = true;
}
SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
setEnabledOK(!error[0]);
@@ -238,28 +231,26 @@
packParentDialog();
if (relativeComponent != null)
{
- Utilities.centerGoldenMean(
- Utilities.getParentDialog(NewIndexPanel.this),
- relativeComponent);
+ Utilities.centerGoldenMean(Utilities.getParentDialog(NewIndexPanel.this), relativeComponent);
}
}
}
});
if (!error[0])
{
- updateErrorPaneAndOKButtonIfAuthRequired(desc,
- isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_NEW_INDEX.get() :
- INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
+ updateErrorPaneAndOKButtonIfAuthRequired(desc, isLocal()
+ ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_NEW_INDEX.get()
+ : INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
}
}
- /** {@inheritDoc} */
+ @Override
public void okClicked()
{
setPrimaryValid(lAttribute);
setPrimaryValid(lEntryLimit);
setPrimaryValid(lType);
- ArrayList<LocalizableMessage> errors = new ArrayList<LocalizableMessage>();
+ List<LocalizableMessage> errors = new ArrayList<LocalizableMessage>();
String attrName = getAttributeName();
if (attrName == null)
{
@@ -271,17 +262,15 @@
try
{
int n = Integer.parseInt(v);
- if ((n < MIN_ENTRY_LIMIT) || (n > MAX_ENTRY_LIMIT))
+ if (n < MIN_ENTRY_LIMIT || n > MAX_ENTRY_LIMIT)
{
- errors.add(ERR_INFO_CTRL_PANEL_ENTRY_LIMIT_NOT_VALID.get(
- MIN_ENTRY_LIMIT, MAX_ENTRY_LIMIT));
+ errors.add(ERR_INFO_CTRL_PANEL_ENTRY_LIMIT_NOT_VALID.get(MIN_ENTRY_LIMIT, MAX_ENTRY_LIMIT));
setPrimaryInvalid(lEntryLimit);
}
}
catch (Throwable t)
{
- errors.add(ERR_INFO_CTRL_PANEL_ENTRY_LIMIT_NOT_VALID.get(
- MIN_ENTRY_LIMIT, MAX_ENTRY_LIMIT));
+ errors.add(ERR_INFO_CTRL_PANEL_ENTRY_LIMIT_NOT_VALID.get(MIN_ENTRY_LIMIT, MAX_ENTRY_LIMIT));
setPrimaryInvalid(lEntryLimit);
}
@@ -300,9 +289,7 @@
setPrimaryInvalid(lType);
}
ProgressDialog dlg = new ProgressDialog(
- Utilities.createFrame(),
- Utilities.getParentDialog(this), INFO_CTRL_PANEL_NEW_INDEX_TITLE.get(),
- getInfo());
+ Utilities.createFrame(), Utilities.getParentDialog(this), INFO_CTRL_PANEL_NEW_INDEX_TITLE.get(), getInfo());
NewIndexTask newTask = new NewIndexTask(getInfo(), dlg);
for (Task task : getInfo().getTasks())
{
@@ -310,14 +297,12 @@
}
if (errors.isEmpty())
{
- launchOperation(newTask,
- INFO_CTRL_PANEL_CREATING_NEW_INDEX_SUMMARY.get(attrName),
+ launchOperation(newTask, INFO_CTRL_PANEL_CREATING_NEW_INDEX_SUMMARY.get(attrName),
INFO_CTRL_PANEL_CREATING_NEW_INDEX_SUCCESSFUL_SUMMARY.get(),
INFO_CTRL_PANEL_CREATING_NEW_INDEX_SUCCESSFUL_DETAILS.get(attrName),
ERR_CTRL_PANEL_CREATING_NEW_INDEX_ERROR_SUMMARY.get(),
ERR_CTRL_PANEL_CREATING_NEW_INDEX_ERROR_DETAILS.get(),
- null,
- dlg);
+ null, dlg);
dlg.setVisible(true);
Utilities.getParentDialog(this).setVisible(false);
}
@@ -327,25 +312,22 @@
}
}
-
private String getAttributeName()
{
CategorizedComboBoxElement o = (CategorizedComboBoxElement) attributes.getSelectedItem();
return o != null ? o.getValue().toString() : null;
}
- /**
- * Creates the layout of the panel (but the contents are not populated here).
- */
+ /** Creates the layout of the panel (but the contents are not populated here). */
private void createLayout()
{
GridBagConstraints gbc = new GridBagConstraints();
-
createBasicLayout(this, gbc, false);
attributes.addItemListener(new ItemListener()
{
- public void itemStateChanged(ItemEvent ev)
+ @Override
+ public void itemStateChanged(final ItemEvent ev)
{
String n = getAttributeName();
AttributeType attr = null;
@@ -359,23 +341,23 @@
entryLimit.setText(String.valueOf(DEFAULT_ENTRY_LIMIT));
}
- /**
- * The task in charge of creating the index.
- *
- */
- protected class NewIndexTask extends Task
+ /** The task in charge of creating the index. */
+ private class NewIndexTask extends Task
{
- private Set<String> backendSet;
- private String attributeName;
- private int entryLimitValue;
- private SortedSet<IndexTypeDescriptor> indexTypes;
+ private final Set<String> backendSet;
+ private final String attributeName;
+ private final int entryLimitValue;
+ private final SortedSet<IndexTypeDescriptor> indexTypes;
/**
* The constructor of the task.
- * @param info the control panel info.
- * @param dlg the progress dialog that shows the progress of the task.
+ *
+ * @param info
+ * the control panel info.
+ * @param dlg
+ * the progress dialog that shows the progress of the task.
*/
- public NewIndexTask(ControlPanelInfo info, ProgressDialog dlg)
+ public NewIndexTask(final ControlPanelInfo info, final ProgressDialog dlg)
{
super(info, dlg);
backendSet = new HashSet<String>();
@@ -385,28 +367,26 @@
indexTypes = getTypes();
}
- /** {@inheritDoc} */
+ @Override
public Type getType()
{
return Type.NEW_INDEX;
}
- /** {@inheritDoc} */
+ @Override
public Set<String> getBackends()
{
return backendSet;
}
- /** {@inheritDoc} */
+ @Override
public LocalizableMessage getTaskDescription()
{
- return INFO_CTRL_PANEL_NEW_INDEX_TASK_DESCRIPTION.get(
- attributeName, backendName.getText());
+ return INFO_CTRL_PANEL_NEW_INDEX_TASK_DESCRIPTION.get(attributeName, backendName.getText());
}
- /** {@inheritDoc} */
- public boolean canLaunch(Task taskToBeLaunched,
- Collection<LocalizableMessage> incompatibilityReasons)
+ @Override
+ public boolean canLaunch(final Task taskToBeLaunched, final Collection<LocalizableMessage> incompatibilityReasons)
{
boolean canLaunch = true;
if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
@@ -439,35 +419,30 @@
DirectoryServer.deregisterBaseDN(DN.valueOf("cn=config"));
}
DirectoryServer.getInstance().initializeConfiguration(
- org.opends.server.extensions.ConfigFileHandler.class.getName(),
- ConfigReader.configFile);
+ org.opends.server.extensions.ConfigFileHandler.class.getName(), ConfigReader.configFile);
getInfo().setMustDeregisterConfig(true);
}
else
{
SwingUtilities.invokeLater(new Runnable()
{
- /** {@inheritDoc} */
+ @Override
public void run()
{
- List<String> args = getObfuscatedCommandLineArguments(
- getDSConfigCommandLineArguments());
+ List<String> args = getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments());
args.removeAll(getConfigCommandLineArguments());
- printEquivalentCommandLine(getConfigCommandLineName(),
- args, INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_CREATE_INDEX.get());
+ printEquivalentCommandLine(
+ getConfigCommandLineName(), args, INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_CREATE_INDEX.get());
}
});
}
SwingUtilities.invokeLater(new Runnable()
{
- /** {@inheritDoc} */
+ @Override
public void run()
{
- getProgressDialog().appendProgressHtml(
- Utilities.getProgressWithPoints(
- INFO_CTRL_PANEL_CREATING_NEW_INDEX_PROGRESS.get(
- attributeName),
- ColorAndFontConstants.progressFont));
+ getProgressDialog().appendProgressHtml(Utilities.getProgressWithPoints(
+ INFO_CTRL_PANEL_CREATING_NEW_INDEX_PROGRESS.get(attributeName), ColorAndFontConstants.progressFont));
}
});
if (isServerRunning())
@@ -482,11 +457,10 @@
}
SwingUtilities.invokeLater(new Runnable()
{
- /** {@inheritDoc} */
+ @Override
public void run()
{
- getProgressDialog().appendProgressHtml(
- Utilities.getProgressDone(ColorAndFontConstants.progressFont));
+ getProgressDialog().appendProgressHtml(Utilities.getProgressDone(ColorAndFontConstants.progressFont));
}
});
}
@@ -494,8 +468,7 @@
{
if (configHandlerUpdated)
{
- DirectoryServer.getInstance().initializeConfiguration(
- ConfigReader.configClassName, ConfigReader.configFile);
+ DirectoryServer.getInstance().initializeConfiguration(ConfigReader.configClassName, ConfigReader.configFile);
getInfo().startPooling();
}
}
@@ -503,20 +476,18 @@
/**
* Returns the LDIF representation of the index to be created.
+ *
* @return the LDIF representation of the index to be created.
*/
private String getIndexLDIF()
{
- String dn = Utilities.getRDNString(
- "ds-cfg-backend-id", backendName.getText())+",cn=Backends,cn=config";
+ String dn = Utilities.getRDNString("ds-cfg-backend-id", backendName.getText()) + ",cn=Backends,cn=config";
ArrayList<String> lines = new ArrayList<String>();
- lines.add("dn: "+Utilities.getRDNString("ds-cfg-attribute",
- attributeName)+
- ",cn=Index,"+dn);
+ lines.add("dn: " + Utilities.getRDNString("ds-cfg-attribute", attributeName) + ",cn=Index," + dn);
lines.add("objectClass: ds-cfg-local-db-index");
lines.add("objectClass: top");
- lines.add("ds-cfg-attribute: "+attributeName);
- lines.add("ds-cfg-index-entry-limit: "+entryLimitValue);
+ lines.add("ds-cfg-attribute: " + attributeName);
+ lines.add("ds-cfg-index-entry-limit: " + entryLimitValue);
for (IndexTypeDescriptor type : indexTypes)
{
lines.add("ds-cfg-index-type: " + type.toLocalDBIndexType());
@@ -547,8 +518,7 @@
}
catch (IOException ioe)
{
- throw new OfflineUpdateException(
- ERR_CTRL_PANEL_ERROR_UPDATING_CONFIGURATION.get(ioe), ioe);
+ throw new OfflineUpdateException(ERR_CTRL_PANEL_ERROR_UPDATING_CONFIGURATION.get(ioe), ioe);
}
finally
{
@@ -559,7 +529,7 @@
}
}
- private void createIndex(InitialLdapContext ctx) throws OpenDsException
+ private void createIndex(final 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
@@ -574,8 +544,7 @@
Attributes attrs = new BasicAttributes();
BasicAttribute oc = new BasicAttribute("objectClass");
- Iterator<ByteString> it =
- indexEntry.getObjectClassAttribute().iterator();
+ Iterator<ByteString> it = indexEntry.getObjectClassAttribute().iterator();
while (it.hasNext())
{
oc.add(it.next().toString());
@@ -597,8 +566,7 @@
final StringBuilder sb = new StringBuilder();
sb.append(getConfigCommandLineName());
- Collection<String> args =
- getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments());
+ Collection<String> args = getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments());
for (String arg : args)
{
sb.append(" ").append(CommandBuilder.escapeValue(arg));
@@ -608,8 +576,7 @@
}
catch (Throwable t)
{
- throw new OnlineUpdateException(
- ERR_CTRL_PANEL_ERROR_UPDATING_CONFIGURATION.get(t), t);
+ throw new OnlineUpdateException(ERR_CTRL_PANEL_ERROR_UPDATING_CONFIGURATION.get(t), t);
}
finally
{
@@ -620,14 +587,14 @@
}
}
- /** {@inheritDoc} */
+ @Override
protected String getCommandLinePath()
{
return null;
}
- /** {@inheritDoc} */
- protected ArrayList<String> getCommandLineArguments()
+ @Override
+ protected List<String> getCommandLineArguments()
{
return new ArrayList<String>();
}
@@ -638,13 +605,11 @@
{
return getCommandLinePath("dsconfig");
}
- else
- {
- return null;
- }
+
+ return null;
}
- /** {@inheritDoc} */
+ @Override
public void runTask()
{
state = State.RUNNING;
@@ -653,14 +618,12 @@
try
{
updateConfiguration();
- for (BackendDescriptor backend :
- getInfo().getServerDescriptor().getBackends())
+ for (BackendDescriptor backend : getInfo().getServerDescriptor().getBackends())
{
if (backend.getBackendID().equalsIgnoreCase(backendName.getText()))
{
newIndex = new IndexDescriptor(attributeName,
- schema.getAttributeType(attributeName.toLowerCase()), backend,
- indexTypes, entryLimitValue);
+ schema.getAttributeType(attributeName.toLowerCase()), backend, indexTypes, entryLimitValue);
getInfo().registerModifiedIndex(newIndex);
notifyConfigurationElementCreated(newIndex);
break;
@@ -675,11 +638,10 @@
}
}
- /** {@inheritDoc} */
+ @Override
public void postOperation()
{
- if ((lastException == null) && (state == State.FINISHED_SUCCESSFULLY) &&
- (newIndex != null))
+ if (lastException == null && state == State.FINISHED_SUCCESSFULLY && newIndex != null)
{
rebuildIndexIfNecessary(newIndex, getProgressDialog());
}
@@ -700,10 +662,10 @@
for (IndexTypeDescriptor type : indexTypes)
{
args.add("--set");
- args.add("index-type:"+type.toLocalDBIndexType());
+ args.add("index-type:" + type.toLocalDBIndexType());
}
args.add("--set");
- args.add("index-entry-limit:"+entryLimitValue);
+ args.add("index-entry-limit:" + entryLimitValue);
args.addAll(getConnectionCommandLineArguments());
args.add(getNoPropertiesFileArgument());
args.add("--no-prompt");
--
Gitblit v1.10.0