Examples of URITemplate


Examples of com.cuubez.core.template.UriTemplate

            }

            resource.setClassMetaData(classMetaData);

            UriTemplateProcessor templateProcessor = new JaxRsUriTemplateProcessor();
            UriTemplate uriTemplate = templateProcessor.compile(classMetaData);
            resource.setUriTemplate(uriTemplate);

            resource.setSubResources(generateSubResource(resourceMetaDataScanner, classMetaData));

        }
View Full Code Here

Examples of com.damnhandy.uri.template.UriTemplate

        String href;

        if (halLink.isTemplated()) {
            try {
                UriTemplate uriTemplate = UriTemplate.fromTemplate(halLink.getHref());

                for (int i = 0; i < args.length; i++) {
                    for (Annotation annotation : parameterAnnotations[i]) {
                        if (annotation.annotationType() == UriVariable.class) {
                            UriVariable uriVariable = (UriVariable) annotation;

                            assignTemplateValue(uriTemplate, uriVariable.name(), args[i]);
                        }
                    }
                }

                for (int i = 0; i < link.uriValues().length; i++) {
                    UriValue uriValue = link.uriValues()[i];

                    assignTemplateValue(uriTemplate, uriValue.name(), uriValue.value());
                }

                href = uriTemplate.expand();
            } catch (MalformedUriTemplateException | VariableExpansionException e) {
                throw new RuntimeException(e);
            }
        } else {
            href = halLink.getHref();
View Full Code Here

Examples of com.github.fge.uritemplate.URITemplate

        final MessageBundle bundle, final FullData data)
        throws ProcessingException
    {
        final String value = data.getInstance().getNode().textValue();
        try {
            new URITemplate(value);
        } catch (URITemplateParseException ignored) {
            report.error(newMsg(data, bundle, "err.format.uriTemplate.invalid")
                .putArgument("value", value));
        }
    }
View Full Code Here

Examples of com.linkedin.jersey.api.uri.UriTemplate

    return getCodeModel().ref(ComplexResourceKey.class).narrow(keyClass, paramsClass);
  }

  private static List<String> getPathKeys(String basePath, Map<String, List<String>> pathToAssocKeys)
  {
    UriTemplate template = new UriTemplate(basePath);
    return fixOldStylePathKeys(template.getTemplateVariables(), basePath, pathToAssocKeys);
  }
View Full Code Here

Examples of com.mockey.model.UriTemplate

   */
  private Service findServiceBasedOnUrlPattern(String url, Service serviceToEvaluate) {
    Url fullUrl = new Url(serviceToEvaluate.getUrl());
    Service foundService = null;
    // EXAMPLE: "http://example.com/hotels/{hotel}/bookings/{booking}"
    UriTemplate template = new UriTemplate(fullUrl.getFullUrl());

    // EXAMPLE: "http://example.com/hotels/1/bookings/42"
    @SuppressWarnings("rawtypes")
    Map results = template.match(url);
    if (results.size() > 0) {
      // Possible match
      foundService = serviceToEvaluate;
    } else {

      // OK, not found based on template URL.
      if (fullUrl.getFullUrl().equalsIgnoreCase(url)) {
        foundService = serviceToEvaluate;
      } else {
        // Let's look at secondary list of real URLs
        List<Url> serviceUrlList = serviceToEvaluate.getRealServiceUrls();
        Iterator<Url> altUrlIter = serviceUrlList.iterator();
        while (altUrlIter.hasNext()) {
          Url altUrl = altUrlIter.next();

          // Variable template is set to the template of the service's
          // full URL.
          // The template is matched against the service real URLs,
          // therefore the match always succeeds. The template should
          // be
          // matched against the url of the request instead.
          template = new UriTemplate(altUrl.getFullUrl());
          results = template.match(url);

          if (results.size() > 0) {
            // Possible match
            foundService = serviceToEvaluate;
            break;
View Full Code Here

Examples of com.sun.jersey.api.uri.UriTemplate

*/
public class PathTemplateTest {

    @Test
    public void testBasicOperations() throws Exception {
        UriTemplate tmpl = new PathTemplate("/{id : \\d+}/test");
        assertEquals(
            "getNumberOfTemplateVariables() returned invalid number",
            1,
            tmpl.getNumberOfTemplateVariables()
        );
        assertEquals(
            "getNumberOfExplicitRegexes() returned invalid number",
            1,
            tmpl.getNumberOfExplicitRegexes()
        );
    }
View Full Code Here

Examples of io.fabric8.gateway.support.UriTemplate

    public HttpProxyRule(String uriTemplate) {
        this.uriTemplate = new UriTemplateDefinition(uriTemplate);
    }

    public MappingResult matches(String[] paths) {
        UriTemplate template = getUriTemplateObject();
        if (template == null) {
            LOG.warn("getUriTemplateObject() returned null!");
            return null;
        }
        return template.matches(paths, this);
    }
View Full Code Here

Examples of org.apache.clerezza.triaxrs.util.URITemplate

import org.apache.clerezza.triaxrs.util.URITemplate;

public class URITemplateTest {
  @Test
  public void simpleTemplateMatching() {
    Assert.assertNull(new URITemplate("/foo/bar").match("/foo"));
    Assert.assertNotNull(new URITemplate("/foo").match("/foo/bar"));
    Assert.assertNotNull(new URITemplate("foo").match("/foo/bar"));
  }
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.URITemplate

    public static boolean checkRequestURI(String servletPath, String uri) {
        boolean wildcard = uri.endsWith("*");
        String theURI = wildcard ? uri.substring(0, uri.length() - 1) : uri;
        try {
            URITemplate template = new URITemplate(theURI);
            MultivaluedMap<String, String> map = new MetadataMap<String, String>();
            if (template.match(servletPath, map)) {
                String finalGroup = map.getFirst(URITemplate.FINAL_MATCH_GROUP);
                if (wildcard || StringUtils.isEmpty(finalGroup) || "/".equals(finalGroup)) {
                    return true;
                }
            }
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.URITemplate

    }

    private URI doBuild(boolean fromEncoded, Object... values) {
       
        String thePath = buildPath(fromEncoded);
        URITemplate pathTempl = new URITemplate(thePath);
        thePath = substituteVarargs(pathTempl, values, 0);
       
        String theQuery = buildQuery(fromEncoded);
        int queryTemplateVarsSize = 0;
        if (theQuery != null) {
            URITemplate queryTempl = new URITemplate(theQuery);
            int lengthDiff = values.length - pathTempl.getVariables().size();
            if (lengthDiff > 0) {
                queryTemplateVarsSize = queryTempl.getVariables().size();
                theQuery = substituteVarargs(queryTempl, values, values.length - lengthDiff);
            }
        }
       
        String theFragment = fragment;
        if (theFragment != null) {
            URITemplate fragmentTempl = new URITemplate(theFragment);
            int lengthDiff = values.length - pathTempl.getVariables().size() - queryTemplateVarsSize;
            if (lengthDiff > 0) {
                theFragment = substituteVarargs(fragmentTempl, values, values.length - lengthDiff);
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.