You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/08/23 23:36:20 UTC
git commit: AMBARI-3009. Trim and/or validate config parameter values
to prevent failures due to extra spaces. (Andrii Babiichuk via yusaku)
Updated Branches:
refs/heads/trunk f011256e2 -> 2a3fa8263
AMBARI-3009. Trim and/or validate config parameter values to prevent failures due to extra spaces. (Andrii Babiichuk via yusaku)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/2a3fa826
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/2a3fa826
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/2a3fa826
Branch: refs/heads/trunk
Commit: 2a3fa82636ff1c5871dc7838208a9ff89ae899c4
Parents: f011256
Author: Yusaku Sako <yu...@hortonworks.com>
Authored: Fri Aug 23 14:35:55 2013 -0700
Committer: Yusaku Sako <yu...@hortonworks.com>
Committed: Fri Aug 23 14:36:11 2013 -0700
----------------------------------------------------------------------
.../security/add/addSecurity_controller.js | 6 +---
.../controllers/main/service/info/configs.js | 6 +---
.../app/controllers/wizard/step8_controller.js | 6 +---
ambari-web/app/data/HDP2/global_properties.js | 4 +--
ambari-web/app/messages.js | 2 ++
ambari-web/app/models/service_config.js | 23 ++++++++++++++
ambari-web/app/utils/config.js | 33 ++++++++++++++++++++
ambari-web/app/utils/validator.js | 9 ++++++
8 files changed, 72 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/2a3fa826/ambari-web/app/controllers/main/admin/security/add/addSecurity_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/security/add/addSecurity_controller.js b/ambari-web/app/controllers/main/admin/security/add/addSecurity_controller.js
index b8c8128..e117eca 100644
--- a/ambari-web/app/controllers/main/admin/security/add/addSecurity_controller.js
+++ b/ambari-web/app/controllers/main/admin/security/add/addSecurity_controller.js
@@ -90,11 +90,7 @@ App.AddSecurityController = App.WizardController.extend({
var serviceConfigProperties = [];
stepController.get('stepConfigs').forEach(function (_content) {
_content.get('configs').forEach(function (_configProperties) {
- var displayType = _configProperties.get('displayType');
- if (displayType === 'directories' || displayType === 'directory') {
- var value = _configProperties.get('value').trim().split(/\s+/g).join(',');
- _configProperties.set('value', value);
- }
+ _configProperties.set('value', App.config.trimProperty(_configProperties,true));
var overrides = _configProperties.get('overrides');
var overridesArray = [];
if(overrides!=null){
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/2a3fa826/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index eb93798..022fab8 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -872,11 +872,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
saveGlobalConfigs: function (configs) {
var globalConfigs = this.get('globalConfigs');
configs.filterProperty('id', 'puppet var').forEach(function (uiConfigProperty) {
- var displayType = uiConfigProperty.get('displayType');
- if (displayType == 'directories' || displayType === 'directory') {
- var value = uiConfigProperty.get('value').replace(/,/g,' ').trim().split(/\s+/g).join(',');
- uiConfigProperty.set('value', value);
- }
+ uiConfigProperty.set('value', App.config.trimProperty(uiConfigProperty),true);
if (globalConfigs.someProperty('name', uiConfigProperty.name)) {
var modelGlobalConfig = globalConfigs.findProperty('name', uiConfigProperty.name);
modelGlobalConfig.value = uiConfigProperty.value;
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/2a3fa826/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 5d49005..6a05d6c 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -89,11 +89,7 @@ App.WizardStep8Controller = Em.Controller.extend({
*/
formatDirectories: function(){
this.get('content.serviceConfigProperties').forEach(function(_configProperty){
- var displayType = _configProperty.displayType;
- if (displayType === 'directories' || displayType === 'directory') {
- var value = _configProperty.value.trim().split(/\s+/g).join(',');
- _configProperty.value = value;
- }
+ _configProperty.value = App.config.trimProperty(_configProperty,false);
});
},
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/2a3fa826/ambari-web/app/data/HDP2/global_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2/global_properties.js b/ambari-web/app/data/HDP2/global_properties.js
index 6f17c57..8f00523 100644
--- a/ambari-web/app/data/HDP2/global_properties.js
+++ b/ambari-web/app/data/HDP2/global_properties.js
@@ -1233,7 +1233,7 @@ module.exports =
"description": "Database user name to use to connect to the database",
"defaultValue": "hive",
"isReconfigurable": true,
- "displayType": "user",
+ "displayType": "host",
"isOverridable": false,
"isVisible": true,
"domain": "global",
@@ -1566,7 +1566,7 @@ module.exports =
"defaultValue": "oozie",
"isReconfigurable": true,
"isOverridable": false,
- "displayType": "user",
+ "displayType": "host",
"isVisible": true,
//"domain": "global",
"serviceName": "OOZIE",
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/2a3fa826/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 5b6bfbf..f9f60f2 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -199,6 +199,8 @@ Em.I18n.translations = {
'graphs.timeRange.year': 'Last 1 year',
'users.userName.validationFail': 'Only lowercase letters and numbers are allowed; must start with a letter',
+ 'host.spacesValidation': 'Can\'t contain whitespaces',
+ 'host.trimspacesValidation': 'Can\'t contain leading or trailing whitespaces',
'services.nagios.description':'Nagios Monitoring and Alerting system',
'services.ganglia.description':'Ganglia Metrics Collection system',
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/2a3fa826/ambari-web/app/models/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js
index 3ec1f51..130401c 100644
--- a/ambari-web/app/models/service_config.js
+++ b/ambari-web/app/models/service_config.js
@@ -543,6 +543,29 @@ App.ServiceConfigProperty = Ember.Object.extend({
isError = true;
}
break;
+ case 'host':
+ var hiveOozieHostNames = ['hive_hostname','hive_existing_mysql_host','hive_existing_oracle_host','hive_ambari_host',
+ 'oozie_hostname','oozie_existing_mysql_host','oozie_existing_oracle_host','oozie_ambari_host']
+ if(hiveOozieHostNames.contains(this.get('name'))) {
+ if (validator.hasSpaces(value)) {
+ this.set('errorMessage', Em.I18n.t('host.spacesValidation'));
+ isError = true;
+ }
+ } else {
+ if (validator.isNotTrimmed(value)) {
+ this.set('errorMessage', Em.I18n.t('host.trimspacesValidation'));
+ isError = true;
+ }
+ }
+ break;
+ case 'advanced':
+ if(this.get('name')=='hive_jdbc_connection_url' || this.get('name')=='oozie_jdbc_connection_url') {
+ if (validator.isNotTrimmed(value)) {
+ this.set('errorMessage', Em.I18n.t('host.trimspacesValidation'));
+ isError = true;
+ }
+ }
+ break;
case 'password':
// retypedPassword is set by the retypePasswordView child view of App.ServiceConfigPasswordField
if (value !== this.get('retypedPassword')) {
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/2a3fa826/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 6918d62..abf8930 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -857,6 +857,39 @@ App.config = Em.Object.create({
}
console.log('ERROR: textarea config - ' + complexConfigName + ' is missing');
return configs;
+ },
+
+ /**
+ * trim trailing spaces for all properties.
+ * trim both trailing and leading spaces for host displayType and hive/oozie datebases url.
+ * for directory or directories displayType format string for further using.
+ * for password and values with spaces only do nothing.
+ * @param property
+ * @returns {*}
+ */
+ trimProperty: function(property, isEmberObject){
+ var displayType = (isEmberObject) ? property.get('displayType') : property.displayType;
+ var value = (isEmberObject) ? property.get('value') : property.value;
+ var rez;
+ switch (displayType){
+ case 'directories':
+ case 'directory':
+ rez = value.trim().split(/\s+/g).join(',');
+ break;
+ case 'host':
+ rez = value.trim();
+ break;
+ case 'advanced':
+ if(this.get('name')=='hive_jdbc_connection_url' || this.get('name')=='oozie_jdbc_connection_url') {
+ rez = value.trim();
+ }
+ break;
+ case 'password':
+ break;
+ default:
+ rez = value.toString().replace(/(\s+$)/g, '');
+ }
+ return (rez == '') ? value : rez;
}
});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/2a3fa826/ambari-web/app/utils/validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/validator.js b/ambari-web/app/utils/validator.js
index a01b0d4..e161f0f 100644
--- a/ambari-web/app/utils/validator.js
+++ b/ambari-web/app/utils/validator.js
@@ -76,6 +76,15 @@ module.exports = {
return regex.test(value);
},
+ hasSpaces: function(value) {
+ var regex = /(\s+)/;
+ return regex.test(value);
+ },
+
+ isNotTrimmed: function(value) {
+ var regex = /(^\s+|\s+$)/;
+ return regex.test(value);
+ },
/**
* validate domain name with port
* @param value