72178d74 by Ean Schuessler

Merge branch 'BF-2757' of /home/git/repositories/brainfood/ofbiz-directcontrolservlet

2 parents 6235725a 0c9488ab
......@@ -119,37 +119,33 @@ public class DirectControlServlet extends HttpServlet {
Debug.logInfo("PARAMETERS: " + paramList, module);
// Handle if this is a form post
String contentType = request.getContentType();
if (contentType != null && contentType.indexOf("x-www-form-urlencoded") != -1) {
method = request.getParameter("_method");
String httpMethod = request.getMethod();
if (method == null && httpMethod != null) method = httpMethod;
Debug.logInfo("Method: HTTP(" + httpMethod + ") embedded(" + method + ")", module);
if (method == null) method = "GET";
// If this is a backbone PUT/DELETE emulated call then handle it
if (request.getParameter("model") != null) {
method = request.getParameter("_method");
String httpMethod = request.getMethod();
if (method == null && httpMethod != null) method = httpMethod;
Debug.logInfo("Method: HTTP(" + httpMethod + ") embedded(" + method + ")", module);
if (method == null) method = "GET";
// If this is a backbone PUT/DELETE emulated call then handle it
if (request.getParameter("model") != null) {
// if (!"CALL".equals(method)) context.put("_method", method);
JSON json = new JSON(new StringReader(request.getParameter("model")));
Map<String,Object> items = json.JSONObject();
for (String key : items.keySet()) {
if (!"sessionId".equals(key) && !"_method".equals(key)) {
context.put(key, items.get(key));
Debug.logInfo(">parameter '" + key + "'=" + items.get(key), module);
}
}
} else {
for (Enumeration<String> params = request.getParameterNames(); params.hasMoreElements();) {
String param = params.nextElement();
Object[] values = request.getParameterValues(param);
if (!"sessionId".equals(param) && !"_method".equals(param)) {
context.put(param, values.length == 1 ? values[0] : values);
Debug.logInfo("!parameter '" + param + "'=" + context.get(param), module);
}
JSON json = new JSON(new StringReader(request.getParameter("model")));
Map<String,Object> items = json.JSONObject();
for (String key : items.keySet()) {
if (!"sessionId".equals(key) && !"_method".equals(key)) {
context.put(key, items.get(key));
Debug.logInfo(">parameter '" + key + "'=" + items.get(key), module);
}
}
} else {
Debug.logInfo("Unsupported form encoding", module);
for (Enumeration<String> params = request.getParameterNames(); params.hasMoreElements();) {
String param = params.nextElement();
Object[] values = request.getParameterValues(param);
if (!"sessionId".equals(param) && !"_method".equals(param)) {
context.put(param, values.length == 1 ? values[0] : values);
Debug.logInfo("!parameter '" + param + "'=" + context.get(param), module);
}
}
}
// If there is a mapping for this pathInfo, run the corresponding service
// otherwise, return an error
String serviceName = serviceURLMappings.get(pathInfo + "#" + method);
......