protected void handleDynamicSubresource(StringBuilder sb, Set<Class<?>> jaxbTypes, ElementQNameResolver qnameResolver, Map<Class<?>, QName> clsMap, OperationResourceInfo ori, ClassResourceInfo subcri, boolean isJson) { if (!isJson) { if (subcri != null) { sb.append("<!-- Recursive subresource -->"); } else { sb.append("<!-- Dynamic subresource -->"); } } startResourceTag(sb, subcri, ori.getURITemplate().getValue()); handlePathAndMatrixParams(sb, ori, isJson); sb.append("</resource>"); }
protected void handleDynamicSubresource(StringBuilder sb, Set<Class<?>> jaxbTypes, ElementQNameResolver qnameResolver, Map<Class<?>, QName> clsMap, OperationResourceInfo ori, ClassResourceInfo subcri, boolean isJson) { if (!isJson) { if (subcri != null) { sb.append("<!-- Recursive subresource -->"); } else { sb.append("<!-- Dynamic subresource -->"); } } startResourceTag(sb, subcri, ori.getURITemplate().getValue()); handlePathAndMatrixParams(sb, ori, isJson); sb.append("</resource>"); }
public int compare(OperationResourceInfo op1, OperationResourceInfo op2) { boolean sub1 = op1.getHttpMethod() == null; boolean sub2 = op2.getHttpMethod() == null; 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; }
public int compare(final OperationResourceInfo op1, final OperationResourceInfo op2) { final boolean sub1 = op1.getHttpMethod() == null; final boolean sub2 = op2.getHttpMethod() == null; if (sub1 && !sub2) { return 1; } else if (!sub1 && sub2) { return -1; } final URITemplate ut1 = op1.getURITemplate(); final URITemplate ut2 = op2.getURITemplate(); int result = ut1.getValue().compareTo(ut2.getValue()); if (result == 0 && !(sub1)) { result = op1.getHttpMethod().compareTo(op2.getHttpMethod()); } return result; }
protected void handleDynamicSubresource(StringBuilder sb, Set<Class<?>> jaxbTypes, ElementQNameResolver qnameResolver, Map<Class<?>, QName> clsMap, OperationResourceInfo ori, ClassResourceInfo subcri, boolean isJson) { if (!isJson) { if (subcri != null) { sb.append("<!-- Recursive subresource -->"); } else { sb.append("<!-- Dynamic subresource -->"); } } startResourceTag(sb, subcri != null ? subcri.getServiceClass() : Object.class, ori.getURITemplate() .getValue()); handlePathAndMatrixParams(sb, ori, isJson); sb.append("</resource>"); }
public List<String> getMatchedURIs(boolean decode) { if (stack != null) { List<String> objects = new ArrayList<String>(); List<String> uris = new LinkedList<String>(); StringBuilder sum = new StringBuilder(""); for (MethodInvocationInfo invocation : stack) { OperationResourceInfo ori = invocation.getMethodInfo(); URITemplate[] paths = { ori.getClassResourceInfo().getURITemplate(), ori.getURITemplate() }; for (URITemplate t : paths) { if (t != null) { String v = t.getValue(); sum.append("/" + (decode ? HttpUtils.pathDecode(v) : v)); } } UriBuilder ub = UriBuilder.fromPath(sum.toString()); objects.addAll(invocation.getTemplateValues()); uris.add(0, ub.build(objects.toArray()).normalize().getRawPath()); } return uris; } LOG.fine("No resource stack information, returning empty list"); return Collections.emptyList(); }
@Override public int compare(OperationResourceInfo op1, OperationResourceInfo op2) { boolean sub1 = op1.getHttpMethod() == null; boolean sub2 = op2.getHttpMethod() == null; 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()); } if (result == 0 && ignoreOverloadedMethods && op1.getMethodToInvoke().getName().equals(op2.getMethodToInvoke().getName())) { Integer paramLen1 = op1.getMethodToInvoke().getParameterTypes().length; Integer paramLen2 = op2.getMethodToInvoke().getParameterTypes().length; result = paramLen1.compareTo(paramLen2) * -1; } return result; }
@Override public int compare(OperationResourceInfo op1, OperationResourceInfo op2) { boolean sub1 = op1.getHttpMethod() == null; boolean sub2 = op2.getHttpMethod() == null; 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()); } if (result == 0 && ignoreOverloadedMethods && op1.getMethodToInvoke().getName().equals(op2.getMethodToInvoke().getName())) { Integer paramLen1 = op1.getMethodToInvoke().getParameterTypes().length; Integer paramLen2 = op2.getMethodToInvoke().getParameterTypes().length; result = paramLen1.compareTo(paramLen2) * -1; } return result; }
private static void logNoMatchMessage(OperationResourceInfo ori, String path, String httpMethod, MediaType requestType, List<MediaType> acceptContentTypes) { org.apache.cxf.common.i18n.Message errorMsg = new org.apache.cxf.common.i18n.Message("OPER_NO_MATCH", BUNDLE, ori.getMethodToInvoke().getName(), path, ori.getURITemplate().getValue(), httpMethod, ori.getHttpMethod(), requestType.toString(), convertTypesToString(ori.getConsumeTypes()), convertTypesToString(acceptContentTypes), convertTypesToString(ori.getProduceTypes())); LOG.fine(errorMsg.toString()); }
private void trackEvent(Exchange ex) { final OperationResourceInfo ori = ex.get(OperationResourceInfo.class); if (ori != null) { final EndpointInfo endpointInfo = super.endpoints.get(ori); if (endpointInfo == null) { return; } final String servicePath = endpointInfo.getParent().getMapping() + endpointInfo.getOri().getClassResourceInfo().getURITemplate().getValue() + endpointInfo.getOri().getURITemplate().getValue(); final Request req = TribestreamRequestContextValve.REQUESTS.get(); if (req != null) { req.setAttribute("service_path", servicePath); } } }
ClassResourceInfo subcri = cri.findResource(cls, cls); if (subcri != null && !visitedResources.contains(subcri)) { startResourceTag(sb, subcri, ori.getURITemplate().getValue()); handleDocs(subcri.getServiceClass().getAnnotations(), sb, DocTarget.RESOURCE, true, isJson);
ClassResourceInfo subcri = cri.findResource(cls, cls); if (subcri != null && !visitedResources.contains(subcri)) { startResourceTag(sb, subcri, ori.getURITemplate().getValue()); handleDocs(subcri.getServiceClass().getAnnotations(), sb, DocTarget.RESOURCE, true, isJson);
ClassResourceInfo subcri = cri.findResource(cls, cls); if (subcri != null && !visitedResources.contains(subcri)) { startResourceTag(sb, subcri.getServiceClass(), ori.getURITemplate().getValue()); handleDocs(subcri.getServiceClass().getAnnotations(), sb, DocTarget.RESOURCE, true, isJson);
private static Supplier<String> matchMessageLogSupplier(OperationResourceInfo ori, String path, String httpMethod, MediaType requestType, List<MediaType> acceptContentTypes, boolean added) { org.apache.cxf.common.i18n.Message errorMsg = added ? new org.apache.cxf.common.i18n.Message("OPER_SELECTED_POSSIBLY", BUNDLE, ori.getMethodToInvoke().getName()) : new org.apache.cxf.common.i18n.Message("OPER_NO_MATCH", BUNDLE, ori.getMethodToInvoke().getName(), path, ori.getURITemplate().getValue(), httpMethod, ori.getHttpMethod(), requestType.toString(), convertTypesToString(ori.getConsumeTypes()), convertTypesToString(acceptContentTypes), convertTypesToString(ori.getProduceTypes())); return () -> errorMsg.toString(); }
protected boolean compareOperations(OperationResourceInfo ori1, OperationResourceInfo ori2) { if (ori1 == null || ori2 == null || !ori1.getURITemplate().getValue().equals(ori2.getURITemplate().getValue()) || ori1.getHttpMethod() != null && ori2.getHttpMethod() == null || ori2.getHttpMethod() != null && ori1.getHttpMethod() == null) { return false; } if (usePathParamsToCompareOperations) { int ori1PathParams = 0; int ori1MatrixParams = 0; for (Parameter p : ori1.getParameters()) { if (p.getType() == ParameterType.PATH) { ori1PathParams++; } else if (p.getType() == ParameterType.MATRIX) { ori1MatrixParams++; } } int ori2PathParams = 0; int ori2MatrixParams = 0; for (Parameter p : ori2.getParameters()) { if (p.getType() == ParameterType.PATH) { ori2PathParams++; } else if (p.getType() == ParameterType.MATRIX) { ori2MatrixParams++; } } return ori1PathParams == ori2PathParams && ori1MatrixParams == ori2MatrixParams; } return true; }
protected boolean compareOperations(OperationResourceInfo ori1, OperationResourceInfo ori2) { if (ori1 == null || ori2 == null || !ori1.getURITemplate().getValue().equals(ori2.getURITemplate().getValue()) || ori1.getHttpMethod() != null && ori2.getHttpMethod() == null || ori2.getHttpMethod() != null && ori1.getHttpMethod() == null) { return false; } if (usePathParamsToCompareOperations) { int ori1PathParams = 0; int ori1MatrixParams = 0; for (Parameter p : ori1.getParameters()) { if (p.getType() == ParameterType.PATH) { ori1PathParams++; } else if (p.getType() == ParameterType.MATRIX) { ori1MatrixParams++; } } int ori2PathParams = 0; int ori2MatrixParams = 0; for (Parameter p : ori2.getParameters()) { if (p.getType() == ParameterType.PATH) { ori2PathParams++; } else if (p.getType() == ParameterType.MATRIX) { ori2MatrixParams++; } } return ori1PathParams == ori2PathParams && ori1MatrixParams == ori2MatrixParams; } return true; }
public static boolean compareOperations(final OperationResourceInfo ori1, final OperationResourceInfo ori2) { if (ori1 == null || ori2 == null || !ori1.getURITemplate().getValue().equals(ori2.getURITemplate().getValue()) || ori1.getHttpMethod() != null && ori2.getHttpMethod() == null || ori2.getHttpMethod() != null && ori1.getHttpMethod() == null) { return false; } int ori1PathParams = 0; int ori1MatrixParams = 0; for (final Parameter p : ori1.getParameters()) { if (p.getType() == ParameterType.PATH) { ori1PathParams++; } else if (p.getType() == ParameterType.MATRIX) { ori1MatrixParams++; } } int ori2PathParams = 0; int ori2MatrixParams = 0; for (final Parameter p : ori2.getParameters()) { if (p.getType() == ParameterType.PATH) { ori2PathParams++; } else if (p.getType() == ParameterType.MATRIX) { ori2MatrixParams++; } } return ori1PathParams == ori2PathParams && ori1MatrixParams == ori2MatrixParams; }
protected boolean compareOperations(OperationResourceInfo ori1, OperationResourceInfo ori2) { if (ori1 == null || ori2 == null || !ori1.getURITemplate().getValue().equals(ori2.getURITemplate().getValue()) || ori1.getHttpMethod() != null && ori2.getHttpMethod() == null || ori2.getHttpMethod() != null && ori1.getHttpMethod() == null) { return false; } int ori1PathParams = 0; int ori1MatrixParams = 0; for (Parameter p : ori1.getParameters()) { if (p.getType() == ParameterType.PATH) { ori1PathParams++; } else if (p.getType() == ParameterType.MATRIX) { ori1MatrixParams++; } } int ori2PathParams = 0; int ori2MatrixParams = 0; for (Parameter p : ori2.getParameters()) { if (p.getType() == ParameterType.PATH) { ori2PathParams++; } else if (p.getType() == ParameterType.MATRIX) { ori2MatrixParams++; } } return ori1PathParams == ori2PathParams && ori1MatrixParams == ori2MatrixParams; }
public WadlHandler.ApplicationDefinition generate(final javax.ws.rs.core.Application jaxrsApp, final List<ClassResourceInfo> cris, final String baseUrl) { final Application wadlApplication = handler.handleApplication(jaxrsApp == null ? new javax.ws.rs.core.Application() : jaxrsApp); final WadlHandler.ApplicationDefinition definition = handler.init(wadlApplication); final Resources wadlResources = handler.handleResources().withBase(baseUrl); // implicitely not null // iterate over the resources if (cris != null) { // not sure we can do everything at the beginning cause we may not have all type handler.handlerGrammars(definition, cris); for (final ClassResourceInfo cri : cris) { final String basePath = cri.getURITemplate().getValue(); final Resource wadlResource = doHandleResource(cri, basePath, new HashSet<ClassResourceInfo>()); if (wadlResource != null) { wadlResources.withResource(wadlResource); } } } if (!wadlResources.getResource().isEmpty()) { wadlApplication.withResources(wadlResources); } return definition; }