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 |
|
package info.magnolia.module.cache.filter; |
35 |
|
|
36 |
|
import java.io.IOException; |
37 |
|
import java.io.Serializable; |
38 |
|
|
39 |
|
import javax.servlet.FilterChain; |
40 |
|
import javax.servlet.ServletException; |
41 |
|
import javax.servlet.http.HttpServletRequest; |
42 |
|
import javax.servlet.http.HttpServletResponse; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
@author |
47 |
|
@version |
48 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
49 |
|
public class CachedRedirect implements CachedEntry, Serializable { |
50 |
|
|
51 |
|
private final int statusCode; |
52 |
|
private final String location; |
53 |
|
private long timestamp; |
54 |
|
private String originalUrl; |
55 |
|
private int timeToLiveInSeconds = -1; |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
57 |
1 |
public CachedRedirect(int statusCode, String location, String originalUrl, int timeToLiveInSeconds) {... |
58 |
1 |
this.statusCode = statusCode; |
59 |
1 |
this.location = location; |
60 |
1 |
this.originalUrl = originalUrl; |
61 |
1 |
this.timestamp = System.currentTimeMillis(); |
62 |
1 |
this.timeToLiveInSeconds = timeToLiveInSeconds; |
63 |
|
} |
64 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
65 |
|
public int getStatusCode() {... |
66 |
|
return statusCode; |
67 |
|
} |
68 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
69 |
|
public String getLocation() {... |
70 |
|
return location; |
71 |
|
} |
72 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
73 |
1 |
@Override... |
74 |
|
public void replay(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { |
75 |
|
|
76 |
|
|
77 |
1 |
if (!response.isCommitted()) { |
78 |
1 |
response.sendRedirect(getLocation()); |
79 |
|
} |
80 |
|
} |
81 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
82 |
|
@Override... |
83 |
|
public String getOriginalURL() { |
84 |
|
return originalUrl; |
85 |
|
} |
86 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
87 |
|
@Override... |
88 |
|
public long getLastModificationTime() { |
89 |
|
return timestamp; |
90 |
|
} |
91 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
92 |
|
@Override... |
93 |
|
public int getTimeToLiveInSeconds() { |
94 |
|
return timeToLiveInSeconds; |
95 |
|
} |
96 |
|
} |