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
0c9488ab
authored
2014-04-24 12:34:12 -0500
by
Jerry Pommer
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Issue #2757 - Workaround to make GETs work under Node.
1 parent
6235725a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
26 deletions
src/com/brainfood/ofbiz/DirectControlServlet.java
src/com/brainfood/ofbiz/DirectControlServlet.java
View file @
0c9488a
...
...
@@ -119,37 +119,33 @@ public class DirectControlServlet extends HttpServlet {
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
)
{
method
=
request
.
getParameter
(
"_method"
);
String
httpMethod
=
request
.
getMethod
();
if
(
method
==
null
&&
httpMethod
!=
null
)
method
=
httpMethod
;
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
(
request
.
getParameter
(
"model"
)
!=
null
)
{
method
=
request
.
getParameter
(
"_method"
);
String
httpMethod
=
request
.
getMethod
();
if
(
method
==
null
&&
httpMethod
!=
null
)
method
=
httpMethod
;
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
(
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
();
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
);
}
}
}
else
{
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
);
}
JSON
json
=
new
JSON
(
new
StringReader
(
request
.
getParameter
(
"model"
)));
Map
<
String
,
Object
>
items
=
json
.
JSONObject
();
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
);
}
}
}
else
{
Debug
.
logInfo
(
"Unsupported form encoding"
,
module
);
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
);
}
}
}
// If there is a mapping for this pathInfo, run the corresponding service
// otherwise, return an error
String
serviceName
=
serviceURLMappings
.
get
(
pathInfo
+
"#"
+
method
);
...
...
Please
register
or
sign in
to post a comment