opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteIndexTask.java
@@ -26,6 +26,7 @@ */ package org.opends.guitools.controlpanel.task; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.messages.AdminToolMessages.*; import java.util.ArrayList; @@ -60,60 +61,58 @@ */ public class DeleteIndexTask extends Task { private Set<String> backendSet; private ArrayList<AbstractIndexDescriptor> indexesToDelete = new ArrayList<AbstractIndexDescriptor>(); private ArrayList<AbstractIndexDescriptor> deletedIndexes = new ArrayList<AbstractIndexDescriptor>(); private final Set<String> backendSet; private final List<AbstractIndexDescriptor> indexesToDelete = new ArrayList<AbstractIndexDescriptor>(); private final List<AbstractIndexDescriptor> deletedIndexes = new ArrayList<AbstractIndexDescriptor>(); /** * Constructor of the task. * @param info the control panel information. * @param dlg the progress dialog where the task progress will be displayed. * @param indexesToDelete the indexes that must be deleted. * * @param info * the control panel information. * @param dlg * the progress dialog where the task progress will be displayed. * @param indexesToDelete * the indexes that must be deleted. */ public DeleteIndexTask(ControlPanelInfo info, ProgressDialog dlg, ArrayList<AbstractIndexDescriptor> indexesToDelete) public DeleteIndexTask(ControlPanelInfo info, ProgressDialog dlg, List<AbstractIndexDescriptor> indexesToDelete) { super(info, dlg); backendSet = new HashSet<String>(); for (AbstractIndexDescriptor index : indexesToDelete) for (final AbstractIndexDescriptor index : indexesToDelete) { backendSet.add(index.getBackend().getBackendID()); } this.indexesToDelete.addAll(indexesToDelete); } /** {@inheritDoc} */ @Override public Type getType() { return Type.DELETE_INDEX; } /** {@inheritDoc} */ @Override public Set<String> getBackends() { return backendSet; } /** {@inheritDoc} */ @Override public LocalizableMessage getTaskDescription() { if (backendSet.size() == 1) { return INFO_CTRL_PANEL_DELETE_INDEX_TASK_DESCRIPTION.get( Utilities.getStringFromCollection(backendSet, ", ")); return INFO_CTRL_PANEL_DELETE_INDEX_TASK_DESCRIPTION.get(getStringFromCollection(backendSet, ", ")); } else { return INFO_CTRL_PANEL_DELETE_INDEX_IN_BACKENDS_TASK_DESCRIPTION.get( Utilities.getStringFromCollection(backendSet, ", ")); return INFO_CTRL_PANEL_DELETE_INDEX_IN_BACKENDS_TASK_DESCRIPTION.get(getStringFromCollection(backendSet, ", ")); } } /** {@inheritDoc} */ public boolean canLaunch(Task taskToBeLaunched, Collection<LocalizableMessage> incompatibilityReasons) @Override public boolean canLaunch(Task taskToBeLaunched, Collection<LocalizableMessage> incompatibilityReasons) { boolean canLaunch = true; if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched)) @@ -121,13 +120,11 @@ // All the operations are incompatible if they apply to this // backend for safety. This is a short operation so the limitation // has not a lot of impact. Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); final Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); backends.retainAll(getBackends()); if (backends.size() > 0) { incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); canLaunch = false; } } @@ -136,7 +133,9 @@ /** * Update the configuration in the server. * @throws OpenDsException if an error occurs. * * @throws OpenDsException * if an error occurs. */ private void updateConfiguration() throws OpenDsException { @@ -154,8 +153,7 @@ 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); } boolean isFirst = true; @@ -165,6 +163,7 @@ { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { getProgressDialog().appendProgressHtml("<br><br>"); @@ -176,35 +175,31 @@ { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { List<String> args = getObfuscatedCommandLineArguments( getDSConfigCommandLineArguments(index)); final List<String> args = getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments(index)); args.removeAll(getConfigCommandLineArguments()); printEquivalentCommandLine(getConfigCommandLineName(index), args, INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_INDEX.get()); printEquivalentCommandLine(getConfigCommandLineName(index), args, INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_INDEX.get()); } }); } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (isVLVIndex(index)) { getProgressDialog().appendProgressHtml( Utilities.getProgressWithPoints( INFO_CTRL_PANEL_DELETING_VLV_INDEX.get( index.getName()), Utilities.getProgressWithPoints(INFO_CTRL_PANEL_DELETING_VLV_INDEX.get(index.getName()), ColorAndFontConstants.progressFont)); } else { getProgressDialog().appendProgressHtml( Utilities.getProgressWithPoints( INFO_CTRL_PANEL_DELETING_INDEX.get( index.getName()), Utilities.getProgressWithPoints(INFO_CTRL_PANEL_DELETING_INDEX.get(index.getName()), ColorAndFontConstants.progressFont)); } } @@ -217,17 +212,16 @@ { deleteIndex(index); } numberDeleted ++; numberDeleted++; final int fNumberDeleted = numberDeleted; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { getProgressDialog().getProgressBar().setIndeterminate(false); getProgressDialog().getProgressBar().setValue( (fNumberDeleted * 100) / totalNumber); getProgressDialog().appendProgressHtml( Utilities.getProgressDone(ColorAndFontConstants.progressFont)); getProgressDialog().getProgressBar().setValue((fNumberDeleted * 100) / totalNumber); getProgressDialog().appendProgressHtml(Utilities.getProgressDone(ColorAndFontConstants.progressFont)); } }); deletedIndexes.add(index); @@ -237,8 +231,7 @@ { if (configHandlerUpdated) { DirectoryServer.getInstance().initializeConfiguration( ConfigReader.configClassName, ConfigReader.configFile); DirectoryServer.getInstance().initializeConfiguration(ConfigReader.configClassName, ConfigReader.configFile); getInfo().startPooling(); } } @@ -247,9 +240,11 @@ /** * Returns <CODE>true</CODE> if the index is a VLV index and * <CODE>false</CODE> otherwise. * @param index the index. * * @param index * the index. * @return <CODE>true</CODE> if the index is a VLV index and * <CODE>false</CODE> otherwise. * <CODE>false</CODE> otherwise. */ private boolean isVLVIndex(AbstractIndexDescriptor index) { @@ -257,44 +252,46 @@ } /** * Deletes an index. The code assumes that the server is not running * and that the configuration file can be edited. * @param index the index to be deleted. * @throws OpenDsException if an error occurs. * Deletes an index. The code assumes that the server is not running and that * the configuration file can be edited. * * @param index * the index to be deleted. * @throws OpenDsException * if an error occurs. */ private void deleteIndex(AbstractIndexDescriptor index) throws OpenDsException { String backendId = Utilities.getRDNString("ds-cfg-backend-id", index.getBackend().getBackendID()); final String backendId = Utilities.getRDNString("ds-cfg-backend-id", index.getBackend().getBackendID()); String dn; if (isVLVIndex(index)) { dn = Utilities.getRDNString("ds-cfg-name", index.getName()) + ",cn=VLV Index," + backendId + ",cn=Backends,cn=config"; dn = getRDNString("ds-cfg-name", index.getName()) + ",cn=VLV Index," + backendId + ",cn=Backends,cn=config"; } else { dn = Utilities.getRDNString("ds-cfg-attribute", index.getName()) + ",cn=Index," + backendId + ",cn=Backends,cn=config"; dn = getRDNString("ds-cfg-attribute", index.getName()) + ",cn=Index," + backendId + ",cn=Backends,cn=config"; } DirectoryServer.getConfigHandler().deleteEntry(DN.valueOf(dn), null); } /** * Deletes an index. The code assumes that the server is running * and that the provided connection is active. * @param index the index to be deleted. * @param ctx the connection to the server. * @throws OpenDsException if an error occurs. * Deletes an index. The code assumes that the server is running and that the * provided connection is active. * * @param index * the index to be deleted. * @param ctx * the connection to the server. * @throws OpenDsException * if an error occurs. */ private void deleteIndex(InitialLdapContext ctx, AbstractIndexDescriptor index) throws OpenDsException private void deleteIndex(InitialLdapContext ctx, AbstractIndexDescriptor index) throws OpenDsException { ManagementContext mCtx = LDAPManagementContext.createFromContext( JNDIDirContextAdaptor.adapt(ctx)); RootCfgClient root = mCtx.getRootConfiguration(); LocalDBBackendCfgClient backend = (LocalDBBackendCfgClient)root.getBackend( index.getBackend().getBackendID()); final ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(ctx)); final RootCfgClient root = mCtx.getRootConfiguration(); final LocalDBBackendCfgClient backend = (LocalDBBackendCfgClient) root.getBackend(index.getBackend().getBackendID()); if (isVLVIndex(index)) { backend.removeLocalDBVLVIndex(index.getName()); @@ -306,13 +303,13 @@ backend.commit(); } /** {@inheritDoc} */ @Override protected String getCommandLinePath() { return null; } /** {@inheritDoc} */ @Override protected ArrayList<String> getCommandLineArguments() { return new ArrayList<String>(); @@ -321,9 +318,11 @@ /** * Returns the path of the command line to be used to delete the specified * index. * @param index the index to be deleted. * * @param index * the index to be deleted. * @return the path of the command line to be used to delete the specified * index. * index. */ private String getConfigCommandLineName(AbstractIndexDescriptor index) { @@ -337,7 +336,7 @@ } } /** {@inheritDoc} */ @Override public void runTask() { state = State.RUNNING; @@ -348,14 +347,14 @@ updateConfiguration(); state = State.FINISHED_SUCCESSFULLY; } catch (Throwable t) catch (final Throwable t) { lastException = t; state = State.FINISHED_WITH_ERROR; } finally { for (AbstractIndexDescriptor index : deletedIndexes) for (final AbstractIndexDescriptor index : deletedIndexes) { getInfo().unregisterModifiedIndex(index); } @@ -364,13 +363,14 @@ /** * Return the dsconfig arguments required to delete an index. * @param index the index to be deleted. * * @param index * the index to be deleted. * @return the dsconfig arguments required to delete an index. */ private ArrayList<String> getDSConfigCommandLineArguments( AbstractIndexDescriptor index) private List<String> getDSConfigCommandLineArguments(AbstractIndexDescriptor index) { ArrayList<String> args = new ArrayList<String>(); final List<String> args = new ArrayList<String>(); if (isVLVIndex(index)) { args.add("delete-local-db-vlv-index"); @@ -388,6 +388,7 @@ args.addAll(getConnectionCommandLineArguments()); args.add("--no-prompt"); args.add(getNoPropertiesFileArgument()); return args; } } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/Task.java
@@ -775,9 +775,9 @@ * script). * @return the command-line arguments that correspond to the configuration. */ protected ArrayList<String> getConfigCommandLineArguments() protected List<String> getConfigCommandLineArguments() { ArrayList<String> args = new ArrayList<String>(); List<String> args = new ArrayList<String>(); args.add("--configClass"); args.add(org.opends.server.extensions.ConfigFileHandler.class.getName()); args.add("--configFile"); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
@@ -25,7 +25,6 @@ * Portions Copyright 2014-2015 ForgeRock AS */ package org.opends.guitools.controlpanel.ui; import static org.opends.messages.AdminToolMessages.*; @@ -92,144 +91,95 @@ /** * 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 { private static final long serialVersionUID = -82857384664911898L; /** * Title panel. */ protected TitlePanel titlePanel = new TitlePanel(LocalizableMessage.EMPTY, LocalizableMessage.EMPTY); /** * Name label. */ protected 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()); /** * Search scope label. */ protected JLabel lSearchScope = Utilities.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()); /** * Sort order label. */ protected 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()); /** * Max block size label. */ protected JLabel lMaxBlockSize = Utilities.createPrimaryLabel( INFO_CTRL_PANEL_VLV_INDEX_MAX_BLOCK_SIZE_LABEL.get()); /** Title panel. */ protected TitlePanel titlePanel = new TitlePanel(LocalizableMessage.EMPTY, LocalizableMessage.EMPTY); /** * Name text field. */ /** Name label. */ protected 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()); /** Search scope label. */ protected JLabel lSearchScope = Utilities.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()); /** Sort order label. */ protected 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()); /** Max block size label. */ protected JLabel lMaxBlockSize = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_VLV_INDEX_MAX_BLOCK_SIZE_LABEL.get()); /** 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(); /** * Base DNs combo box. */ protected JComboBox baseDNs = Utilities.createComboBox(); /** * Subtree text field. */ protected JTextField baseDN = Utilities.createLongTextField(); /** * Base Object scope radio button. */ protected JRadioButton baseObject = Utilities.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()); /** * Subordinate subtree scope radio button. */ protected JRadioButton subordinateSubtree = Utilities.createRadioButton( INFO_CTRL_PANEL_VLV_INDEX_SUBORDINATE_SUBTREE_LABEL.get()); /** * Whole subtree scope radio button. */ protected JRadioButton wholeSubtree = Utilities.createRadioButton( INFO_CTRL_PANEL_VLV_INDEX_WHOLE_SUBTREE_LABEL.get()); /** * Filter text field. */ /** Read-only name label. */ protected JLabel readOnlyName = Utilities.createDefaultLabel(); /** Read-only backend name label. */ protected JLabel backendName = Utilities.createDefaultLabel(); /** Base DNs combo box. */ protected JComboBox baseDNs = Utilities.createComboBox(); /** Subtree text field. */ protected JTextField baseDN = Utilities.createLongTextField(); /** Base Object scope radio button. */ protected JRadioButton baseObject = Utilities.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()); /** Subordinate subtree scope radio button. */ protected JRadioButton subordinateSubtree = Utilities .createRadioButton(INFO_CTRL_PANEL_VLV_INDEX_SUBORDINATE_SUBTREE_LABEL.get()); /** Whole subtree scope radio button. */ protected JRadioButton wholeSubtree = Utilities .createRadioButton(INFO_CTRL_PANEL_VLV_INDEX_WHOLE_SUBTREE_LABEL.get()); /** Filter text field. */ protected JTextField filter = Utilities.createLongTextField(); /** * Max block size text field. */ /** Max block size text field. */ protected JTextField maxBlockSize = Utilities.createShortTextField(); /** * Attributes combo box. */ /** Attributes combo box. */ protected JComboBox attributes = Utilities.createComboBox(); /** * The list containing the sort order elements. */ /** The list containing the sort order elements. */ protected JList sortOrder = new JList(); /** * The add button. */ protected 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()); /** * The move down button. */ protected 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()); /** * Ascending order combo box. */ /** The add button. */ protected 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()); /** The move down button. */ protected 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()); /** Ascending order combo box. */ protected JComboBox ascendingOrder = Utilities.createComboBox(); /** * Combo box containing the sort order. */ /** Combo box containing the sort order. */ protected DefaultListModel sortOrderModel; /** * The list of labels. */ protected JLabel[] labels = {lName, lBaseDN, lSearchScope, lFilter, lSortOrder, lBackend, lMaxBlockSize}; /** The list of labels. */ protected JLabel[] labels = { lName, lBaseDN, lSearchScope, lFilter, lSortOrder, lBackend, lMaxBlockSize }; /** * The relative component that must be used to center the parent dialog of @@ -237,82 +187,56 @@ */ protected 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(); /** * Descending message. */ protected final LocalizableMessage DESCENDING = INFO_CTRL_PANEL_VLV_DESCENDING_LABEL.get(); /** Other base DN message. */ protected final LocalizableMessage OTHER_BASE_DN = INFO_CTRL_PANEL_VLV_OTHER_BASE_DN_LABEL.get(); /** * Custom attributes message. */ protected LocalizableMessage CUSTOM_ATTRIBUTES = INFO_CTRL_PANEL_CUSTOM_ATTRIBUTES_LABEL.get(); /** Ascending message. */ protected final LocalizableMessage ASCENDING = INFO_CTRL_PANEL_VLV_ASCENDING_LABEL.get(); /** * Standard attributes message. */ protected LocalizableMessage STANDARD_ATTRIBUTES = INFO_CTRL_PANEL_STANDARD_ATTRIBUTES_LABEL.get(); /** Descending message. */ protected final LocalizableMessage DESCENDING = INFO_CTRL_PANEL_VLV_DESCENDING_LABEL.get(); /** * The list of standard attribute names. */ protected TreeSet<String> standardAttrNames = new TreeSet<String>(new LowerCaseComparator()); /** * The list of configuration attribute names. */ protected TreeSet<String> configurationAttrNames = new TreeSet<String>(new LowerCaseComparator()); /** * The list of custom attribute names. */ protected TreeSet<String> customAttrNames = new TreeSet<String>(new LowerCaseComparator()); /** 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(); /** The list of standard attribute names. */ protected TreeSet<String> standardAttrNames = new TreeSet<String>(new LowerCaseComparator()); /** The list of configuration attribute names. */ protected TreeSet<String> configurationAttrNames = new TreeSet<String>(new LowerCaseComparator()); /** The list of custom attribute names. */ protected TreeSet<String> customAttrNames = new TreeSet<String>(new LowerCaseComparator()); private int defaultVLVEntryLimitValue; { DefinedDefaultBehaviorProvider<Integer> provider = (DefinedDefaultBehaviorProvider<Integer>) LocalDBVLVIndexCfgDefn.getInstance().getMaxBlockSizePropertyDefinition(). getDefaultBehaviorProvider(); defaultVLVEntryLimitValue = Integer.parseInt(provider.getDefaultValues().iterator().next()); (DefinedDefaultBehaviorProvider<Integer>) LocalDBVLVIndexCfgDefn.getInstance() .getMaxBlockSizePropertyDefinition().getDefaultBehaviorProvider(); defaultVLVEntryLimitValue = Integer.parseInt(provider.getDefaultValues().iterator().next()); } /** * Minimum value for max block size. */ protected final int MIN_MAX_BLOCK_SIZE = LocalDBVLVIndexCfgDefn.getInstance().getMaxBlockSizePropertyDefinition(). getLowerLimit(); /** * Maximum value for max block size. */ protected final int MAX_MAX_BLOCK_SIZE = 2147483647; /** * Default value for max block size. */ protected final int DEFAULT_MAX_BLOCK_SIZE = defaultVLVEntryLimitValue; /** Minimum value for max block size. */ protected final int MIN_MAX_BLOCK_SIZE = LocalDBVLVIndexCfgDefn.getInstance().getMaxBlockSizePropertyDefinition() .getLowerLimit(); /** Maximum value for max block size. */ protected final int MAX_MAX_BLOCK_SIZE = 2147483647; /** Default value for max block size. */ protected final int DEFAULT_MAX_BLOCK_SIZE = defaultVLVEntryLimitValue; /** * Constructor. * @param backendID the backend ID where the index is defined (or will be * defined). * @param relativeComponent the relative component where the dialog containing * this panel must be centered. * * @param backendID * the backend ID where the index is defined (or will be defined). * @param relativeComponent * the relative component where the dialog containing this panel must * be centered. */ protected AbstractVLVIndexPanel(String backendID, Component relativeComponent) { @@ -326,7 +250,9 @@ /** * Sets the name of the backend where the index is defined or will be defined. * @param backendID the ID of the backend. * * @param backendID * the ID of the backend. */ public void setBackendName(String backendID) { @@ -335,34 +261,35 @@ /** * Returns the LDIF representing the new index. * @param indexName the name of the index. * * @param indexName * the name of the index. * @return the LDIF representing the new index. */ protected String getIndexLDIF(String indexName) { 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-name", indexName)+ ",cn=VLV Index,"+dn); final String dn = Utilities.getRDNString("ds-cfg-backend-id", backendName.getText()) + ",cn=Backends,cn=config"; List<String> lines = new ArrayList<String>(); lines.add("dn: " + Utilities.getRDNString("ds-cfg-name", indexName) + ",cn=VLV Index," + dn); lines.add("objectClass: ds-cfg-local-db-vlv-index"); lines.add("objectClass: top"); lines.add("ds-cfg-name: "+indexName); lines.add("ds-cfg-filter: "+filter.getText().trim()); lines.add("ds-cfg-sort-order: "+getSortOrderStringValue(getSortOrder())); lines.add("ds-cfg-base-dn: "+getBaseDN()); lines.add("ds-cfg-scope: " + getScope()); lines.add("ds-cfg-max-block-size: "+maxBlockSize.getText().trim()); lines.add("ds-cfg-name: " + indexName); lines.add("ds-cfg-filter: " + filter.getText().trim()); lines.add("ds-cfg-sort-order: " + getSortOrderStringValue(getSortOrder())); lines.add("ds-cfg-base-dn: " + getBaseDN()); lines.add("ds-cfg-max-block-size: " + maxBlockSize.getText().trim()); StringBuilder sb = new StringBuilder(); for (String line : lines) { sb.append(line).append(ServerConstants.EOL); } return sb.toString(); } /** * Returns the scope of the VLV index as it appears on the panel. * * @return the scope of the VLV index as it appears on the panel. */ protected Scope getScope() @@ -390,22 +317,26 @@ /** * Returns the list of VLV sort order elements as they are displayed in the * panel. * * @return the list of VLV sort order elements as they are displayed in the * panel. * panel. */ protected List<VLVSortOrder> getSortOrder() { ArrayList<VLVSortOrder> sortOrder = new ArrayList<VLVSortOrder>(); for (int i=0; i<sortOrderModel.getSize(); i++) List<VLVSortOrder> sortOrder = new ArrayList<VLVSortOrder>(); for (int i = 0; i < sortOrderModel.getSize(); i++) { sortOrder.add((VLVSortOrder)sortOrderModel.get(i)); sortOrder.add((VLVSortOrder) sortOrderModel.get(i)); } return sortOrder; } /** * Returns the string representation for the provided list of VLV sort order. * @param sortOrder the list of VLV sort order elements. * * @param sortOrder * the list of VLV sort order elements. * @return the string representation for the provided list of VLV sort order. */ protected String getSortOrderStringValue(List<VLVSortOrder> sortOrder) @@ -427,22 +358,24 @@ } sb.append(s.getAttributeName()); } return sb.toString(); } /** * Updates the layout with the provided server descriptor. * @param desc the server descriptor. * * @param desc * the server descriptor. * @return <CODE>true</CODE> if an error has been displayed and * <CODE>false</CODE> otherwise. * <CODE>false</CODE> otherwise. */ protected boolean updateLayout(final ServerDescriptor desc) { Schema schema = desc.getSchema(); BackendDescriptor backend = getBackend(); final boolean[] repack = {false}; final boolean[] error = {false}; final boolean[] repack = { false }; final boolean[] error = { false }; if (backend != null) { updateBaseDNCombo(backend); @@ -451,10 +384,9 @@ if (schema != null) { repack[0] = attributes.getItemCount() == 0; LinkedHashSet<CategorizedComboBoxElement> newElements = new LinkedHashSet<CategorizedComboBoxElement>(); LinkedHashSet<CategorizedComboBoxElement> newElements = new LinkedHashSet<CategorizedComboBoxElement>(); synchronized(standardAttrNames) synchronized (standardAttrNames) { standardAttrNames.clear(); configurationAttrNames.clear(); @@ -465,9 +397,9 @@ String name = attr.getPrimaryName(); boolean defined = false; ListModel model = sortOrder.getModel(); for (int i=0; i < model.getSize(); i++) for (int i = 0; i < model.getSize(); i++) { VLVSortOrder s = (VLVSortOrder)model.getElementAt(i); VLVSortOrder s = (VLVSortOrder) model.getElementAt(i); if (name.equalsIgnoreCase(s.getAttributeName())) { defined = true; @@ -493,54 +425,36 @@ } if (customAttrNames.size() > 0) { 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.size() > 0) { 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)); } } // 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)); } } * 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(); 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; } @@ -549,8 +463,7 @@ { public void run() { if ((getButtonType() == GenericDialog.ButtonType.OK) || (getButtonType() == GenericDialog.ButtonType.OK)) if (getButtonType() == GenericDialog.ButtonType.OK) { setEnabledOK(!error[0]); } @@ -562,27 +475,27 @@ packParentDialog(); if (relativeComponent != null) { Utilities.centerGoldenMean( Utilities.getParentDialog(AbstractVLVIndexPanel.this), relativeComponent); Utilities.centerGoldenMean(Utilities.getParentDialog(AbstractVLVIndexPanel.this), relativeComponent); } } } }); return !error[0]; } /** * 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 * index. Returns <CODE>false</CODE> if the user does not accept to create * the index. Note that the confirmation dialog will only be displayed when * the indexes are not defined, if the dialog is not displayed the method * returns <CODE>true</CODE>. * index. Returns <CODE>false</CODE> if the user does not accept to create the * index. Note that the confirmation dialog will only be displayed when the * indexes are not defined, if the dialog is not displayed the method returns * <CODE>true</CODE>. * * @return <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 * index. Returns <CODE>false</CODE> if the user does not accept to create * the index. * index even if no indexes are created for the provided filter for * the VLV index. Returns <CODE>false</CODE> if the user does not * accept to create the index. */ protected boolean checkIndexRequired() { @@ -600,30 +513,31 @@ { sb.append("<br>-").append(msg); } confirm = displayConfirmationDialog( INFO_CTRL_PANEL_VLV_INDEXES_NOT_DEFINED_CONFIRMATION_TITLE.get(), INFO_CTRL_PANEL_VLV_INDEXES_NOT_DEFINED_CONFIRMATION_MSG.get( getBackend().getBackendID(), sb)); confirm = displayConfirmationDialog(INFO_CTRL_PANEL_VLV_INDEXES_NOT_DEFINED_CONFIRMATION_TITLE.get(), INFO_CTRL_PANEL_VLV_INDEXES_NOT_DEFINED_CONFIRMATION_MSG.get(getBackend().getBackendID(), sb)); } } catch (Throwable t) { // Bug throw new RuntimeException("Unexpected error: "+t, t); throw new RuntimeException("Unexpected error: " + t, t); } return confirm; } /** * Updates the provided list of error messages by analyzing the provided * filter. The idea is basically to analyze the filter and check if what * appears on the filter is indexed or not. If it is not indexed it updates * filter. The idea is basically to analyze the filter and check if what * appears on the filter is indexed or not. If it is not indexed it updates * the error message list with a message explaining that. * @param filter the filter to analyze. * @param msgs the list of messages to be updated. * * @param filter * the filter to analyze. * @param msgs * the list of messages to be updated. */ private void updateIndexRequiredMessages(RawFilter filter, Collection<LocalizableMessage> msgs) private void updateIndexRequiredMessages(RawFilter filter, Collection<LocalizableMessage> msgs) { switch (filter.getFilterType()) { @@ -641,24 +555,19 @@ updateIndexRequiredMessages(filter.getNOTComponent(), msgs); break; default: FilterType[] filterTypes = {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 }; LocalizableMessage[] indexTypeNames = {INFO_CTRL_PANEL_VLV_INDEX_EQUALITY_TYPE.get(), INFO_CTRL_PANEL_VLV_INDEX_SUBSTRING_TYPE.get(), INFO_CTRL_PANEL_VLV_INDEX_ORDERING_TYPE.get(), INFO_CTRL_PANEL_VLV_INDEX_ORDERING_TYPE.get(), INFO_CTRL_PANEL_VLV_INDEX_PRESENCE_TYPE.get(), INFO_CTRL_PANEL_VLV_INDEX_APPROXIMATE_TYPE.get(), null }; for (int i=0; i<filterTypes.length; i++) FilterType[] filterTypes = { 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 }; LocalizableMessage[] indexTypeNames = { INFO_CTRL_PANEL_VLV_INDEX_EQUALITY_TYPE.get(), INFO_CTRL_PANEL_VLV_INDEX_SUBSTRING_TYPE.get(), INFO_CTRL_PANEL_VLV_INDEX_ORDERING_TYPE.get(), INFO_CTRL_PANEL_VLV_INDEX_ORDERING_TYPE.get(), INFO_CTRL_PANEL_VLV_INDEX_PRESENCE_TYPE.get(), INFO_CTRL_PANEL_VLV_INDEX_APPROXIMATE_TYPE.get(), null }; for (int i = 0; i < filterTypes.length; i++) { if (filterTypes[i] == filter.getFilterType()) { @@ -668,8 +577,8 @@ IndexType type = indexTypes[i]; if (type != null && !index.getTypes().contains(type)) { msgs.add(INFO_CTRL_PANEL_MUST_UPDATE_INDEX_DEFINITION_TYPE.get( filter.getAttributeType(), indexTypeNames[i])); msgs.add(INFO_CTRL_PANEL_MUST_UPDATE_INDEX_DEFINITION_TYPE.get(filter.getAttributeType(), indexTypeNames[i])); } } else @@ -677,13 +586,11 @@ LocalizableMessage type = indexTypeNames[i]; if (type != null) { msgs.add(INFO_CTRL_PANEL_MUST_DEFINE_INDEX_TYPE.get( filter.getAttributeType(), type)); msgs.add(INFO_CTRL_PANEL_MUST_DEFINE_INDEX_TYPE.get(filter.getAttributeType(), type)); } else { msgs.add(INFO_CTRL_PANEL_MUST_DEFINE_INDEX.get( filter.getAttributeType())); msgs.add(INFO_CTRL_PANEL_MUST_DEFINE_INDEX.get(filter.getAttributeType())); } } } @@ -694,7 +601,9 @@ /** * Returns the index descriptor for a given index name (<CODE>null</CODE> if * no index descriptor is found for that name). * @param indexName the name of the index. * * @param indexName * the name of the index. * @return the index descriptor for a given index name. */ private IndexDescriptor getIndex(String indexName) @@ -717,33 +626,36 @@ /** * Updates the base DN combo box with the provided backend. * @param backend the backend to be used with the provided backend. * * @param backend * the backend to be used with the provided backend. */ protected void updateBaseDNCombo(BackendDescriptor backend) { ArrayList<Object> newElements = new ArrayList<Object>(); List<Object> newElements = new ArrayList<Object>(); for (BaseDNDescriptor baseDN : backend.getBaseDns()) { String dn = null; try { dn = Utilities.unescapeUtf8(baseDN.getDn().toString()); dn = Utilities.unescapeUtf8(baseDN.getDn().toString()); } catch (Throwable t) { throw new RuntimeException("Unexpected error: "+t, t); throw new RuntimeException("Unexpected error: " + t, t); } newElements.add(dn); } newElements.add(COMBO_SEPARATOR); newElements.add(OTHER_BASE_DN); updateComboBoxModel(newElements, (DefaultComboBoxModel)baseDNs.getModel()); updateComboBoxModel(newElements, (DefaultComboBoxModel) baseDNs.getModel()); } /** * Updates a list of errors with the errors found in the panel. * @param checkName whether the name of the VLV index must be checked or not. * * @param checkName * whether the name of the VLV index must be checked or not. * @return a list containing the error messages found. */ protected List<LocalizableMessage> checkErrors(boolean checkName) @@ -755,7 +667,7 @@ BackendDescriptor backend = getBackend(); ArrayList<LocalizableMessage> errors = new ArrayList<LocalizableMessage>(); List<LocalizableMessage> errors = new ArrayList<LocalizableMessage>(); if (checkName) { String n = name.getText(); @@ -771,8 +683,7 @@ { if (index.getName().equalsIgnoreCase(n)) { errors.add(ERR_CTRL_PANEL_VLV_INDEX_ALREADY_DEFINED.get(n, backendName.getText())); errors.add(ERR_CTRL_PANEL_VLV_INDEX_ALREADY_DEFINED.get(n, backendName.getText())); setPrimaryInvalid(lName); break; } @@ -781,7 +692,7 @@ } String baseDN = getBaseDN(); if ((baseDN == null) || (baseDN.length() == 0)) if (baseDN == null || baseDN.length() == 0) { errors.add(ERR_CTRL_PANEL_NO_BASE_DN_FOR_VLV_PROVIDED.get()); setPrimaryInvalid(lBaseDN); @@ -800,7 +711,7 @@ } String f = filter.getText().trim(); if (f.equals("")) if ("".equals(f)) { errors.add(ERR_CTRL_PANEL_NO_FILTER_FOR_VLV_PROVIDED.get()); setPrimaryInvalid(lFilter); @@ -823,33 +734,34 @@ errors.add(ERR_CTRL_PANEL_NO_ATTRIBUTE_FOR_VLV_PROVIDED.get()); setPrimaryInvalid(lSortOrder); } String v = maxBlockSize.getText(); try { int n = Integer.parseInt(v); if ((n < MIN_MAX_BLOCK_SIZE) || (n > MAX_MAX_BLOCK_SIZE)) if (n < MIN_MAX_BLOCK_SIZE || n > MAX_MAX_BLOCK_SIZE) { errors.add(ERR_CTRL_PANEL_INVALID_MAX_BLOCK_SIZE_FOR_VLV_PROVIDED.get( MIN_MAX_BLOCK_SIZE, MAX_MAX_BLOCK_SIZE)); errors.add(ERR_CTRL_PANEL_INVALID_MAX_BLOCK_SIZE_FOR_VLV_PROVIDED.get(MIN_MAX_BLOCK_SIZE, MAX_MAX_BLOCK_SIZE)); setPrimaryInvalid(lMaxBlockSize); } } catch (Throwable t) { errors.add(ERR_CTRL_PANEL_INVALID_MAX_BLOCK_SIZE_FOR_VLV_PROVIDED.get( MIN_MAX_BLOCK_SIZE, MAX_MAX_BLOCK_SIZE)); errors.add(ERR_CTRL_PANEL_INVALID_MAX_BLOCK_SIZE_FOR_VLV_PROVIDED.get(MIN_MAX_BLOCK_SIZE, MAX_MAX_BLOCK_SIZE)); setPrimaryInvalid(lMaxBlockSize); } return errors; } /** * Returns the backend for the index. * * @return the backend for the index. */ protected BackendDescriptor getBackend() { // Check that the index does not exist // Check that the index does not exist BackendDescriptor backend = null; for (BackendDescriptor b : getInfo().getServerDescriptor().getBackends()) { @@ -864,6 +776,7 @@ /** * Returns the base DN for the VLV index. * * @return the base DN for the VLV index. */ protected String getBaseDN() @@ -883,16 +796,15 @@ } } /** * Returns the selected attribute. * * @return the selected attribute. */ protected String getSelectedAttribute() { String attrName; CategorizedComboBoxElement o = (CategorizedComboBoxElement)attributes.getSelectedItem(); CategorizedComboBoxElement o = (CategorizedComboBoxElement) attributes.getSelectedItem(); if (o != null) { attrName = o.getValue().toString(); @@ -904,15 +816,17 @@ return attrName; } /** * 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) protected void createBasicLayout(Container c, GridBagConstraints gbc, boolean nameReadOnly) { gbc.gridx = 0; gbc.gridy = 0; @@ -921,7 +835,7 @@ if (nameReadOnly) { gbc.gridy ++; gbc.gridy++; titlePanel.setTitle(INFO_CTRL_PANEL_VLV_INDEX_DETAILS_LABEL.get()); gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.WEST; @@ -929,7 +843,7 @@ c.add(titlePanel, gbc); } gbc.gridy ++; gbc.gridy++; gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; @@ -958,7 +872,7 @@ gbc2.weightx = 0.7; p.add(Box.createHorizontalGlue(), gbc2); } gbc.gridy ++; gbc.gridy++; gbc.insets.left = 0; gbc.insets.top = 10; @@ -968,7 +882,7 @@ gbc.gridx = 1; gbc.gridwidth = 2; c.add(backendName, gbc); gbc.gridy ++; gbc.gridy++; gbc.insets.left = 0; gbc.gridx = 0; @@ -982,10 +896,9 @@ JPanel p = new JPanel(new GridBagLayout()); p.setOpaque(false); c.add(p, gbc); gbc.gridy ++; gbc.gridy++; DefaultComboBoxModel model = new DefaultComboBoxModel( new Object[]{COMBO_SEPARATOR, OTHER_BASE_DN}); DefaultComboBoxModel model = new DefaultComboBoxModel(new Object[] { COMBO_SEPARATOR, OTHER_BASE_DN }); baseDNs.setModel(model); baseDNs.setRenderer(new CustomListCellRenderer(baseDNs)); ItemListener listener = new IgnoreItemListener(baseDNs); @@ -1006,11 +919,9 @@ gbc2.insets.left = 5; p.add(baseDN, gbc2); gbc2.insets.top = 3; JLabel inlineHelp = Utilities.createInlineHelpLabel( INFO_CTRL_PANEL_SUBTREE_INLINE_HELP_LABEL.get()); JLabel inlineHelp = Utilities.createInlineHelpLabel(INFO_CTRL_PANEL_SUBTREE_INLINE_HELP_LABEL.get()); p.add(inlineHelp, gbc2); gbc.insets.left = 0; gbc.gridx = 0; gbc.gridwidth = 1; @@ -1018,9 +929,7 @@ gbc.insets.left = 10; gbc.gridx = 1; gbc.gridwidth = 2; JRadioButton [] radios = {baseObject, singleLevel, subordinateSubtree, wholeSubtree }; JRadioButton[] radios = { baseObject, singleLevel, subordinateSubtree, wholeSubtree }; singleLevel.setSelected(true); ButtonGroup group = new ButtonGroup(); for (JRadioButton radio : radios) @@ -1028,7 +937,7 @@ c.add(radio, gbc); group.add(radio); gbc.insets.top = 5; gbc.gridy ++; gbc.gridy++; } gbc.insets.top = 10; @@ -1040,12 +949,11 @@ gbc.gridx = 1; gbc.gridwidth = 2; c.add(filter, gbc); gbc.gridy ++; gbc.gridy++; gbc.insets.top = 3; inlineHelp = Utilities.createInlineHelpLabel( INFO_CTRL_PANEL_FILTER_INLINE_HELP_LABEL.get()); inlineHelp = Utilities.createInlineHelpLabel(INFO_CTRL_PANEL_FILTER_INLINE_HELP_LABEL.get()); c.add(inlineHelp, gbc); gbc.gridy ++; gbc.gridy++; gbc.insets.top = 10; gbc.insets.left = 0; @@ -1057,7 +965,7 @@ gbc.fill = GridBagConstraints.HORIZONTAL; c.add(maxBlockSize, gbc); maxBlockSize.setText(String.valueOf(DEFAULT_MAX_BLOCK_SIZE)); gbc.gridy ++; gbc.gridy++; gbc.insets.top = 10; gbc.insets.left = 0; @@ -1070,23 +978,21 @@ attributes.addItemListener(new IgnoreItemListener(attributes)); attributes.setRenderer(new IndexComboBoxCellRenderer(attributes)); c.add(attributes, gbc); gbc.gridx ++; gbc.gridx++; ascendingOrder.setModel(new DefaultComboBoxModel( new Object[] {ASCENDING, DESCENDING})); ascendingOrder.setModel(new DefaultComboBoxModel(new Object[] { ASCENDING, DESCENDING })); c.add(ascendingOrder, gbc); gbc.gridy ++; gbc.gridy++; final ListSelectionListener listListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent ev) { int[] indexes = sortOrder.getSelectedIndices(); if ((indexes != null) && (indexes.length > 0)) if (indexes != null && indexes.length > 0) { moveUp.setEnabled(indexes[0] != 0); moveDown.setEnabled(indexes[indexes.length - 1] != sortOrder.getModel().getSize() - 1); moveDown.setEnabled(indexes[indexes.length - 1] != sortOrder.getModel().getSize() - 1); remove.setEnabled(true); } else @@ -1098,7 +1004,7 @@ } }; JButton[] buttons = {add, remove, moveUp, moveDown}; JButton[] buttons = { add, remove, moveUp, moveDown }; for (JButton button : buttons) { button.setOpaque(false); @@ -1114,17 +1020,15 @@ { boolean isAscending = ASCENDING == ascendingOrder.getSelectedItem(); sortOrderModel.addElement(new VLVSortOrder(attr, isAscending)); DefaultComboBoxModel model = (DefaultComboBoxModel)attributes.getModel(); DefaultComboBoxModel model = (DefaultComboBoxModel) attributes.getModel(); int i = attributes.getSelectedIndex(); if (i > 0) { // To avoid issues, try to figure out first the new selection int newIndex = -1; for (int j= i -1; j>0 && (newIndex == -1); j--) for (int j = i - 1; j > 0 && newIndex == -1; j--) { CategorizedComboBoxElement o = (CategorizedComboBoxElement) model.getElementAt(j); CategorizedComboBoxElement o = (CategorizedComboBoxElement) model.getElementAt(j); if (o.getType() == CategorizedComboBoxElement.Type.REGULAR) { newIndex = j; @@ -1132,10 +1036,9 @@ } if (newIndex == -1) { for (int j= i + 1; j<model.getSize() && (newIndex == -1); j++) for (int j = i + 1; j < model.getSize() && newIndex == -1; j++) { CategorizedComboBoxElement o = (CategorizedComboBoxElement) model.getElementAt(j); CategorizedComboBoxElement o = (CategorizedComboBoxElement) model.getElementAt(j); if (o.getType() == CategorizedComboBoxElement.Type.REGULAR) { newIndex = j; @@ -1157,11 +1060,11 @@ public void actionPerformed(ActionEvent ev) { int[] indexes = sortOrder.getSelectedIndices(); for (int i=0; i<indexes.length; i++) for (int i = 0; i < indexes.length; i++) { Object o1 = sortOrderModel.elementAt(indexes[i] - 1); Object o2 = sortOrderModel.elementAt(indexes[i]); sortOrderModel.set(indexes[i] - 1, o2); sortOrderModel.set(indexes[i] - 1, o2); sortOrderModel.set(indexes[i], o1); indexes[i] = indexes[i] - 1; @@ -1175,11 +1078,11 @@ public void actionPerformed(ActionEvent ev) { int[] indexes = sortOrder.getSelectedIndices(); for (int i=0; i<indexes.length; i++) for (int i = 0; i < indexes.length; i++) { Object o1 = sortOrderModel.elementAt(indexes[i] + 1); Object o2 = sortOrderModel.elementAt(indexes[i]); sortOrderModel.set(indexes[i] + 1, o2); sortOrderModel.set(indexes[i] + 1, o2); sortOrderModel.set(indexes[i], o1); indexes[i] = indexes[i] + 1; @@ -1196,26 +1099,21 @@ synchronized (standardAttrNames) { DefaultComboBoxModel model = (DefaultComboBoxModel)attributes.getModel(); for (int i=0; i<indexes.length; i++) DefaultComboBoxModel model = (DefaultComboBoxModel) attributes.getModel(); for (int i = 0; i < indexes.length; i++) { VLVSortOrder sortOrder = (VLVSortOrder)sortOrderModel.getElementAt( indexes[i]); VLVSortOrder sortOrder = (VLVSortOrder) sortOrderModel.getElementAt(indexes[i]); String attrName = sortOrder.getAttributeName(); boolean isCustom = customAttrNames.contains(attrName); boolean dealingWithCustom = true; for (int j = 0; j < model.getSize(); j++) { CategorizedComboBoxElement o = (CategorizedComboBoxElement) model.getElementAt(j); CategorizedComboBoxElement o = (CategorizedComboBoxElement) model.getElementAt(j); if (o.getType() == CategorizedComboBoxElement.Type.REGULAR) { if (dealingWithCustom == isCustom && attrName.compareTo(o.getValue().toString()) < 0) if (dealingWithCustom == isCustom && attrName.compareTo(o.getValue().toString()) < 0) { model.insertElementAt(new CategorizedComboBoxElement( attrName, model.insertElementAt(new CategorizedComboBoxElement(attrName, CategorizedComboBoxElement.Type.REGULAR), j); break; } @@ -1225,8 +1123,7 @@ dealingWithCustom = false; if (isCustom) { model.insertElementAt(new CategorizedComboBoxElement( attrName, model.insertElementAt(new CategorizedComboBoxElement(attrName, CategorizedComboBoxElement.Type.REGULAR), j); break; } @@ -1235,7 +1132,7 @@ } } for (int i=indexes.length - 1; i >=0; i--) for (int i = indexes.length - 1; i >= 0; i--) { sortOrderModel.remove(indexes[i]); } @@ -1248,7 +1145,7 @@ gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.EAST; c.add(add, gbc); gbc.gridy ++; gbc.gridy++; gbc.insets.top = 10; gbc.gridwidth = 1; @@ -1274,25 +1171,23 @@ gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.WEST; c.add(moveUp, gbc); gbc.gridy ++; gbc.gridy++; gbc.insets.top = 5; c.add(moveDown, gbc); gbc.insets.top = 0; gbc.gridy ++; gbc.gridy++; gbc.weighty = 1.0; Dimension d = new Dimension( Math.max(moveUp.getPreferredSize().width, moveDown.getPreferredSize().width), Math.max(moveUp.getPreferredSize().height, moveDown.getPreferredSize().height)); Dimension d = new Dimension(Math.max(moveUp.getPreferredSize().width, moveDown.getPreferredSize().width), Math.max(moveUp.getPreferredSize().height, moveDown.getPreferredSize().height)); moveUp.setPreferredSize(d); moveDown.setPreferredSize(d); c.add(Box.createVerticalGlue(), gbc); gbc.gridx = 1; gbc.gridy ++; gbc.gridy++; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.NORTHEAST; gbc.fill = GridBagConstraints.NONE; opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java
@@ -27,6 +27,7 @@ package org.opends.guitools.controlpanel.ui; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.messages.AdminToolMessages.*; import java.awt.Component; @@ -39,9 +40,11 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; import javax.naming.ldap.InitialLdapContext; import javax.swing.SwingUtilities; import org.forgerock.i18n.LocalizableMessage; import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; @@ -51,8 +54,6 @@ import org.opends.guitools.controlpanel.task.OfflineUpdateException; 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.client.ManagementContext; import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor; import org.opends.server.admin.client.ldap.LDAPManagementContext; @@ -70,7 +71,6 @@ /** * Panel that appears when the user defines a new VLV index. * */ public class NewVLVIndexPanel extends AbstractVLVIndexPanel { @@ -78,9 +78,12 @@ /** * 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 NewVLVIndexPanel(String backendName, Component relativeComponent) { @@ -88,33 +91,35 @@ createBasicLayout(this, new GridBagConstraints(), false); } /** {@inheritDoc} */ @Override public LocalizableMessage getTitle() { return INFO_CTRL_PANEL_NEW_VLV_INDEX_TITLE.get(); } /** {@inheritDoc} */ @Override public Component getPreferredFocusComponent() { return name; } /** {@inheritDoc} */ @Override public void configurationChanged(ConfigurationChangeEvent ev) { ServerDescriptor desc = ev.getNewDescriptor(); final ServerDescriptor desc = ev.getNewDescriptor(); if (updateLayout(desc)) { updateErrorPaneAndOKButtonIfAuthRequired(desc, isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_NEW_VLV.get() : INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname())); LocalizableMessage msg = isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_NEW_VLV.get() : INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()); updateErrorPaneAndOKButtonIfAuthRequired(desc, msg); } } /** * 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) { @@ -123,34 +128,29 @@ } /** {@inheritDoc} */ @Override public void okClicked() { List<LocalizableMessage> errors = checkErrors(true); final List<LocalizableMessage> errors = checkErrors(true); if (errors.isEmpty()) { ProgressDialog dlg = new ProgressDialog( Utilities.createFrame(), Utilities.getParentDialog(this), INFO_CTRL_PANEL_NEW_VLV_INDEX_TITLE.get(), getInfo()); NewVLVIndexTask newTask = new NewVLVIndexTask(getInfo(), dlg); for (Task task : getInfo().getTasks()) final ProgressDialog dlg = new ProgressDialog( createFrame(), getParentDialog(this), INFO_CTRL_PANEL_NEW_VLV_INDEX_TITLE.get(), getInfo()); final NewVLVIndexTask newTask = new NewVLVIndexTask(getInfo(), dlg); for (final Task task : getInfo().getTasks()) { task.canLaunch(newTask, errors); } if (errors.isEmpty() && checkIndexRequired()) { String indexName = name.getText().trim(); launchOperation(newTask, INFO_CTRL_PANEL_CREATING_NEW_VLV_INDEX_SUMMARY.get(indexName), final String indexName = name.getText().trim(); launchOperation(newTask, INFO_CTRL_PANEL_CREATING_NEW_VLV_INDEX_SUMMARY.get(indexName), INFO_CTRL_PANEL_CREATING_NEW_VLV_INDEX_SUCCESSFUL_SUMMARY.get(), INFO_CTRL_PANEL_CREATING_NEW_VLV_INDEX_SUCCESSFUL_DETAILS.get( indexName), INFO_CTRL_PANEL_CREATING_NEW_VLV_INDEX_SUCCESSFUL_DETAILS.get(indexName), ERR_CTRL_PANEL_CREATING_NEW_VLV_INDEX_ERROR_SUMMARY.get(), ERR_CTRL_PANEL_CREATING_NEW_VLV_INDEX_ERROR_DETAILS.get(), null, dlg); ERR_CTRL_PANEL_CREATING_NEW_VLV_INDEX_ERROR_DETAILS.get(), null, dlg); dlg.setVisible(true); Utilities.getParentDialog(this).setVisible(false); getParentDialog(this).setVisible(false); } } @@ -160,28 +160,28 @@ } } /** * The task in charge of creating the VLV index. * */ /** The task in charge of creating the VLV index. */ protected class NewVLVIndexTask extends Task { private Set<String> backendSet; private String indexName; private Scope scope; private List<VLVSortOrder> sortOrder; private String baseDN; private String filterValue; private String backendID; private String ldif; private String sortOrderStringValue; private int maxBlock; private final Set<String> backendSet; private final String indexName; private final Scope scope; private final List<VLVSortOrder> sortOrder; private final String baseDN; private final String filterValue; private final String backendID; private final String ldif; private final String sortOrderStringValue; private final int maxBlock; private VLVIndexDescriptor newIndex; /** * 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 NewVLVIndexTask(ControlPanelInfo info, ProgressDialog dlg) { @@ -199,28 +199,26 @@ maxBlock = Integer.parseInt(maxBlockSize.getText()); } /** {@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_VLV_INDEX_TASK_DESCRIPTION.get( indexName, backendID); return INFO_CTRL_PANEL_NEW_VLV_INDEX_TASK_DESCRIPTION.get(indexName, backendID); } /** {@inheritDoc} */ public boolean canLaunch(Task taskToBeLaunched, Collection<LocalizableMessage> incompatibilityReasons) @Override public boolean canLaunch(Task taskToBeLaunched, Collection<LocalizableMessage> incompatibilityReasons) { boolean canLaunch = true; if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched)) @@ -228,13 +226,11 @@ // All the operations are incompatible if they apply to this // backend for safety. This is a short operation so the limitation // has not a lot of impact. Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); final Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); backends.retainAll(getBackends()); if (backends.size() > 0) { incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); canLaunch = false; } } @@ -255,35 +251,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() { @Override public void run() { List<String> args = getObfuscatedCommandLineArguments( getDSConfigCommandLineArguments()); final List<String> args = getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments()); args.removeAll(getConfigCommandLineArguments()); printEquivalentCommandLine(getConfigCommandLineName(), args, INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_CREATE_VLV_INDEX.get()); printEquivalentCommandLine( getConfigCommandLineName(), args, INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_CREATE_VLV_INDEX.get()); } }); } SwingUtilities.invokeLater(new Runnable() { /** {@inheritDoc} */ @Override public void run() { getProgressDialog().appendProgressHtml( Utilities.getProgressWithPoints( INFO_CTRL_PANEL_CREATING_NEW_VLV_INDEX_PROGRESS.get( indexName), ColorAndFontConstants.progressFont)); getProgressDialog().appendProgressHtml(getProgressWithPoints( INFO_CTRL_PANEL_CREATING_NEW_VLV_INDEX_PROGRESS.get(indexName), ColorAndFontConstants.progressFont)); } }); if (isServerRunning()) @@ -298,11 +289,10 @@ } SwingUtilities.invokeLater(new Runnable() { /** {@inheritDoc} */ @Override public void run() { getProgressDialog().appendProgressHtml( Utilities.getProgressDone(ColorAndFontConstants.progressFont)); getProgressDialog().appendProgressHtml(getProgressDone(ColorAndFontConstants.progressFont)); } }); } @@ -310,8 +300,7 @@ { if (configHandlerUpdated) { DirectoryServer.getInstance().initializeConfiguration( ConfigReader.configClassName, ConfigReader.configFile); DirectoryServer.getInstance().initializeConfiguration(ConfigReader.configClassName, ConfigReader.configFile); getInfo().startPooling(); } } @@ -322,31 +311,23 @@ LDIFImportConfig ldifImportConfig = null; try { String topEntryDN = "cn=VLV Index,"+Utilities.getRDNString("ds-cfg-backend-id", backendName.getText())+",cn=Backends,cn=config"; boolean topEntryExists = DirectoryServer.getConfigHandler().entryExists( DN.valueOf(topEntryDN)); 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) { String completeLDIF = Utilities.makeLdif( "dn: "+topEntryDN, "objectClass: top", "objectClass: ds-cfg-branch", "cn: VLV Index", "") + ldif; ldifImportConfig = new LDIFImportConfig(new StringReader(completeLDIF)); 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)); } LDIFReader reader = new LDIFReader(ldifImportConfig); final LDIFReader reader = new LDIFReader(ldifImportConfig); Entry backendConfigEntry; while ((backendConfigEntry = reader.readEntry()) != null) { @@ -354,10 +335,9 @@ } DirectoryServer.getConfigHandler().writeUpdatedConfig(); } catch (IOException ioe) catch (final 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 { @@ -370,14 +350,11 @@ private void createIndex(InitialLdapContext ctx) throws OpenDsException { 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); final ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(ctx)); final RootCfgClient root = mCtx.getRootConfiguration(); final LocalDBBackendCfgClient backend = (LocalDBBackendCfgClient) root.getBackend(backendName.getText()); final LocalDBVLVIndexCfgDefn provider = LocalDBVLVIndexCfgDefn.getInstance(); final LocalDBVLVIndexCfgClient index = backend.createLocalDBVLVIndex(provider, name.getText(), null); index.setFilter(filter.getText().trim()); index.setSortOrder(getSortOrderStringValue(getSortOrder())); @@ -387,16 +364,14 @@ index.commit(); } /** {@inheritDoc} */ @Override protected String getCommandLinePath() { return null; } /** {@inheritDoc} */ @Override protected ArrayList<String> getCommandLineArguments() protected List<String> getCommandLineArguments() { return new ArrayList<String>(); } @@ -413,7 +388,6 @@ } } /** {@inheritDoc} */ @Override public void runTask() { @@ -423,14 +397,12 @@ try { updateConfiguration(); for (BackendDescriptor backend : getInfo().getServerDescriptor().getBackends()) for (final BackendDescriptor backend : getInfo().getServerDescriptor().getBackends()) { if (backend.getBackendID().equalsIgnoreCase(backendID)) { newIndex = new VLVIndexDescriptor( indexName, backend, DN.valueOf(baseDN), scope, filterValue, sortOrder, maxBlock); newIndex = new VLVIndexDescriptor(indexName, backend, DN.valueOf(baseDN), scope, filterValue, sortOrder, maxBlock); getInfo().registerModifiedIndex(newIndex); notifyConfigurationElementCreated(newIndex); break; @@ -438,27 +410,25 @@ } state = State.FINISHED_SUCCESSFULLY; } catch (Throwable t) catch (final Throwable t) { lastException = t; state = State.FINISHED_WITH_ERROR; } } /** {@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()); } } private ArrayList<String> getDSConfigCommandLineArguments() private List<String> getDSConfigCommandLineArguments() { ArrayList<String> args = new ArrayList<String>(); final List<String> args = new ArrayList<String>(); args.add("create-local-db-vlv-index"); args.add("--backend-name"); args.add(backendID); @@ -469,16 +439,16 @@ args.add(indexName); args.add("--set"); args.add("base-dn:"+baseDN); args.add("base-dn:" + baseDN); args.add("--set"); args.add("filter:"+filterValue); args.add("filter:" + filterValue); args.add("--set"); args.add("scope:"+scope); args.add("scope:" + scope); args.add("--set"); args.add("sort-order:"+sortOrderStringValue); args.add("sort-order:" + sortOrderStringValue); args.addAll(getConnectionCommandLineArguments()); args.add(getNoPropertiesFileArgument()); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java
@@ -27,6 +27,7 @@ package org.opends.guitools.controlpanel.ui; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.messages.AdminToolMessages.*; import java.awt.Component; @@ -93,16 +94,15 @@ /** * The panel that displays an existing VLV index (it appears on the right of the * 'Manage Indexes' dialog). * */ public class VLVIndexPanel extends AbstractVLVIndexPanel { private static final long serialVersionUID = 6333337497315464283L; private JButton deleteIndex = Utilities.createButton( INFO_CTRL_PANEL_DELETE_INDEX_LABEL.get()); private JButton saveChanges = Utilities.createButton( INFO_CTRL_PANEL_SAVE_CHANGES_LABEL.get()); private JLabel warning = Utilities.createDefaultLabel(); private static final LocalizableMessage INDEX_MODIFIED = INFO_CTRL_PANEL_INDEX_MODIFIED_MESSAGE.get(); private final JButton deleteIndex = Utilities.createButton(INFO_CTRL_PANEL_DELETE_INDEX_LABEL.get()); private final JButton saveChanges = Utilities.createButton(INFO_CTRL_PANEL_SAVE_CHANGES_LABEL.get()); private final JLabel warning = Utilities.createDefaultLabel(); private ScrollPaneBorderListener scrollListener; @@ -110,47 +110,39 @@ private boolean ignoreCheckSave; private LocalizableMessage INDEX_MODIFIED = INFO_CTRL_PANEL_INDEX_MODIFIED_MESSAGE.get(); private VLVIndexDescriptor index; /** * Default constructor. * */ /** Default constructor. */ public VLVIndexPanel() { super(null, null); createLayout(); } /** {@inheritDoc} */ @Override public LocalizableMessage getTitle() { return INFO_CTRL_PANEL_VLV_INDEX_PANEL_TITLE.get(); } /** {@inheritDoc} */ @Override public Component getPreferredFocusComponent() { return baseDN; } /** {@inheritDoc} */ @Override public void configurationChanged(ConfigurationChangeEvent ev) { final ServerDescriptor desc = ev.getNewDescriptor(); if (updateLayout(desc)) { updateErrorPaneIfAuthRequired(desc, isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_VLV_INDEX_EDITING.get() : INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname())); LocalizableMessage msg = isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_VLV_INDEX_EDITING.get() : INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()); updateErrorPaneIfAuthRequired(desc, msg); SwingUtilities.invokeLater(new Runnable() { /** {@inheritDoc} */ @Override public void run() { checkSaveButton(); @@ -160,47 +152,46 @@ } } /** {@inheritDoc} */ @Override public void okClicked() { } /** * Method used to know if there are unsaved changes or not. It is used by * the index selection listener when the user changes the selection. * Method used to know if there are unsaved changes or not. It is used by the * index selection listener when the user changes the selection. * * @return <CODE>true</CODE> if there are unsaved changes (and so the * selection of the index should be canceled) and <CODE>false</CODE> * otherwise. * selection of the index should be canceled) and <CODE>false</CODE> * otherwise. */ public boolean mustCheckUnsavedChanges() { return (index != null) && saveChanges.isVisible() && saveChanges.isEnabled(); return index != null && saveChanges.isVisible() && saveChanges.isEnabled(); } /** * Tells whether the user chose to save the changes in the panel, to not save * them or simply cancelled the selection in the tree. * * @return the value telling whether the user chose to save the changes in the * panel, to not save them or simply cancelled the selection change in the * tree. * panel, to not save them or simply cancelled the selection change in * the tree. */ public UnsavedChangesDialog.Result checkUnsavedChanges() { UnsavedChangesDialog.Result result; UnsavedChangesDialog unsavedChangesDlg = new UnsavedChangesDialog( Utilities.getParentDialog(this), getInfo()); final UnsavedChangesDialog unsavedChangesDlg = new UnsavedChangesDialog(getParentDialog(this), getInfo()); unsavedChangesDlg.setMessage(INFO_CTRL_PANEL_UNSAVED_CHANGES_SUMMARY.get(), INFO_CTRL_PANEL_UNSAVED_INDEX_CHANGES_DETAILS.get(index.getName())); Utilities.centerGoldenMean(unsavedChangesDlg, Utilities.getParentDialog(this)); INFO_CTRL_PANEL_UNSAVED_INDEX_CHANGES_DETAILS.get(index.getName())); centerGoldenMean(unsavedChangesDlg, getParentDialog(this)); unsavedChangesDlg.setVisible(true); result = unsavedChangesDlg.getResult(); if (result == UnsavedChangesDialog.Result.SAVE) { saveIndex(false); if ((newModifyTask == null) || // The user data is not valid (newModifyTask.getState() != Task.State.FINISHED_SUCCESSFULLY)) if (newModifyTask == null || newModifyTask.getState() != Task.State.FINISHED_SUCCESSFULLY) // The user data is not valid { result = UnsavedChangesDialog.Result.CANCEL; } @@ -211,11 +202,9 @@ private void checkSaveButton() { if (!ignoreCheckSave && (index != null)) if (!ignoreCheckSave && index != null) { saveChanges.setEnabled( !authenticationRequired(getInfo().getServerDescriptor()) && isModified()); saveChanges.setEnabled(!authenticationRequired(getInfo().getServerDescriptor()) && isModified()); } } @@ -232,7 +221,7 @@ private void createLayout() { GridBagConstraints gbc = new GridBagConstraints(); JPanel p = new JPanel(new GridBagLayout()); final JPanel p = new JPanel(new GridBagLayout()); p.setOpaque(false); super.createBasicLayout(p, gbc, true); p.setBorder(new EmptyBorder(10, 10, 10, 10)); @@ -242,12 +231,11 @@ gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy = 0; JScrollPane scroll = Utilities.createBorderLessScrollBar(p); scrollListener = ScrollPaneBorderListener.createBottomBorderListener(scroll); final JScrollPane scroll = Utilities.createBorderLessScrollBar(p); scrollListener = ScrollPaneBorderListener.createBottomBorderListener(scroll); add(scroll, gbc); gbc.gridy ++; gbc.gridy++; gbc.gridx = 0; gbc.weightx = 1.0; gbc.weighty = 0.0; @@ -262,8 +250,8 @@ add(warning, gbc); Utilities.setWarningLabel(warning, INDEX_MODIFIED); gbc.gridy ++; JPanel buttonPanel = new JPanel(new GridBagLayout()); gbc.gridy++; final JPanel buttonPanel = new JPanel(new GridBagLayout()); buttonPanel.setOpaque(false); gbc.insets = new Insets(10, 10, 10, 10); add(buttonPanel, gbc); @@ -278,7 +266,7 @@ buttonPanel.add(deleteIndex, gbc); deleteIndex.addActionListener(new ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(ActionEvent ev) { deleteIndex(); @@ -294,44 +282,43 @@ buttonPanel.add(saveChanges, gbc); saveChanges.addActionListener(new ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(ActionEvent ev) { saveIndex(false); } }); DocumentListener documentListener = new DocumentListener() final DocumentListener documentListener = new DocumentListener() { /** {@inheritDoc} */ @Override public void insertUpdate(DocumentEvent ev) { checkSaveButton(); } /** {@inheritDoc} */ @Override public void changedUpdate(DocumentEvent ev) { checkSaveButton(); } /** {@inheritDoc} */ @Override public void removeUpdate(DocumentEvent ev) { checkSaveButton(); } }; ActionListener actionListener = new ActionListener() final ActionListener actionListener = new ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(ActionEvent ev) { checkSaveButton(); } }; baseDNs.addActionListener(actionListener); baseObject.addActionListener(actionListener); singleLevel.addActionListener(actionListener); @@ -340,19 +327,19 @@ attributes.addActionListener(actionListener); sortOrder.getModel().addListDataListener(new ListDataListener() { /** {@inheritDoc} */ @Override public void contentsChanged(ListDataEvent e) { checkSaveButton(); } /** {@inheritDoc} */ @Override public void intervalAdded(ListDataEvent e) { checkSaveButton(); } /** {@inheritDoc} */ @Override public void intervalRemoved(ListDataEvent e) { checkSaveButton(); @@ -367,38 +354,31 @@ private void deleteIndex() { ArrayList<LocalizableMessage> errors = new ArrayList<LocalizableMessage>(); ProgressDialog dlg = new ProgressDialog( Utilities.createFrame(), Utilities.getParentDialog(this), INFO_CTRL_PANEL_DELETE_VLV_INDEX_TITLE.get(), getInfo()); ArrayList<AbstractIndexDescriptor> indexesToDelete = new ArrayList<AbstractIndexDescriptor>(); final List<LocalizableMessage> errors = new ArrayList<LocalizableMessage>(); final ProgressDialog dlg = new ProgressDialog( createFrame(), getParentDialog(this), INFO_CTRL_PANEL_DELETE_VLV_INDEX_TITLE.get(), getInfo()); final List<AbstractIndexDescriptor> indexesToDelete = new ArrayList<AbstractIndexDescriptor>(); indexesToDelete.add(index); DeleteIndexTask newTask = new DeleteIndexTask(getInfo(), dlg, indexesToDelete); for (Task task : getInfo().getTasks()) final DeleteIndexTask newTask = new DeleteIndexTask(getInfo(), dlg, indexesToDelete); for (final Task task : getInfo().getTasks()) { task.canLaunch(newTask, errors); } if (errors.isEmpty()) { String indexName = index.getName(); String backendName = index.getBackend().getBackendID(); if (displayConfirmationDialog( INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(), INFO_CTRL_PANEL_CONFIRMATION_VLV_INDEX_DELETE_DETAILS.get(indexName, backendName))) final String indexName = index.getName(); final String backendName = index.getBackend().getBackendID(); if (displayConfirmationDialog(INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(), INFO_CTRL_PANEL_CONFIRMATION_VLV_INDEX_DELETE_DETAILS.get(indexName, backendName))) { launchOperation(newTask, INFO_CTRL_PANEL_DELETING_VLV_INDEX_SUMMARY.get(), INFO_CTRL_PANEL_DELETING_VLV_INDEX_COMPLETE.get(), INFO_CTRL_PANEL_DELETING_VLV_INDEX_SUCCESSFUL.get(indexName, backendName), ERR_CTRL_PANEL_DELETING_VLV_INDEX_ERROR_SUMMARY.get(), ERR_CTRL_PANEL_DELETING_VLV_INDEX_ERROR_DETAILS.get(indexName), null, dlg); INFO_CTRL_PANEL_DELETING_VLV_INDEX_SUMMARY.get(), INFO_CTRL_PANEL_DELETING_VLV_INDEX_COMPLETE.get(), INFO_CTRL_PANEL_DELETING_VLV_INDEX_SUCCESSFUL.get(indexName, backendName), ERR_CTRL_PANEL_DELETING_VLV_INDEX_ERROR_SUMMARY.get(), ERR_CTRL_PANEL_DELETING_VLV_INDEX_ERROR_DETAILS.get(indexName), null, dlg); dlg.setVisible(true); } } @@ -415,32 +395,29 @@ { return; } List<LocalizableMessage> errors = checkErrors(false); final List<LocalizableMessage> errors = checkErrors(false); if (errors.isEmpty()) { ProgressDialog dlg = new ProgressDialog( Utilities.getFrame(this), Utilities.getFrame(this), INFO_CTRL_PANEL_MODIFYING_INDEX_TITLE.get(), getInfo()); final ProgressDialog dlg = new ProgressDialog(getFrame(this), getFrame(this), INFO_CTRL_PANEL_MODIFYING_INDEX_TITLE.get(), getInfo()); dlg.setModal(modal); newModifyTask = new ModifyVLVIndexTask(getInfo(), dlg); for (Task task : getInfo().getTasks()) for (final Task task : getInfo().getTasks()) { task.canLaunch(newModifyTask, errors); } if (errors.isEmpty() && checkIndexRequired()) { String indexName = index.getName(); String backendName = index.getBackend().getBackendID(); final String indexName = index.getName(); final String backendName = index.getBackend().getBackendID(); launchOperation(newModifyTask, INFO_CTRL_PANEL_MODIFYING_VLV_INDEX_SUMMARY.get(indexName), INFO_CTRL_PANEL_MODIFYING_VLV_INDEX_COMPLETE.get(), INFO_CTRL_PANEL_MODIFYING_VLV_INDEX_SUCCESSFUL.get(indexName, backendName), ERR_CTRL_PANEL_MODIFYING_VLV_INDEX_ERROR_SUMMARY.get(), ERR_CTRL_PANEL_MODIFYING_VLV_INDEX_ERROR_DETAILS.get(indexName), null, dlg); INFO_CTRL_PANEL_MODIFYING_VLV_INDEX_SUMMARY.get(indexName), INFO_CTRL_PANEL_MODIFYING_VLV_INDEX_COMPLETE.get(), INFO_CTRL_PANEL_MODIFYING_VLV_INDEX_SUCCESSFUL.get(indexName, backendName), ERR_CTRL_PANEL_MODIFYING_VLV_INDEX_ERROR_SUMMARY.get(), ERR_CTRL_PANEL_MODIFYING_VLV_INDEX_ERROR_DETAILS.get(indexName), null, dlg); saveChanges.setEnabled(false); dlg.setVisible(true); } @@ -452,10 +429,11 @@ } } /** * Updates the contents of the panel with the provided VLV index. * @param index the VLV index descriptor to be used to update the panel. * * @param index * the VLV index descriptor to be used to update the panel. */ public void update(VLVIndexDescriptor index) { @@ -467,8 +445,8 @@ updateBaseDNCombo(index.getBackend()); backendName.setText(index.getBackend().getBackendID()); } String dn = Utilities.unescapeUtf8(index.getBaseDN().toString()); if (((DefaultComboBoxModel)baseDNs.getModel()).getIndexOf(dn) != -1) final String dn = Utilities.unescapeUtf8(index.getBaseDN().toString()); if (((DefaultComboBoxModel) baseDNs.getModel()).getIndexOf(dn) != -1) { baseDN.setText(""); baseDNs.setSelectedItem(dn); @@ -478,27 +456,12 @@ baseDN.setText(dn); baseDNs.setSelectedItem(OTHER_BASE_DN); } switch (index.getScope()) { case BASE_OBJECT: baseObject.setSelected(true); break; case SINGLE_LEVEL: singleLevel.setSelected(true); break; case SUBORDINATE_SUBTREE: subordinateSubtree.setSelected(true); break; case WHOLE_SUBTREE: wholeSubtree.setSelected(true); break; } selectScopeRadioButton(index); filter.setText(index.getFilter()); // Simulate a remove to update the attribute combo box and add them again. int indexes[] = new int[sortOrderModel.getSize()]; for (int i=0; i<indexes.length; i++) final int indexes[] = new int[sortOrderModel.getSize()]; for (int i = 0; i < indexes.length; i++) { indexes[i] = i; } @@ -506,17 +469,14 @@ remove.doClick(); // The list is now empty and the attribute combo properly updated. DefaultComboBoxModel model = (DefaultComboBoxModel)attributes.getModel(); for (VLVSortOrder s : index.getSortOrder()) final DefaultComboBoxModel model = (DefaultComboBoxModel) attributes.getModel(); for (final VLVSortOrder s : index.getSortOrder()) { sortOrderModel.addElement(s); for (int i=0; i<model.getSize(); i++) for (int i = 0; i < model.getSize(); i++) { CategorizedComboBoxElement o = (CategorizedComboBoxElement)model.getElementAt(i); if ((o.getType() == CategorizedComboBoxElement.Type.REGULAR) && o.getValue().equals(s.getAttributeName())) final CategorizedComboBoxElement o = (CategorizedComboBoxElement) model.getElementAt(i); if (o.getType() == CategorizedComboBoxElement.Type.REGULAR && o.getValue().equals(s.getAttributeName())) { model.removeElementAt(i); break; @@ -532,7 +492,7 @@ { if (getInfo().mustReindex(index)) { Utilities.setWarningLabel(warning, INDEX_MODIFIED); setWarningLabel(warning, INDEX_MODIFIED); warning.setVisible(true); warning.setVerticalTextPosition(SwingConstants.TOP); } @@ -549,18 +509,34 @@ scrollListener.updateBorder(); } private void selectScopeRadioButton(final VLVIndexDescriptor index) { switch (index.getScope()) { case BASE_OBJECT: baseObject.setSelected(true); break; case SINGLE_LEVEL: singleLevel.setSelected(true); break; case SUBORDINATE_SUBTREE: subordinateSubtree.setSelected(true); break; case WHOLE_SUBTREE: wholeSubtree.setSelected(true); break; } } private boolean isModified() { try { return !index.getBaseDN().equals(DN.valueOf(getBaseDN())) || (getScope() != index.getScope()) || !filter.getText().trim().equals(index.getFilter()) || !getSortOrder().equals(index.getSortOrder()) || !String.valueOf(index.getMaxBlockSize()).equals( maxBlockSize.getText().trim()); return !index.getBaseDN().equals(DN.valueOf(getBaseDN())) || index.getScope() != getScope() || !index.getFilter().equals(filter.getText().trim()) || !index.getSortOrder().equals(getSortOrder()) || !Integer.toString(index.getMaxBlockSize()).equals(maxBlockSize.getText().trim()); } catch (OpenDsException odse) catch (final OpenDsException odse) { // The base DN is not valid. This means that the index has been modified. return true; @@ -569,27 +545,29 @@ /** * The task in charge of modifying the VLV index. * */ protected class ModifyVLVIndexTask extends Task { private Set<String> backendSet; private String indexName; private String baseDN; private String filterValue; private Scope scope; private List<VLVSortOrder> sortOrder; private String backendID; private String sortOrderStringValue; private String ldif; private VLVIndexDescriptor indexToModify; private int maxBlock; private final Set<String> backendSet; private final String indexName; private final String baseDN; private final String filterValue; private final Scope scope; private final List<VLVSortOrder> sortOrder; private final String backendID; private final String sortOrderStringValue; private final String ldif; private final VLVIndexDescriptor indexToModify; private final int maxBlock; private VLVIndexDescriptor modifiedIndex; /** * 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 ModifyVLVIndexTask(ControlPanelInfo info, ProgressDialog dlg) { @@ -608,28 +586,26 @@ indexToModify = index; } /** {@inheritDoc} */ @Override public Type getType() { return Type.MODIFY_INDEX; } /** {@inheritDoc} */ @Override public Set<String> getBackends() { return backendSet; } /** {@inheritDoc} */ @Override public LocalizableMessage getTaskDescription() { return INFO_CTRL_PANEL_MODIFY_VLV_INDEX_TASK_DESCRIPTION.get( indexName, backendID); return INFO_CTRL_PANEL_MODIFY_VLV_INDEX_TASK_DESCRIPTION.get(indexName, backendID); } /** {@inheritDoc} */ public boolean canLaunch(Task taskToBeLaunched, Collection<LocalizableMessage> incompatibilityReasons) @Override public boolean canLaunch(Task taskToBeLaunched, Collection<LocalizableMessage> incompatibilityReasons) { boolean canLaunch = true; if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched)) @@ -637,13 +613,11 @@ // All the operations are incompatible if they apply to this // backend for safety. This is a short operation so the limitation // has not a lot of impact. Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); final Set<String> backends = new TreeSet<String>(taskToBeLaunched.getBackends()); backends.retainAll(getBackends()); if (backends.size() > 0) { incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); canLaunch = false; } } @@ -664,32 +638,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() { @Override public void run() { List<String> args = getObfuscatedCommandLineArguments( getDSConfigCommandLineArguments()); final List<String> args = getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments()); args.removeAll(getConfigCommandLineArguments()); printEquivalentCommandLine(getConfigCommandLineName(), args, printEquivalentCommandLine(getConfigCommandLineName(), args, INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_MODIFY_VLV_INDEX.get()); } }); } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { getProgressDialog().appendProgressHtml( Utilities.getProgressWithPoints( INFO_CTRL_PANEL_MODIFYING_VLV_INDEX_PROGRESS.get(indexName), Utilities.getProgressWithPoints(INFO_CTRL_PANEL_MODIFYING_VLV_INDEX_PROGRESS.get(indexName), ColorAndFontConstants.progressFont)); } }); @@ -706,10 +678,10 @@ SwingUtilities.invokeLater(new Runnable() { /** {@inheritDoc} */ @Override public void run() { getProgressDialog().appendProgressHtml( Utilities.getProgressDone(ColorAndFontConstants.progressFont)); getProgressDialog().appendProgressHtml(Utilities.getProgressDone(ColorAndFontConstants.progressFont)); } }); } @@ -717,8 +689,7 @@ { if (configHandlerUpdated) { DirectoryServer.getInstance().initializeConfiguration( ConfigReader.configClassName, ConfigReader.configFile); DirectoryServer.getInstance().initializeConfiguration(ConfigReader.configClassName, ConfigReader.configFile); getInfo().startPooling(); } } @@ -730,19 +701,15 @@ try { ldifImportConfig = new LDIFImportConfig(new StringReader(ldif)); LDIFReader reader = new LDIFReader(ldifImportConfig); Entry newConfigEntry = reader.readEntry(); Entry oldEntry = DirectoryServer.getConfigEntry( newConfigEntry.getName()).getEntry(); DirectoryServer.getConfigHandler().replaceEntry(oldEntry, newConfigEntry, null); final LDIFReader reader = new LDIFReader(ldifImportConfig); final Entry newConfigEntry = reader.readEntry(); final Entry oldEntry = DirectoryServer.getConfigEntry(newConfigEntry.getName()).getEntry(); DirectoryServer.getConfigHandler().replaceEntry(oldEntry, newConfigEntry, null); DirectoryServer.getConfigHandler().writeUpdatedConfig(); } catch (IOException ioe) catch (final 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 { @@ -755,40 +722,43 @@ /** * Modifies index using the provided connection. * @param ctx the connection to be used to update the index configuration. * @throws OpenDsException if there is an error updating the server. * * @param ctx * the connection to be used to update the index configuration. * @throws OpenDsException * if there is an error updating the server. */ private void modifyIndex(InitialLdapContext ctx) throws OpenDsException { final StringBuilder sb = new StringBuilder(); sb.append(getConfigCommandLineName()); Collection<String> args = getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments()); for (String arg : args) final Collection<String> args = getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments()); for (final String arg : args) { sb.append(" "); sb.append(CommandBuilder.escapeValue(arg)); } ManagementContext mCtx = LDAPManagementContext.createFromContext( JNDIDirContextAdaptor.adapt(ctx)); RootCfgClient root = mCtx.getRootConfiguration(); LocalDBBackendCfgClient backend = (LocalDBBackendCfgClient)root.getBackend(backendID); LocalDBVLVIndexCfgClient index = backend.getLocalDBVLVIndex(indexName); DN b = DN.valueOf(baseDN); final ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(ctx)); final RootCfgClient root = mCtx.getRootConfiguration(); final LocalDBBackendCfgClient backend = (LocalDBBackendCfgClient) root.getBackend(backendID); final LocalDBVLVIndexCfgClient index = backend.getLocalDBVLVIndex(indexName); final DN b = DN.valueOf(baseDN); if (!indexToModify.getBaseDN().equals(b)) { index.setBaseDN(b); } if (!indexToModify.getFilter().equals(filterValue)) { index.setFilter(filterValue); } if (indexToModify.getScope() != scope) { index.setScope(scope); } if (!indexToModify.getSortOrder().equals(sortOrder)) { index.setSortOrder(sortOrderStringValue); @@ -796,13 +766,13 @@ index.commit(); } /** {@inheritDoc} */ @Override protected String getCommandLinePath() { return null; } /** {@inheritDoc} */ @Override protected ArrayList<String> getCommandLineArguments() { return new ArrayList<String>(); @@ -817,7 +787,7 @@ return null; } /** {@inheritDoc} */ @Override public void runTask() { state = State.RUNNING; @@ -826,32 +796,31 @@ try { updateConfiguration(); modifiedIndex = new VLVIndexDescriptor( indexName, indexToModify.getBackend(), DN.valueOf(baseDN), scope, filterValue, sortOrder, maxBlock); modifiedIndex = new VLVIndexDescriptor(indexName, indexToModify.getBackend(), DN.valueOf(baseDN), scope, filterValue, sortOrder, maxBlock); getInfo().registerModifiedIndex(modifiedIndex); state = State.FINISHED_SUCCESSFULLY; } catch (Throwable t) catch (final Throwable t) { lastException = t; state = State.FINISHED_WITH_ERROR; } } /** {@inheritDoc} */ @Override public void postOperation() { if ((lastException == null) && (state == State.FINISHED_SUCCESSFULLY)) if (lastException == null && state == State.FINISHED_SUCCESSFULLY) { rebuildIndexIfNecessary(modifiedIndex, getProgressDialog()); } } private ArrayList<String> getDSConfigCommandLineArguments() private List<String> getDSConfigCommandLineArguments() { ArrayList<String> args = new ArrayList<String>(); final List<String> args = new ArrayList<String>(); args.add("set-local-db-vlv-index-prop"); args.add("--backend-name"); args.add(backendID); @@ -861,33 +830,33 @@ try { DN b = DN.valueOf(baseDN); final DN b = DN.valueOf(baseDN); if (!indexToModify.getBaseDN().equals(b)) { args.add("--set"); args.add("base-dn:"+baseDN); args.add("base-dn:" + baseDN); } } catch (OpenDsException odse) catch (final OpenDsException odse) { throw new RuntimeException("Unexpected error parsing DN "+ getBaseDN()+": "+odse, odse); throw new RuntimeException("Unexpected error parsing DN " + getBaseDN() + ": " + odse, odse); } if (indexToModify.getScope() != scope) { args.add("--set"); args.add("scope:"+scope); args.add("scope:" + scope); } if (!indexToModify.getFilter().equals(filterValue)) { args.add("--set"); args.add("filter:"+filterValue); args.add("filter:" + filterValue); } if (!indexToModify.getSortOrder().equals(sortOrder)) { args.add("--set"); args.add("sort-order:"+sortOrderStringValue); args.add("sort-order:" + sortOrderStringValue); } args.addAll(getConnectionCommandLineArguments());