@Override protected void processMethod(ResourceFactory rf, String base, ResourceLocator method) ResteasyUriBuilder builder = new ResteasyUriBuilder(); if (base != null) { builder.path(base); builder.path(method.getFullpath()); String fullpath = builder.getPath(); if (fullpath == null) { fullpath = ""; builder = new ResteasyUriBuilder(); if (base != null) { builder.path(base); builder.path(method.getResourceClass().getPath()); String classExpression = builder.getPath(); if (classExpression == null) { classExpression = "";
if (classPathAnno != null) { classTemplate = (ResteasyUriBuilder) UriBuilder.fromUri(classPathAnno.value()); classLevelVariables.addAll(classTemplate.getPathParamNamesInDeclarationOrder()); template.host("localhost"); Set<String> allVariables = new HashSet<>(template.getPathParamNamesInDeclarationOrder()); Map<String, Object> paramMap = new HashMap<>(); for (Parameter p : method.getParameters()) { template.resolveTemplates(paramMap, false).build(); } catch (IllegalArgumentException ex) { throw new RestClientDefinitionException("Parameter names don't match variable names on " + typeDef + "::" + method.getName(), ex);
/** * Get a new UriBuilder explicitly using RESTEasy implementation * (instead of running UriBuilder.fromUri(uri) which relies on * current registered JAX-RS implementation) * * @param uri * @return */ private static UriBuilder uriBuilderFromUri(URI uri) { return new ResteasyUriBuilder().uri(uri); }
public ClientInvoker(URI baseUri, Class declaring, Method method, ProxyConfig config) { this.declaring = declaring; this.method = method; this.marshallers = ClientMarshallerFactory.createMarshallers(declaring, method, providerFactory, config.getServerConsumes()); this.providerFactory = (org.jboss.resteasy.spi.old.ResteasyProviderFactory)config.getProviderFactory(); this.executor = config.getExecutor(); final MediaType[] acpts = MediaTypeHelper.getProduces(declaring, method, config.getServerProduces()); accepts = acpts != null ? acpts[0] : null; this.uri = new ResteasyUriBuilder(); this.baseUri = baseUri; uri.uri(baseUri); if (declaring.isAnnotationPresent(Path.class)) uri.path(declaring); if (method.isAnnotationPresent(Path.class)) uri.path(method); this.extractorFactory = config.getExtractorFactory(); this.extractor = extractorFactory.createExtractor(method); }
@Override public ResteasyWebTarget queryParamsNoTemplate(MultivaluedMap<String, Object> parameters) throws IllegalArgumentException, NullPointerException { client.abortIfClosed(); if (parameters == null) throw new NullPointerException(Messages.MESSAGES.parametersWasNull()); ResteasyUriBuilder copy; if (uriBuilder instanceof ResteasyUriBuilder) { copy = (ResteasyUriBuilder)uriBuilder.clone(); } else { copy = (ResteasyUriBuilder)ResteasyUriBuilder.fromTemplate(uriBuilder.toTemplate()); } for (Map.Entry<String, List<Object>> entry : parameters.entrySet()) { String[] stringValues = toStringValues(entry.getValue().toArray()); for (String val : stringValues) { copy.clientQueryParam(entry.getKey(), val); } } return new ClientWebTarget(client, copy, configuration); }
private static UriBuilder getBuilder(String uriTemplate) { return new ResteasyUriBuilder().uriTemplate(uriTemplate); }
return finalUri; ResteasyUriBuilder builder = (ResteasyUriBuilder) uri.clone(); if (matrixParameters != null) builder.matrixParam(entry.getKey(), value); builder.clientQueryParam(entry.getKey(), value); finalUri = builder.build(pathParameterList.toArray()).toString(); builder.substitutePathParam(entry.getKey(), value, true); finalUri = builder.build().toString(); return finalUri;
protected ResteasyUriBuilder getUriBuilder(Class<? extends Object> clazz) { MappedBy mappedBy = clazz.getAnnotation(MappedBy.class); ResteasyUriBuilder uriBuilderImpl = new ResteasyUriBuilder(); Class<?> resourceType = mappedBy.resource(); uriBuilderImpl.path(resourceType); String method = mappedBy.method(); if (method != null && method.length() > 0) { uriBuilderImpl.path(resourceType, method); } return uriBuilderImpl; } }
@Override public UriBuilder resolveTemplates(Map<String, Object> templateValues) throws IllegalArgumentException { if (templateValues == null) throw new IllegalArgumentException(Messages.MESSAGES.templateValuesParamNull()); if (templateValues.containsKey(null)) throw new IllegalArgumentException(Messages.MESSAGES.mapKeyNull()); String str = buildString(templateValues, false, true, true); return fromTemplate(str); }
@Override public void start() throws Exception { initAuthentication(); method = registration.getTarget().getMethod(); if (method == null) method = "POST"; contentType = registration.getTarget().getType(); targetUri = ResteasyUriBuilder.fromTemplate(registration.getTarget().getHref()); }
protected ResteasyUriBuilder getUriBuilder(Class<? extends Object> clazz) { String uriTemplate = clazz.getAnnotation(URITemplate.class).value(); ResteasyUriBuilder uriBuilderImpl = new ResteasyUriBuilder(); uriBuilderImpl.replacePath(uriTemplate); return uriBuilderImpl; } }
@SuppressWarnings("unchecked") public String resolveURI(Object object) { Class<? extends Object> clazz = AnnotationResolver .getClassWithAnnotation(object.getClass(), getAnnotationType()); ResteasyUriBuilder uriBuilderImpl = getUriBuilder(clazz); Map<String, PropertyDescriptor> descriptors = getPropertyDescriptors(clazz); List<Object> values = getValues(object, descriptors, uriBuilderImpl .getPathParamNamesInDeclarationOrder()); return uriBuilderImpl.build(values.toArray()).toString(); }
public UriBuilder createUriBuilder() { return new ResteasyUriBuilder(); }
@Override public UriBuilder resolveTemplate(String name, Object value) throws IllegalArgumentException { if (name == null) throw new IllegalArgumentException(Messages.MESSAGES.nameParamIsNull()); if (value == null) throw new IllegalArgumentException(Messages.MESSAGES.valueParamIsNull()); HashMap<String, Object> vals = new HashMap<String, Object>(); vals.put(name, value); return resolveTemplates(vals); }
@Override public UriBuilder segment(String... segments) throws IllegalArgumentException { if (segments == null) throw new IllegalArgumentException(Messages.MESSAGES.segmentsParameterNull()); for (String segment : segments) { if (segment == null) throw new IllegalArgumentException(Messages.MESSAGES.segmentNull()); path(Encode.encodePathSegment(segment)); } return this; }
public void overrideUri(URI uri) { this.uri.uri(uri); }
if (classPathAnno != null) { classTemplate = (ResteasyUriBuilder) UriBuilder.fromUri(classPathAnno.value()); classLevelVariables.addAll(classTemplate.getPathParamNamesInDeclarationOrder()); template.host("localhost"); Set<String> allVariables = new HashSet<>(template.getPathParamNamesInDeclarationOrder()); Map<String, Object> paramMap = new HashMap<>(); for (Parameter p : method.getParameters()) { template.resolveTemplates(paramMap, false).build(); } catch (IllegalArgumentException ex) { throw new RestClientDefinitionException("Parameter names don't match variable names on " + typeDef + "::" + method.getName(), ex);
/** * Get a new UriBuilder explicitly using RESTEasy implementation * (instead of running UriBuilder.fromUri(uri) which relies on * current registered JAX-RS implementation) * * @param uri * @return */ private static UriBuilder uriBuilderFromUri(URI uri) { return new ResteasyUriBuilder().uri(uri); }
public ClientInvoker(URI baseUri, Class declaring, Method method, ProxyConfig config) { this.declaring = declaring; this.method = method; this.marshallers = ClientMarshallerFactory.createMarshallers(declaring, method, providerFactory, config.getServerConsumes()); this.providerFactory = config.getProviderFactory(); this.executor = config.getExecutor(); accepts = MediaTypeHelper.getProduces(declaring, method, config.getServerProduces()); this.uri = new ResteasyUriBuilder(); this.baseUri = baseUri; uri.uri(baseUri); if (declaring.isAnnotationPresent(Path.class)) uri.path(declaring); if (method.isAnnotationPresent(Path.class)) uri.path(method); this.extractorFactory = config.getExtractorFactory(); this.extractor = extractorFactory.createExtractor(method); }
@Override public ResteasyWebTarget queryParamsNoTemplate(MultivaluedMap<String, Object> parameters) throws IllegalArgumentException, NullPointerException { client.abortIfClosed(); if (parameters == null) throw new NullPointerException(Messages.MESSAGES.parametersWasNull()); ResteasyUriBuilder copy; if (uriBuilder instanceof ResteasyUriBuilder) { copy = (ResteasyUriBuilder)uriBuilder.clone(); } else { copy = (ResteasyUriBuilder)ResteasyUriBuilder.fromTemplate(uriBuilder.toTemplate()); } for (Map.Entry<String, List<Object>> entry : parameters.entrySet()) { String[] stringValues = toStringValues(entry.getValue().toArray()); for (String val : stringValues) { copy.clientQueryParam(entry.getKey(), val); } } return newInstance(client, copy, configuration); }