Coverage Report - org.seasar.teeda.core.lifecycle.impl.RenderResponsePhase
 
Classes in this File Line Coverage Branch Coverage Complexity
RenderResponsePhase
54%
13/24
20%
2/10
6.5
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
 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,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.teeda.core.lifecycle.impl;
 17  
 
 18  
 import java.io.IOException;
 19  
 
 20  
 import javax.faces.FacesException;
 21  
 import javax.faces.application.ViewHandler;
 22  
 import javax.faces.context.FacesContext;
 23  
 import javax.faces.el.EvaluationException;
 24  
 import javax.faces.event.PhaseId;
 25  
 import javax.faces.internal.scope.RedirectScope;
 26  
 
 27  
 import org.seasar.teeda.core.lifecycle.AbstractPhase;
 28  
 import org.seasar.teeda.core.util.FacesContextUtil;
 29  
 import org.seasar.teeda.core.util.PortletUtil;
 30  
 
 31  
 /**
 32  
  * @author shot
 33  
  */
 34  3
 public class RenderResponsePhase extends AbstractPhase {
 35  
 
 36  
     public void executePhase(FacesContext context) throws FacesException {
 37  2
         ViewHandler viewHandler = FacesContextUtil.getViewHandler(context);
 38  
         try {
 39  2
             viewHandler.renderView(context, context.getViewRoot());
 40  2
         } catch (IOException e) {
 41  1
             throw new FacesException(e.getMessage(), e);
 42  0
         } catch (EvaluationException ex) {
 43  0
             Throwable cause = ex.getCause();
 44  0
             if (cause instanceof RuntimeException) {
 45  0
                 throw (RuntimeException) cause;
 46  0
             } else if (cause instanceof Error) {
 47  0
                 throw (Error) cause;
 48  
             } else {
 49  0
                 throw ex;
 50  
             }
 51  
         } finally {
 52  1
             synchronized (this) {
 53  2
                 if (RedirectScope.isRedirecting(context)) {
 54  0
                     if (!context.getResponseComplete()) {
 55  0
                         String path = RedirectScope.getRedirectingPath(context);
 56  0
                         RedirectScope.clearContext(context);
 57  0
                         RedirectScope.setRedirectedPath(context, path);
 58  
                     }
 59  
                 } else {
 60  
                     // PortletSupport
 61  2
                     if (!PortletUtil.isPortlet(context)) {
 62  2
                         RedirectScope.clearContext(context);
 63  
                     }
 64  
                 }
 65  2
             }
 66  1
         }
 67  1
     }
 68  
 
 69  
     protected PhaseId getCurrentPhaseId() {
 70  1
         return PhaseId.RENDER_RESPONSE;
 71  
     }
 72  
 
 73  
 }