소스 검색

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

Dipayan Bhowmick 8 년 전
부모
커밋
edb5b66044

+ 4 - 4
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);

+ 16 - 2
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);
+                }
               }
             }
         );

+ 6 - 1
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();
         }
     });