VLVIndexPanel.java revision 334fa0a1bbf2e529f296842cbee5b24f9ff70f31
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* 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 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 ScrollPaneBorderListener scrollListener;
private ModifyVLVIndexTask newModifyTask;
private boolean ignoreCheckSave;
private VLVIndexDescriptor index;
/** Default constructor. */
public VLVIndexPanel()
{
createLayout();
}
public LocalizableMessage getTitle()
{
return INFO_CTRL_PANEL_VLV_INDEX_PANEL_TITLE.get();
}
public Component getPreferredFocusComponent()
{
return baseDN;
}
{
if (updateLayout(desc))
{
LocalizableMessage msg = isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_VLV_INDEX_EDITING.get()
{
public void run()
{
}
});
}
}
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.
*
* @return <CODE>true</CODE> if there are unsaved changes (and so the
* selection of the index should be canceled) and <CODE>false</CODE>
* otherwise.
*/
public boolean mustCheckUnsavedChanges()
{
}
/**
* 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.
*/
{
final UnsavedChangesDialog unsavedChangesDlg = new UnsavedChangesDialog(getParentDialog(this), getInfo());
unsavedChangesDlg.setVisible(true);
{
saveIndex(false);
if (newModifyTask == null
{
}
}
return result;
}
private void checkSaveButton()
{
{
}
}
/** {@inheritDoc} */
{
}
/**
* Creates the layout of the panel (but the contents are not populated here).
*/
private void createLayout()
{
p.setOpaque(false);
super.createBasicLayout(p, gbc, true);
gbc = new GridBagConstraints();
buttonPanel.setOpaque(false);
deleteIndex.setOpaque(false);
{
{
deleteIndex();
}
});
saveChanges.setOpaque(false);
{
{
saveIndex(false);
}
});
{
{
}
{
}
{
}
};
{
{
}
};
{
public void contentsChanged(ListDataEvent e)
{
}
public void intervalAdded(ListDataEvent e)
{
}
public void intervalRemoved(ListDataEvent e)
{
}
});
}
private void deleteIndex()
{
{
}
{
{
dlg.setVisible(true);
}
}
else
{
}
}
{
if (!isModified())
{
return;
}
{
final ProgressDialog dlg =
new ProgressDialog(getFrame(this), getFrame(this), INFO_CTRL_PANEL_MODIFYING_INDEX_TITLE.get(), getInfo());
{
}
{
saveChanges.setEnabled(false);
dlg.setVisible(true);
}
}
{
}
}
/**
* Updates the contents of the panel with the provided VLV index.
*
* @param index
* the VLV index descriptor to be used to update the panel.
*/
{
ignoreCheckSave = true;
{
}
{
}
else
{
}
// Simulate a remove to update the attribute combo box and add them again.
{
indexes[i] = i;
}
// The list is now empty and the attribute combo properly updated.
{
{
if (o.getType() == CategorizedComboBoxElement.Type.REGULAR && o.getValue().equals(s.getAttributeName()))
{
model.removeElementAt(i);
break;
}
}
}
{
}
{
{
warning.setVisible(true);
}
else
{
warning.setVisible(false);
}
}
ignoreCheckSave = false;
}
{
switch (indexScope.asEnum())
{
case BASE_OBJECT:
baseObject.setSelected(true);
break;
case SINGLE_LEVEL:
singleLevel.setSelected(true);
break;
case SUBORDINATES:
subordinateSubtree.setSelected(true);
break;
case WHOLE_SUBTREE:
wholeSubtree.setSelected(true);
break;
default:
break;
}
}
private boolean isModified()
{
try
{
|| !index.getFilter().equals(filter.getText().trim()) || !index.getSortOrder().equals(getSortOrder())
}
catch (final OpenDsException odse)
{
// The base DN is not valid. This means that the index has been modified.
return true;
}
}
/**
* The task in charge of modifying the VLV index.
*/
protected class ModifyVLVIndexTask extends Task
{
private final String filterValue;
private final SearchScope searchScope;
private final String sortOrderStringValue;
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.
*/
{
sortOrder = getSortOrder();
searchScope = getScope();
}
{
return Type.MODIFY_INDEX;
}
{
return backendSet;
}
public LocalizableMessage getTaskDescription()
{
}
public boolean canLaunch(Task taskToBeLaunched, Collection<LocalizableMessage> incompatibilityReasons)
{
boolean canLaunch = true;
{
// 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.
{
canLaunch = false;
}
}
return canLaunch;
}
{
boolean configHandlerUpdated = false;
try
{
if (!isServerRunning())
{
configHandlerUpdated = true;
getInfo().stopPooling();
if (getInfo().mustDeregisterConfig())
{
}
getInfo().setMustDeregisterConfig(true);
}
else
{
{
public void run()
{
}
});
}
{
public void run()
{
}
});
if (isServerRunning())
{
// Create additional indexes and display the equivalent command.
// Everything is done in the method createAdditionalIndexes
}
else
{
modifyIndex();
}
{
/** {@inheritDoc} */
public void run()
{
getProgressDialog().appendProgressHtml(Utilities.getProgressDone(ColorAndFontConstants.progressFont));
}
});
}
finally
{
if (configHandlerUpdated)
{
DirectoryServer.getInstance().initializeConfiguration(ConfigReader.configClassName, ConfigReader.configFile);
getInfo().startPooling();
}
}
}
{
try
{
}
catch (final IOException ioe)
{
}
finally
{
if (ldifImportConfig != null)
{
}
}
}
/**
* 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.
*/
{
final Collection<String> args = getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments());
{
}
final ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(ctx));
{
}
{
}
{
}
{
}
}
protected String getCommandLinePath()
{
return null;
}
{
}
private String getConfigCommandLineName()
{
if (isServerRunning() && isModified())
{
return getCommandLinePath("dsconfig");
}
return null;
}
public void runTask()
{
try
{
new VLVIndexDescriptor(indexName, indexToModify.getBackend(), DN.valueOf(baseDN), searchScope, filterValue,
}
catch (final Throwable t)
{
lastException = t;
}
}
public void postOperation()
{
{
}
}
{
try
{
{
}
}
catch (final OpenDsException odse)
{
}
{
}
{
}
{
}
return args;
}
}
}