Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
ofbiz-directcontrolservlet
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
498612c9
authored
2016-07-04 18:08:57 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Changes to support latest ofbiz upstream.
1 parent
2d2edf98
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
14 deletions
src/com/brainfood/ofbiz/DirectControlServlet.java
src/com/brainfood/ofbiz/DirectControlServlet.java
View file @
498612c
...
...
@@ -37,11 +37,13 @@ import javax.servlet.http.HttpSession;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.Part
;
import
org.ofbiz.base.lang.JSON
;
import
org.ofbiz.base.util.Debug
;
import
org.ofbiz.base.util.GroovyUtil
;
import
org.ofbiz.base.util.ScriptHelper
;
import
org.ofbiz.base.util.ScriptUtil
;
import
org.ofbiz.base.util.StringUtil
;
import
org.ofbiz.base.util.UtilGenerics
;
import
org.ofbiz.base.util.UtilHttp
;
import
org.ofbiz.base.util.UtilMisc
;
import
org.ofbiz.base.util.UtilProperties
;
...
...
@@ -70,7 +72,6 @@ import groovy.lang.GroovyClassLoader;
import
groovy.lang.Script
;
import
org.codehaus.groovy.runtime.InvokerHelper
;
import
org.ofbiz.base.json.JSON
;
import
net.sf.json.JSONObject
;
import
net.sf.json.JsonConfig
;
...
...
@@ -158,10 +159,9 @@ public class DirectControlServlet extends HttpServlet {
if
(
"application/json"
.
equals
(
contentType
))
{
// Read request body as JSON and insert into the context
JSON
json
=
new
JSON
(
request
.
getReader
());
Map
<
String
,
Object
>
items
=
json
.
JSONObject
();
for
(
String
key
:
items
.
keySet
())
{
context
.
put
(
key
,
items
.
get
(
key
));
Map
<
String
,
Object
>
items
=
UtilGenerics
.
cast
(
JSON
.
from
(
UtilIO
.
readString
(
request
.
getReader
())).
toObject
(
Map
.
class
));
for
(
Object
key
:
items
.
keySet
())
{
context
.
put
((
String
)
key
,
items
.
get
(
key
));
}
}
else
if
(
"text/csv"
.
equals
(
contentType
))
{
Iterable
<
CSVRecord
>
records
=
CSVFormat
.
EXCEL
.
parse
(
request
.
getReader
());
...
...
@@ -199,11 +199,10 @@ public class DirectControlServlet extends HttpServlet {
// Check if the request is a backbone style "emulateJSON" request
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"
)));
Map
<
String
,
Object
>
items
=
json
.
JSONObject
();
for
(
String
key
:
items
.
keySet
())
{
Map
<
String
,
Object
>
items
=
UtilGenerics
.
cast
(
JSON
.
from
(
UtilIO
.
readString
(
request
.
getReader
())).
toObject
(
Map
.
class
));
for
(
Object
key
:
items
.
keySet
())
{
if
(!
"sessionId"
.
equals
(
key
))
{
context
.
put
(
key
,
items
.
get
(
key
));
context
.
put
(
(
String
)
key
,
items
.
get
(
key
));
}
}
}
...
...
@@ -313,11 +312,7 @@ public class DirectControlServlet extends HttpServlet {
PrintWriter
writer
=
response
.
getWriter
();
JsonConfig
jsonConfig
=
new
JsonConfig
();
jsonConfig
.
registerJsonValueProcessor
(
Date
.
class
,
new
ISODateValueProcessor
());
jsonConfig
.
registerJsonValueProcessor
(
Timestamp
.
class
,
new
ISODateValueProcessor
());
JSONObject
json
=
JSONObject
.
fromObject
(
result
,
jsonConfig
);
String
jsonStr
=
json
.
toString
();
String
jsonStr
=
JSON
.
from
(
result
).
toString
();
response
.
setContentLength
(
jsonStr
.
getBytes
(
"UTF8"
).
length
);
writer
.
write
(
jsonStr
);
writer
.
flush
();
...
...
Please
register
or
sign in
to post a comment