Coverage Report - org.kuali.rice.kns.web.struts.form.pojo.AuthorizationExceptionHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
AuthorizationExceptionHandler
0%
0/11
0%
0/4
3
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kns.web.struts.form.pojo;
 17  
 
 18  
 import org.apache.commons.logging.Log;
 19  
 import org.apache.commons.logging.LogFactory;
 20  
 import org.apache.struts.Globals;
 21  
 import org.apache.struts.action.ActionForm;
 22  
 import org.apache.struts.action.ActionForward;
 23  
 import org.apache.struts.action.ActionMapping;
 24  
 import org.apache.struts.action.ExceptionHandler;
 25  
 import org.apache.struts.config.ExceptionConfig;
 26  
 
 27  
 import javax.servlet.http.HttpServletRequest;
 28  
 import javax.servlet.http.HttpServletResponse;
 29  
 
 30  
 /**
 31  
  * Handles any AuthorizationException by logging it first and then passing it forward to an explanation page.
 32  
  */
 33  0
 public class AuthorizationExceptionHandler extends ExceptionHandler {
 34  
     
 35  
     private static final String AUTHORIZATION_EXCEPTION_HANDLER = "authorizationExceptionHandler";
 36  
 
 37  0
     private static final Log LOG = LogFactory.getLog(AuthorizationExceptionHandler.class);
 38  
     
 39  
     /**
 40  
      * Logs the AuthorizationException before forwarding the user to the explanation page.
 41  
      * 
 42  
      * @see org.apache.struts.action.ExceptionHandler#execute(
 43  
      *      java.lang.Exception, org.apache.struts.config.ExceptionConfig, org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, 
 44  
      *      javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 45  
      */
 46  
     @Override
 47  
     public ActionForward execute(Exception exception, ExceptionConfig exceptionConfig, ActionMapping mapping, ActionForm form, HttpServletRequest request, 
 48  
             HttpServletResponse response) {
 49  
         
 50  0
         if (LOG.isTraceEnabled()) {
 51  0
             String message = String.format("ENTRY %s", exception.getMessage());
 52  0
             LOG.trace(message);
 53  
         }
 54  0
         exception.printStackTrace();
 55  0
         request.setAttribute(Globals.EXCEPTION_KEY, exception);
 56  
         
 57  0
         ActionForward forward = mapping.findForward(AUTHORIZATION_EXCEPTION_HANDLER);
 58  
         
 59  0
         if (LOG.isTraceEnabled()) {
 60  0
             LOG.trace(String.format("EXIT %s", exception.getMessage()));
 61  
         }
 62  
         
 63  0
         return forward;
 64  
     }
 65  
 
 66  
 }