stubbed in servlet
0 parents
Showing
3 changed files
with
150 additions
and
0 deletions
build.xml
0 → 100644
1 | <?xml version="1.0"?> | ||
2 | <!-- | ||
3 | Licensed to the Apache Software Foundation (ASF) under one | ||
4 | or more contributor license agreements. See the NOTICE file | ||
5 | distributed with this work for additional information | ||
6 | regarding copyright ownership. The ASF licenses this file | ||
7 | to you under the Apache License, Version 2.0 (the | ||
8 | "License"); you may not use this file except in compliance | ||
9 | with the License. You may obtain a copy of the License at | ||
10 | |||
11 | http://www.apache.org/licenses/LICENSE-2.0 | ||
12 | |||
13 | Unless required by applicable law or agreed to in writing, | ||
14 | software distributed under the License is distributed on an | ||
15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
16 | KIND, either express or implied. See the License for the | ||
17 | specific language governing permissions and limitations | ||
18 | under the License. | ||
19 | --> | ||
20 | |||
21 | <project name="nginx-uploader" default="jar" basedir="."> | ||
22 | <property name="ofbiz.home.dir" value="../ofbiz"/> | ||
23 | <import file="${ofbiz.home.dir}/common.xml"/> | ||
24 | |||
25 | <!-- ================================================================== --> | ||
26 | <!-- Initialization of all property settings --> | ||
27 | <!-- ================================================================== --> | ||
28 | |||
29 | <property name="desc" value="NGINX Upload emulator"/> | ||
30 | <property name="name" value="nginx-uploader"/> | ||
31 | |||
32 | <path id="local.class.path"> | ||
33 | <!--<fileset dir="${lib.dir}" includes="*.jar"/>--> | ||
34 | <fileset dir="${ofbiz.home.dir}/framework/webapp/lib" includes="*.jar"/> | ||
35 | <fileset dir="${ofbiz.home.dir}/framework/webapp/build/lib" includes="*.jar"/> | ||
36 | <fileset dir="${ofbiz.home.dir}/framework/base/lib" includes="*.jar"/> | ||
37 | <fileset dir="${ofbiz.home.dir}/framework/base/lib/commons" includes="*.jar"/> | ||
38 | <fileset dir="${ofbiz.home.dir}/framework/base/lib/scripting" includes="*.jar"/> | ||
39 | <fileset dir="${ofbiz.home.dir}/framework/base/lib/j2eespecs" includes="*.jar"/> | ||
40 | <fileset dir="${ofbiz.home.dir}/framework/base/build/lib" includes="*.jar"/> | ||
41 | <fileset dir="${ofbiz.home.dir}/framework/entity/lib" includes="*.jar"/> | ||
42 | <fileset dir="${ofbiz.home.dir}/framework/entity/build/lib" includes="*.jar"/> | ||
43 | <fileset dir="${ofbiz.home.dir}/framework/security/build/lib" includes="*.jar"/> | ||
44 | <fileset dir="${ofbiz.home.dir}/framework/service/lib" includes="*.jar"/> | ||
45 | <fileset dir="${ofbiz.home.dir}/framework/service/build/lib" includes="*.jar"/> | ||
46 | <fileset dir="${ofbiz.home.dir}/framework/minilang/build/lib" includes="*.jar"/> | ||
47 | <fileset dir="${ofbiz.home.dir}/framework/common/build/lib" includes="*.jar"/> | ||
48 | <fileset dir="${ofbiz.home.dir}/framework/webapp/build/lib" includes="*.jar"/> | ||
49 | <fileset dir="${ofbiz.home.dir}/applications/party/build/lib" includes="*.jar"/> | ||
50 | <fileset dir="${ofbiz.home.dir}/applications/product/build/lib" includes="*.jar"/> | ||
51 | <fileset dir="${ofbiz.home.dir}/applications/marketing/build/lib" includes="*.jar"/> | ||
52 | <fileset dir="${ofbiz.home.dir}/applications/order/build/lib" includes="*.jar"/> | ||
53 | <fileset dir="${ofbiz.home.dir}/applications/accounting/build/lib" includes="*.jar"/> | ||
54 | <fileset dir="${ofbiz.home.dir}/applications/securityext/build/lib" includes="*.jar"/> | ||
55 | |||
56 | <fileset dir="${ofbiz.home.dir}/framework/start/build/lib" includes="*.jar"/> | ||
57 | <fileset dir="${ofbiz.home.dir}/framework/catalina/lib" includes="*.jar"/> | ||
58 | </path> | ||
59 | </project> |
ofbiz-component.xml
0 → 100644
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ofbiz-component name="nginxuploader" | ||
3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/ofbiz-component.xsd"> | ||
5 | <resource-loader name="main" type="component"/> | ||
6 | |||
7 | <classpath type="dir" location="config"/> | ||
8 | <classpath type="jar" location="lib/*"/> | ||
9 | <classpath type="jar" location="build/lib/*"/> | ||
10 | |||
11 | <webapp name="nginx-uploader" | ||
12 | title="Big Fun Print Client Files" | ||
13 | server="default-server" | ||
14 | location="www" | ||
15 | mount-point="/upload" | ||
16 | app-bar-display="false"/> | ||
17 | |||
18 | </ofbiz-component> | ||
19 |
1 | package com.brainfood.servlet; | ||
2 | |||
3 | import java.io.IOException; | ||
4 | import java.io.File; | ||
5 | import java.io.PrintWriter; | ||
6 | import java.util.List; | ||
7 | |||
8 | import javax.servlet.*; | ||
9 | import javax.servlet.http.*; | ||
10 | |||
11 | import org.apache.commons.fileupload.*; | ||
12 | import org.apache.commons.fileupload.disk.DiskFileItemFactory; | ||
13 | import org.apache.commons.fileupload.servlet.ServletFileUpload; | ||
14 | |||
15 | public class NGINXUploadProcessor extends HttpServlet { | ||
16 | private static final long serialVersionUID = 1L; | ||
17 | |||
18 | @Override | ||
19 | public void destroy() { | ||
20 | // TODO Auto-generated method stub | ||
21 | } | ||
22 | |||
23 | @Override | ||
24 | public ServletConfig getServletConfig() { | ||
25 | // TODO Auto-generated method stub | ||
26 | return null; | ||
27 | } | ||
28 | |||
29 | @Override | ||
30 | public String getServletInfo() { | ||
31 | // TODO Auto-generated method stub | ||
32 | return null; | ||
33 | } | ||
34 | |||
35 | @Override | ||
36 | public void init(ServletConfig config) throws ServletException { | ||
37 | // TODO Auto-generated method stub | ||
38 | } | ||
39 | |||
40 | @Override | ||
41 | public void service(HttpServletRequest request, HttpServletResponse response) | ||
42 | throws ServletException, IOException { | ||
43 | if (ServletFileUpload.isMultipartContent(request)) { | ||
44 | // Create a factory for disk-based file items | ||
45 | DiskFileItemFactory factory = new DiskFileItemFactory(); | ||
46 | |||
47 | // Configure a repository (to ensure a secure temp location is used) | ||
48 | ServletContext servletContext = this.getServletConfig() | ||
49 | .getServletContext(); | ||
50 | File repository = (File) servletContext | ||
51 | .getAttribute("javax.servlet.context.tempdir"); | ||
52 | factory.setRepository(repository); | ||
53 | |||
54 | // Create a new file upload handler | ||
55 | ServletFileUpload upload = new ServletFileUpload(factory); | ||
56 | |||
57 | // Parse the request | ||
58 | PrintWriter out = new PrintWriter(response.getWriter()); | ||
59 | try { | ||
60 | List<?> items = upload.parseRequest(request); | ||
61 | out.println(items); | ||
62 | } catch (Exception ex) { | ||
63 | ex.printStackTrace(); | ||
64 | } | ||
65 | out.close(); | ||
66 | } else { | ||
67 | PrintWriter out = new PrintWriter(response.getWriter()); | ||
68 | out.println("Must be a multipart upload"); | ||
69 | out.close(); | ||
70 | } | ||
71 | } | ||
72 | } |
-
Please register or sign in to post a comment