df0c8942 by Ean Schuessler

Merge branch 'BF-5727-5729-5731' of /home/git/repositories/brainfood/ofbiz-directcontrolservlet

2 parents 494816c9 0eec71bc
......@@ -22,6 +22,7 @@ under the License.
<first id="possible.ofbiz.home.common.xml">
<resources>
<fileset dir="..">
<include name="apache-ofbiz/common.xml"/>
<include name="ofbiz/common.xml"/>
</fileset>
<fileset dir="/">
......@@ -43,7 +44,7 @@ under the License.
<property name="name" value="direct-control"/>
<path id="local.class.path">
<!--<fileset dir="${lib.dir}" includes="*.jar"/>-->
<fileset dir="${lib.dir}" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/webapp/lib" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/webapp/build/lib" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib" includes="*.jar"/>
......
No preview for this file type
......@@ -64,7 +64,6 @@ import groovy.lang.Script;
import org.codehaus.groovy.runtime.InvokerHelper;
import org.ofbiz.base.json.JSON;
import org.ofbiz.base.json.ParseException;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
......@@ -93,6 +92,9 @@ public class DirectControlServlet extends HttpServlet {
BufferedReader in = new BufferedReader(new InputStreamReader(context.getResourceAsStream(mappingFile)));
String line;
while ((line = in.readLine()) != null) {
if (line.startsWith("#")) {
continue;
}
String[] confItem = line.split("=");
serviceURLMappings.put(confItem[0], confItem[1]);
}
......@@ -136,6 +138,16 @@ public class DirectControlServlet extends HttpServlet {
// Load context
Map<String, Object> context = new HashMap<String, Object>();
// Directly copy request parameters into context.
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);
}
}
if ("application/json".equals(contentType)) {
// Read request body as JSON and insert into the context
JSON json = new JSON(request.getReader());
......@@ -144,15 +156,6 @@ public class DirectControlServlet extends HttpServlet {
context.put(key, items.get(key));
}
} else if ("text/csv".equals(contentType)) {
// Directly copy request parameters into context.
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);
}
}
Iterable<CSVRecord> records = CSVFormat.EXCEL.parse(request.getReader());
List<List<String>> data = new ArrayList<List<String>>();
for (CSVRecord record : records) {
......@@ -176,15 +179,6 @@ public class DirectControlServlet extends HttpServlet {
context.put(key, items.get(key));
}
}
} else {
// Directly copy request parameters into context.
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);
}
}
}
}
......