You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by vv...@apache.org on 2015/09/04 13:26:23 UTC

svn commit: r1701216 - in /felix/trunk/webconsole-plugins/event/src/main: java/org/apache/felix/webconsole/plugins/event/internal/PropertiesEditorSupport.java resources/res/ui/propeditor.js

Author: vvalchev
Date: Fri Sep  4 11:26:23 2015
New Revision: 1701216

URL: http://svn.apache.org/r1701216
Log:
Fixed FELIX-5026 : Web Console Event plugin exception when sending event with property of type hex/base64
https://issues.apache.org/jira/browse/FELIX-5026

Modified:
    felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PropertiesEditorSupport.java
    felix/trunk/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js

Modified: felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PropertiesEditorSupport.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PropertiesEditorSupport.java?rev=1701216&r1=1701215&r2=1701216&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PropertiesEditorSupport.java (original)
+++ felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PropertiesEditorSupport.java Fri Sep  4 11:26:23 2015
@@ -17,6 +17,7 @@
 package org.apache.felix.webconsole.plugins.event.internal;
 
 import java.util.Hashtable;
+import java.util.StringTokenizer;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -85,11 +86,27 @@ public class PropertiesEditorSupport
         {
             return new Character(value.toString().charAt(0));
         }
+        else if ("byte array".equals(type)) //$NON-NLS-1$
+        {
+            return decodeHex(value.toString());
+        }
         else
         {
             throw new IllegalArgumentException("Unsupported type!");
         }
-        // TODO: hex, base64, sha1
+    }
+    
+    private static final byte[] decodeHex(String data)
+    {
+        final StringTokenizer tok = new StringTokenizer(data, "[]{},;: \t"); //$NON-NLS-1$
+        final byte[] bs = new byte[tok.countTokens()];
+        int i = 0;
+        while (tok.hasMoreTokens())
+        {
+            final String next = tok.nextToken();
+            bs[i++] = Integer.decode(next).byteValue();
+        }
+        return bs;
     }
 
 }

Modified: felix/trunk/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js?rev=1701216&r1=1701215&r2=1701216&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js (original)
+++ felix/trunk/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js Fri Sep  4 11:26:23 2015
@@ -45,7 +45,7 @@
 				// If options exist, lets merge them with our default settings
 				var settings = {
 					validator  : false,
-					types      : ['byte', 'int', 'long', 'float', 'double', 'string', 'char', 'hex', 'base64', 'sha1']
+					types      : ['byte', 'int', 'long', 'float', 'double', 'string', 'char', 'byte array']
 				};
 				if (options) settings = $.extend(settings, options);