use of org.apache.atlas.model.impexp.AtlasExportResult in project 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()");
}
AtlasAuthorizationUtils.verifyAccess(new AtlasAdminAccessRequest(AtlasPrivilege.ADMIN_EXPORT), "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()");
}
}
}
use of org.apache.atlas.model.impexp.AtlasExportResult in project atlas by apache.
the class ZipSinkTest method getDefaultExportResult.
private AtlasExportResult getDefaultExportResult() {
AtlasExportRequest request = new AtlasExportRequest();
List<AtlasObjectId> itemsToExport = new ArrayList<>();
itemsToExport.add(new AtlasObjectId("hive_db", "qualifiedName", "default"));
request.setItemsToExport(itemsToExport);
defaultExportResult = new AtlasExportResult(request, "admin", "1.0.0.0", "root", 100);
return defaultExportResult;
}
use of org.apache.atlas.model.impexp.AtlasExportResult in project atlas by apache.
the class ExportServiceTest method requestingEntityNotFound_NoData.
@Test
public void requestingEntityNotFound_NoData() throws AtlasBaseException, IOException {
String requestingIP = "1.0.0.0";
String hostName = "root";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipSink zipSink = new ZipSink(baos);
AtlasExportResult result = exportService.run(zipSink, getRequestForFullFetch(), "admin", hostName, requestingIP);
Assert.assertNull(result.getData());
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ZipSource zipSource = new ZipSource(bais);
assertNotNull(exportService);
assertNotNull(zipSource.getCreationOrder());
Assert.assertFalse(zipSource.hasNext());
}
use of org.apache.atlas.model.impexp.AtlasExportResult in project incubator-atlas by apache.
the class ZipSinkTest method getDefaultExportResult.
private AtlasExportResult getDefaultExportResult() {
AtlasExportRequest request = new AtlasExportRequest();
List<AtlasObjectId> itemsToExport = new ArrayList<>();
itemsToExport.add(new AtlasObjectId("hive_db", "qualifiedName", "default"));
request.setItemsToExport(itemsToExport);
defaultExportResult = new AtlasExportResult(request, "admin", "1.0.0.0", "root", 100);
return defaultExportResult;
}
use of org.apache.atlas.model.impexp.AtlasExportResult in project incubator-atlas by apache.
the class ExportServiceTest method exportType_Succeeds.
@Test
public void exportType_Succeeds() throws AtlasBaseException, FileNotFoundException {
String requestingIP = "1.0.0.0";
String hostName = "root";
AtlasExportRequest request = getRequestForFullFetch();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipSink zipSink = new ZipSink(baos);
AtlasExportResult result = exportService.run(zipSink, request, "admin", hostName, requestingIP);
assertNotNull(exportService);
assertEquals(result.getHostName(), hostName);
assertEquals(result.getClientIpAddress(), requestingIP);
assertEquals(request, result.getRequest());
}
Aggregations