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