1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.shared.renderkit.html.util; |
20 | |
|
21 | |
import java.io.IOException; |
22 | |
import java.io.InputStream; |
23 | |
import java.lang.reflect.InvocationTargetException; |
24 | |
import java.lang.reflect.Method; |
25 | |
import java.util.Collection; |
26 | |
import javax.faces.FacesException; |
27 | |
import javax.faces.FacesWrapper; |
28 | |
import javax.faces.component.StateHolder; |
29 | |
import javax.faces.context.FacesContext; |
30 | |
import javax.servlet.http.Part; |
31 | |
|
32 | 0 | public class HttpPartWrapper implements Part, FacesWrapper<Part>, StateHolder |
33 | |
{ |
34 | |
private Part delegate; |
35 | |
|
36 | |
public HttpPartWrapper() |
37 | 0 | { |
38 | 0 | } |
39 | |
|
40 | |
public HttpPartWrapper(Part delegate) |
41 | 0 | { |
42 | 0 | this.delegate = delegate; |
43 | 0 | } |
44 | |
|
45 | |
public void delete() throws IOException |
46 | |
{ |
47 | 0 | getWrapped().delete(); |
48 | 0 | } |
49 | |
|
50 | |
public String getContentType() |
51 | |
{ |
52 | 0 | return getWrapped().getContentType(); |
53 | |
} |
54 | |
|
55 | |
public String getHeader(String headerName) |
56 | |
{ |
57 | 0 | return getWrapped().getHeader(headerName); |
58 | |
} |
59 | |
|
60 | |
public Collection<String> getHeaderNames() |
61 | |
{ |
62 | 0 | return getWrapped().getHeaderNames(); |
63 | |
} |
64 | |
|
65 | |
public Collection<String> getHeaders(String headerName) |
66 | |
{ |
67 | 0 | return getWrapped().getHeaders(headerName); |
68 | |
} |
69 | |
|
70 | |
public InputStream getInputStream() throws IOException |
71 | |
{ |
72 | 0 | return getWrapped().getInputStream(); |
73 | |
} |
74 | |
|
75 | |
public String getName() |
76 | |
{ |
77 | 0 | return getWrapped().getName(); |
78 | |
} |
79 | |
|
80 | |
public long getSize() |
81 | |
{ |
82 | 0 | return getWrapped().getSize(); |
83 | |
} |
84 | |
|
85 | |
public void write(String fileName) throws IOException |
86 | |
{ |
87 | 0 | getWrapped().write(fileName); |
88 | 0 | } |
89 | |
|
90 | |
public String getSubmittedFileName() |
91 | |
{ |
92 | 0 | Part wrapped = getWrapped(); |
93 | |
try |
94 | |
{ |
95 | 0 | Method m = wrapped.getClass().getMethod("getSubmittedFileName"); |
96 | 0 | return (String) m.invoke(wrapped); |
97 | |
} |
98 | 0 | catch (NoSuchMethodException ex) |
99 | |
{ |
100 | 0 | throw new FacesException(ex); |
101 | |
} |
102 | 0 | catch (SecurityException ex) |
103 | |
{ |
104 | 0 | throw new FacesException(ex); |
105 | |
} |
106 | 0 | catch (IllegalAccessException ex) |
107 | |
{ |
108 | 0 | throw new FacesException(ex); |
109 | |
} |
110 | 0 | catch (IllegalArgumentException ex) |
111 | |
{ |
112 | 0 | throw new FacesException(ex); |
113 | |
} |
114 | 0 | catch (InvocationTargetException ex) |
115 | |
{ |
116 | 0 | throw new FacesException(ex); |
117 | |
} |
118 | |
} |
119 | |
|
120 | |
public Object saveState(FacesContext context) |
121 | |
{ |
122 | 0 | return null; |
123 | |
} |
124 | |
|
125 | |
public void restoreState(FacesContext context, Object state) |
126 | |
{ |
127 | 0 | } |
128 | |
|
129 | |
public boolean isTransient() |
130 | |
{ |
131 | 0 | return true; |
132 | |
} |
133 | |
|
134 | |
public void setTransient(boolean newTransientValue) |
135 | |
{ |
136 | 0 | } |
137 | |
|
138 | |
public Part getWrapped() |
139 | |
{ |
140 | 0 | return delegate; |
141 | |
} |
142 | |
|
143 | |
} |