1 /***
2 * The contents of this file are subject to the Mozilla Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/MPL/
6 *
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
11 *
12 * The Original Code is pow2ACL library.
13 *
14 * The Initial Owner of the Original Code is Power Of Two S.R.L.
15 * Portions created by Power Of Two S.R.L. are Copyright (C) Power Of Two S.R.L.
16 * All Rights Reserved.
17 *
18 * Contributor(s):
19 */
20
21
22 package com.pow2.acl.dbforms.interceptors;
23
24 import java.util.Hashtable;
25 import java.sql.Connection;
26 import javax.servlet.http.HttpServletRequest;
27
28 import org.apache.log4j.Category;
29
30 import org.dbforms.event.DbEventInterceptor;
31 import org.dbforms.event.DbEventInterceptorSupport;
32 import org.dbforms.event.ValidationException;
33 import org.dbforms.DbFormsConfig;
34
35 import com.pow2.dao.DAO;
36
37
38 /***
39 * DbForm interceptor (hook up class) for ACL Group table.
40 */
41 public class PermissionInterceptor extends com.pow2.dbforms.Interceptor
42 {
43 /***
44 * Delete all the permission related records from ACL_ROLE_PERMISSION table.
45 */
46 public int preDelete(HttpServletRequest request,
47 Hashtable fieldValues,
48 DbFormsConfig config,
49 Connection con)
50 throws
51 ValidationException
52 {
53 String cond = "PERMISSION_ID = " + fieldValues.get("PERMISSION_ID");
54 return delete("ACL_ROLE_PERMISSION", cond, con);
55 }
56
57
58 /***
59 * Calculate and set a new key for the new Permission entry.
60 */
61 public int preInsert(HttpServletRequest request,
62 Hashtable fieldValues,
63 DbFormsConfig config,
64 Connection con)
65 throws
66 ValidationException
67 {
68 String newKey = String.valueOf(getNewKey());
69 fieldValues.put("PERMISSION_ID", newKey);
70 return GRANT_OPERATION;
71 }
72 }
This page was automatically generated by Maven