NewIndexPanel.java revision c73e8d55f04419c98b9a4d977aafeff39539f0ce
/*
* 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
* 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
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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.
*/
/**
* 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}
*/
{
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()
{
if (o != null)
{
}
else
{
}
return attrName;
}
/**
* 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 Message 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(
ioe);
}
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;
}
}
}