Bug 1075757 - Group metric graphs for resources with quotes in name do not display graph - JSON bug
Summary: Group metric graphs for resources with quotes in name do not display graph - ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Core UI
Version: 4.9
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: RHQ 4.12
Assignee: RHQ Project Maintainer
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-03-12 18:26 UTC by Elias Ross
Modified: 2014-12-15 11:35 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2014-12-15 11:35:54 UTC
Embargoed:


Attachments (Terms of Use)

Description Elias Ross 2014-03-12 18:26:47 UTC
Description of problem:

FINE: Multi-resource Graph json: [{ "key": "HornetQ Queue "ims-null"","value" : 
...
Wed Mar 12 11:23:19 GMT-700 2014 
WARNING: Globally uncaught exception
com.google.gwt.core.client.JavaScriptException: (SyntaxError) 
 stack: SyntaxError: Unexpected token i
    at Object.parse (native)
    at Function.e.extend.parseJSON (http://st11p01ad-rhq001:7080/coregui/js/jquery-1.7.2.min.js:2:10821)
    at new $drawJsniChart_1.MultiLineChartContext (<anonymous>:100558:94)
    at $drawJsniChart_1 (<anonymous>:100576:18)

As you can see here, the quote isn't escaped properly

Version-Release number of selected component (if applicable): 4.9


How reproducible: Always


Steps to Reproduce:
1. Create a resource with a quote in the name
2. Try to graph as part of a group
3. See 

Actual results: exception, no graph

Comment 1 Elias Ross 2014-03-13 17:37:05 UTC
Not the correct escape characters but pretty close.

See: http://stackoverflow.com/questions/3020094/how-should-i-escape-strings-in-json

diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java b
index cd637ac..516f98e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java
@@ -378,7 +378,7 @@ public String getJsonMetrics() {
             for (MultiLineGraphData multiLineGraphData : measurementForEachResource) {
                 if(null != multiLineGraphData.getMeasurementData() && multiLineGraphData.getMeasurementData().size() > 0){
                     sb.append("{ \"key\": \"");
-                    sb.append(multiLineGraphData.getResourceName());
+                    sb.append(multiLineGraphData.getResourceNameEscaped());
                     sb.append("\",\"value\" : ");
                     sb.append(produceInnerValuesArray(multiLineGraphData.getMeasurementData()));
                     sb.append("},");
@@ -477,6 +477,10 @@ public String getResourceName() {
             return resourceName;
         }
 
+        public String getResourceNameEscaped() {
+            return resourceName.replace('"', '\'');
+        }
+
         public int getResourceId() {
             return resourceId;
         }

Comment 2 Jirka Kremser 2014-05-07 23:12:22 UTC
97cc62c3caa1288dac023f4 
(pull request #30 - https://github.com/rhq-project/rhq/pull/30)

Comment 3 Heiko W. Rupp 2014-12-15 11:35:54 UTC
Bulk close of items fixed in RHQ 4.12

If you think this is not solved, then please open a *new* BZ and link to this one.


Note You need to log in before you can comment on or make changes to this bug.