NewIndexPanel.java revision 866cc640d33ce92abbd907d35d4c1b62f2328959
/*
* 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 2014-2015 ForgeRock AS
*/
/**
* Panel that appears when the user defines a new index.
*/
public class NewIndexPanel extends AbstractIndexPanel
{
private static final long serialVersionUID = -3516011638125862137L;
private Component relativeComponent;
private IndexDescriptor newIndex;
/**
* 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.
*/
{
super();
this.relativeComponent = relativeComponent;
createLayout();
}
/** {@inheritDoc} */
public LocalizableMessage getTitle()
{
return INFO_CTRL_PANEL_NEW_INDEX_TITLE.get();
}
/** {@inheritDoc} */
public Component getPreferredFocusComponent()
{
return attributes;
}
/**
* Updates the contents of the panel with the provided backend.
* @param backend the backend where the index will be created.
*/
{
}
/** {@inheritDoc} */
{
final boolean[] repack = {false};
final boolean[] error = {false};
if (s != null)
{
schema = s;
// Check that the index does not exist
{
{
backend = b;
break;
}
}
{
boolean defined = false;
{
{
{
defined = true;
break;
}
}
}
if (!defined)
{
{
}
{
}
else
{
}
}
}
{
{
}
}
{
{
}
}
// 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));
}
}
*/
}
else
{
repack[0] = true;
error[0] = true;
}
{
public void run()
{
if (repack[0])
{
if (relativeComponent != null)
{
}
}
}
});
if (!error[0])
{
}
}
/** {@inheritDoc} */
public void okClicked()
{
{
}
try
{
if ((n < MIN_ENTRY_LIMIT) || (n > MAX_ENTRY_LIMIT))
{
}
}
catch (Throwable t)
{
}
boolean somethingSelected = false;
{
if (somethingSelected)
{
break;
}
}
if (!somethingSelected)
{
}
getInfo());
{
}
{
null,
dlg);
dlg.setVisible(true);
}
else
{
}
}
private String getAttributeName()
{
}
/**
* Creates the layout of the panel (but the contents are not populated here).
*/
private void createLayout()
{
createBasicLayout(this, gbc, false);
{
{
String n = getAttributeName();
if (n != null)
{
}
}
});
}
/**
* The task in charge of creating the index.
*
*/
protected class NewIndexTask extends Task
{
private String attributeName;
private int entryLimitValue;
/**
* The constructor of the task.
* @param info the control panel info.
* @param dlg the progress dialog that shows the progress of the task.
*/
{
indexTypes = getTypes();
}
/** {@inheritDoc} */
{
}
/** {@inheritDoc} */
{
return backendSet;
}
/** {@inheritDoc} */
public LocalizableMessage getTaskDescription()
{
}
/** {@inheritDoc} */
{
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;
}
private void updateConfiguration() throws OpenDsException
{
boolean configHandlerUpdated = false;
try
{
if (!isServerRunning())
{
configHandlerUpdated = true;
getInfo().stopPooling();
if (getInfo().mustDeregisterConfig())
{
}
getInfo().setMustDeregisterConfig(true);
}
else
{
{
/** {@inheritDoc} */
public void run()
{
}
});
}
{
/** {@inheritDoc} */
public void run()
{
}
});
if (isServerRunning())
{
// Create additional indexes and display the equivalent command.
// Everything is done in the method createAdditionalIndexes
}
else
{
createIndex();
}
{
/** {@inheritDoc} */
public void run()
{
}
});
}
finally
{
if (configHandlerUpdated)
{
getInfo().startPooling();
}
}
}
/**
* Returns the LDIF representation of the index to be created.
* @return the LDIF representation of the index to be created.
*/
private String getIndexLDIF()
{
",cn=Index,"+dn);
{
}
{
}
}
private void createIndex() throws OpenDsException
{
try
{
{
}
}
catch (IOException ioe)
{
throw new OfflineUpdateException(
}
finally
{
if (ldifImportConfig != null)
{
}
}
}
{
// Instead of adding indexes using management framework, use this approach
// so that we have to define the additional indexes only in the method
// getBackendLdif.
try
{
{
}
{
{
}
}
{
}
}
catch (Throwable t)
{
throw new OnlineUpdateException(
}
finally
{
if (ldifImportConfig != null)
{
}
}
}
/** {@inheritDoc} */
protected String getCommandLinePath()
{
return null;
}
/** {@inheritDoc} */
{
}
private String getConfigCommandLineName()
{
if (isServerRunning())
{
return getCommandLinePath("dsconfig");
}
else
{
return null;
}
}
/** {@inheritDoc} */
public void runTask()
{
try
{
for (BackendDescriptor backend :
{
{
break;
}
}
}
catch (Throwable t)
{
lastException = t;
}
}
/** {@inheritDoc} */
public void postOperation()
{
{
}
}
{
{
}
return args;
}
}
}