Search in sources :

Example 1 with ZipSource

use of org.apache.atlas.repository.impexp.ZipSource in project incubator-atlas by apache.

the class AdminResource method importData.

@POST
@Path("/import")
@Produces(Servlets.JSON_MEDIA_TYPE)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public AtlasImportResult importData(@FormDataParam("request") String jsonData, @FormDataParam("data") InputStream inputStream) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AdminResource.importData(jsonData={}, inputStream={})", jsonData, (inputStream != null));
    }
    acquireExportImportLock("import");
    AtlasImportResult result;
    try {
        AtlasImportRequest request = AtlasType.fromJson(jsonData, AtlasImportRequest.class);
        ImportService importService = new ImportService(this.typesDefStore, this.entityStore, this.typeRegistry);
        ZipSource zipSource = new ZipSource(inputStream);
        result = importService.run(zipSource, request, Servlets.getUserName(httpServletRequest), Servlets.getHostName(httpServletRequest), AtlasAuthorizationUtils.getRequestIpAddress(httpServletRequest));
    } catch (Exception excp) {
        LOG.error("importData(binary) failed", excp);
        throw new AtlasBaseException(excp);
    } finally {
        releaseExportImportLock();
        if (LOG.isDebugEnabled()) {
            LOG.debug("<== AdminResource.importData(binary)");
        }
    }
    return result;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) ImportService(org.apache.atlas.repository.impexp.ImportService) ZipSource(org.apache.atlas.repository.impexp.ZipSource) AtlasImportResult(org.apache.atlas.model.impexp.AtlasImportResult) AtlasImportRequest(org.apache.atlas.model.impexp.AtlasImportRequest) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) WebApplicationException(javax.ws.rs.WebApplicationException) ConfigurationException(org.apache.commons.configuration.ConfigurationException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes)

Aggregations

IOException (java.io.IOException)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)1 AtlasImportRequest (org.apache.atlas.model.impexp.AtlasImportRequest)1 AtlasImportResult (org.apache.atlas.model.impexp.AtlasImportResult)1 ImportService (org.apache.atlas.repository.impexp.ImportService)1 ZipSource (org.apache.atlas.repository.impexp.ZipSource)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 JSONException (org.codehaus.jettison.json.JSONException)1