blob: b7608cd655c681f3f33de779aac4bd00e8a61ee0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*
@ITMillApache2LicenseForJavaFiles@
*/
package com.vaadin.terminal;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.Map;
/**
* A {@link WrappedRequest} with path and parameters from one request and
* {@link BrowserDetails} extracted from another request.
*
* This class is intended to be used for a two request initialization where the
* first request fetches the actual application page and the second request
* contains information extracted from the browser using javascript.
*
*/
public class CombinedRequest implements WrappedRequest {
private final WrappedRequest secondRequest;
private final Map<String, String[]> parameterMap;
private final String pathInfo;
public CombinedRequest(WrappedRequest secondRequest,
Map<String, String[]> parameterMap, String pathInfo) {
this.secondRequest = secondRequest;
this.parameterMap = parameterMap;
this.pathInfo = pathInfo;
}
public String getParameter(String parameter) {
String[] strings = parameterMap.get(parameter);
if (strings == null || strings.length == 0) {
return null;
} else {
return strings[0];
}
}
public Map<String, String[]> getParameterMap() {
return Collections.unmodifiableMap(parameterMap);
}
public int getContentLength() {
return secondRequest.getContentLength();
}
public InputStream getInputStream() throws IOException {
return secondRequest.getInputStream();
}
public Object getAttribute(String name) {
return secondRequest.getAttribute(name);
}
public void setAttribute(String name, Object value) {
secondRequest.setAttribute(name, value);
}
public String getRequestPathInfo() {
return pathInfo;
}
public int getSessionMaxInactiveInterval() {
return secondRequest.getSessionMaxInactiveInterval();
}
public Object getSessionAttribute(String name) {
return secondRequest.getSessionAttribute(name);
}
public void setSessionAttribute(String name, Object attribute) {
secondRequest.setSessionAttribute(name, attribute);
}
public String getContentType() {
return secondRequest.getContentType();
}
public String getStaticFileLocation() {
return secondRequest.getStaticFileLocation();
}
public BrowserDetails getBrowserDetails() {
return new BrowserDetails() {
public String getUriFragmet() {
return secondRequest.getParameter("f");
}
};
}
public WrappedRequest getSecondRequest() {
return secondRequest;
}
}
|