Coverage Report - org.mule.module.atom.routing.URIRouteFilter
 
Classes in this File Line Coverage Branch Coverage Complexity
URIRouteFilter
0%
0/16
0%
0/8
0
 
 1  
 /*
 2  
  * $Id: URIRouteFilter.java 20321 2010-11-24 15:21:24Z dfeist $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 package org.mule.module.atom.routing;
 11  
 
 12  
 import org.mule.api.MuleMessage;
 13  
 import org.mule.api.routing.filter.Filter;
 14  
 import org.mule.transport.http.HttpConnector;
 15  
 import org.mule.util.StringUtils;
 16  
 
 17  
 import java.util.HashSet;
 18  
 import java.util.Set;
 19  
 
 20  
 import org.apache.abdera.i18n.templates.Route;
 21  
 
 22  
 public class URIRouteFilter implements Filter
 23  
 {
 24  
 
 25  
     private Set<String> verbs;
 26  
     private Route route;
 27  
 
 28  
     public URIRouteFilter()
 29  
     {
 30  0
         super();
 31  0
     }
 32  
 
 33  
     public void setRoute(String routePattern)
 34  
     {
 35  0
         route = new Route("", routePattern);
 36  0
     }
 37  
 
 38  
     public void setVerbs(String verbString)
 39  
     {
 40  0
         if (verbString.equals("*"))
 41  
         {
 42  0
             return;
 43  
         }
 44  
 
 45  0
         String[] split = verbString.split(",");
 46  0
         verbs = new HashSet<String>();
 47  0
         for (String s : split)
 48  
         {
 49  0
             verbs.add(s.toUpperCase());
 50  
         }
 51  0
     }
 52  
 
 53  
     public boolean accept(MuleMessage message)
 54  
     {
 55  0
         String method = message.getInboundProperty(HttpConnector.HTTP_METHOD_PROPERTY, StringUtils.EMPTY);
 56  0
         if (verbs != null && !verbs.contains(method.toUpperCase()))
 57  
         {
 58  0
             return false;
 59  
         }
 60  
 
 61  0
         String path = message.getInboundProperty(HttpConnector.HTTP_REQUEST_PROPERTY, StringUtils.EMPTY);
 62  
 
 63  0
         return route.match(path);
 64  
     }
 65  
 
 66  
 }