27a74df2 by Ean Schuessler

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

2 parents ba0e1190 405d4072
......@@ -97,11 +97,12 @@ public class DirectControlServlet extends HttpServlet {
}
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String pathInfo = request.getPathInfo();
String contentType = request.getContentType();
try {
Debug.logInfo("getPathInfo: " + request.getPathInfo() +
" request.getContentType: " + request.getContentType(), module);
Debug.logInfo("getPathInfo: " + pathInfo +
" request.getContentType: " + contentType, module);
String pathInfo = request.getPathInfo();
if (pathInfo == null || pathInfo.length() == 0) {
return;
}
......@@ -109,7 +110,12 @@ public class DirectControlServlet extends HttpServlet {
// Determine type of request and load the context from JSON content or
// parameter values accordingly
String contentType = request.getContentType();
if (contentType != null) {
int semi = contentType.indexOf(";");
if (semi != -1) {
contentType = contentType.substring(0, semi);
}
}
// Determine the request method for service lookup and parameter filters
String method = "";
......@@ -122,15 +128,15 @@ public class DirectControlServlet extends HttpServlet {
Map<String, Object> context = new HashMap<String, Object>();
if ("application/json".equals(contentType)) {
// Read request body as JSON and insert into the context
JSON json = new JSON(new InputStreamReader(request.getInputStream()));
JSON json = new JSON(request.getReader());
Map<String,Object> items = json.JSONObject();
for (String key : items.keySet()) {
context.put(key, items.get(key));
}
} else {
// Check if the request is a backbone style "emulateJSON" request
if (request.getContentType() != null &&
request.getContentType().indexOf("x-www-form-urlencoded") != -1 &&
if (contentType != null &&
contentType.indexOf("x-www-form-urlencoded") != -1 &&
request.getParameter("model") != null) {
Debug.logInfo("MODEL: " + request.getParameter("model"), module);
JSON json = new JSON(new StringReader(request.getParameter("model")));
......