Examples of PathPattern


Examples of com.sun.jersey.server.impl.uri.PathPattern

    @Test
    public void testExpectsPositiveAcceptance() throws Exception {
        UriTemplate template = new UriTemplate("/test/{name}/{id}");
        Object foo = new ResourceDbl();
        Map<PathPattern, UriRule> map = new HashMap<PathPattern, UriRule>();
        map.put(new PathPattern(template), new ResourceObjectRule(template, foo));
        UriRule rule = new RootResourceClassesRule(map);
        assertFalse(rule.accept("/test", foo, UriRuleContextDbl.make()));
    }
View Full Code Here

Examples of com.sun.jersey.server.impl.uri.PathPattern

     */
    private TrieNode<R> initTrie(List<PatternRulePair<R>> rules) {
        TrieNode<R> a = new TrieNode<R>();
        for (PatternRulePair<R> prp : rules) {
            if (prp.p instanceof PathPattern) {
                PathPattern p = (PathPattern)prp.p;           
                a.add(p.getTemplate().getTemplate(), prp.r, prp.p);
            } else {
                throw new IllegalArgumentException(
                        "The automata matching algorithm currently only works" +
                        "for UriPattern instance that are instances of " +
                        "PathPattern");
View Full Code Here

Examples of com.sun.jersey.server.impl.uri.PathPattern

    private void initWadlResource() {
        if (!wadlFactory.isSupported())
            return;

        final PathPattern p = new PathPattern(new PathTemplate("application.wadl"));

        // If "application.wadl" is already defined to not add the
        // default WADL resource
        if (rules.containsKey(p))
            return;

        // Configure meta-data
        wa.initiateResource(WadlResource.class);

        rules.put(p, new RightHandPathRule(
                resourceConfig.getFeature(ResourceConfig.FEATURE_REDIRECT),
                p.getTemplate().endsWithSlash(),
                new ResourceClassRule(p.getTemplate(), WadlResource.class)));
    }
View Full Code Here

Examples of com.sun.jersey.server.impl.uri.PathPattern

                p.getTemplate().endsWithSlash(),
                new ResourceClassRule(p.getTemplate(), WadlResource.class)));
    }

    private void addRule(final String path, final Class c) {
        final PathPattern p = getPattern(path, c);
        if (isPatternValid(p, c)) {
            rules.put(p, new RightHandPathRule(
                        resourceConfig.getFeature(ResourceConfig.FEATURE_REDIRECT),
                        p.getTemplate().endsWithSlash(),
                        new ResourceClassRule(p.getTemplate(), c)));
        }
    }
View Full Code Here

Examples of com.sun.jersey.server.impl.uri.PathPattern

                        new ResourceClassRule(p.getTemplate(), c)));
        }
    }

    private void addRule(final String path, final Object o) {
        final PathPattern p = getPattern(path, o.getClass());
        if (isPatternValid(p, o.getClass())) {
            rules.put(p, new RightHandPathRule(
                        resourceConfig.getFeature(ResourceConfig.FEATURE_REDIRECT),
                        p.getTemplate().endsWithSlash(),
                        new ResourceObjectRule(p.getTemplate(), o)));
        }
    }
View Full Code Here

Examples of com.sun.jersey.server.impl.uri.PathPattern

                        new ResourceObjectRule(p.getTemplate(), o)));
        }
    }

    private PathPattern getPattern(String path, Class c) {
        PathPattern p = null;
        try {
            p = new PathPattern(new PathTemplate(path));
        } catch (IllegalArgumentException ex) {
            Errors.error("Illegal URI template for root resource class " + c.getName() +
                    ": "+ ex.getMessage());
        }
        return p;
View Full Code Here

Examples of com.sun.jersey.server.impl.uri.PathPattern

    private boolean isPatternValid(PathPattern p, Class c) {
        if (p == null)
            return false;

        final PathPattern conflict = rules.hasConflict(p);
        if (conflict != null) {
            Errors.error(String.format("Conflicting URI templates. "
                    + "The URI template %s for root resource class %s "
                    + "and the URI template %s transform to the same regular expression %s",
                    p.getTemplate().getTemplate(),
                    c.getName(),
                    conflict.getTemplate().getTemplate(),
                    p));
            return false;
        } else {
            return true;
        }
View Full Code Here

Examples of com.sun.jersey.server.impl.uri.PathPattern

    private void processSubResourceLocators(
            final AbstractResource resource,
            final RulesMap<UriRule> rulesMap) {
        for (final AbstractSubResourceLocator locator : resource.getSubResourceLocators()) {
            PathPattern p = null;
            try {
                p = new PathPattern(new PathTemplate(locator.getPath().getValue()));
            } catch (IllegalArgumentException ex) {
                Errors.error(String.format("Illegal URI template for sub-resource locator %s: %s",
                        locator.getMethod(), ex.getMessage()));
                continue;
            }

            final PathPattern conflict = rulesMap.hasConflict(p);
            if (conflict != null) {
                Errors.error(String.format("Conflicting URI templates. "
                        + "The URI template %s for sub-resource locator %s "
                        + "and the URI template %s transform to the same regular expression %s",
                        p.getTemplate().getTemplate(),
                        locator.getMethod(),
                        conflict.getTemplate().getTemplate(),
                        p));
                continue;
            }

            final List<Injectable> is = injectableContext.getInjectable(
View Full Code Here

Examples of com.sun.jersey.server.impl.uri.PathPattern

        final Map<PathPattern, ResourceMethodMap> patternMethodMap =
                new HashMap<PathPattern, ResourceMethodMap>();

        for (final AbstractSubResourceMethod method : resource.getSubResourceMethods()) {

            PathPattern p;
            try {
                p = new PathPattern(new PathTemplate(method.getPath().getValue()), "(/)?");
            } catch (IllegalArgumentException ex) {
                Errors.error(String.format("Illegal URI template for sub-resource method %s: %s",
                        method.getMethod(), ex.getMessage()));
                continue;
            }

            final ResourceMethod rm = new ResourceHttpMethod(dp, ff, p.getTemplate(), method);
            ResourceMethodMap rmm = patternMethodMap.get(p);
            if (rmm == null) {
                rmm = new ResourceMethodMap();
                patternMethodMap.put(p, rmm);
            }

            if (isValidResourceMethod(rm, rmm)) {
                rmm.put(rm);
            }

            rmm.put(rm);
        }

        // Create the rules for the sub-resource HTTP methods
        for (final Map.Entry<PathPattern, ResourceMethodMap> e : patternMethodMap.entrySet()) {
            addImplicitMethod(implictProduces, e.getValue());

            final PathPattern p = e.getKey();
            final ResourceMethodMap rmm = e.getValue();

            processHead(rmm);
            processOptions(rmm, resource, p);

            rmm.sort();

            rulesMap.put(p,
                    new RightHandPathRule(
                            resourceConfig.getFeature(ResourceConfig.FEATURE_REDIRECT),
                            p.getTemplate().endsWithSlash(),
                            new HttpMethodRule(rmm, true, dispatchingListener)));
        }
    }
View Full Code Here

Examples of com.sun.jersey.server.impl.uri.PathPattern

    }

    public void processConflicts(ConflictClosure cc) {
        final List<PathPattern> ks = new ArrayList<PathPattern>(keySet());
        for (int i = 0; i < ks.size(); i++) {
            final PathPattern p1 = ks.get(i);
            for (int j = i + 1; j < ks.size(); j++) {
                final PathPattern p2 = ks.get(j);
                if (p1.equals(p2)) {
                    cc.onConflict(p1, p2);
                }
            }
        }
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.