@Override public InputStream downloadFile(String fileId) throws FileNotFoundException { try { return schemaRegistry.downloadFile(fileId); } catch (IOException e) { throw new RuntimeException(e); } }
@GET @Produces({"application/octet-stream", "application/json"}) @Path("/files/download/{fileId}") @ApiOperation(value = "Downloads the respective for the given fileId if it exists", response = StreamingOutput.class, tags = OPERATION_GROUP_OTHER) @Timed public Response downloadFile(@ApiParam(value = "Identifier of the file to be downloaded", required = true) @PathParam("fileId") String fileId) { Response response; try { StreamingOutput streamOutput = WSUtils.wrapWithStreamingOutput(schemaRegistry.downloadFile(fileId)); response = Response.ok(streamOutput).build(); return response; } catch (FileNotFoundException e) { LOG.error("No file found for fileId [{}]", fileId, e); response = WSUtils.respondEntity(fileId, Response.Status.NOT_FOUND); } catch (Exception ex) { LOG.error("Encountered error while downloading file [{}]", fileId, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@GET @Produces({"application/octet-stream", "application/json"}) @Path("/files/download/{fileId}") @ApiOperation(value = "Downloads the respective for the given fileId if it exists", response = StreamingOutput.class, tags = OPERATION_GROUP_OTHER) @Timed public Response downloadFile(@ApiParam(value = "Identifier of the file to be downloaded", required = true) @PathParam("fileId") String fileId) { Response response; try { StreamingOutput streamOutput = WSUtils.wrapWithStreamingOutput(schemaRegistry.downloadFile(fileId)); response = Response.ok(streamOutput).build(); return response; } catch (FileNotFoundException e) { LOG.error("No file found for fileId [{}]", fileId, e); response = WSUtils.respondEntity(fileId, Response.Status.NOT_FOUND); } catch (Exception ex) { LOG.error("Encountered error while downloading file [{}]", fileId, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }