DeleteBaseDNAndBackendTask.java revision 8196da2152209c8c628611aeeb4adae32079921e
/*
* 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 used to delete a set of base DNs or backends. */
public class DeleteBaseDNAndBackendTask extends Task
{
/**
* Constructor of the task.
* @param info the control panel information.
* @param dlg the progress dialog where the task progress will be displayed.
* @param backendsToDelete the backends to delete.
* @param baseDNsToDelete the base DNs to delete.
*/
{
backendSet = new HashSet<>();
{
}
{
}
{
{
}
}
{
{
// All of the suffixes must be deleted.
}
}
{
}
}
{
}
{
return backendSet;
}
public LocalizableMessage getTaskDescription()
{
if (!baseDNsToDelete.isEmpty())
{
{
{
}
}
{
}
else
{
{
}
}
}
if (!backendsToDelete.isEmpty())
{
{
}
{
}
else
{
{
}
}
}
}
{
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.
*/
{
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()
{
}
});
}
{
public void run()
{
{
}
else
{
{
}
}
}
});
if (isServerRunning())
{
}
else
{
}
numberDeleted ++;
final int fNumberDeleted = numberDeleted;
{
public void run()
{
}
});
}
{
if (!isFirst)
{
{
public void run()
{
}
});
}
{
}
isFirst = false;
if (isServerRunning())
{
{
public void run()
{
}
});
}
{
public void run()
{
backend.getBackendID()),
}
});
if (isServerRunning())
{
}
else
{
}
numberDeleted ++;
final int fNumberDeleted = numberDeleted;
{
public void run()
{
}
});
}
}
finally
{
if (configHandlerUpdated)
{
getInfo().startPooling();
}
}
}
/**
* Returns the DN in the configuration for a given backend.
* @param backend the backend.
* @return the backend configuration entry DN.
*/
{
}
/**
* Deletes a set of base DNs. The code assumes that the server is not running
* and that the configuration file can be edited.
* @param baseDNs the list of base DNs.
* @throws OpenDsException if an error occurs.
*/
throws OpenDsException, ConfigException
{
{
}
{
}
",cn=Backends,cn=config";
new DNConfigAttribute(
true, true, false, newBaseDNs);
}
/**
* Deletes a set of base DNs. The code assumes that the server is running
* and that the provided connection is active.
* @param baseDNs the list of base DNs.
* @param ctx the connection to the server.
* @throws OpenDsException if an error occurs.
*/
{
{
}
}
/**
* Deletes a backend. The code assumes that the server is not running
* and that the configuration file can be edited.
* @param backend the backend to be deleted.
* @throws OpenDsException if an error occurs.
*/
{
}
/**
* Deletes a backend. The code assumes that the server is running
* and that the provided connection is active.
* @param backend the backend to be deleted.
* @param ctx the connection to the server.
* @throws OpenDsException if an error occurs.
*/
{
}
protected String getCommandLinePath()
{
return null;
}
{
return new ArrayList<>();
}
/**
* Returns the path of the command line to be used.
*
* @return the path of the command line to be used
*/
private String getConfigCommandLinePath()
{
if (isServerRunning())
{
return getCommandLinePath("dsconfig");
}
return null;
}
public void runTask()
{
try
{
}
catch (Throwable t)
{
lastException = t;
}
}
/**
* Return the dsconfig arguments required to delete a set of base DNs.
* @param baseDNs the base DNs to be deleted.
* @return the dsconfig arguments required to delete a set of base DNs.
*/
{
if (isServerRunning())
{
{
}
}
return args;
}
/**
* Return the dsconfig arguments required to delete a backend.
* @param backend the backend to be deleted.
* @return the dsconfig arguments required to delete a backend.
*/
{
return args;
}
/**
* Disables replication if required: if the deleted base DN is replicated,
* update the replication configuration to remove any reference to it.
* @param baseDN the base DN that is going to be removed.
* @throws OpenDsException if an error occurs.
*/
throws OpenDsException, ConfigException
{
{
try
{
if (isServerRunning())
{
try
{
}
catch (OpenDsException oe)
{
// Ignore this one
}
{
{
{
{
break;
}
}
}
}
}
else
{
try
{
}
catch (ConfigException oe)
{
// Ignore this one
}
{
{
{
{
break;
}
}
}
}
}
}
finally
{
// This is not super clean, but this way we calculate the domain name only once.
{
{
public void run()
{
}
});
}
{
public void run()
{
}
});
}
{
public void run()
{
"<br>");
}
});
}
}
/**
* Return the dsconfig arguments required to delete a replication domain.
* @param domainName the name of the domain to be deleted.
* @return the dsconfig arguments required to delete a replication domain.
*/
{
return args;
}
}