This is an automated email from the ASF dual-hosted git repository.

vvraskin pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-openwhisk-runtime-java.git


The following commit(s) were added to refs/heads/master by this push:
     new 666aece  update run handler to accept more environment variables (#67)
666aece is described below

commit 666aeced52725917b7d9363222e974d2dc8860bc
Author: Carlos Santana <csantan...@apache.org>
AuthorDate: Tue Aug 14 10:15:37 2018 -0400

    update run handler to accept more environment variables (#67)
---
 .../proxy/src/main/java/openwhisk/java/action/Proxy.java    | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/core/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java 
b/core/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java
index dc6c861..209f436 100644
--- a/core/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java
+++ b/core/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java
@@ -28,6 +28,8 @@ import java.net.InetSocketAddress;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Path;
 import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
 
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
@@ -136,14 +138,15 @@ public class Proxy {
             try {
                 InputStream is = t.getRequestBody();
                 JsonParser parser = new JsonParser();
-                JsonElement ie = parser.parse(new BufferedReader(new 
InputStreamReader(is, StandardCharsets.UTF_8)));
-                JsonObject inputObject = 
ie.getAsJsonObject().getAsJsonObject("value");
+                JsonObject body = parser.parse(new BufferedReader(new 
InputStreamReader(is, StandardCharsets.UTF_8))).getAsJsonObject();
+                JsonObject inputObject = body.getAsJsonObject("value");
 
                 HashMap<String, String> env = new HashMap<String, String>();
-                for (String p : new String[] { "api_key", "namespace", 
"action_name", "activation_id", "deadline" }) {
+                Set<Map.Entry<String, JsonElement>> entrySet = body.entrySet();
+                for(Map.Entry<String, JsonElement> entry : entrySet){
                     try {
-                        String val = 
ie.getAsJsonObject().getAsJsonPrimitive(p).getAsString();
-                        env.put(String.format("__OW_%s", p.toUpperCase()), 
val);
+                        if(!entry.getKey().equalsIgnoreCase("value"))
+                            env.put(String.format("__OW_%s", 
entry.getKey().toUpperCase()), entry.getValue().getAsString());
                     } catch (Exception e) {}
                 }
 

Reply via email to