AMBARI-20516 create table failing with HiveAccessControlException (additional patch). (ababiichuk)
diff --git a/ambari-web/app/controllers/wizard/step7/assign_master_controller.js b/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
index 580b761..e2c5fa6 100644
--- a/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
+++ b/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
@@ -18,6 +18,7 @@
 
 var stringUtils = require('utils/string_utils');
 var numberUtils = require('utils/number_utils');
+var blueprintUtils = require('utils/blueprint');
 
 App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin, App.AssignMasterComponents, {
 
@@ -392,9 +393,20 @@
       var componentHostName = self.getSelectedHostName(configActionComponent.componentName);
       var config = self.get('configWidgetContext.config');
       var oldValueKey = context.get('controller.wizardController.name') === 'installerController' ? 'initialValue' : 'savedValue';
+
+      // TODO remove after stack advisor is able to handle this case
+      // workaround for hadoop.proxyuser.{{hiveUser}}.hosts after adding Hive Server Interactive from Install Wizard
+      var serviceConfigs = context.get('controller.stepConfigs').findProperty('serviceName', context.get('controller.selectedService.serviceName')).get('configs');
+      var dependencies = context.get('config.configAction.dependencies');
+
       if (self.get('content.controllerName')) {
         self.saveMasterComponentHosts();
         self.saveRecommendationsHostGroups();
+
+        // TODO remove after stack advisor is able to handle this case
+        // workaround for hadoop.proxyuser.{{hiveUser}}.hosts after adding Hive Server Interactive from Install Wizard
+        var miscConfigs = context.get('controller.stepConfigs').findProperty('serviceName', 'MISC').get('configs');
+        serviceConfigs = serviceConfigs.concat(miscConfigs);
       } else {
         self.setGlobalComponentToBeAdded(configActionComponent.componentName, componentHostName);
         self.clearComponentsToBeDeleted(configActionComponent.componentName);
@@ -402,11 +414,115 @@
 
       configActionComponent.hostName = componentHostName;
       config.set('configActionComponent', configActionComponent);
+      /* TODO uncomment after stack advisor is able to handle this case
       context.get('controller').loadConfigRecommendations([{
         type: App.config.getConfigTagFromFileName(config.get('fileName')),
         name: config.get('name'),
         old_value: config.get(oldValueKey)
       }]);
+      */
+
+      // TODO remove after stack advisor is able to handle this case
+      // workaround for hadoop.proxyuser.{{hiveUser}}.hosts after adding Hive Server Interactive
+      if (dependencies) {
+        var foreignKeys = {};
+        if (dependencies.foreignKeys) {
+          dependencies.foreignKeys.forEach(function (dependency) {
+            var matchingProperty = serviceConfigs.find(function (property) {
+              return property.get('filename') === App.config.getOriginalFileName(dependency.fileName) && property.get('name') === dependency.propertyName;
+            });
+            if (matchingProperty) {
+              foreignKeys[dependency.key] = matchingProperty.get('value');
+            }
+          });
+        }
+        if (dependencies.properties && dependencies.initializer) {
+          var initializer = App.get(dependencies.initializer.name);
+          var setup = Em.getProperties(foreignKeys, dependencies.initializer.setupKeys);
+          initializer.setup(setup);
+          var blueprintObject = {};
+          dependencies.properties.forEach(function (property) {
+            var propertyObject = Em.getProperties(property, ['name', 'fileName']);
+            if (property.nameTemplate) {
+              var name = property.nameTemplate;
+              Em.keys(foreignKeys).forEach(function (key) {
+                name = name.replace('{{' + key + '}}', foreignKeys[key]);
+              });
+              propertyObject.name = name;
+            }
+            if (!blueprintObject[property.fileName]) {
+              blueprintObject[property.fileName] = {
+                properties: {}
+              };
+            }
+            var masterComponents = [];
+            if (self.get('content.controllerName')) {
+              var savedMasterComponents = context.get('controller.content.masterComponentHosts').filter(function (componentObject) {
+                return dependencies.initializer.componentNames.contains(componentObject.component);
+              });
+              masterComponents = savedMasterComponents.map(function (componentObject) {
+                var masterComponent = Em.getProperties(componentObject, ['component', 'hostName']);
+                masterComponent.isInstalled = true;
+                return masterComponent;
+              });
+            } else {
+              var hostsMap = blueprintUtils.getComponentForHosts();
+              Em.keys(hostsMap).forEach(function (hostName) {
+                hostsMap[hostName].forEach(function (componentName) {
+                  if (dependencies.initializer.componentNames.contains(componentName)) {
+                    masterComponents.push({
+                      component: componentName,
+                      hostName: hostName,
+                      isInstalled: true
+                    });
+                  }
+                });
+              });
+            }
+            var result = initializer.initialValue(propertyObject, {
+              masterComponentHosts: masterComponents
+            });
+            var propertiesMap = blueprintObject[propertyObject.fileName].properties;
+            propertiesMap[propertyObject.name] = result.value;
+            if (property.isHostsList) {
+              var service = App.config.get('serviceByConfigTypeMap')[propertyObject.fileName];
+              if (service) {
+                var serviceName = service.get('serviceName');
+                var configs = serviceName === context.get('controller.selectedService.serviceName') ? serviceConfigs :
+                  context.get('controller.stepConfigs').findProperty('serviceName', serviceName).get('configs');
+                var originalFileName = App.config.getOriginalFileName(propertyObject.fileName);
+                var currentProperty = configs.find(function (configProperty) {
+                  return configProperty.get('filename') === originalFileName && configProperty.get('name') === propertyObject.name;
+                });
+                if (currentProperty) {
+                  propertiesMap[propertyObject.name] = currentProperty.get('value');
+                  App.config.updateHostsListValue(propertiesMap, propertyObject.fileName, propertyObject.name, propertyObject.value, property.isHostsArray);
+                }
+              }
+            }
+            context.get('controller').loadRecommendationsSuccess({
+              resources: [
+                {
+                  recommendations: {
+                    blueprint: {
+                      configurations: blueprintObject
+                    }
+                  }
+                }
+              ]
+            }, null, {
+              dataToSend: {
+                changed_configurations: [{
+                  type: App.config.getConfigTagFromFileName(config.get('fileName')),
+                  name: config.get('name'),
+                  old_value: config.get(oldValueKey)
+                }]
+              }
+            });
+            initializer.cleanup();
+          });
+        }
+      }
     });
   },
 
