| | |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | import javax.swing.event.DocumentListener; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.datamodel.IndexDescriptor; |
| | |
| | | import org.opends.server.admin.client.ldap.LDAPManagementContext; |
| | | import org.opends.server.admin.std.client.BackendCfgClient; |
| | | import org.opends.server.admin.std.client.BackendIndexCfgClient; |
| | | import org.opends.server.admin.std.client.LocalDBBackendCfgClient; |
| | | import org.opends.server.admin.std.client.LocalDBIndexCfgClient; |
| | | import org.opends.server.admin.std.client.PluggableBackendCfgClient; |
| | | import org.opends.server.backends.jeb.RemoveOnceLocalDBBackendIsPluggable; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | |
| | | public class IndexPanel extends AbstractIndexPanel |
| | | { |
| | | private static final long serialVersionUID = 1439500626486823366L; |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | private IndexDescriptor index; |
| | | private ScrollPaneBorderListener scrollListener; |
| | |
| | | |
| | | private ModifyIndexTask newModifyTask; |
| | | |
| | | /** |
| | | * Default constructor. |
| | | */ |
| | | /** Default constructor. */ |
| | | public IndexPanel() |
| | | { |
| | | super(); |
| | |
| | | buttonPanel.add(deleteIndex, gbc); |
| | | deleteIndex.addActionListener(new ActionListener() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | deleteIndex(); |
| | |
| | | buttonPanel.add(saveChanges, gbc); |
| | | saveChanges.addActionListener(new ActionListener() |
| | | { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | saveIndex(false); |
| | |
| | | |
| | | entryLimit.getDocument().addDocumentListener(new DocumentListener() |
| | | { |
| | | @Override |
| | | public void insertUpdate(DocumentEvent ev) |
| | | { |
| | | checkSaveButton(); |
| | | } |
| | | |
| | | @Override |
| | | public void changedUpdate(DocumentEvent ev) |
| | | { |
| | | checkSaveButton(); |
| | | } |
| | | |
| | | @Override |
| | | public void removeUpdate(DocumentEvent ev) |
| | | { |
| | | checkSaveButton(); |
| | |
| | | |
| | | ActionListener listener = new ActionListener() |
| | | { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | checkSaveButton(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage getTitle() |
| | | { |
| | | return INFO_CTRL_PANEL_INDEX_PANEL_TITLE.get(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return entryLimit; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | final ServerDescriptor desc = ev.getNewDescriptor(); |
| | |
| | | INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname())); |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | checkSaveButton(); |
| | |
| | | }); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void okClicked() |
| | | { |
| | | } |
| | |
| | | |
| | | JComponent[] comps = {entryLimit, lType, typesPanel, lEntryLimit}; |
| | | |
| | | for (int i = 0; i < comps.length; i++) |
| | | for (JComponent comp : comps) |
| | | { |
| | | comps[i].setVisible(!index.isDatabaseIndex()); |
| | | comp.setVisible(!index.isDatabaseIndex()); |
| | | } |
| | | |
| | | AttributeType attr = index.getAttributeType(); |
| | |
| | | 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_INDEX_TASK_DESCRIPTION.get(attributeName, |
| | | backendName); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean canLaunch(Task taskToBeLaunched, Collection<LocalizableMessage> incompatibilityReasons) |
| | | { |
| | | boolean canLaunch = true; |
| | |
| | | { |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | |
| | | |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | getProgressDialog().appendProgressHtml( |
| | |
| | | |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | getProgressDialog().appendProgressHtml( |
| | |
| | | { |
| | | final ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(ctx)); |
| | | final BackendCfgClient backend = mCtx.getRootConfiguration().getBackend(backendName); |
| | | if (backend instanceof LocalDBBackendCfgClient) |
| | | { |
| | | modifyLocalDBIndexOnline((LocalDBBackendCfgClient) backend); |
| | | return; |
| | | } |
| | | modifyBackendIndexOnline((PluggableBackendCfgClient) backend); |
| | | } |
| | | |
| | |
| | | index.commit(); |
| | | } |
| | | |
| | | @RemoveOnceLocalDBBackendIsPluggable |
| | | private void modifyLocalDBIndexOnline(final LocalDBBackendCfgClient backend) throws OpenDsException |
| | | { |
| | | final LocalDBIndexCfgClient index = backend.getLocalDBIndex(attributeName); |
| | | if (!indexTypes.equals(indexToModify.getTypes())) |
| | | { |
| | | index.setIndexType(IndexTypeDescriptor.toLocalDBIndexTypes(indexTypes)); |
| | | } |
| | | |
| | | if (entryLimitValue != index.getIndexEntryLimit()) |
| | | { |
| | | index.setIndexEntryLimit(entryLimitValue); |
| | | } |
| | | index.commit(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected String getCommandLinePath() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected ArrayList<String> getCommandLineArguments() |
| | | { |
| | | return new ArrayList<>(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void runTask() |
| | | { |
| | | state = State.RUNNING; |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void postOperation() |
| | | { |
| | | if (lastException == null && state == State.FINISHED_SUCCESSFULLY) |
| | |
| | | private List<String> getDSConfigCommandLineArguments() |
| | | { |
| | | List<String> args = new ArrayList<>(); |
| | | args.add("set-local-db-index-prop"); |
| | | args.add("set-backend-index-prop"); |
| | | args.add("--backend-name"); |
| | | args.add(backendName); |
| | | |
| | |
| | | for (IndexTypeDescriptor newType : toAdd) |
| | | { |
| | | args.add("--add"); |
| | | args.add("index-type:" + newType.toLocalDBIndexType()); |
| | | args.add("index-type:" + newType.toBackendIndexType()); |
| | | } |
| | | } |
| | | if (entryLimitValue != indexToModify.getEntryLimit()) |