Author: yusaku
Date: Fri Jan 11 03:19:14 2013
New Revision: 1431855
URL: http://svn.apache.org/viewvc?rev=1431855&view=rev
Log:
AMBARI-1159. Check the log/run dir locations to make sure its an abs path.
(yusaku)
Modified:
incubator/ambari/trunk/ambari-web/app/data/config_properties.js
incubator/ambari/trunk/ambari-web/app/models/service_config.js
incubator/ambari/trunk/ambari-web/app/utils/validator.js
Modified: incubator/ambari/trunk/ambari-web/app/data/config_properties.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/data/config_properties.js?rev=1431855&r1=1431854&r2=1431855&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/data/config_properties.js (original)
+++ incubator/ambari/trunk/ambari-web/app/data/config_properties.js Fri Jan 11
03:19:14 2013
@@ -1294,7 +1294,7 @@ module.exports =
"displayName": "MapReduce Capacity Scheduler",
"description": "The scheduler to use for scheduling of MapReduce jobs",
"defaultValue": "org.apache.hadoop.mapred.CapacityTaskScheduler",
- "displayType": "directory",
+ //"displayType": "directory",
"isVisible": true,
"serviceName": "MAPREDUCE"
},
Modified: incubator/ambari/trunk/ambari-web/app/models/service_config.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/models/service_config.js?rev=1431855&r1=1431854&r2=1431855&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/models/service_config.js (original)
+++ incubator/ambari/trunk/ambari-web/app/models/service_config.js Fri Jan 11
03:19:14 2013
@@ -337,10 +337,12 @@ App.ServiceConfigProperty = Ember.Object
var isError = false;
- if (this.get('isRequired')) {
- if (typeof value === 'string' && value.trim().length === 0) {
+ if (typeof value === 'string' && value.trim().length === 0) {
+ if (this.get('isRequired')) {
this.set('errorMessage', 'This is required');
isError = true;
+ } else {
+ return;
}
}
@@ -361,6 +363,16 @@ App.ServiceConfigProperty = Ember.Object
case 'checkbox':
break;
case 'directories':
+ if (!validator.isValidDir(value)) {
+ this.set('errorMessage', 'Must be a slash at the start');
+ isError = true;
+ }
+ break;
+ case 'directory':
+ if (!validator.isValidDir(value)) {
+ this.set('errorMessage', 'Must be a slash at the start');
+ isError = true;
+ }
break;
case 'custom':
break;
Modified: incubator/ambari/trunk/ambari-web/app/utils/validator.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/utils/validator.js?rev=1431855&r1=1431854&r2=1431855&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/utils/validator.js (original)
+++ incubator/ambari/trunk/ambari-web/app/utils/validator.js Fri Jan 11
03:19:14 2013
@@ -35,6 +35,21 @@ module.exports = {
var floatRegex = /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/;
return floatRegex.test(value);
},
+ /**
+ * validate directory with slash at the start
+ * @param value
+ * @return {Boolean}
+ */
+ isValidDir: function(value){
+ var floatRegex = /^\/[0-9a-z]*/;
+ var dirs = value.replace(/,/g,' ').trim().split(new RegExp("\\s+", "g"));
+ for(var i = 0; i < dirs.length; i++){
+ if(!floatRegex.test(dirs[i])){
+ return false;
+ }
+ }
+ return true;
+ },
/**
* validate ip address with port