You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2017/05/10 13:37:35 UTC

[12/22] ambari git commit: 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)

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/8dae74cc
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8dae74cc
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8dae74cc

Branch: refs/heads/branch-feature-AMBARI-12556
Commit: 8dae74cc26c8b60d082076e9852f06a399e009c4
Parents: aecc890
Author: Nitiraj Singh Rathore <ni...@gmail.com>
Authored: Tue May 9 17:30:47 2017 +0530
Committer: Nitiraj Singh Rathore <ni...@gmail.com>
Committed: Tue May 9 17:31:36 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/8dae74cc/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/8dae74cc/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/8dae74cc/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/8dae74cc/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;
   }