diff --git a/ambari-web/app/models/configs/theme/config_action.js b/ambari-web/app/models/configs/theme/config_action.js
index b2ba09a..cc24d45 100644
--- a/ambari-web/app/models/configs/theme/config_action.js
+++ b/ambari-web/app/models/configs/theme/config_action.js
@@ -52,7 +52,14 @@
   popupProperties: DS.attr('object', {
     defaultValue: function () { return {}; }
   }),
-  serviceName: DS.attr('string')
+  serviceName: DS.attr('string'),
+  // TODO remove after stack advisor is able to handle this case
+  // dependencies is used as workaround for hadoop.proxyuser.{{hiveUser}}.hosts after adding Hive Server Interactive from Install Wizard
+  dependencies: DS.attr('object', {
+    defaultValue: function () {
+      return {};
+    }
+  })
 });
 
 App.ConfigAction.FIXTURES = [
@@ -63,7 +70,31 @@
     file_name: "hive-interactive-env.xml",
     if:'${hive-interactive-env/enable_hive_interactive}',
     then:'add',
-    else: 'delete'
+    else: 'delete',
+    // TODO remove after stack advisor is able to handle this case
+    // dependencies is used as workaround for hadoop.proxyuser.{{hiveUser}}.hosts after adding Hive Server Interactive from Install Wizard
+    dependencies: {
+      initializer: {
+        name: 'AddHiveServerInteractiveInitializer',
+        setupKeys: ['hiveUser'],
+        componentNames: ['HIVE_SERVER', 'WEBHCAT_SERVER', 'HIVE_METASTORE', 'HIVE_SERVER_INTERACTIVE']
+      },
+      properties: [
+        {
+          fileName: 'core-site',
+          nameTemplate: 'hadoop.proxyuser.{{hiveUser}}.hosts',
+          isHostsList: true,
+          isHostsArray: false
+        }
+      ],
+      foreignKeys: [
+        {
+          key: 'hiveUser',
+          fileName: 'hive-env.xml',
+          propertyName: 'hive_user'
+        }
+      ]
+    }
   },
   {
     id: 2,
diff --git a/ambari-web/app/utils/configs/add_component_config_initializer.js b/ambari-web/app/utils/configs/add_component_config_initializer.js
index 21fb6b4..2ffd4b4 100644
--- a/ambari-web/app/utils/configs/add_component_config_initializer.js
+++ b/ambari-web/app/utils/configs/add_component_config_initializer.js
@@ -58,7 +58,7 @@
       'hadoop.registry.zk.quorum': this.getHDPStackOnlyHostsPortConfig('2.2', 'ZOOKEEPER_SERVER', '', '', ',', 'zkClientPort', true),
       'nimbus.seeds': this.getHostsListComponentJSONStringifiedConfig('NIMBUS', true),
       'hadoop.proxyuser.{{webhcatUser}}.hosts': this.getComponentsHostsConfig(['HIVE_SERVER', 'WEBHCAT_SERVER', 'HIVE_METASTORE'], false, true),
-      'hadoop.proxyuser.{{hiveUser}}.hosts': this.getComponentsHostsConfig(['HIVE_SERVER', 'WEBHCAT_SERVER', 'HIVE_METASTORE'], false, true),
+      'hadoop.proxyuser.{{hiveUser}}.hosts': this.getComponentsHostsConfig(['HIVE_SERVER', 'WEBHCAT_SERVER', 'HIVE_METASTORE', 'HIVE_SERVER_INTERACTIVE'], false, true),
       'hive.metastore.uris': this.getHostsWithPortConfig(['HIVE_METASTORE'], 'thrift://', '', ',thrift://', 'hiveMetastorePort', true),
       'atlas.audit.hbase.zookeeper.quorum': this.getHostsListComponentConfig('ZOOKEEPER_SERVER', true),
       'atlas.graph.storage.hostname': this.getHostsListComponentConfig('ZOOKEEPER_SERVER', true),
@@ -332,3 +332,13 @@
     'hadoop.proxyuser.{{webhcatUser}}.hosts'
   ]
 });
