tempFile.getAbsolutePath(),
currentConfig.dn().toString(),
stackTraceToSingleLineString(e));
DirectoryServer.sendAlertNotification(this,
ALERT_TYPE_LDIF_BACKEND_CANNOT_WRITE_UPDATE, m);
throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
m, e);
}
for (Entry entry : entryMap.values())
{
try
{
writer.writeEntry(entry);
}
catch (Exception e)
{
if (debugEnabled())
{
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
try
{
writer.close();
} catch (Exception e2) {}
Message m = ERR_LDIF_BACKEND_ERROR_WRITING_FILE.get(
tempFile.getAbsolutePath(),
currentConfig.dn().toString(),
stackTraceToSingleLineString(e));
DirectoryServer.sendAlertNotification(this,
ALERT_TYPE_LDIF_BACKEND_CANNOT_WRITE_UPDATE, m);
throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
m, e);
}
}
try
{
writer.close();
} catch (Exception e) {}
// Rename the existing "live" file out of the way and move the new file
// into place.
try
{
if (oldFile.exists())
{
oldFile.delete();
}
} catch (Exception e) {}
try
{
if (ldifFile.exists())
{
ldifFile.renameTo(oldFile);
}
}
catch (Exception e)
{
if (debugEnabled())
{
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
}
try
{
tempFile.renameTo(ldifFile);
}
catch (Exception e)
{
if (debugEnabled())
{
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
Message m = ERR_LDIF_BACKEND_ERROR_RENAMING_FILE.get(
tempFile.getAbsolutePath(),
ldifFile.getAbsolutePath(),
currentConfig.dn().toString(),
stackTraceToSingleLineString(e));
DirectoryServer.sendAlertNotification(this,
ALERT_TYPE_LDIF_BACKEND_CANNOT_WRITE_UPDATE, m);
throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
m, e);
}
}