* @throws Exception If an unexpected problem occurs.
*/
public static void clearJEBackend(boolean createBaseEntry, String beID,
String dn) throws Exception
{
BackendImpl backend = (BackendImpl)DirectoryServer.getBackend(beID);
// FIXME Should setBackendEnabled be part of TaskUtils ?
TaskUtils.disableBackend(beID);
try
{
String lockFile = LockFileManager.getBackendLockFileName(backend);
StringBuilder failureReason = new StringBuilder();
if (!LockFileManager.acquireExclusiveLock(lockFile, failureReason))
{
throw new RuntimeException(failureReason.toString());
}
try
{
backend.clearBackend();
}
finally
{
LockFileManager.releaseLock(lockFile, failureReason);
}
}
finally
{
TaskUtils.enableBackend(beID);
}
if (createBaseEntry)
{
DN baseDN = DN.decode(dn);
Entry e = createEntry(baseDN);
backend = (BackendImpl)DirectoryServer.getBackend(beID);
backend.addEntry(e, null);
}
}