DeleteIndexTask.java revision 55c9e7bd9ea802475e0d4fdaad7caa22f1671dda
/*
* 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
*/
/**
* The task that is launched when an index must be deleted.
*/
public class DeleteIndexTask extends Task
{
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.
*/
public DeleteIndexTask(ControlPanelInfo info, ProgressDialog dlg, List<AbstractIndexDescriptor> indexesToDelete)
{
{
}
}
{
return Type.DELETE_INDEX;
}
{
return backendSet;
}
public LocalizableMessage getTaskDescription()
{
{
return INFO_CTRL_PANEL_DELETE_INDEX_TASK_DESCRIPTION.get(getStringFromCollection(backendSet, ", "));
}
else
{
return INFO_CTRL_PANEL_DELETE_INDEX_IN_BACKENDS_TASK_DESCRIPTION.get(getStringFromCollection(backendSet, ", "));
}
}
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;
}
/**
* Update the configuration in the server.
*
* @throws OpenDsException
* if an error occurs.
*/
private void updateConfiguration() throws OpenDsException
{
boolean configHandlerUpdated = false;
int numberDeleted = 0;
try
{
if (!isServerRunning())
{
configHandlerUpdated = true;
getInfo().stopPooling();
if (getInfo().mustDeregisterConfig())
{
}
getInfo().setMustDeregisterConfig(true);
}
boolean isFirst = true;
{
if (!isFirst)
{
{
public void run()
{
}
});
}
isFirst = false;
if (isServerRunning())
{
{
public void run()
{
final List<String> args = getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments(index));
}
});
}
{
public void run()
{
if (isVLVIndex(index))
{
}
else
{
}
}
});
if (isServerRunning())
{
}
else
{
}
final int fNumberDeleted = numberDeleted;
{
public void run()
{
getProgressDialog().appendProgressHtml(Utilities.getProgressDone(ColorAndFontConstants.progressFont));
}
});
}
}
finally
{
if (configHandlerUpdated)
{
DirectoryServer.getInstance().initializeConfiguration(ConfigReader.configClassName, ConfigReader.configFile);
getInfo().startPooling();
}
}
}
/**
* Returns <CODE>true</CODE> if the index is a VLV index and
* <CODE>false</CODE> otherwise.
*
* @param index
* the index.
* @return <CODE>true</CODE> if the index is a VLV index and
* <CODE>false</CODE> otherwise.
*/
{
return index instanceof VLVIndexDescriptor;
}
/**
* 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.
*/
{
final String backendId = Utilities.getRDNString("ds-cfg-backend-id", index.getBackend().getBackendID());
if (isVLVIndex(index))
{
dn = getRDNString("ds-cfg-name", index.getName()) + ",cn=VLV Index," + backendId + ",cn=Backends,cn=config";
}
else
{
dn = getRDNString("ds-cfg-attribute", index.getName()) + ",cn=Index," + backendId + ",cn=Backends,cn=config";
}
}
/**
* 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
{
final ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(ctx));
final LocalDBBackendCfgClient backend =
if (isVLVIndex(index))
{
}
else
{
}
}
protected String getCommandLinePath()
{
return null;
}
{
}
/**
* Returns the path of the command line to be used to delete the specified
* index.
*
* @param index
* the index to be deleted.
* @return the path of the command line to be used to delete the specified
* index.
*/
{
if (isServerRunning())
{
return getCommandLinePath("dsconfig");
}
else
{
return null;
}
}
public void runTask()
{
try
{
}
catch (final Throwable t)
{
lastException = t;
}
finally
{
{
}
}
}
/**
* Return the dsconfig arguments required to delete an index.
*
* @param index
* the index to be deleted.
* @return the dsconfig arguments required to delete an index.
*/
{
if (isVLVIndex(index))
{
}
else
{
}
return args;
}
}