use of password.pwm.http.PwmResponse in project pwm by pwm-project.
the class ConfigManagerLocalDBServlet method doExportLocalDB.
private void doExportLocalDB(final PwmRequest pwmRequest) throws IOException, ServletException, PwmUnrecoverableException {
final PwmResponse resp = pwmRequest.getPwmResponse();
final Instant startTime = Instant.now();
resp.setHeader(HttpHeader.ContentDisposition, "attachment;filename=" + PwmConstants.PWM_APP_NAME + "-LocalDB.bak");
resp.setContentType(HttpContentType.octetstream);
resp.setHeader(HttpHeader.ContentTransferEncoding, "binary");
final LocalDBUtility localDBUtility = new LocalDBUtility(pwmRequest.getPwmApplication().getLocalDB());
try {
final int bufferSize = Integer.parseInt(pwmRequest.getConfig().readAppProperty(AppProperty.HTTP_DOWNLOAD_BUFFER_SIZE));
final OutputStream bos = new BufferedOutputStream(resp.getOutputStream(), bufferSize);
localDBUtility.exportLocalDB(bos, LOGGER.asAppendable(PwmLogLevel.DEBUG, pwmRequest.getSessionLabel()), true);
LOGGER.debug(pwmRequest, "completed localDBExport process in " + TimeDuration.fromCurrent(startTime).asCompactString());
} catch (Exception e) {
LOGGER.error(pwmRequest, "error downloading export localdb: " + e.getMessage());
}
}
Aggregations