1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| package org.apache.tapestry.portlet.multipart; |
15 |
| |
16 |
| import java.io.IOException; |
17 |
| |
18 |
| import javax.portlet.ActionRequest; |
19 |
| import javax.portlet.ActionResponse; |
20 |
| import javax.portlet.PortletException; |
21 |
| |
22 |
| import org.apache.tapestry.portlet.ActionRequestServicer; |
23 |
| import org.apache.tapestry.portlet.ActionRequestServicerFilter; |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| public class PortletMultipartDecoderFilter implements ActionRequestServicerFilter |
30 |
| { |
31 |
| private PortletMultipartDecoder _decoder; |
32 |
| |
33 |
0
| public void service(ActionRequest request, ActionResponse response,
|
34 |
| ActionRequestServicer servicer) throws IOException, PortletException |
35 |
| { |
36 |
0
| String contentType = request.getContentType();
|
37 |
| |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
0
| boolean encoded = contentType != null && contentType.startsWith("multipart/form-data");
|
43 |
| |
44 |
0
| try
|
45 |
| { |
46 |
0
| ActionRequest newRequest = encoded ? _decoder.decode(request) : request;
|
47 |
| |
48 |
0
| servicer.service(newRequest, response);
|
49 |
| } |
50 |
| finally |
51 |
| { |
52 |
0
| if (encoded)
|
53 |
0
| _decoder.cleanup();
|
54 |
| } |
55 |
| } |
56 |
| |
57 |
0
| public void setDecoder(PortletMultipartDecoder decoder) {
|
58 |
0
| this._decoder = decoder;
|
59 |
| } |
60 |
| |
61 |
| } |