AMBARI-18810. Hive View shows LDAP login pop-up for all login errors. (Ashwin 
Rajeev via dipayanb)

(cherry picked from commit 1953bdc1d0fb32c9e9d41e37900058ddb4a98ef1)

Change-Id: Ib17565b51e19abf9d969743ee91638612890e59f


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f18f46b4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f18f46b4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f18f46b4

Branch: refs/heads/AMBARI-2.4.2.16
Commit: f18f46b421cd1c875b3f2144c330d4ce95fad07d
Parents: 092c762
Author: Dipayan Bhowmick <dipayan.bhowm...@gmail.com>
Authored: Sat Nov 12 23:54:38 2016 +0530
Committer: Dipayan Bhowmick <dipayan.bhowm...@gmail.com>
Committed: Sat Nov 12 18:45:14 2016 +0000

----------------------------------------------------------------------
 .../resources/browser/ConnectionService.java      |  8 ++++----
 .../ui/hive-web/app/controllers/splash.js         | 18 ++++++++++++++++--
 .../resources/ui/hive-web/app/routes/splash.js    |  7 ++++++-
 3 files changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f18f46b4/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/browser/ConnectionService.java
----------------------------------------------------------------------
diff --git 
a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/browser/ConnectionService.java
 
b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/browser/ConnectionService.java
index cd4d30e..d71d7da 100644
--- 
a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/browser/ConnectionService.java
+++ 
b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/browser/ConnectionService.java
@@ -80,9 +80,9 @@ public class ConnectionService {
       // get the password
         String pass = password.get();
       // password may be stale, try to connect to Hive
-        return attemptHiveConnection(pass);
+        return attemptHiveConnection(pass,ldapEnabled);
     }
-      return attemptHiveConnection(NO_PASSWORD);
+      return attemptHiveConnection(NO_PASSWORD,ldapEnabled);
 
   }
 
@@ -95,7 +95,7 @@ public class ConnectionService {
         return 
Response.ok().entity(response).type(MediaType.APPLICATION_JSON).build();
     }
 
-    private Response attemptHiveConnection(String pass) {
+    private Response attemptHiveConnection(String pass, boolean ldapEnabled) {
         ConnectionConfig connectionConfig = ConnectionFactory.create(context);
         HiveConnectionWrapper hiveConnectionWrapper = new 
HiveConnectionWrapper(connectionConfig.getJdbcUrl(), 
connectionConfig.getUsername(), pass,new AuthParams(context));
         try {
@@ -105,7 +105,7 @@ public class ConnectionService {
           // check the message to see if the cause was a login failure
           // return a 401
           // else return a 500
-          if(isLoginError(e))
+          if(isLoginError(e) && ldapEnabled)
             return Response.status(Response.Status.UNAUTHORIZED).build();
           else
               throw new ServiceFormattedException(e.getMessage(), e);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f18f46b4/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/splash.js
----------------------------------------------------------------------
diff --git 
a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/splash.js
 
b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/splash.js
index 97b3ea6..1bf6d42 100644
--- 
a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/splash.js
+++ 
b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/splash.js
@@ -41,12 +41,26 @@ checkConnection: function() {
         .then(
             function(data) {
               console.log("fulfil");
-              model.set('ldapSuccess',true);
+              model.set('ldapFailure',false);
             },
             function(reason) {
               console.log("fail");
               if(reason.status === 401){
-                model.set('ldapSuccess',false);
+                model.set('ldapFailure',true);
+              } else {
+
+                  var data = reason.responseJSON;
+                  var checkFailedMessage = "Service Hive check failed";
+                  var errors = self.get("errors");
+                  errors += checkFailedMessage;
+                  errors += (data.message) ? (': <i>' + data.message + 
'</i><br>') : '<br>';
+                  self.set("errors", errors);
+
+                if (data.trace != null) {
+                  var stackTrace = self.get("stackTrace");
+                  stackTrace += checkFailedMessage + ':\n' + data.trace;
+                  self.set("stackTrace", stackTrace);
+                }
               }
             }
         );

http://git-wip-us.apache.org/repos/asf/ambari/blob/f18f46b4/contrib/views/hive-next/src/main/resources/ui/hive-web/app/routes/splash.js
----------------------------------------------------------------------
diff --git 
a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/routes/splash.js 
b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/routes/splash.js
index 6328256..e2601f9 100644
--- 
a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/routes/splash.js
+++ 
b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/routes/splash.js
@@ -64,7 +64,7 @@ export default Ember.Route.extend({
       model.set('percent', percent + 25);
       loadView();
     },function(){
-        if(!model.get('ldapSuccess')) {
+        if(model.get('ldapFailure')) {
           var percent = model.get('percent');
           controller.requestLdapPassword(function(){
             // check the connection again
@@ -86,6 +86,11 @@ export default Ember.Route.extend({
               loadView();
             });
           });
+        } else {
+          model.get("hiveserverTest",false);
+          model.set("hiveserver" + 'TestDone', true);
+          model.set('percent', model.get('percent') + 25);
+          loadView();
         }
     });
 

Reply via email to