View Javadoc
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 RoleInterceptor extends com.pow2.dbforms.Interceptor 42 { 43 /*** 44 * Delete all the related records from 45 * ACL_USER_GROUP_ROLE and ROLE_PERMISSION tables; 46 */ 47 public int preDelete(HttpServletRequest request, 48 Hashtable fieldValues, 49 DbFormsConfig config, 50 Connection con) 51 throws 52 ValidationException 53 { 54 String cond = "ROLE_ID = " + fieldValues.get("ROLE_ID"); 55 56 // the record deletion should done under transaction; 57 delete("ACL_USER_GROUP_ROLE", cond, con); 58 delete("ACL_ROLE_PERMISSION", cond, con); 59 60 return GRANT_OPERATION; 61 } 62 63 64 /*** 65 * Calculate and set a new key for the new Role entry. 66 */ 67 public int preInsert(HttpServletRequest request, 68 Hashtable fieldValues, 69 DbFormsConfig config, 70 Connection con) 71 throws 72 ValidationException 73 { 74 String newKey = String.valueOf(getNewKey()); 75 fieldValues.put("ROLE_ID", newKey); 76 return GRANT_OPERATION; 77 } 78 } 79

This page was automatically generated by Maven