Repository: ambari Updated Branches: refs/heads/branch-2.5 d8f815c26 -> 397c3a77e
AMBARI-20962 : hive view 1.5 and 2.0 made fileName as path param instead of query param. Now downloaded file preserves unicode characters (nitirajrathore) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/397c3a77 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/397c3a77 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/397c3a77 Branch: refs/heads/branch-2.5 Commit: 397c3a77e14648bb1967c72769f7c736b36b1508 Parents: d8f815c Author: Nitiraj Singh Rathore <nitiraj.rath...@gmail.com> Authored: Tue May 9 17:30:47 2017 +0530 Committer: Nitiraj Singh Rathore <nitiraj.rath...@gmail.com> Committed: Tue May 9 17:30:47 2017 +0530 ---------------------------------------------------------------------- .../view/hive2/resources/jobs/JobService.java | 9 ++------- .../resources/ui/hive-web/app/controllers/index.js | 2 +- .../view/hive20/resources/jobs/JobService.java | 16 +++++----------- .../src/main/resources/ui/app/adapters/job.js | 2 +- 4 files changed, 9 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/397c3a77/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/JobService.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/JobService.java b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/JobService.java index 5fa96bb..80f4e24 100644 --- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/JobService.java +++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/JobService.java @@ -176,11 +176,11 @@ public class JobService extends BaseService { * Get job results in csv format */ @GET - @Path("{jobId}/results/csv") + @Path("{jobId}/results/csv/{fileName}") @Produces("text/csv") public Response getResultsCSV(@PathParam("jobId") String jobId, @Context HttpServletResponse response, - @QueryParam("fileName") String fileName, + @PathParam("fileName") String fileName, @QueryParam("columns") final String requestedColumns) { try { @@ -223,12 +223,7 @@ public class JobService extends BaseService { } }; - if (fileName == null || fileName.isEmpty()) { - fileName = "results.csv"; - } - return Response.ok(stream). - header("Content-Disposition", String.format("attachment; filename=\"%s\"", fileName)). build(); http://git-wip-us.apache.org/repos/asf/ambari/blob/397c3a77/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index.js index 8250dbb..5644feb 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index.js @@ -586,7 +586,7 @@ export default Ember.Controller.extend({ defer.promise.then(function (text) { // download file ... - var urlString = "%@/?fileName=%@.csv"; + var urlString = "%@/%@.csv"; var url = self.get('csvUrl'); url = urlString.fmt(url, text); window.open(url); http://git-wip-us.apache.org/repos/asf/ambari/blob/397c3a77/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/jobs/JobService.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/jobs/JobService.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/jobs/JobService.java index f2e4ee9..d99938f 100644 --- a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/jobs/JobService.java +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/jobs/JobService.java @@ -181,11 +181,11 @@ public class JobService extends BaseService { * Get job results in csv format */ @GET - @Path("{jobId}/results/csv") + @Path("{jobId}/results/csv/{fileName}") @Produces("text/csv") public Response getResultsCSV(@PathParam("jobId") String jobId, @Context HttpServletResponse response, - @QueryParam("fileName") String fileName, + @PathParam("fileName") String fileName, @QueryParam("columns") final String requestedColumns) { try { @@ -228,18 +228,12 @@ public class JobService extends BaseService { } }; - if (fileName == null || fileName.isEmpty()) { - fileName = "results.csv"; - } - - return Response.ok(stream). - header("Content-Disposition", String.format("attachment; filename=\"%s\"", fileName)). - build(); - - + return Response.ok(stream).build(); } catch (WebApplicationException ex) { + LOG.error("Error occurred while downloading result with fileName : {}", fileName ,ex); throw ex; } catch (Throwable ex) { + LOG.error("Error occurred while downloading result with fileName : {}", fileName ,ex); throw new ServiceFormattedException(ex.getMessage(), ex); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/397c3a77/contrib/views/hive20/src/main/resources/ui/app/adapters/job.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/adapters/job.js b/contrib/views/hive20/src/main/resources/ui/app/adapters/job.js index e40c0ba..8491cf2 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/adapters/job.js +++ b/contrib/views/hive20/src/main/resources/ui/app/adapters/job.js @@ -73,7 +73,7 @@ export default ApplicationAdapter.extend({ }, downloadAsCsv(jobId, path){ - let resultUrl = this.urlForFindRecord(jobId, 'job') + "/results/csv/?fileName=" + path + ".csv"; + let resultUrl = this.urlForFindRecord(jobId, 'job') + "/results/csv/" + path + ".csv"; return resultUrl; }