1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.wysiwyg.server.internal.filter.http; |
21 |
|
|
22 |
|
import java.io.IOException; |
23 |
|
import java.util.Collections; |
24 |
|
import java.util.Enumeration; |
25 |
|
import java.util.HashMap; |
26 |
|
import java.util.Map; |
27 |
|
|
28 |
|
import javax.servlet.ServletResponse; |
29 |
|
import javax.servlet.http.HttpServletRequest; |
30 |
|
import javax.servlet.http.HttpServletRequestWrapper; |
31 |
|
import javax.servlet.http.HttpServletResponse; |
32 |
|
|
33 |
|
import org.xwiki.wysiwyg.server.filter.MutableServletRequest; |
34 |
|
|
35 |
|
|
36 |
|
@link |
37 |
|
|
38 |
|
@version |
39 |
|
|
|
|
| 88.9% |
Uncovered Elements: 4 (36) |
Complexity: 18 |
Complexity Density: 1 |
|
40 |
|
public class MutableHttpServletRequest extends HttpServletRequestWrapper implements MutableServletRequest |
41 |
|
{ |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
private final Map<String, String[]> params = new HashMap<String, String[]>(); |
47 |
|
|
48 |
|
|
49 |
|
@link |
50 |
|
|
51 |
|
@param |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
53 |
5 |
@SuppressWarnings("unchecked")... |
54 |
|
public MutableHttpServletRequest(HttpServletRequest request) |
55 |
|
{ |
56 |
5 |
super(request); |
57 |
|
|
58 |
5 |
params.putAll(request.getParameterMap()); |
59 |
|
} |
60 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
61 |
5 |
@Override... |
62 |
|
public String setParameter(String name, String value) |
63 |
|
{ |
64 |
5 |
String[] previousValues = params.put(name, new String[] {value}); |
65 |
5 |
return (previousValues == null || previousValues.length == 0) ? null : previousValues[0]; |
66 |
|
} |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
68 |
0 |
@Override... |
69 |
|
public String[] setParameterValues(String name, String[] values) |
70 |
|
{ |
71 |
0 |
return params.put(name, values); |
72 |
|
} |
73 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
74 |
12 |
@Override... |
75 |
|
public String removeParameter(String name) |
76 |
|
{ |
77 |
12 |
String[] previousValues = params.remove(name); |
78 |
12 |
return (previousValues == null || previousValues.length == 0) ? null : previousValues[0]; |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
81 |
166 |
@Override... |
82 |
|
public String getParameter(String name) |
83 |
|
{ |
84 |
166 |
String[] values = params.get(name); |
85 |
166 |
return (values == null || values.length == 0) ? null : values[0]; |
86 |
|
} |
87 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
5 |
@Override... |
89 |
|
public Map<String, String[]> getParameterMap() |
90 |
|
{ |
91 |
5 |
return Collections.unmodifiableMap(params); |
92 |
|
} |
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
94 |
5 |
@Override... |
95 |
|
public Enumeration<String> getParameterNames() |
96 |
|
{ |
97 |
5 |
return Collections.enumeration(params.keySet()); |
98 |
|
} |
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
100 |
68 |
@Override... |
101 |
|
public String[] getParameterValues(String name) |
102 |
|
{ |
103 |
68 |
return params.get(name); |
104 |
|
} |
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
106 |
1 |
@Override... |
107 |
|
public void sendRedirect(ServletResponse res, String url) throws IOException |
108 |
|
{ |
109 |
1 |
((HttpServletResponse) res).sendRedirect(url); |
110 |
|
} |
111 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
1 |
@Override... |
113 |
|
public String getReferer() |
114 |
|
{ |
115 |
1 |
return getHeader("Referer"); |
116 |
|
} |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
118 |
2 |
@Override... |
119 |
|
public Object getSessionAttribute(String attrName) |
120 |
|
{ |
121 |
2 |
return getSession().getAttribute(attrName); |
122 |
|
} |
123 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
124 |
2 |
@Override... |
125 |
|
public Object setSessionAttribute(String attrName, Object attrValue) |
126 |
|
{ |
127 |
2 |
Object oldValue = getSession().getAttribute(attrName); |
128 |
2 |
getSession().setAttribute(attrName, attrValue); |
129 |
2 |
return oldValue; |
130 |
|
} |
131 |
|
} |