1    /*
2     * Copyright 2009 :torweg free software group
3     * 
4     * This program is free software: you can redistribute it and/or modify
5     * it under the terms of the GNU General Public License as published by
6     * the Free Software Foundation, either version 3 of the License, or
7     * (at your option) any later version.
8     * 
9     * This program is distributed in the hope that it will be useful,
10    * but WITHOUT ANY WARRANTY; without even the implied warranty of
11    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    * GNU General Public License for more details.
13    * 
14    * You should have received a copy of the GNU General Public License
15    * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16    *
17    */
18   package org.torweg.pulse.service.event;
19   
20   import javax.servlet.http.HttpServletResponse;
21   
22   import org.torweg.pulse.service.request.CacheMode;
23   import org.torweg.pulse.service.request.ServiceRequest;
24   
25   /**
26    * sends a {@code 403 HTTP error} with an XSL output.
27    * 
28    * @author Thomas Weber
29    * @version $Revision: 1393 $
30    */
31   public class ForbiddenEvent implements Event {
32   
33       /**
34        * the cache mode.
35        */
36       private CacheMode cache = CacheMode.NONE;
37   
38       /**
39        * builds a new {@code ForbiddenEvent} which will be processed by the
40        * standard output.
41        * <p>
42        * This {@code ForbiddenEvent} will neither be an output nor a stop
43        * event.
44        * </p>
45        */
46       public ForbiddenEvent() {
47           super();
48       }
49   
50       /**
51        * @param req
52        *            the current request
53        * @see org.torweg.pulse.service.event.Event#run(org.torweg.pulse.service.request.ServiceRequest)
54        */
55       public final void run(final ServiceRequest req) {
56           req.getHttpServletResponse()
57                   .setStatus(HttpServletResponse.SC_FORBIDDEN);
58       }
59   
60       /**
61        * @return {@code false}
62        * @see org.torweg.pulse.service.event.Event#isOutputEvent()
63        */
64       public final boolean isOutputEvent() {
65           return false;
66       }
67   
68       /**
69        * @return {@code false}
70        * @see org.torweg.pulse.service.event.Event#isStopEvent()
71        */
72       public final boolean isStopEvent() {
73           return false;
74       }
75   
76       /**
77        * @see org.torweg.pulse.service.event.Event#isSingularEvent()
78        * @return {@code true}
79        */
80       public final boolean isSingularEvent() {
81           return true;
82       }
83   
84       /**
85        * returns the {@code CacheMode}.
86        * 
87        * @return the cache mode
88        * @see org.torweg.pulse.service.event.Event#getCacheMode()
89        */
90       public final CacheMode getCacheMode() {
91           return this.cache;
92       }
93   
94       /**
95        * sets the {@code CacheMode}.
96        * 
97        * @param c
98        *            the cache mode to set
99        * @see org.torweg.pulse.service.event.Event#setCacheMode(org.torweg.pulse.service.request.CacheMode)
100       */
101      public final void setCacheMode(final CacheMode c) {
102          this.cache = c;
103      }
104  
105  }
106