01: package net.sourceforge.cruisecontrol.dashboard.web;
02:
03: import javax.servlet.http.HttpServletRequest;
04: import javax.servlet.http.HttpServletResponse;
05:
06: import net.sourceforge.cruisecontrol.dashboard.service.ConfigurationService;
07:
08: import org.springframework.web.servlet.HandlerInterceptor;
09: import org.springframework.web.servlet.ModelAndView;
10:
11: public class ForceBuildEnabledInterceptor implements HandlerInterceptor {
12: private final ConfigurationService configuration;
13:
14: public ForceBuildEnabledInterceptor(
15: ConfigurationService configuration) {
16: this .configuration = configuration;
17: }
18:
19: public void afterCompletion(HttpServletRequest request,
20: HttpServletResponse response, Object command, Exception mov)
21: throws Exception {
22: }
23:
24: public void postHandle(HttpServletRequest request,
25: HttpServletResponse response, Object command,
26: ModelAndView mov) throws Exception {
27: mov.getModel().put("forceBuildEnabled",
28: Boolean.valueOf(configuration.isForceBuildEnabled()));
29: }
30:
31: public boolean preHandle(HttpServletRequest request,
32: HttpServletResponse response, Object command)
33: throws Exception {
34: return true;
35: }
36: }
|