Examples of URITemplate


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

                Customer.class.getMethod("testConversion",
                                         new Class[]{PathSegmentImpl.class,
                                                     SimpleFactory.class}),
                cri);
        ori.setHttpMethod("GET");
        ori.setURITemplate(new URITemplate("{id1}/{id2}"));
        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
        values.putSingle("id1", "1");
        values.putSingle("id2", "2");
       
        Message m = createMessage();
View Full Code Here

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

        boolean samePathOperationFollows = singleResourceMultipleMethods && compareOperations(ori, nextOp);

        String path = ori.getURITemplate().getValue();
        if (!resourceTagOpened && openResource(path)) {
            resourceTagOpened = true;
            URITemplate template = ori.getClassResourceInfo().getURITemplate();
            if (template != null) {
                String parentPath = template.getValue();
                if (parentPath.endsWith("/") && path.startsWith("/") && path.length() > 1) {
                    path = path.substring(1);
                }
            }
            sb.append("<resource path=\"").append(getPath(path)).append("\">");
View Full Code Here

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

                if (sub1 && !sub2) {
                    return 1;
                } else if (!sub1 && sub2) {
                    return -1;
                }
                URITemplate ut1 = op1.getURITemplate();
                URITemplate ut2 = op2.getURITemplate();
                int result = ut1.getValue().compareTo(ut2.getValue());
                if (result == 0 && !(sub1 && sub2)) {
                    result = op1.getHttpMethod().compareTo(op2.getHttpMethod());
                }
                return result;
            }
View Full Code Here

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

     * @param values template variable values
     * @return updated WebClient
     */
    public WebClient path(String path, Object... values) {
        URI u = UriBuilder.fromUri(URI.create("http://tempuri")).path(path).buildFromEncoded(values);
        getState().setTemplates(getTemplateParametersMap(new URITemplate(path), Arrays.asList(values)));
        return path(u.getRawPath());
    }
