2c98ab02 by Ean Schuessler

Check for model parameter to detect compatibility

1 parent 15b9531c
......@@ -111,14 +111,12 @@ public class DirectControlServlet extends HttpServlet {
// Build context
Map<String, Object> context = new HashMap<String, Object>();
String authToken = null;
String paramList = "";
for (Iterator<String> k = request.getParameterMap().keySet().iterator(); k.hasNext(); ) {
paramList += " " + k.next();
}
Debug.logInfo("PARAMETERS: " + request.getParameterMap(), module);
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) {
......@@ -128,25 +126,23 @@ public class DirectControlServlet extends HttpServlet {
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 ("PUT".equals(method) || "DELETE".equals(method) || "CALL".equals(method) || "POST".equals(method)) {
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();
authToken = (String) items.get("sessionId");
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);
Debug.logInfo(">parameter '" + key + "'=" + items.get(key), module);
}
}
} else {
authToken = request.getParameter("sessionId");
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);
Debug.logInfo("!parameter '" + param + "'=" + context.get(param), module);
}
}
}
......@@ -177,6 +173,7 @@ public class DirectControlServlet extends HttpServlet {
// If the sessionId parameter is set, attempt to look up the corresponding
// UserLogin and apply it to the service context
String authToken = request.getParameter("sessionId");
if (authToken != null) {
GenericValue authTokenEntity = EntityUtil.getFirst(
delegator.findList("Visit",
......@@ -198,6 +195,8 @@ public class DirectControlServlet extends HttpServlet {
}
}
Debug.logInfo("USERLOGIN " + context.get("userLogin") + " AUTHTOKEN " + authToken, module);
// some needed info for when running the service
Locale locale = UtilHttp.getLocale(request);
TimeZone timeZone = UtilHttp.getTimeZone(request);
......