private void startMethodTag(StringBuilder sb, OperationResourceInfo ori) { sb.append("<method name=\"").append(ori.getHttpMethod()).append("\""); if (addResourceAndMethodIds) { sb.append(" id=\"").append(getMethod(ori).getName()).append("\""); } sb.append(">"); } protected void endMethodTag(StringBuilder sb, OperationResourceInfo ori) {
protected Message createMessage(Object body, OperationResourceInfo ori, MultivaluedMap<String, String> headers, URI currentURI, Exchange exchange, Map<String, Object> invocationContext, boolean isProxy) { return createMessage(body, ori.getHttpMethod(), headers, currentURI, exchange, invocationContext, isProxy); }
protected Message createMessage(Object body, OperationResourceInfo ori, MultivaluedMap<String, String> headers, URI currentURI, Exchange exchange, Map<String, Object> invocationContext, boolean isProxy) { return createMessage(body, ori.getHttpMethod(), headers, currentURI, exchange, invocationContext, isProxy); }
public Set<String> getAllowedMethods() { Set<String> methods = new HashSet<>(); for (OperationResourceInfo o : methodDispatcher.getOperationResourceInfos()) { String method = o.getHttpMethod(); if (method != null) { methods.add(method); } } return methods; }
protected void startMethodTag(StringBuilder sb, OperationResourceInfo ori) { sb.append("<method name=\"").append(ori.getHttpMethod()).append("\""); if (idGenerator != null) { String id = idGenerator.getMethodResourceId(ori); sb.append(" id=\"").append(id).append("\""); } sb.append(">"); } protected void endMethodTag(StringBuilder sb, OperationResourceInfo ori) {
public Set<String> getAllowedMethods() { Set<String> methods = new HashSet<String>(); for (OperationResourceInfo o : methodDispatcher.getOperationResourceInfos()) { String method = o.getHttpMethod(); if (method != null) { methods.add(method); } } return methods; }
protected void startMethodTag(StringBuilder sb, OperationResourceInfo ori) { sb.append("<method name=\"").append(ori.getHttpMethod()).append("\""); if (idGenerator != null) { String id = idGenerator.getMethodResourceId(ori); sb.append(" id=\"").append(id).append("\""); } sb.append(">"); } protected void endMethodTag(StringBuilder sb, OperationResourceInfo ori) {
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; }
@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; }
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; }
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()); }
OperationResourceInfo ori = sortedOps.get(i); if (ori.getHttpMethod() == null) { Class<?> cls = getMethod(ori).getReturnType(); ClassResourceInfo subcri = cri.findResource(cls, cls);
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(); }
@Override public Method handleMethod(final ClassResourceInfo cri, final OperationResourceInfo ori) { return new Method() .withName(ori.getHttpMethod()) .withDoc(handlerDoc(getDescription(new MetaAnnotatedMethod(getMethod(ori))), DocTarget.METHOD)); }
private void prepareAndSendEvent(final OperationResourceInfo ori, final EndpointInfo endpointInfo, final ApplicationInfo applicationInfo, final long handlingTime, final int httpStatus) { if (!isEventEnabled) { return; } try { final JaxrsServiceInvocationEvent event = new JaxrsServiceInvocationEvent(); event.setCategory("jaxrs"); event.setSubCategory("service"); event.setElapsedTimeNano(handlingTime * 1000000); // convert ms to ns event.setStatus(httpStatus); event.setHttpMethod(ori.getHttpMethod()); event.setRequestTemplate(endpointInfo.getUri().getPath()); event.setApplicationPath(applicationInfo.getMapping()); event.setMethodToInvoke(endpointInfo.getMethodName()); SystemInstance.get().fireEvent(event); } catch (final Throwable throwable) { LOGGER.severe(ContainerCodes.RESPOSNE_TIME_INTERCEPTOR_ERROR, String.format("Could not fire event for JAXRS invocation %s. Error is %s", ori.getHttpMethod(), throwable.getMessage()) ); } }
public void filter(ContainerRequestContext reqC, ContainerResponseContext respC) throws IOException { Message m = JAXRSUtils.getCurrentMessage(); OperationResourceInfo ori = m.getExchange().get(OperationResourceInfo.class); String method = ori.getHttpMethod(); if ("PUT".equals(method)) { XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(m.getContent(OutputStream.class)); m.setContent(XMLStreamWriter.class, new CustomXmlStreamWriter(writer)); } }