Merge branch 'BF-2755' of /home/git/repositories/brainfood/ofbiz-directcontrolservlet
Showing
1 changed file
with
7 additions
and
8 deletions
... | @@ -111,14 +111,12 @@ public class DirectControlServlet extends HttpServlet { | ... | @@ -111,14 +111,12 @@ public class DirectControlServlet extends HttpServlet { |
111 | 111 | ||
112 | // Build context | 112 | // Build context |
113 | Map<String, Object> context = new HashMap<String, Object>(); | 113 | Map<String, Object> context = new HashMap<String, Object>(); |
114 | String authToken = null; | ||
115 | |||
116 | String paramList = ""; | 114 | String paramList = ""; |
117 | for (Iterator<String> k = request.getParameterMap().keySet().iterator(); k.hasNext(); ) { | 115 | for (Iterator<String> k = request.getParameterMap().keySet().iterator(); k.hasNext(); ) { |
118 | paramList += " " + k.next(); | 116 | paramList += " " + k.next(); |
119 | } | 117 | } |
120 | 118 | ||
121 | Debug.logInfo("PARAMETERS: " + request.getParameterMap(), module); | 119 | Debug.logInfo("PARAMETERS: " + paramList, module); |
122 | // Handle if this is a form post | 120 | // Handle if this is a form post |
123 | String contentType = request.getContentType(); | 121 | String contentType = request.getContentType(); |
124 | if (contentType != null && contentType.indexOf("x-www-form-urlencoded") != -1) { | 122 | if (contentType != null && contentType.indexOf("x-www-form-urlencoded") != -1) { |
... | @@ -128,25 +126,23 @@ public class DirectControlServlet extends HttpServlet { | ... | @@ -128,25 +126,23 @@ public class DirectControlServlet extends HttpServlet { |
128 | Debug.logInfo("Method: HTTP(" + httpMethod + ") embedded(" + method + ")", module); | 126 | Debug.logInfo("Method: HTTP(" + httpMethod + ") embedded(" + method + ")", module); |
129 | if (method == null) method = "GET"; | 127 | if (method == null) method = "GET"; |
130 | // If this is a backbone PUT/DELETE emulated call then handle it | 128 | // If this is a backbone PUT/DELETE emulated call then handle it |
131 | if ("PUT".equals(method) || "DELETE".equals(method) || "CALL".equals(method) || "POST".equals(method)) { | 129 | if (request.getParameter("model") != null) { |
132 | // if (!"CALL".equals(method)) context.put("_method", method); | 130 | // if (!"CALL".equals(method)) context.put("_method", method); |
133 | JSON json = new JSON(new StringReader(request.getParameter("model"))); | 131 | JSON json = new JSON(new StringReader(request.getParameter("model"))); |
134 | Map<String,Object> items = json.JSONObject(); | 132 | Map<String,Object> items = json.JSONObject(); |
135 | authToken = (String) items.get("sessionId"); | ||
136 | for (String key : items.keySet()) { | 133 | for (String key : items.keySet()) { |
137 | if (!"sessionId".equals(key) && !"_method".equals(key)) { | 134 | if (!"sessionId".equals(key) && !"_method".equals(key)) { |
138 | context.put(key, items.get(key)); | 135 | context.put(key, items.get(key)); |
139 | Debug.logInfo("parameter '" + key + "'=" + items.get(key), module); | 136 | Debug.logInfo(">parameter '" + key + "'=" + items.get(key), module); |
140 | } | 137 | } |
141 | } | 138 | } |
142 | } else { | 139 | } else { |
143 | authToken = request.getParameter("sessionId"); | ||
144 | for (Enumeration<String> params = request.getParameterNames(); params.hasMoreElements();) { | 140 | for (Enumeration<String> params = request.getParameterNames(); params.hasMoreElements();) { |
145 | String param = params.nextElement(); | 141 | String param = params.nextElement(); |
146 | Object[] values = request.getParameterValues(param); | 142 | Object[] values = request.getParameterValues(param); |
147 | if (!"sessionId".equals(param) && !"_method".equals(param)) { | 143 | if (!"sessionId".equals(param) && !"_method".equals(param)) { |
148 | context.put(param, values.length == 1 ? values[0] : values); | 144 | context.put(param, values.length == 1 ? values[0] : values); |
149 | Debug.logInfo("parameter '" + param + "'=" + context.get(param), module); | 145 | Debug.logInfo("!parameter '" + param + "'=" + context.get(param), module); |
150 | } | 146 | } |
151 | } | 147 | } |
152 | } | 148 | } |
... | @@ -177,6 +173,7 @@ public class DirectControlServlet extends HttpServlet { | ... | @@ -177,6 +173,7 @@ public class DirectControlServlet extends HttpServlet { |
177 | 173 | ||
178 | // If the sessionId parameter is set, attempt to look up the corresponding | 174 | // If the sessionId parameter is set, attempt to look up the corresponding |
179 | // UserLogin and apply it to the service context | 175 | // UserLogin and apply it to the service context |
176 | String authToken = request.getParameter("sessionId"); | ||
180 | if (authToken != null) { | 177 | if (authToken != null) { |
181 | GenericValue authTokenEntity = EntityUtil.getFirst( | 178 | GenericValue authTokenEntity = EntityUtil.getFirst( |
182 | delegator.findList("Visit", | 179 | delegator.findList("Visit", |
... | @@ -198,6 +195,8 @@ public class DirectControlServlet extends HttpServlet { | ... | @@ -198,6 +195,8 @@ public class DirectControlServlet extends HttpServlet { |
198 | } | 195 | } |
199 | } | 196 | } |
200 | 197 | ||
198 | Debug.logInfo("USERLOGIN " + context.get("userLogin") + " AUTHTOKEN " + authToken, module); | ||
199 | |||
201 | // some needed info for when running the service | 200 | // some needed info for when running the service |
202 | Locale locale = UtilHttp.getLocale(request); | 201 | Locale locale = UtilHttp.getLocale(request); |
203 | TimeZone timeZone = UtilHttp.getTimeZone(request); | 202 | TimeZone timeZone = UtilHttp.getTimeZone(request); | ... | ... |
-
Please register or sign in to post a comment