This is an automated email from the ASF dual-hosted git repository.

nitiraj pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 629e79d  AMBARI-23294: Ambari files view throws 500 ERROR while trying 
to upload/download to/from HDFS encrypted zone (nitirajrathore) (#715)
629e79d is described below

commit 629e79d72594d3fb46a9667955e6d0d85facf210
Author: nitirajrathore <nitiraj.rath...@gmail.com>
AuthorDate: Mon Apr 16 20:52:38 2018 +0530

    AMBARI-23294: Ambari files view throws 500 ERROR while trying to 
upload/download to/from HDFS encrypted zone (nitirajrathore) (#715)
    
    * AMBARI-22833 : change commons-collections-3.2.1.jar being used by ambari 
views to commons-collections-3.2.2.jar (nitirajrathore)
    
    * AMBARI-23294: Ambari files view throws 500 ERROR while trying to 
upload/download to/from HDFS encrypted zone (nitirajrathore)
---
 .../main/resources/ui/app/adapters/application.js  | 23 +++++++++++++++++++---
 .../main/resources/ui/app/services/file-preview.js |  5 ++++-
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git 
a/contrib/views/files/src/main/resources/ui/app/adapters/application.js 
b/contrib/views/files/src/main/resources/ui/app/adapters/application.js
index 059d379..cc46922 100644
--- a/contrib/views/files/src/main/resources/ui/app/adapters/application.js
+++ b/contrib/views/files/src/main/resources/ui/app/adapters/application.js
@@ -18,6 +18,7 @@
 
 import DS from 'ember-data';
 import Ember from 'ember';
+import ENV from 'files-view/config/environment';
 
 export default DS.RESTAdapter.extend({
   init: function () {
@@ -38,10 +39,26 @@ export default DS.RESTAdapter.extend({
       instance = parts[parts.length - 2];
       version = '';
     }
+
+    if (ENV.environment === 'development') {
+      return '/resources/files/fileops';
+    }
+
     return 'api/v1/views/' + view + version + '/instances/' + instance + 
'/resources/files/fileops';
   }),
 
-  headers: {
-    'X-Requested-By': 'ambari'
-  }
+ headers: Ember.computed(function () {
+    let headers = {
+      'X-Requested-By': 'ambari',
+      'Content-Type': 'application/json'
+    };
+
+    if (ENV.environment === 'development') {
+      // In development mode when the UI is served using ember serve the xhr 
requests are proxied to ambari server
+      // by setting the proxyurl parameter in ember serve and for ambari to 
authenticate the requests, it needs this
+      // basic authorization. This is for default admin/admin 
username/password combination.
+      headers['Authorization'] = 'Basic YWRtaW46YWRtaW4=';
+    }
+    return headers;
+  })
 });
diff --git 
a/contrib/views/files/src/main/resources/ui/app/services/file-preview.js 
b/contrib/views/files/src/main/resources/ui/app/services/file-preview.js
index e4484c2..ea5bf6f 100644
--- a/contrib/views/files/src/main/resources/ui/app/services/file-preview.js
+++ b/contrib/views/files/src/main/resources/ui/app/services/file-preview.js
@@ -21,6 +21,7 @@ import FileOperationMixin from '../mixins/file-operation';
 
 export default Ember.Service.extend(FileOperationMixin, {
   fileSelectionService: Ember.inject.service('files-selection'),
+  logger: Ember.inject.service('alert-messages'),
   selectedFiles: Ember.computed.alias('fileSelectionService.files'),
   selected: Ember.computed('selectedFiles', function () {
     return this.get('selectedFiles').objectAt(0);
@@ -83,7 +84,9 @@ export default Ember.Service.extend(FileOperationMixin, {
           return resolve(response);
         }, (responseError) => {
           _self.set('isLoading', false);
-          return reject(error);
+          var error = this.extractError(responseError);
+          this.get('logger').danger("Failed to preview file.", error);
+          return reject(responseError);
         });
     });
   },

-- 
To stop receiving notification emails like this one, please contact
niti...@apache.org.

Reply via email to