Merge branch 'BF-4169' of /home/git/repositories/brainfood/ofbiz-directcontrolservlet
Showing
1 changed file
with
13 additions
and
7 deletions
... | @@ -97,11 +97,12 @@ public class DirectControlServlet extends HttpServlet { | ... | @@ -97,11 +97,12 @@ public class DirectControlServlet extends HttpServlet { |
97 | } | 97 | } |
98 | 98 | ||
99 | public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | 99 | public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
100 | String pathInfo = request.getPathInfo(); | ||
101 | String contentType = request.getContentType(); | ||
100 | try { | 102 | try { |
101 | Debug.logInfo("getPathInfo: " + request.getPathInfo() + | 103 | Debug.logInfo("getPathInfo: " + pathInfo + |
102 | " request.getContentType: " + request.getContentType(), module); | 104 | " request.getContentType: " + contentType, module); |
103 | 105 | ||
104 | String pathInfo = request.getPathInfo(); | ||
105 | if (pathInfo == null || pathInfo.length() == 0) { | 106 | if (pathInfo == null || pathInfo.length() == 0) { |
106 | return; | 107 | return; |
107 | } | 108 | } |
... | @@ -109,7 +110,12 @@ public class DirectControlServlet extends HttpServlet { | ... | @@ -109,7 +110,12 @@ public class DirectControlServlet extends HttpServlet { |
109 | 110 | ||
110 | // Determine type of request and load the context from JSON content or | 111 | // Determine type of request and load the context from JSON content or |
111 | // parameter values accordingly | 112 | // parameter values accordingly |
112 | String contentType = request.getContentType(); | 113 | if (contentType != null) { |
114 | int semi = contentType.indexOf(";"); | ||
115 | if (semi != -1) { | ||
116 | contentType = contentType.substring(0, semi); | ||
117 | } | ||
118 | } | ||
113 | 119 | ||
114 | // Determine the request method for service lookup and parameter filters | 120 | // Determine the request method for service lookup and parameter filters |
115 | String method = ""; | 121 | String method = ""; |
... | @@ -122,15 +128,15 @@ public class DirectControlServlet extends HttpServlet { | ... | @@ -122,15 +128,15 @@ public class DirectControlServlet extends HttpServlet { |
122 | Map<String, Object> context = new HashMap<String, Object>(); | 128 | Map<String, Object> context = new HashMap<String, Object>(); |
123 | if ("application/json".equals(contentType)) { | 129 | if ("application/json".equals(contentType)) { |
124 | // Read request body as JSON and insert into the context | 130 | // Read request body as JSON and insert into the context |
125 | JSON json = new JSON(new InputStreamReader(request.getInputStream())); | 131 | JSON json = new JSON(request.getReader()); |
126 | Map<String,Object> items = json.JSONObject(); | 132 | Map<String,Object> items = json.JSONObject(); |
127 | for (String key : items.keySet()) { | 133 | for (String key : items.keySet()) { |
128 | context.put(key, items.get(key)); | 134 | context.put(key, items.get(key)); |
129 | } | 135 | } |
130 | } else { | 136 | } else { |
131 | // Check if the request is a backbone style "emulateJSON" request | 137 | // Check if the request is a backbone style "emulateJSON" request |
132 | if (request.getContentType() != null && | 138 | if (contentType != null && |
133 | request.getContentType().indexOf("x-www-form-urlencoded") != -1 && | 139 | contentType.indexOf("x-www-form-urlencoded") != -1 && |
134 | request.getParameter("model") != null) { | 140 | request.getParameter("model") != null) { |
135 | Debug.logInfo("MODEL: " + request.getParameter("model"), module); | 141 | Debug.logInfo("MODEL: " + request.getParameter("model"), module); |
136 | JSON json = new JSON(new StringReader(request.getParameter("model"))); | 142 | JSON json = new JSON(new StringReader(request.getParameter("model"))); | ... | ... |
-
Please register or sign in to post a comment