/** * Perform a <code>PUT</code> request against the specified URL. * * @param url * The URL of the remote REST resource. * Can be any of the following: {@link String}, {@link URI}, {@link URL}. * @param o * The object to serialize and transmit to the URL as the body of the request. * Can be of the following types: * <ul class='spaced-list'> * <li> * {@link Reader} - Raw contents of {@code Reader} will be serialized to remote resource. * <li> * {@link InputStream} - Raw contents of {@code InputStream} will be serialized to remote resource. * <li> * {@link Object} - POJO to be converted to text using the {@link Serializer} registered with the * {@link RestClient}. * <li> * {@link HttpEntity} - Bypass Juneau serialization and pass HttpEntity directly to HttpClient. * </ul> * @return * A {@link RestCall} object that can be further tailored before executing the request * and getting the response as a parsed object. * @throws RestCallException If any authentication errors occurred. */ public RestCall doPut(Object url, Object o) throws RestCallException { return doCall("PUT", url, true).body(o); }
/** * Perform a <code>PUT</code> request against the specified URL. * * @param url * The URL of the remote REST resource. * Can be any of the following: {@link String}, {@link URI}, {@link URL}. * @param o * The object to serialize and transmit to the URL as the body of the request. * Can be of the following types: * <ul class='spaced-list'> * <li> * {@link Reader} - Raw contents of {@code Reader} will be serialized to remote resource. * <li> * {@link InputStream} - Raw contents of {@code InputStream} will be serialized to remote resource. * <li> * {@link Object} - POJO to be converted to text using the {@link Serializer} registered with the * {@link RestClient}. * <li> * {@link HttpEntity} - Bypass Juneau serialization and pass HttpEntity directly to HttpClient. * </ul> * @return * A {@link RestCall} object that can be further tailored before executing the request * and getting the response as a parsed object. * @throws RestCallException If any authentication errors occurred. */ public RestCall doPut(Object url, Object o) throws RestCallException { return doCall("PUT", url, true).body(o); }
/** * Perform a <code>PUT</code> request against the specified URL. * * @param url * The URL of the remote REST resource. * Can be any of the following: {@link String}, {@link URI}, {@link URL}. * @param o * The object to serialize and transmit to the URL as the body of the request. * Can be of the following types: * <ul class='spaced-list'> * <li> * {@link Reader} - Raw contents of {@code Reader} will be serialized to remote resource. * <li> * {@link InputStream} - Raw contents of {@code InputStream} will be serialized to remote resource. * <li> * {@link Object} - POJO to be converted to text using the {@link Serializer} registered with the * {@link RestClient}. * <li> * {@link HttpEntity} - Bypass Juneau serialization and pass HttpEntity directly to HttpClient. * </ul> * @return * A {@link RestCall} object that can be further tailored before executing the request * and getting the response as a parsed object. * @throws RestCallException If any authentication errors occurred. */ public RestCall doPut(Object url, Object o) throws RestCallException { return doCall("PUT", url, true).body(o); }
return doCall("POST", url, true).body(o);
return doCall("POST", url, true).body(o);
return doCall("POST", url, true).body(o);
/** * Perform a <code>POST</code> request with a content type of <code>application/x-www-form-urlencoded</code> * against the specified URL. * * @param url * The URL of the remote REST resource. * Can be any of the following: {@link String}, {@link URI}, {@link URL}. * @param o * The object to serialize and transmit to the URL as the body of the request, serialized as a form post * using the {@link UrlEncodingSerializer#DEFAULT} serializer. * @return * A {@link RestCall} object that can be further tailored before executing the request and getting the response * as a parsed object. * @throws RestCallException If any authentication errors occurred. */ public RestCall doFormPost(Object url, Object o) throws RestCallException { return doCall("POST", url, true) .body(o instanceof HttpEntity ? o : new RestRequestEntity(o, urlEncodingSerializer, null)); }
/** * Perform a <code>POST</code> request with a content type of <code>application/x-www-form-urlencoded</code> * against the specified URL. * * @param url * The URL of the remote REST resource. * Can be any of the following: {@link String}, {@link URI}, {@link URL}. * @param o * The object to serialize and transmit to the URL as the body of the request, serialized as a form post * using the {@link UrlEncodingSerializer#DEFAULT} serializer. * @return * A {@link RestCall} object that can be further tailored before executing the request and getting the response * as a parsed object. * @throws RestCallException If any authentication errors occurred. */ public RestCall doFormPost(Object url, Object o) throws RestCallException { return doCall("POST", url, true) .body(o instanceof HttpEntity ? o : new RestRequestEntity(o, urlEncodingSerializer, null)); }
/** * Perform a <code>POST</code> request with a content type of <code>application/x-www-form-urlencoded</code> * against the specified URL. * * @param url * The URL of the remote REST resource. * Can be any of the following: {@link String}, {@link URI}, {@link URL}. * @param o * The object to serialize and transmit to the URL as the body of the request, serialized as a form post * using the {@link UrlEncodingSerializer#DEFAULT} serializer. * @return * A {@link RestCall} object that can be further tailored before executing the request and getting the response * as a parsed object. * @throws RestCallException If any authentication errors occurred. */ public RestCall doFormPost(Object url, Object o) throws RestCallException { return doCall("POST", url, true) .body(o instanceof HttpEntity ? o : new RestRequestEntity(o, urlEncodingSerializer, null)); }
@Override /* InvocationHandler */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { RemoteInterfaceMethod rim = rm.getMethodMeta(method); if (rim == null) throw new RuntimeException("Method is not exposed as a remote method."); String url = rim.getUrl(); try (RestCall rc = doCall("POST", url, true)) { rc.serializer(serializer).parser(parser).body(args); Object v = rc.getResponse(method.getGenericReturnType()); if (v == null && method.getReturnType().isPrimitive()) v = ClassUtils.getPrimitiveDefault(method.getReturnType()); return v; } catch (RestCallException e) { // Try to throw original exception if possible. e.throwServerException(interfaceClass.getClassLoader(), method.getExceptionTypes()); throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } } });
@Override /* InvocationHandler */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { RemoteInterfaceMethod rim = rm.getMethodMeta(method); if (rim == null) throw new RuntimeException("Method is not exposed as a remote method."); String url = rim.getUrl(); try (RestCall rc = doCall("POST", url, true)) { rc.serializer(serializer).parser(parser).body(args); Object v = rc.getResponse(method.getGenericReturnType()); if (v == null && method.getReturnType().isPrimitive()) v = ClassUtils.getPrimitiveDefault(method.getReturnType()); return v; } catch (RestCallException e) { // Try to throw original exception if possible. e.throwServerException(interfaceClass.getClassLoader(), method.getExceptionTypes()); throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } } });
@Override /* InvocationHandler */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { RemoteInterfaceMethod rim = rm.getMethodMeta(method); if (rim == null) throw new RuntimeException("Method is not exposed as a remote method."); String url = rim.getUrl(); try (RestCall rc = doCall("POST", url, true)) { rc.serializer(serializer).parser(parser).body(args); Object v = rc.getResponse(method.getGenericReturnType()); if (v == null && method.getReturnType().isPrimitive()) v = ClassUtils.getPrimitiveDefault(method.getReturnType()); return v; } catch (RestCallException e) { // Try to throw original exception if possible. e.throwServerException(interfaceClass.getClassLoader(), method.getExceptionTypes()); throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } } });
rc = doCall(method, uri, content != null); if (content != null) rc.body(new StringEntity(content)); if (h != null) for (Map.Entry<String,Object> e : h.entrySet())
rc = doCall(method, uri, content != null); if (content != null) rc.body(new StringEntity(content)); if (h != null) for (Map.Entry<String,Object> e : h.entrySet())
RestCall rc = doCall(method.name(), url, method.hasContent()); if (method.hasContent()) rc.body(content); return rc;
RestCall rc = doCall(method.name(), url, method.hasContent()); if (method.hasContent()) rc.body(content); return rc;
RestCall rc = doCall(method.name(), url, method.hasContent()); if (method.hasContent()) rc.body(content); return rc;
} else if (value instanceof Reader || value instanceof InputStream) { contentType("application/x-www-form-urlencoded"); body(value); } else if (value instanceof CharSequence) { try { contentType("application/x-www-form-urlencoded"); body(new StringEntity(value.toString())); } catch (UnsupportedEncodingException e) {} } else {
} else if (value instanceof Reader || value instanceof InputStream) { contentType("application/x-www-form-urlencoded"); body(value); } else if (value instanceof CharSequence) { try { contentType("application/x-www-form-urlencoded"); body(new StringEntity(value.toString())); } catch (UnsupportedEncodingException e) {} } else {
} else if (value instanceof Reader || value instanceof InputStream) { contentType("application/x-www-form-urlencoded"); body(value); } else if (value instanceof CharSequence) { try { contentType("application/x-www-form-urlencoded"); body(new StringEntity(value.toString())); } catch (UnsupportedEncodingException e) {} } else {