7eca963e by Jerry Pommer

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

2 parents 59e7ce90 27c25626
......@@ -60,6 +60,7 @@ import net.sf.json.JSONObject;
public class DirectControlServlet extends HttpServlet {
public static final String module = DirectControlServlet.class.getName();
public static final Map<String, String> serviceURLMappings = new HashMap<String, String>();
private String sessionTokenName = "_AUTHTOKEN";
public void init(ServletConfig config) throws ServletException {
// get the mapping file for this webapp
......@@ -67,6 +68,10 @@ public class DirectControlServlet extends HttpServlet {
String mappingFile = context.getInitParameter("serviceURLMappings");
Debug.logError("Mapping file: " + mappingFile, module);
if (context.getInitParameter("sessionTokenName") != null) {
sessionTokenName = context.getInitParameter("sessionTokenName");
}
if (mappingFile == null) {
Debug.logError("No mapping file configured", module);
} else {
......@@ -117,19 +122,19 @@ public class DirectControlServlet extends HttpServlet {
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("_AUTHTOKEN");
authToken = (String) items.get("sessionId");
for (String key : items.keySet()) {
if (!"_AUTHTOKEN".equals(key)) {
if (!"sessionId".equals(key)) {
context.put(key, items.get(key));
Debug.logInfo("parameter '" + key + "'=" + items.get(key), module);
}
}
} else {
authToken = request.getParameter("_AUTHTOKEN");
authToken = request.getParameter("sessionId");
for (Enumeration<String> params = request.getParameterNames(); params.hasMoreElements();) {
String param = params.nextElement();
Object[] values = request.getParameterValues(param);
if (!"_AUTHTOKEN".equals(param)) {
if (!"sessionId".equals(param)) {
context.put(param, values.length == 1 ? values[0] : values);
Debug.logInfo("parameter '" + param + "'=" + context.get(param), module);
}
......@@ -155,7 +160,7 @@ public class DirectControlServlet extends HttpServlet {
}
}
// If the _AUTHTOKEN parameter is set, attempt to look up the corresponding
// If the sessionId parameter is set, attempt to look up the corresponding
// UserLogin and apply it to the service context
if (authToken != null) {
GenericValue authTokenEntity = EntityUtil.getFirst(
......