Tomas Jelinek has uploaded a new change for review.

Change subject: frontend: if SpiceReleaseCursorKeys is set SPICE is not opened
......................................................................

frontend: if SpiceReleaseCursorKeys is set SPICE is not opened

If the SpiceReleaseCursorKeys changes to for example
"shift+a" than after clicking the console button the
AsyncDataProvider.getComplexValueFromSpiceRedKeysResource
throws an exception.

The problem was that the getComplexValueFromSpiceRedKeysResource
expects to have all parts of the release cursor keys in the
SpiceRedKeys. In case of "shift+a" it finds "shift" but
does not find "a" and fails.

Fixed by first tying to localize the key (look up in SpiceRedKeys)
but if it does not succeed than returning the key itself.

It is safe to do because the result of getComplexValueFromSpiceRedKeysResource
is used only to show up in the title of the SPICE window and the
SpiceRedKeys contains only the localized parts of it.

Change-Id: Iacbaadf7d6d91c04ec4ec79edc73514bad031714
Signed-off-by: Tomas Jelinek <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceConsoleModel.java
2 files changed, 14 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/16/17016/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
index 1211091..a39b8d3 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
@@ -10,6 +10,7 @@
 import java.util.List;
 import java.util.Map;
 
+import java.util.MissingResourceException;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.EventNotificationEntity;
 import org.ovirt.engine.core.common.TimeZoneType;
@@ -2884,20 +2885,25 @@
      *            string in the form of "[string1]+[string2]+..."
      * @return string in the form of 
"[string1Translated]+[string2Translated]+..."
      */
-    public static String getComplexValueFromSpiceRedKeysResource(String 
complexValue)
-    {
-        if (StringHelper.isNullOrEmpty(complexValue))
-        {
+    public static String getComplexValueFromSpiceRedKeysResource(String 
complexValue) {
+        if (StringHelper.isNullOrEmpty(complexValue)) {
             return ""; //$NON-NLS-1$
         }
         ArrayList<String> values = new ArrayList<String>();
 
-        for (String s : complexValue.split("[+]", -1)) //$NON-NLS-1$
-        {
-            values.add(SpiceConstantsManager.getInstance()
+        for (String s : complexValue.split("[+]", -1)) { //$NON-NLS-1$
+            try {
+                String value =
+                    SpiceConstantsManager.getInstance()
                     .getSpiceRedKeys()
-                    .getString(s.replaceAll("-", "_"))); //$NON-NLS-1$ 
//$NON-NLS-2$
+                    .getString(s.replaceAll("-", "_")); //$NON-NLS-1$ 
//$NON-NLS-2$
+                values.add(value);
+            } catch (MissingResourceException e) {
+                values.add(s);
+            }
+
         }
+
         return StringHelper.join("+", values.toArray(new String[] {})); 
//$NON-NLS-1$
     }
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceConsoleModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceConsoleModel.java
index b53b180..e6a8a4d 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceConsoleModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceConsoleModel.java
@@ -394,9 +394,6 @@
 
         String toggleFullScreenKeys = (String) 
returnValues.get(6).getReturnValue();
         String releaseCursorKeys = (String) 
returnValues.get(7).getReturnValue();
-        String ctrlAltDel = "ctrl+alt+del"; //$NON-NLS-1$
-        String ctrlAltEnd = "ctrl+alt+end"; //$NON-NLS-1$
-
         String releaseCursorKeysTranslated =
                 
AsyncDataProvider.getComplexValueFromSpiceRedKeysResource((releaseCursorKeys != 
null) ? releaseCursorKeys
                         : "shift+f12"); //$NON-NLS-1$


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

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

Reply via email to