1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.dbforms.event;
25
26
27 import org.dbforms.config.DbFormsConfig;
28 import org.dbforms.config.Table;
29
30 import java.util.Properties;
31
32 import javax.servlet.http.HttpServletRequest;
33
34
35
36 /***
37 * Abstract base class for all web-events. <br>
38 * Implementations of this class will be generated by the
39 * controller/EventEngine by dispatchting the incoming HTTP-request from the
40 * client. In fact, the WebEvent classes itselves may provide methods
41 * (constructors) to help parsing the request data. <br>
42 * WebEvents may be processed by the controller and/or by the custom tags at
43 * JSP-side.
44 *
45 * @author Joe Peer
46 *
47 */
48 public abstract class AbstractWebEvent {
49
50 /*** the configuration object */
51 private DbFormsConfig config;
52
53 /*** the HttpServletRequest object */
54 private HttpServletRequest request;
55
56 /*** event properties */
57 private Properties properties = null;
58
59 /*** followUp URL string */
60 private String followUp;
61
62 /*** followUp URL string used when an error occurs */
63 private String followUpOnError;
64
65 /*** type of event */
66 private String type = "UNDEFINED";
67
68 /*** table that tells on which table does the event operate on */
69 private Table table;
70
71 /***
72 * Creates a new WebEvent object.
73 *
74 * @param tableId the table id
75 * @param request the request object
76 * @param config the configuration object
77 */
78 public AbstractWebEvent(int tableId,
79 HttpServletRequest request,
80 DbFormsConfig config) {
81 setTable(config.getTable(tableId));
82 setRequest(request);
83 this.config = config;
84 }
85
86 /***
87 * Gets the config attribute of the WebEvent object
88 *
89 * @return The config value
90 */
91 public DbFormsConfig getConfig() {
92 return config;
93 }
94
95
96 /***
97 * Sets the followUp attribute of the WebEvent object
98 *
99 * @param followUp The new followUp value
100 */
101 public void setFollowUp(String followUp) {
102 this.followUp = followUp;
103 }
104
105
106 /***
107 * Gets the followUp attribute of the WebEvent object
108 *
109 * @return The followUp value
110 */
111 public String getFollowUp() {
112 return followUp;
113 }
114
115
116 /***
117 * Sets the followUpOnError attribute of the WebEvent object
118 *
119 * @param followUpOnError The new followUpOnError value
120 */
121 public void setFollowUpOnError(String followUpOnError) {
122 this.followUpOnError = followUpOnError;
123 }
124
125
126 /***
127 * Gets the followUpOnError attribute of the WebEvent object
128 *
129 * @return The followUpOnError value
130 */
131 public String getFollowUpOnError() {
132 return followUpOnError;
133 }
134
135
136 /***
137 * Sets the properties attribute of the WebEvent object
138 *
139 * @param properties The new properties value
140 */
141 public void setProperties(Properties properties) {
142 this.properties = properties;
143 }
144
145
146 /***
147 * Gets the properties attribute of the WebEvent object
148 *
149 * @return The properties value
150 */
151 public Properties getProperties() {
152 return properties;
153 }
154
155
156 /***
157 * sets the request attribute of the WebEvent object
158 *
159 * @param request The new request value
160 */
161 public void setRequest(HttpServletRequest request) {
162 this.request = request;
163 }
164
165
166 /***
167 * Gets the request attribute of the WebEvent object
168 *
169 * @return The request value
170 */
171 public HttpServletRequest getRequest() {
172 return request;
173 }
174
175
176 /***
177 * DOCUMENT ME!
178 *
179 * @param table DOCUMENT ME!
180 */
181 public void setTable(Table table) {
182 this.table = table;
183 }
184
185
186 /***
187 * DOCUMENT ME!
188 *
189 * @return DOCUMENT ME!
190 */
191 public Table getTable() {
192 return table;
193 }
194
195
196 /***
197 * Sets the event type
198 *
199 * @param type The type to set
200 */
201 public void setType(String type) {
202 this.type = type;
203 }
204
205
206 /***
207 * Get the string that defines the current event type
208 *
209 * @return the string that defines the current event type
210 */
211 public String getType() {
212 return type;
213 }
214
215
216 /***
217 * Check if the current user has got the input privilege
218 *
219 * @param privileg the privilege value
220 *
221 * @return true if the current user has got the input privilege, false
222 * otherwise
223 */
224 protected boolean hasUserPrivileg(int privileg) {
225 return config.getTable(getTable().getId())
226 .hasUserPrivileg(getRequest(), privileg);
227 }
228 }