Martin Sivák has uploaded a new change for review.

Change subject: webadmin: Replace inner variable references in failure messages
......................................................................

webadmin: Replace inner variable references in failure messages

Currently the message processing code ignores variables that were
added by expanding other variables. This is not consistent with
the handling in AuditLog.

This patch fixes that and makes the behaviour the same. The only
risk here is that we have an expansion cycle, but that is
under our control and should not happen.

As an usage example think about the expansion of the following
messages:

"$filterType internal"
"$hostName dev-03"
"$filterName Network"
"$networkNames test"
"$detailMessage network(s) ${networkNames} are missing"
"The host ${hostName} did not satisfy ${filterType} filter
 ${filterName} because ${detailMessage}."

This is related to the our improvement of how we report scheduling
failures.

Change-Id: If70582ae35b8f94b4101dfc33865cc7976fd625c
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1077627
Signed-off-by: Martin Sivak <[email protected]>
---
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/ErrorTranslator.java
1 file changed, 5 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/21/26621/1

diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/ErrorTranslator.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/ErrorTranslator.java
index 747c6f1..a29aad4 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/ErrorTranslator.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/ErrorTranslator.java
@@ -168,20 +168,17 @@
 
         RegExp regex = RegExp.compile(VARIABLE_PATTERN, "gi"); //$NON-NLS-1$ 
//$NON-NLS-2$
 
-        int fromIndex = 0;
-        int length = message.length();
         MatchResult result;
-        while (fromIndex < length) {
-            result = regex.exec(message);
+        while (returnValue.length() > 0) {
+            result = regex.exec(returnValue);
             if (result == null) {
                 // No more matches
                 break;
             }
 
-            int index = result.getIndex();
             String match = result.getGroup(0);
-
             String key = match.substring(2, match.length() - 1);
+
             if (variables.containsKey(key)) {
                 LinkedList<String> values = variables.get(key);
                 String value = values.size() == 1 ? values.getFirst() :
@@ -189,6 +186,8 @@
                 returnValue = returnValue.replace(match, value);
             }
 
+            // Make the next search start from the beginning
+            regex.setLastIndex(0);
         }
 
         return returnValue;


-- 
To view, visit http://gerrit.ovirt.org/26621
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If70582ae35b8f94b4101dfc33865cc7976fd625c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Sivák <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to