use of org.apache.atlas.repository.impexp.ZipSink in project incubator-atlas by apache.
the class AdminResource method export.
@POST
@Path("/export")
@Consumes(Servlets.JSON_MEDIA_TYPE)
public Response export(AtlasExportRequest request) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AdminResource.export()");
}
acquireExportImportLock("export");
ZipSink exportSink = null;
try {
exportSink = new ZipSink(httpServletResponse.getOutputStream());
AtlasExportResult result = exportService.run(exportSink, request, Servlets.getUserName(httpServletRequest), Servlets.getHostName(httpServletRequest), AtlasAuthorizationUtils.getRequestIpAddress(httpServletRequest));
exportSink.close();
httpServletResponse.addHeader("Content-Encoding", "gzip");
httpServletResponse.setContentType("application/zip");
httpServletResponse.setHeader("Content-Disposition", "attachment; filename=" + result.getClass().getSimpleName());
httpServletResponse.setHeader("Transfer-Encoding", "chunked");
httpServletResponse.getOutputStream().flush();
return Response.ok().build();
} catch (IOException excp) {
LOG.error("export() failed", excp);
throw new AtlasBaseException(excp);
} finally {
releaseExportImportLock();
if (exportSink != null) {
exportSink.close();
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AdminResource.export()");
}
}
}
Aggregations