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 |
|
import org.slf4j.Logger; |
45 |
|
import org.slf4j.LoggerFactory; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@author |
50 |
|
@version |
51 |
|
|
|
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
52 |
|
public class CachedError implements CachedEntry, Serializable { |
53 |
|
|
54 |
|
private static Logger log = LoggerFactory.getLogger(CachedError.class); |
55 |
|
|
56 |
|
private final int statusCode; |
57 |
|
private String originalUrl; |
58 |
|
private long timestamp; |
59 |
|
private int timeToLiveInSeconds = -1; |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
61 |
3 |
public CachedError(int statusCode, String originalUrl, int timeToLiveInSeconds) {... |
62 |
3 |
this.statusCode = statusCode; |
63 |
3 |
this.originalUrl = originalUrl; |
64 |
3 |
this.timestamp = System.currentTimeMillis(); |
65 |
3 |
this.timeToLiveInSeconds = timeToLiveInSeconds; |
66 |
|
} |
67 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
68 |
|
public int getStatusCode() {... |
69 |
|
return statusCode; |
70 |
|
} |
71 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
72 |
3 |
@Override... |
73 |
|
public void replay(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { |
74 |
3 |
if (!response.isCommitted()) { |
75 |
3 |
response.sendError(getStatusCode()); |
76 |
|
} else { |
77 |
|
|
78 |
|
|
79 |
0 |
log.debug("Failed to serve cached error due to response already committed."); |
80 |
|
} |
81 |
|
} |
82 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
83 |
|
@Override... |
84 |
|
public String getOriginalURL() { |
85 |
|
return originalUrl; |
86 |
|
} |
87 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
88 |
|
@Override... |
89 |
|
public long getLastModificationTime() { |
90 |
|
return timestamp; |
91 |
|
} |
92 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
93 |
|
@Override... |
94 |
|
public int getTimeToLiveInSeconds() { |
95 |
|
return timeToLiveInSeconds; |
96 |
|
} |
97 |
|
} |