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


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1701216 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PropertiesEditorSupport.java b/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PropertiesEditorSupport.java
index 9815aa0..5cbd1ae 100644
--- a/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PropertiesEditorSupport.java
+++ b/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/PropertiesEditorSupport.java
@@ -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 @@
         {

             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;

     }

 

 }

diff --git a/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js b/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js
index b04dc22..cf26a0b 100644
--- a/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js
+++ b/webconsole-plugins/event/src/main/resources/res/ui/propeditor.js
@@ -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);