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
93372177
authored
2015-09-01 17:06:51 -0500
by
Deepak Gankidi
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'BF-6039' of /home/git/repositories/brainfood/ofbiz-directcontrolservlet
2 parents
df0c8942
b910d789
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
2 deletions
src/com/brainfood/ofbiz/DirectControlServlet.java
src/com/brainfood/ofbiz/DirectControlServlet.java
View file @
9337217
...
...
@@ -6,6 +6,7 @@ import java.io.BufferedReader;
import
java.io.StringReader
;
import
java.io.InputStreamReader
;
import
java.io.InputStream
;
import
java.io.File
;
import
java.util.Collections
;
import
java.util.Collection
;
import
java.util.Map
;
...
...
@@ -34,6 +35,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.Part
;
import
org.ofbiz.base.util.Debug
;
import
org.ofbiz.base.util.GroovyUtil
;
...
...
@@ -59,6 +61,11 @@ import org.ofbiz.service.ServiceContainer;
import
org.apache.commons.csv.CSVFormat
;
import
org.apache.commons.csv.CSVRecord
;
import
org.apache.commons.fileupload.*
;
import
org.apache.commons.fileupload.disk.DiskFileItemFactory
;
import
org.apache.commons.fileupload.disk.DiskFileItem
;
import
org.apache.commons.fileupload.servlet.ServletFileUpload
;
import
groovy.lang.GroovyClassLoader
;
import
groovy.lang.Script
;
...
...
@@ -74,9 +81,11 @@ public class DirectControlServlet extends HttpServlet {
public
static
final
Map
<
String
,
String
>
serviceURLMappings
=
new
HashMap
<
String
,
String
>();
private
String
sessionTokenName
=
"_AUTHTOKEN"
;
private
String
checkSessionService
;
private
ServletConfig
config
;
public
void
init
(
ServletConfig
config
)
throws
ServletException
{
// get the mapping file for this webapp
this
.
config
=
config
;
ServletContext
context
=
config
.
getServletContext
();
String
mappingFile
=
context
.
getInitParameter
(
"serviceURLMappings"
);
Debug
.
logInfo
(
"Mapping file: "
+
mappingFile
,
module
);
...
...
@@ -168,6 +177,25 @@ public class DirectControlServlet extends HttpServlet {
data
.
add
(
row
);
}
context
.
put
(
"data"
,
data
);
}
else
if
(
contentType
!=
null
&&
contentType
.
indexOf
(
"multipart/form-data"
)
!=
-
1
)
{
// Create a factory for disk-based file items
DiskFileItemFactory
factory
=
new
DiskFileItemFactory
();
// Configure a repository (to ensure a secure temp location is used)
ServletContext
servletContext
=
config
.
getServletContext
();
File
repository
=
(
File
)
servletContext
.
getAttribute
(
"javax.servlet.context.tempdir"
);
factory
.
setRepository
(
repository
);
ServletFileUpload
upload
=
new
ServletFileUpload
(
factory
);
//Map<String, FileItem> itemMap = new HashMap<String, FileItem>();
List
<
FileItem
>
items
=
(
List
<
FileItem
>)
upload
.
parseRequest
(
request
);
for
(
FileItem
item
:
items
)
{
Debug
.
logInfo
(
"PART: "
+
item
.
getFieldName
(),
module
);
context
.
put
(
item
.
getFieldName
(),
item
.
getString
());
}
}
else
{
// Check if the request is a backbone style "emulateJSON" request
if
(
contentType
!=
null
&&
contentType
.
indexOf
(
"x-www-form-urlencoded"
)
!=
-
1
&&
request
.
getParameter
(
"model"
)
!=
null
)
{
...
...
@@ -301,10 +329,10 @@ public class DirectControlServlet extends HttpServlet {
response
.
setContentType
(
"text/csv"
);
// Find the first list
List
resList
=
null
;
List
<
Map
>
resList
=
null
;
for
(
Object
o
:
result
.
values
())
{
if
(
o
instanceof
List
)
{
resList
=
(
List
)
o
;
resList
=
(
List
<
Map
>
)
o
;
break
;
}
}
...
...
Please
register
or
sign in
to post a comment