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. ...@@ -22,6 +22,7 @@ under the License.
22 <first id="possible.ofbiz.home.common.xml"> 22 <first id="possible.ofbiz.home.common.xml">
23 <resources> 23 <resources>
24 <fileset dir=".."> 24 <fileset dir="..">
25 <include name="apache-ofbiz/common.xml"/>
25 <include name="ofbiz/common.xml"/> 26 <include name="ofbiz/common.xml"/>
26 </fileset> 27 </fileset>
27 <fileset dir="/"> 28 <fileset dir="/">
...@@ -43,7 +44,7 @@ under the License. ...@@ -43,7 +44,7 @@ under the License.
43 <property name="name" value="direct-control"/> 44 <property name="name" value="direct-control"/>
44 45
45 <path id="local.class.path"> 46 <path id="local.class.path">
46 <!--<fileset dir="${lib.dir}" includes="*.jar"/>--> 47 <fileset dir="${lib.dir}" includes="*.jar"/>
47 <fileset dir="${ofbiz.home.dir}/framework/webapp/lib" includes="*.jar"/> 48 <fileset dir="${ofbiz.home.dir}/framework/webapp/lib" includes="*.jar"/>
48 <fileset dir="${ofbiz.home.dir}/framework/webapp/build/lib" includes="*.jar"/> 49 <fileset dir="${ofbiz.home.dir}/framework/webapp/build/lib" includes="*.jar"/>
49 <fileset dir="${ofbiz.home.dir}/framework/base/lib" includes="*.jar"/> 50 <fileset dir="${ofbiz.home.dir}/framework/base/lib" includes="*.jar"/>
......
No preview for this file type
...@@ -64,7 +64,6 @@ import groovy.lang.Script; ...@@ -64,7 +64,6 @@ import groovy.lang.Script;
64 64
65 import org.codehaus.groovy.runtime.InvokerHelper; 65 import org.codehaus.groovy.runtime.InvokerHelper;
66 import org.ofbiz.base.json.JSON; 66 import org.ofbiz.base.json.JSON;
67 import org.ofbiz.base.json.ParseException;
68 67
69 import net.sf.json.JSONObject; 68 import net.sf.json.JSONObject;
70 import net.sf.json.JsonConfig; 69 import net.sf.json.JsonConfig;
...@@ -93,6 +92,9 @@ public class DirectControlServlet extends HttpServlet { ...@@ -93,6 +92,9 @@ public class DirectControlServlet extends HttpServlet {
93 BufferedReader in = new BufferedReader(new InputStreamReader(context.getResourceAsStream(mappingFile))); 92 BufferedReader in = new BufferedReader(new InputStreamReader(context.getResourceAsStream(mappingFile)));
94 String line; 93 String line;
95 while ((line = in.readLine()) != null) { 94 while ((line = in.readLine()) != null) {
95 if (line.startsWith("#")) {
96 continue;
97 }
96 String[] confItem = line.split("="); 98 String[] confItem = line.split("=");
97 serviceURLMappings.put(confItem[0], confItem[1]); 99 serviceURLMappings.put(confItem[0], confItem[1]);
98 } 100 }
...@@ -136,6 +138,16 @@ public class DirectControlServlet extends HttpServlet { ...@@ -136,6 +138,16 @@ public class DirectControlServlet extends HttpServlet {
136 138
137 // Load context 139 // Load context
138 Map<String, Object> context = new HashMap<String, Object>(); 140 Map<String, Object> context = new HashMap<String, Object>();
141
142 // Directly copy request parameters into context.
143 for (Enumeration<String> params = request.getParameterNames(); params.hasMoreElements();) {
144 String param = params.nextElement();
145 Object[] values = request.getParameterValues(param);
146 if (!"sessionId".equals(param) && !"_method".equals(param)) {
147 context.put(param, values.length == 1 ? values[0] : values);
148 }
149 }
150
139 if ("application/json".equals(contentType)) { 151 if ("application/json".equals(contentType)) {
140 // Read request body as JSON and insert into the context 152 // Read request body as JSON and insert into the context
141 JSON json = new JSON(request.getReader()); 153 JSON json = new JSON(request.getReader());
...@@ -144,15 +156,6 @@ public class DirectControlServlet extends HttpServlet { ...@@ -144,15 +156,6 @@ public class DirectControlServlet extends HttpServlet {
144 context.put(key, items.get(key)); 156 context.put(key, items.get(key));
145 } 157 }
146 } else if ("text/csv".equals(contentType)) { 158 } else if ("text/csv".equals(contentType)) {
147 // Directly copy request parameters into context.
148 for (Enumeration<String> params = request.getParameterNames(); params.hasMoreElements();) {
149 String param = params.nextElement();
150 Object[] values = request.getParameterValues(param);
151 if (!"sessionId".equals(param) && !"_method".equals(param)) {
152 context.put(param, values.length == 1 ? values[0] : values);
153 }
154 }
155
156 Iterable<CSVRecord> records = CSVFormat.EXCEL.parse(request.getReader()); 159 Iterable<CSVRecord> records = CSVFormat.EXCEL.parse(request.getReader());
157 List<List<String>> data = new ArrayList<List<String>>(); 160 List<List<String>> data = new ArrayList<List<String>>();
158 for (CSVRecord record : records) { 161 for (CSVRecord record : records) {
...@@ -176,15 +179,6 @@ public class DirectControlServlet extends HttpServlet { ...@@ -176,15 +179,6 @@ public class DirectControlServlet extends HttpServlet {
176 context.put(key, items.get(key)); 179 context.put(key, items.get(key));
177 } 180 }
178 } 181 }
179 } else {
180 // Directly copy request parameters into context.
181 for (Enumeration<String> params = request.getParameterNames(); params.hasMoreElements();) {
182 String param = params.nextElement();
183 Object[] values = request.getParameterValues(param);
184 if (!"sessionId".equals(param) && !"_method".equals(param)) {
185 context.put(param, values.length == 1 ? values[0] : values);
186 }
187 }
188 } 182 }
189 } 183 }
190 184
......