/** * Create new instance using existing Client instance, and the URI from which the parameters will be extracted * */ public PathIdRevisions( com.sun.jersey.api.client.Client client, URI uri ) { _client = client; StringBuilder template = new StringBuilder( BASE_URI.toString() ); if ( template.charAt( ( template.length() - 1 ) ) != '/' ) { template.append( "/pur-repository-plugin/api/revision/{pathId : .+}/revisions" ); } else { template.append( "pur-repository-plugin/api/revision/{pathId : .+}/revisions" ); } _uriBuilder = UriBuilder.fromPath( template.toString() ); _templateAndMatrixParameterValues = new HashMap<String, Object>(); com.sun.jersey.api.uri.UriTemplate uriTemplate = new com.sun.jersey.api.uri.UriTemplate( template.toString() ); HashMap<String, String> parameters = new HashMap<String, String>(); uriTemplate.match( uri.toString(), parameters ); _templateAndMatrixParameterValues.putAll( parameters ); }
/** * Create new instance using existing Client instance, and the URI from which the parameters will be extracted * */ public PathIdPurge( com.sun.jersey.api.client.Client client, URI uri ) { _client = client; StringBuilder template = new StringBuilder( BASE_URI.toString() ); if ( template.charAt( ( template.length() - 1 ) ) != '/' ) { template.append( "/pur-repository-plugin/api/purge/{pathId : .+}/purge" ); } else { template.append( "pur-repository-plugin/api/purge/{pathId : .+}/purge" ); } _uriBuilder = UriBuilder.fromPath( template.toString() ); _templateAndMatrixParameterValues = new HashMap<String, Object>(); com.sun.jersey.api.uri.UriTemplate uriTemplate = new com.sun.jersey.api.uri.UriTemplate( template.toString() ); HashMap<String, String> parameters = new HashMap<String, String>(); uriTemplate.match( uri.toString(), parameters ); _templateAndMatrixParameterValues.putAll( parameters ); }
/** * Create new instance using existing Client instance, and the URI from which the parameters will be extracted * */ public PathIdVersioningConfiguration( com.sun.jersey.api.client.Client client, URI uri ) { _client = client; StringBuilder template = new StringBuilder( BASE_URI.toString() ); if ( template.charAt( ( template.length() - 1 ) ) != '/' ) { template.append( "/pur-repository-plugin/api/revision/{pathId}/versioningConfiguration" ); } else { template.append( "pur-repository-plugin/api/revision/{pathId}/versioningConfiguration" ); } _uriBuilder = UriBuilder.fromPath( template.toString() ); _templateAndMatrixParameterValues = new HashMap<String, Object>(); com.sun.jersey.api.uri.UriTemplate uriTemplate = new com.sun.jersey.api.uri.UriTemplate( template.toString() ); HashMap<String, String> parameters = new HashMap<String, String>(); uriTemplate.match( uri.toString(), parameters ); _templateAndMatrixParameterValues.putAll( parameters ); }
/** * This will match a list of route rules against request URI. The best rule wins. Just how we determine the best rule * is heuristically driven. If there is only a single {@link com.atlassian.prettyurls.api.route.UrlRouteRuleSet} in play then * it is simply the first rule in the list that matches. * * However if there are multiple rule sets in play then we use a different strategy. We pick the most specific rule based on * how specific the {@link UriTemplate} is. * * @param requestURI the request URI in play * @param routeRules the list of possible matching rules * @param strategy the number of top level matching rule sets that the rules came from * * @return a match result */ Result getMatchingRule(String requestURI, List<UrlRouteRule> routeRules, Strategy strategy) { final List<UrlRouteRule> sortedRules = strategy.sortRules(routeRules); final Map<String, String> parsedVariableValues = new HashMap<>(); // now match - first rule to match is what we return for (UrlRouteRule routeRule : sortedRules) { if (routeRule.getFrom().match(requestURI, parsedVariableValues)) { return new Result(some(routeRule), parsedVariableValues); } } return new Result(none(), parsedVariableValues); }