001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kns.web.struts.form.pojo; 017 018import org.apache.commons.logging.Log; 019import org.apache.commons.logging.LogFactory; 020import org.apache.struts.Globals; 021import org.apache.struts.action.ActionForm; 022import org.apache.struts.action.ActionForward; 023import org.apache.struts.action.ActionMapping; 024import org.apache.struts.action.ExceptionHandler; 025import org.apache.struts.config.ExceptionConfig; 026 027import javax.servlet.http.HttpServletRequest; 028import javax.servlet.http.HttpServletResponse; 029 030/** 031 * Handles any AuthorizationException by logging it first and then passing it forward to an explanation page. 032 * 033 * @deprecated KNS Struts deprecated, use KRAD and the Spring MVC framework. 034 */ 035@Deprecated 036public class AuthorizationExceptionHandler extends ExceptionHandler { 037 038 private static final String AUTHORIZATION_EXCEPTION_HANDLER = "authorizationExceptionHandler"; 039 040 private static final Log LOG = LogFactory.getLog(AuthorizationExceptionHandler.class); 041 042 /** 043 * Logs the AuthorizationException before forwarding the user to the explanation page. 044 * 045 * @see org.apache.struts.action.ExceptionHandler#execute( 046 * java.lang.Exception, org.apache.struts.config.ExceptionConfig, org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, 047 * javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) 048 */ 049 @Override 050 public ActionForward execute(Exception exception, ExceptionConfig exceptionConfig, ActionMapping mapping, ActionForm form, HttpServletRequest request, 051 HttpServletResponse response) { 052 053 if (LOG.isTraceEnabled()) { 054 String message = String.format("ENTRY %s", exception.getMessage()); 055 LOG.trace(message); 056 } 057 exception.printStackTrace(); 058 request.setAttribute(Globals.EXCEPTION_KEY, exception); 059 060 ActionForward forward = mapping.findForward(AUTHORIZATION_EXCEPTION_HANDLER); 061 062 if (LOG.isTraceEnabled()) { 063 LOG.trace(String.format("EXIT %s", exception.getMessage())); 064 } 065 066 return forward; 067 } 068 069}