+
+/**
+ * Hive Server Interactive component add initializer.
+ * @instance App.AddHiveServerInteractiveInitializer
+ */
+App.AddHiveServerInteractiveInitializer = App.AddComponentConfigInitializer.create({
+  initializeForProperties: [
+    'hadoop.proxyuser.{{hiveUser}}.hosts'
+  ]
+});
diff --git a/ambari-web/app/utils/configs/move_hm_config_initializer.js b/ambari-web/app/utils/configs/move_hm_config_initializer.js
index ab150e9..c5f6c1f 100644
--- a/ambari-web/app/utils/configs/move_hm_config_initializer.js
+++ b/ambari-web/app/utils/configs/move_hm_config_initializer.js
@@ -27,7 +27,7 @@
 App.MoveHmConfigInitializer = App.MoveHiveComponentConfigInitializerClass.create({
 
   initializers: {
-    'hadoop.proxyuser.{{hiveUser}}.hosts': App.MoveHiveComponentConfigInitializerClass.getHostsWithComponentsConfig(['HIVE_SERVER', 'HIVE_METASTORE'], 'HIVE_METASTORE')
+    'hadoop.proxyuser.{{hiveUser}}.hosts': App.MoveHiveComponentConfigInitializerClass.getHostsWithComponentsConfig(['HIVE_SERVER', 'HIVE_METASTORE', 'HIVE_SERVER_INTERACTIVE'], 'HIVE_METASTORE')
   },
 
   uniqueInitializers: {
diff --git a/ambari-web/app/utils/configs/move_hs_config_initializer.js b/ambari-web/app/utils/configs/move_hs_config_initializer.js
index 7b15d0d..394d722 100644
--- a/ambari-web/app/utils/configs/move_hs_config_initializer.js
+++ b/ambari-web/app/utils/configs/move_hs_config_initializer.js
@@ -27,7 +27,7 @@
 App.MoveHsConfigInitializer = App.MoveHiveComponentConfigInitializerClass.create({
 
   initializers: {
-    'hadoop.proxyuser.{{hiveUser}}.hosts': App.MoveHiveComponentConfigInitializerClass.getHostsWithComponentsConfig(['HIVE_SERVER', 'HIVE_METASTORE'], 'HIVE_SERVER')
+    'hadoop.proxyuser.{{hiveUser}}.hosts': App.MoveHiveComponentConfigInitializerClass.getHostsWithComponentsConfig(['HIVE_SERVER', 'HIVE_METASTORE', 'HIVE_SERVER_INTERACTIVE'], 'HIVE_SERVER')
   }
 
 });
\ No newline at end of file
diff --git a/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js b/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
index 0f3c599..e70055b 100644
--- a/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
+++ b/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
Binary files differ