public int compare(ClassResourceInfo cr1, ClassResourceInfo cr2) { if (rc != null) { int result = rc.compare(cr1, cr2, message); if (result != 0) { return result; } } return URITemplate.compareTemplates( cr1.getURITemplate(), cr2.getURITemplate()); } }
public int compare(ClassResourceInfo cr1, ClassResourceInfo cr2) { int result = 0; if (rc != null) { result = rc.compare(cr1, cr2, message); if (result != 0) { return result; } } result = URITemplate.compareTemplates( cr1.getURITemplate(), cr2.getURITemplate()); return result == 0 ? -1 : result; } }
private void initValuesMap(Object... varValues) { if (isRoot) { List<String> vars = cri.getURITemplate().getVariables(); valuesMap = new LinkedHashMap<>(); for (int i = 0; i < vars.size(); i++) { if (varValues.length > 0) { if (i < varValues.length) { valuesMap.put(vars.get(i), varValues[i]); } else { org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message( "ROOT_VARS_MISMATCH", BUNDLE, vars.size(), varValues.length); LOG.info(msg.toString()); break; } } else { valuesMap.put(vars.get(i), ""); } } } }
private void initValuesMap(Object... varValues) { if (isRoot) { List<String> vars = cri.getURITemplate().getVariables(); valuesMap = new LinkedHashMap<>(); for (int i = 0; i < vars.size(); i++) { if (varValues.length > 0) { if (i < varValues.length) { valuesMap.put(vars.get(i), varValues[i]); } else { org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message( "ROOT_VARS_MISMATCH", BUNDLE, vars.size(), varValues.length); LOG.info(msg.toString()); break; } } else { valuesMap.put(vars.get(i), ""); } } } }
private void initValuesMap(Object... varValues) { if (isRoot) { List<String> vars = cri.getURITemplate().getVariables(); valuesMap = new LinkedHashMap<String, Object>(); for (int i = 0; i < vars.size(); i++) { if (varValues.length > 0) { if (i < varValues.length) { valuesMap.put(vars.get(i), varValues[i]); } else { org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message( "ROOT_VARS_MISMATCH", BUNDLE, vars.size(), varValues.length); LOG.info(msg.toString()); break; } } else { valuesMap.put(vars.get(i), ""); } } } }
public List<ClassResourceInfo> getResourcesList(Message m, UriInfo ui) { final String slash = "/"; String path = ui.getPath(); if (!path.startsWith(slash)) { path = slash + path; } List<ClassResourceInfo> all = ((JAXRSServiceImpl)m.getExchange().getService()) .getClassResourceInfos(); boolean absolutePathSlashOn = checkAbsolutePathSlash && ui.getAbsolutePath().getPath().endsWith(slash); if (slash.equals(path) && !absolutePathSlashOn) { return all; } List<ClassResourceInfo> cris = new LinkedList<>(); for (ClassResourceInfo cri : all) { MultivaluedMap<String, String> map = new MetadataMap<>(); if (cri.getURITemplate().match(path, map) && slash.equals(map.getFirst(URITemplate.FINAL_MATCH_GROUP))) { cris.add(cri); } } return cris; }
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(); }
public List<ClassResourceInfo> getResourcesList(Message m, UriInfo ui) { final String slash = "/"; String path = ui.getPath(); if (!path.startsWith(slash)) { path = slash + path; } List<ClassResourceInfo> all = ((JAXRSServiceImpl)m.getExchange().getService()) .getClassResourceInfos(); boolean absolutePathSlashOn = checkAbsolutePathSlash && ui.getAbsolutePath().getPath().endsWith(slash); if (slash.equals(path) && !absolutePathSlashOn) { return all; } List<ClassResourceInfo> cris = new LinkedList<>(); for (ClassResourceInfo cri : all) { MultivaluedMap<String, String> map = new MetadataMap<>(); if (cri.getURITemplate().match(path, map) && slash.equals(map.getFirst(URITemplate.FINAL_MATCH_GROUP))) { cris.add(cri); } } return cris; }
OperationResourceInfo ori = invocation.getMethodInfo(); URITemplate[] paths = { ori.getClassResourceInfo().getURITemplate(), ori.getURITemplate() };
if (resources.size() == 1) { MultivaluedMap<String, String> values = new MetadataMap<>(); return resources.get(0).getURITemplate().match(path, values) ? Collections.singletonMap(resources.get(0), values) : null; if (cri.getURITemplate().match(path, map)) { candidateList.put(cri, map); LOG.fine(() -> new org.apache.cxf.common.i18n.Message("CRI_SELECTED_POSSIBLY", cri.getServiceClass().getName(), path, cri.getURITemplate().getValue()).toString()); } else { LOG.fine(() -> new org.apache.cxf.common.i18n.Message("CRI_NO_MATCH", cris.put(cri, entry.getValue()); } else if (firstCri != null && URITemplate.compareTemplates(firstCri.getURITemplate(), cri.getURITemplate()) == 0) { cris.put(cri, entry.getValue()); } else { BUNDLE, cri.getServiceClass().getName(), path, cri.getURITemplate().getValue()).toString());
return resources.get(0).getURITemplate().match(path, values) ? resources.get(0) : null; if (cri.getURITemplate().match(path, map)) { candidateList.put(cri, map); if (isFineLevelLoggable) { cri.getServiceClass().getName(), path, cri.getURITemplate().getValue()).toString()); BUNDLE, cri.getServiceClass().getName(), path, cri.getURITemplate().getValue()).toString());
Set<ClassResourceInfo> visitedResources = new LinkedHashSet<>(); for (ClassResourceInfo cri : cris) { startResourceTag(sbResources, cri, cri.getURITemplate().getValue());
Set<ClassResourceInfo> visitedResources = new LinkedHashSet<ClassResourceInfo>(); for (ClassResourceInfo cri : cris) { startResourceTag(sbResources, cri.getServiceClass(), cri.getURITemplate().getValue()); Annotation description = AnnotationUtils.getClassAnnotation(cri.getServiceClass(), Description.class); if (description == null) {
cri.getMethodDispatcher().getOperationResourceInfos().forEach(ori -> { String normalizedPath = getNormalizedPath( cri.getURITemplate().getValue(), ori.getURITemplate().getValue()); tag.setName(cri.getURITemplate().getValue().replaceAll("/", "_")); if (javadocProvider != null) { tag.setDescription(javadocProvider.getClassDoc(cri));
cri.getMethodDispatcher().getOperationResourceInfos().forEach(ori -> { String normalizedPath = getNormalizedPath( cri.getURITemplate().getValue(), ori.getURITemplate().getValue()); tag.setName(cri.getURITemplate().getValue().replaceAll("/", "_")); if (javadocProvider != null) { tag.setDescription(javadocProvider.getClassDoc(cri));
boolean isRoot = cri.getURITemplate() != null; ClientState actualState = getActualState(); ClientProxyImpl proxyImpl = createClientProxy(cri, isRoot, actualState, varValues);
boolean isRoot = cri.getURITemplate() != null; ClientState actualState = getActualState(); ClientProxyImpl proxyImpl = createClientProxy(cri, isRoot, actualState, varValues);
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); } } }
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; }
public static void pushOntoStack(OperationResourceInfo ori, MultivaluedMap<String, String> params, Message msg) { OperationResourceInfoStack stack = msg.get(OperationResourceInfoStack.class); if (stack == null) { stack = new OperationResourceInfoStack(); msg.put(OperationResourceInfoStack.class, stack); } List<String> values = null; if (params.size() <= 1) { values = Collections.emptyList(); } else { values = new ArrayList<>(params.size() - 1); addTemplateVarValues(values, params, ori.getClassResourceInfo().getURITemplate()); addTemplateVarValues(values, params, ori.getURITemplate()); } Class<?> realClass = ori.getClassResourceInfo().getServiceClass(); stack.push(new MethodInvocationInfo(ori, realClass, values)); }