ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-18798. Long rack_id value causes sql-error (onechiporenko)
Date Fri, 04 Nov 2016 10:27:39 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 0c165e336 -> d348b65e0


AMBARI-18798. Long rack_id value causes sql-error (onechiporenko)


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

Branch: refs/heads/trunk
Commit: d348b65e023d17589767c7a2c45700bf4ad674ed
Parents: 0c165e3
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Fri Nov 4 12:01:28 2016 +0200
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Fri Nov 4 12:01:28 2016 +0200

----------------------------------------------------------------------
 ambari-web/app/messages.js                      |  2 +-
 ambari-web/app/styles/application.less          | 12 ++++------
 ambari-web/app/templates/main/host/summary.hbs  |  2 +-
 ambari-web/app/utils/validator.js               |  3 ++-
 .../common/helpers/format_word_break_view.js    |  8 +++----
 ambari-web/test/utils/validator_test.js         | 22 ++++++++++++++++++
 .../helpers/format_word_break_view_test.js      | 24 +++++++++++---------
 7 files changed, 48 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d348b65e/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index b0ebddd..fa5e1bb 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -408,7 +408,7 @@ Em.I18n.translations = {
   'hostPopup.reccomendation.beforeDecommission': '{0} Maintenance Mode is pre required for
decommissioning.',
   'hostPopup.setRackId.success': 'Updating rack id to \"{0}\". It may take a few moments
for it to get refreshed.',
   'hostPopup.setRackId.error': 'Updating the rack id failed.',
-  'hostPopup.setRackId.invalid': 'Should start with a forward slash it may include alphanumeric
chars, dots, dashes and forward slashes.',
+  'hostPopup.setRackId.invalid': 'Should start with a forward slash it may include alphanumeric
chars, dots, dashes and forward slashes. Should be less than 255 symbols.',
   'hostPopup.RackId': 'Rack',
   'hostPopup.recommendation.beforeDecommission': '{0} Maintenance Mode is pre required for
decommissioning.',
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d348b65e/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 64b5797..821c087 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -4663,6 +4663,11 @@ ul.list-inline li {
   width: 100%
 }
 
+.rack-id {
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+}
 
 .big-arrow-right {
   background-repeat: no-repeat;
@@ -4672,13 +4677,6 @@ ul.list-inline li {
 .advanced-header-table {
   table-layout: fixed;
 
-  td {
-    &.rack-id {
-      white-space: nowrap;
-      overflow: hidden;
-      text-overflow: ellipsis;
-    }
-  }
   .sorting_asc {
     background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAKQWlDQ1BJQ0MgUHJvZmlsZQAASA2dlndUU9kWh8+9N73QEiIgJfQaegkg0jtIFQRRiUmAUAKGhCZ2RAVGFBEpVmRUwAFHhyJjRRQLg4Ji1wnyEFDGwVFEReXdjGsJ7601896a/cdZ39nnt9fZZ+9917oAUPyCBMJ0WAGANKFYFO7rwVwSE8vE9wIYEAEOWAHA4WZmBEf4RALU/L09mZmoSMaz9u4ugGS72yy/UCZz1v9/kSI3QyQGAApF1TY8fiYX5QKUU7PFGTL/BMr0lSkyhjEyFqEJoqwi48SvbPan5iu7yZiXJuShGlnOGbw0noy7UN6aJeGjjAShXJgl4GejfAdlvVRJmgDl9yjT0/icTAAwFJlfzOc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XPq24hSmGJ3srvz5vdmga8NIhK1GhW2B8q+M+F/96DRRHE0hUEagegUEyK4VdVoqgv3fL2h3HAMQ3I+sQDLCpRdUlWNUux8prjZltXTRUIQ4X4T6HSRcRwkPxLj7r7ZHPXFSgO7A3xgwQfsncRghJKKzpPMPiBv9pBwDQmhgaTgnRU5zD7S86U3necH2CtQJIyKHkWKyXTGCrFZh4XtxxWt4x6eda9u/+U/gZ+dwBODrVwv7HA8iwAAAABJRU5ErkJggg==)
no-repeat right 50%;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d348b65e/ambari-web/app/templates/main/host/summary.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/summary.hbs b/ambari-web/app/templates/main/host/summary.hbs
index 1ec0ac6..ea4be05 100644
--- a/ambari-web/app/templates/main/host/summary.hbs
+++ b/ambari-web/app/templates/main/host/summary.hbs
@@ -154,7 +154,7 @@
             <dd class="summary-ipaddress-value">&nbsp;{{view.content.ip}}</dd>
 
             <dt class="summary-rack-label">{{t common.rack}}:</dt>
-            <dd class="summary-rack-value">&nbsp;{{view.content.rack}}
+            <dd class="summary-rack-value">&nbsp;{{formatWordBreak view.content.rack}}
                 {{#isAuthorized "HOST.TOGGLE_MAINTENANCE"}}
                   <a class="set-rack-id" {{action setRackId view.content target="controller"}}><i
                     class="glyphicon glyphicon-pencil"></i></a>

http://git-wip-us.apache.org/repos/asf/ambari/blob/d348b65e/ambari-web/app/utils/validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/validator.js b/ambari-web/app/utils/validator.js
index 48ba4dd..c7248bb 100644
--- a/ambari-web/app/utils/validator.js
+++ b/ambari-web/app/utils/validator.js
@@ -269,8 +269,9 @@ module.exports = {
   },
 
   isValidRackId: function(path) {
+    var _path = '' + path;
     // See app/message.js:hostPopup.setRackId.invalid
-    return /^\/[/.\w-]+$/.test(path);
+    return /^\/[/.\w-]+$/.test(_path) && _path.length < 255;
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/d348b65e/ambari-web/app/views/common/helpers/format_word_break_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/helpers/format_word_break_view.js b/ambari-web/app/views/common/helpers/format_word_break_view.js
index d33692c..8601cdc 100644
--- a/ambari-web/app/views/common/helpers/format_word_break_view.js
+++ b/ambari-web/app/views/common/helpers/format_word_break_view.js
@@ -31,7 +31,7 @@ App.FormatWordBreakView = Em.View.extend({
     if (str.length <= maxBlockLength || str.contains('-') || str.contains(' ')) {
       return str;
     }
-    return str.split(/(?=[A-Z])/).join('<wbr />');
+    return str.split(/(?=[A-Z])/).join('<wbr>');
   },
 
   /**
@@ -40,13 +40,13 @@ App.FormatWordBreakView = Em.View.extend({
   result: function() {
     var content = this.get('content') || '';
     var self = this;
-    ['.', '_'].forEach(function (delimiter) {
+    ['.', '_', '/'].forEach(function (delimiter) {
       if (content.contains(delimiter)) {
         content = content.split(delimiter).map(function (substr) {
           return self._splitLongSubStrings(substr);
-        }).join(delimiter + '<wbr />');
+        }).join(delimiter + '<wbr>');
       }
     });
-    return content.replace(/(<wbr \/>){2,}/, '<wbr />'); // no need for double
<wbr />
+    return content.replace(/(<wbr>){2,}/g, '<wbr>'); // no need for double <wbr>
   }.property('content')
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/d348b65e/ambari-web/test/utils/validator_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/validator_test.js b/ambari-web/test/utils/validator_test.js
index 2a30993..4f069e0 100644
--- a/ambari-web/test/utils/validator_test.js
+++ b/ambari-web/test/utils/validator_test.js
@@ -498,4 +498,26 @@ describe('validator', function () {
       })
     });
   });
+
+  describe('#isValidRackId()', function () {
+
+    [
+      {v: '', e: false},
+      {v: 'a', e: false},
+      {v: '1', e: false},
+      {v: '/', e: false},
+      {v: '/a', e: true},
+      {v: '/1', e: true},
+      {v: '/-', e: true},
+      {v: '/' + (new Array(255)).join('a'), m: 'Value bigger than 255 symbols', e: false}
+    ].forEach(function (test) {
+
+      it(test.m || test.v, function () {
+        expect(validator.isValidRackId(test.v)).to.be.equal(test.e);
+      })
+
+    });
+
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/d348b65e/ambari-web/test/views/common/helpers/format_word_break_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/helpers/format_word_break_view_test.js b/ambari-web/test/views/common/helpers/format_word_break_view_test.js
index 40154af..f656fbe 100644
--- a/ambari-web/test/views/common/helpers/format_word_break_view_test.js
+++ b/ambari-web/test/views/common/helpers/format_word_break_view_test.js
@@ -30,17 +30,19 @@ describe('App.FormatWordBreakView', function () {
 
     Em.A([
       {content: 'abc', expected: 'abc'},
-      {content: 'a.bc', expected: 'a.<wbr />bc'},
-      {content: 'a.b.c', expected: 'a.<wbr />b.<wbr />c'},
-      {content: 'a.123456789A123456789B12345.c', expected: 'a.<wbr />123456789<wbr
/>A123456789<wbr />B12345.<wbr />c'},
-      {content: 'a_bc', expected: 'a_<wbr />bc'},
-      {content: 'a_b_c', expected: 'a_<wbr />b_<wbr />c'},
-      {content: 'a_123456789A123456789B12345_c', expected: 'a_<wbr />123456789<wbr
/>A123456789<wbr />B12345_<wbr />c'},
-      {content: 'a.123456789A123456789B12345_c', expected: 'a.<wbr />123456789<wbr
/>A123456789<wbr />B12345_<wbr />c'},
-      {content: 'a.123456789a123456789b12345_c', expected: 'a.<wbr />123456789a123456789b12345_<wbr
/>c'},
-      {content: 'a.123456789a-23456789b12345_c', expected: 'a.<wbr />123456789a-23456789b12345_<wbr
/>c'},
-      {content: 'a.123456789a 23456789b12345_c', expected: 'a.<wbr />123456789a 23456789b12345_<wbr
/>c'},
-      {content: 'a.123456789a123456789_c', expected: 'a.<wbr />123456789a123456789_<wbr
/>c'},
+      {content: 'a.bc', expected: 'a.<wbr>bc'},
+      {content: 'a.b.c', expected: 'a.<wbr>b.<wbr>c'},
+      {content: 'a/bc', expected: 'a/<wbr>bc'},
+      {content: 'a/b/c', expected: 'a/<wbr>b/<wbr>c'},
+      {content: 'a.123456789A123456789B12345.c', expected: 'a.<wbr>123456789<wbr>A123456789<wbr>B12345.<wbr>c'},
+      {content: 'a_bc', expected: 'a_<wbr>bc'},
+      {content: 'a_b_c', expected: 'a_<wbr>b_<wbr>c'},
+      {content: 'a_123456789A123456789B12345_c', expected: 'a_<wbr>123456789<wbr>A123456789<wbr>B12345_<wbr>c'},
+      {content: 'a.123456789A123456789B12345_c', expected: 'a.<wbr>123456789<wbr>A123456789<wbr>B12345_<wbr>c'},
+      {content: 'a.123456789a123456789b12345_c', expected: 'a.<wbr>123456789a123456789b12345_<wbr>c'},
+      {content: 'a.123456789a-23456789b12345_c', expected: 'a.<wbr>123456789a-23456789b12345_<wbr>c'},
+      {content: 'a.123456789a 23456789b12345_c', expected: 'a.<wbr>123456789a 23456789b12345_<wbr>c'},
+      {content: 'a.123456789a123456789_c', expected: 'a.<wbr>123456789a123456789_<wbr>c'},
     ]).forEach(function (test) {
       var message = 'content: {0}, expected: {1}'.format(JSON.stringify(test.content), JSON.stringify(test.expected));
       it(message, function () {


Mime
View raw message