Coverage Report - org.apache.tapestry.portlet.MatchingPortletPageResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
MatchingPortletPageResolver
0%
0/18
0%
0/4
2
 
 1  
 // Copyright 2005 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry.portlet;
 16  
 
 17  
 import java.util.ArrayList;
 18  
 import java.util.Collections;
 19  
 import java.util.Iterator;
 20  
 import java.util.List;
 21  
 
 22  
 import javax.portlet.PortletRequest;
 23  
 
 24  
 import org.apache.tapestry.IRequestCycle;
 25  
 import org.apache.tapestry.PageNotFoundException;
 26  
 
 27  
 /**
 28  
  * Uses the tapestry.portlet.resolver.PageResolverRules configuration point to find a match.
 29  
  * 
 30  
  * @author Howard M. Lewis Ship
 31  
  * @since 4.0
 32  
  */
 33  0
 public class MatchingPortletPageResolver implements PortletPageResolver
 34  
 {
 35  
     private List _contributions;
 36  
 
 37  
     private List _sortedContributions;
 38  
 
 39  
     private PortletRequest _request;
 40  
 
 41  
     public void initializeService()
 42  
     {
 43  0
         _sortedContributions = new ArrayList(_contributions);
 44  0
         Collections.sort(_sortedContributions);
 45  0
     }
 46  
 
 47  
     public String getPageNameForRequest(IRequestCycle cycle)
 48  
     {
 49  0
         Iterator i = _sortedContributions.iterator();
 50  0
         while (i.hasNext())
 51  
         {
 52  0
             PageResolverContribution c = (PageResolverContribution) i.next();
 53  
 
 54  0
             if (c.match(_request))
 55  
             {
 56  0
                 String pageName = c.getPageName();
 57  
 
 58  
                 try
 59  
                 {
 60  0
                     cycle.getPage(pageName);
 61  
 
 62  0
                     return pageName;
 63  
                 }
 64  0
                 catch (PageNotFoundException ex)
 65  
                 {
 66  
                     // Ignore.
 67  
                 }
 68  
             }
 69  0
         }
 70  
 
 71  
         // No match, or no matches where the page actually exists.
 72  
 
 73  0
         return null;
 74  
     }
 75  
 
 76  
     public void setContributions(List contributions)
 77  
     {
 78  0
         _contributions = contributions;
 79  0
     }
 80  
 
 81  
     public void setRequest(PortletRequest request)
 82  
     {
 83  0
         _request = request;
 84  0
     }
 85  
 
 86  
 }