View Full Code Here

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

        int produceMatched = 0;
       
        boolean subresourcesOnly = true;
        for (MediaType acceptType : acceptContentTypes) {
            for (OperationResourceInfo ori : resource.getMethodDispatcher().getOperationResourceInfos()) {
                URITemplate uriTemplate = ori.getURITemplate();
                MultivaluedMap<String, String> map = new MetadataMap<String, String>(values);
                if (uriTemplate != null && uriTemplate.match(path, map)) {
                    boolean added = false;
                    if (ori.isSubResourceLocator()) {
                        candidateList.put(ori, map);
                        added = true;
                    } else {
View Full Code Here

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

            throw new RuntimeException("Resource class " + sClass.getName() + " has no model info");
        }
        ClassResourceInfo cri =
            new ClassResourceInfo(sClass, sClass, isRoot, enableStatic, true,
                                  model.getConsumes(), model.getProduces());
        URITemplate t = URITemplate.createTemplate(model.getPath());
        cri.setURITemplate(t);
        MethodDispatcher md = new MethodDispatcher();
        Map<String, UserOperation> ops = model.getOperationsAsMap();
        for (Method m : cri.getServiceClass().getMethods()) {
            UserOperation op = ops.get(m.getName());
View Full Code Here

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

                                                            boolean root,
                                                            boolean enableStatic) {
        ClassResourceInfo cri  = new ClassResourceInfo(rClass, sClass, root, enableStatic);
        cri.setParent(parent);
        if (root) {
            URITemplate t = URITemplate.createTemplate(cri.getPath());
            cri.setURITemplate(t);
        }
       
        evaluateResourceClass(cri, enableStatic);
        return checkMethodDispatcher(cri) ? cri : null;
View Full Code Here

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

   
   
    private static OperationResourceInfo createOperationInfo(Method m, Method annotatedMethod,
                                                      ClassResourceInfo cri, Path path, String httpMethod) {
        OperationResourceInfo ori = new OperationResourceInfo(m, annotatedMethod, cri);
        URITemplate t = URITemplate.createTemplate(path);
        ori.setURITemplate(t);
        ori.setHttpMethod(httpMethod);
        return ori;
    }
View Full Code Here

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

        final int resolvedTsSize = alreadyResolvedTs.size()
            + alreadyResolvedEncTs.size()
            + alreadyResolvedTsPathEnc.size();
       
        String thePath = buildPath();
        URITemplate pathTempl = new URITemplate(thePath);
        thePath = substituteVarargs(pathTempl, alreadyResolvedTs, alreadyResolvedTsPathEnc,
                                    alreadyResolvedEncTs, values, 0, false, fromEncoded,
                                    allowUnresolved, encodePathSlash);
        int pathTemplateVarsSize = pathTempl.getVariables().size();
       
        String theQuery = buildQuery();
        int queryTemplateVarsSize = 0;
        if (theQuery != null) {
            URITemplate queryTempl = new URITemplate(theQuery);
            queryTemplateVarsSize = queryTempl.getVariables().size();
            if (queryTemplateVarsSize > 0) {
                int lengthDiff = values.length + resolvedTsSize
                    - alreadyResolvedTs.size() - alreadyResolvedTsPathEnc.size() - alreadyResolvedEncTs.size()
                    - pathTemplateVarsSize;
                theQuery = substituteVarargs(queryTempl, alreadyResolvedTs, alreadyResolvedTsPathEnc,
                                             alreadyResolvedEncTs, values, values.length - lengthDiff,
                                             true, fromEncoded, allowUnresolved, false);
            }
        }
       
        String theFragment = fragment;
        if (theFragment != null) {
            URITemplate fragmentTempl = new URITemplate(theFragment);
            if (fragmentTempl.getVariables().size() > 0) {
                int lengthDiff = values.length  + resolvedTsSize
                    - alreadyResolvedTs.size() - alreadyResolvedTsPathEnc.size() - alreadyResolvedEncTs.size()
                    - pathTemplateVarsSize - queryTemplateVarsSize;
                theFragment = substituteVarargs(fragmentTempl, alreadyResolvedTs, alreadyResolvedTsPathEnc,
                                                alreadyResolvedEncTs, values, values.length - lengthDiff,
View Full Code Here

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

                                    Map<String, Object> alreadyResolvedTsEnc,
                                    boolean isQuery,
                                    boolean fromEncoded,
                                    boolean encodePathSlash) {
    //CHECKSTYLE:ON
        URITemplate templ = new URITemplate(path);
       
        Set<String> uniqueVars = new HashSet<String>(templ.getVariables());
        if (varValueMap.size() + alreadyResolvedTs.size() + alreadyResolvedTsEnc.size()
            + alreadyResolvedTsPathEnc.size() < uniqueVars.size()) {
            throw new IllegalArgumentException("Unresolved variables; only " + varValueMap.size()
                                               + " value(s) given for " + uniqueVars.size()
                                               + " unique variable(s)");
        }
       
        Set<String> pathEncodeVars = alreadyResolvedTsPathEnc.isEmpty() && !encodePathSlash
            ? Collections.<String>emptySet() : new HashSet<String>();
       
        Map<String, Object> theMap = new LinkedHashMap<String, Object>();
        for (String var : uniqueVars) {
            boolean isPathEncVar = !isQuery && alreadyResolvedTsPathEnc.containsKey(var);
           
            boolean isVarEncoded = isPathEncVar || alreadyResolvedTs.containsKey(var) ? false : true;
            Map<String, Object> resolved = isVarEncoded ? alreadyResolvedTsEnc
                : isPathEncVar ? alreadyResolvedTsPathEnc : alreadyResolvedTs;
            Object oval = resolved.isEmpty() ? null : resolved.remove(var);
            if (oval == null) {
                oval = varValueMap.get(var);
           
            if (oval == null) {
                throw new IllegalArgumentException("No object for " + var);
            }
            if (fromEncoded) {
                oval = HttpUtils.encodePartiallyEncoded(oval.toString(), isQuery);
            } else {
                oval = isQuery ? HttpUtils.queryEncode(oval.toString()) : HttpUtils.pathEncode(oval.toString());
            }
            theMap.put(var, oval);
            if (!isQuery && (isPathEncVar || encodePathSlash)) {
                pathEncodeVars.add(var);
            }
        }
        return templ.substitute(theMap, pathEncodeVars, false);
    }
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.