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 package com.pow2.acl.dbforms.interceptors; 22 import java.sql.Connection; 23 24 import java.util.Hashtable; 25 import javax.servlet.http.HttpServletRequest; 26 import javax.servlet.http.HttpSession; 27 28 import org.apache.log4j.Category; 29 30 import com.pow2.dao.DAO; 31 import org.dbforms.DbFormsConfig; 32 33 import org.dbforms.event.DbEventInterceptor; 34 import org.dbforms.event.DbEventInterceptorSupport; 35 import org.dbforms.event.ValidationException; 36 37 /*** 38 * DbForm interceptor (hook up class) for User table. 39 * 40 * @author Luca Fossato 41 */ 42 public class UserInterceptor extends com.pow2.dbforms.Interceptor 43 { 44 /*** key for the session entry that holds the new user table key */ 45 protected final static String KEY_USERINTERCEPTOR_NEWKEY = "com.pow2.userInterceptor.newKey"; 46 47 48 /*** 49 * Remove the user key session attribute previously added 50 * by preInsert(). 51 * 52 * @param request Description of the Parameter 53 * @param config Description of the Parameter 54 * @param con Description of the Parameter 55 */ 56 public void postInsert(HttpServletRequest request, DbFormsConfig config, Connection con) 57 { 58 HttpSession session = request.getSession(); 59 session.removeAttribute(KEY_USERINTERCEPTOR_NEWKEY); 60 } 61 62 63 64 /*** 65 * Delete all the related records from ACL_USER_GROUP_ROLE table; 66 * 67 * @param request Description of the Parameter 68 * @param fieldValues Description of the Parameter 69 * @param config Description of the Parameter 70 * @param con Description of the Parameter 71 * @return Description of the Return Value 72 * @exception ValidationException Description of the Exception 73 */ 74 public int preDelete(HttpServletRequest request, 75 Hashtable fieldValues, 76 DbFormsConfig config, 77 Connection con) 78 throws ValidationException 79 { 80 String cond = ("USER_ID = " + fieldValues.get("USER_ID")); 81 return delete("ACL_USER_GROUP_ROLE", cond, con); 82 } 83 84 85 /*** 86 * Get a new key for the new User entry. 87 * 88 * @param request Description of the Parameter 89 * @param fieldValues Description of the Parameter 90 * @param config Description of the Parameter 91 * @param con Description of the Parameter 92 * @return Description of the Return Value 93 * @exception ValidationException Description of the Exception 94 */ 95 public int preInsert(HttpServletRequest request, 96 Hashtable fieldValues, 97 DbFormsConfig config, 98 Connection con) 99 throws ValidationException 100 { 101 String newKey = String.valueOf(getNewKey()); 102 fieldValues.put("USER_ID", newKey); 103 104 // store the key into the session object; 105 // thit session entry should be deleted by postInsert(); 106 HttpSession session = request.getSession(); 107 session.setAttribute(KEY_USERINTERCEPTOR_NEWKEY, newKey); 108 109 return GRANT_OPERATION; 110 } 111 }

This page was automatically generated by Maven