Class RequestHelper
- java.lang.Object
-
- com.github.davidmoten.odata.client.internal.RequestHelper
-
public final class RequestHelper extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddContentLengthHeader(List<RequestHeader> h, int length)static voidcheckResponseCode(ContextPath cp, HttpResponse response, int expectedResponseCode)static voidcheckResponseCode(String url, HttpResponse response, int expectedResponseCodeMin, int expectedResponseCodeMax)static voidcheckResponseCodeOk(ContextPath cp, HttpResponse response)static List<RequestHeader>cleanAndSupplementRequestHeaders(RequestOptions options, String contentTypeOdataMetadataValue, boolean hasPayload)static List<RequestHeader>cleanAndSupplementRequestHeaders(List<RequestHeader> requestHeaders, String contentTypeOdataMetadataValue, boolean hasPayload)static Optional<StreamProvider>createStream(ContextPath contextPath, ODataEntityType entity)static Optional<StreamProvider>createStreamForEdmStream(ContextPath contextPath, ODataType item, String fieldName, String base64)static <T extends ODataEntityType>
voiddelete(ContextPath cp, RequestOptions options)static <T> Tget(ContextPath contextPath, Class<T> returnCls, RequestOptions options)Returns the json from an HTTP GET of the url built from the contextPath and options.static InputStreamgetStream(ContextPath contextPath, RequestOptions options, String base64)static <T> Class<? extends T>getSubClass(ContextPath cp, List<SchemaInfo> schemas, Class<T> cls, String json)static Optional<Object>getValue(UnmappedFields unmappedFields, String name)static <T,S>
TgetWithParametricType(ContextPath contextPath, Class<T> cls, Class<S> parametricTypeClass, RequestOptions options)static <T extends ODataEntityType>
Tpatch(T entity, ContextPath contextPath, RequestOptions options)static <T extends ODataEntityType>
Tpatch(T entity, ContextPath contextPath, Class<T> cls, RequestOptions options)static <T> TpatchAny(Object object, ContextPath contextPath, Class<T> responseClass, RequestOptions options)static voidpost(Map<String,Object> parameters, ContextPath contextPath, RequestOptions options)static <T extends ODataEntityType>
Tpost(T entity, ContextPath contextPath, Class<T> cls, RequestOptions options)static <T> TpostAny(Object object, ContextPath contextPath, Class<T> responseClass, RequestOptions options)static <T,S>
TpostAnyWithParametricType(Object object, ContextPath contextPath, Class<T> cls, Class<S> parametricTypeClass, RequestOptions options)static voidput(ContextPath contextPath, RequestOptions options, InputStream in, int length)static <T extends ODataEntityType>
Tput(T entity, ContextPath contextPath, RequestOptions options)static voidputChunk(HttpService service, String url, InputStream in, List<RequestHeader> requestHeaders, long startByte, long finishByte, long size, HttpRequestOptions options)static voidsend(HttpMethod method, ContextPath contextPath, RequestOptions options, InputStream in, int length)static voidsendChunk(HttpMethod method, HttpService service, String url, InputStream in, List<RequestHeader> requestHeaders, long startByte, long finishByte, long size, HttpRequestOptions options)static <T> TsubmitAny(HttpMethod method, Object object, ContextPath contextPath, Class<T> responseClass, RequestOptions options)static Optional<StreamUploaderSingleCall>uploader(ContextPath contextPath, ODataType item, String fieldName, HttpMethod method)
-
-
-
Method Detail
-
get
public static <T> T get(ContextPath contextPath, Class<T> returnCls, RequestOptions options)
Returns the json from an HTTP GET of the url built from the contextPath and options. In the case where the returned object is actually a sub-class of T we lookup the sub-class from context schemaInfos based on the namespaced type of the return object.- Type Parameters:
T- return object type- Parameters:
contextPath- context and current pathreturnCls- return classoptions- request options- Returns:
- object hydrated from json
-
checkResponseCode
public static void checkResponseCode(String url, HttpResponse response, int expectedResponseCodeMin, int expectedResponseCodeMax)
-
checkResponseCodeOk
public static void checkResponseCodeOk(ContextPath cp, HttpResponse response)
-
checkResponseCode
public static void checkResponseCode(ContextPath cp, HttpResponse response, int expectedResponseCode)
-
getWithParametricType
public static <T,S> T getWithParametricType(ContextPath contextPath, Class<T> cls, Class<S> parametricTypeClass, RequestOptions options)
-
post
public static <T extends ODataEntityType> T post(T entity, ContextPath contextPath, Class<T> cls, RequestOptions options)
-
patch
public static <T extends ODataEntityType> T patch(T entity, ContextPath contextPath, Class<T> cls, RequestOptions options)
-
post
public static void post(Map<String,Object> parameters, ContextPath contextPath, RequestOptions options)
-
postAny
public static <T> T postAny(Object object, ContextPath contextPath, Class<T> responseClass, RequestOptions options)
-
patchAny
public static <T> T patchAny(Object object, ContextPath contextPath, Class<T> responseClass, RequestOptions options)
-
submitAny
public static <T> T submitAny(HttpMethod method, Object object, ContextPath contextPath, Class<T> responseClass, RequestOptions options)
-
postAnyWithParametricType
public static <T,S> T postAnyWithParametricType(Object object, ContextPath contextPath, Class<T> cls, Class<S> parametricTypeClass, RequestOptions options)
-
patch
public static <T extends ODataEntityType> T patch(T entity, ContextPath contextPath, RequestOptions options)
-
delete
public static <T extends ODataEntityType> void delete(ContextPath cp, RequestOptions options)
-
put
public static <T extends ODataEntityType> T put(T entity, ContextPath contextPath, RequestOptions options)
-
put
public static void put(ContextPath contextPath, RequestOptions options, InputStream in, int length)
-
send
public static void send(HttpMethod method, ContextPath contextPath, RequestOptions options, InputStream in, int length)
-
addContentLengthHeader
public static void addContentLengthHeader(List<RequestHeader> h, int length)
-
getSubClass
public static <T> Class<? extends T> getSubClass(ContextPath cp, List<SchemaInfo> schemas, Class<T> cls, String json)
-
cleanAndSupplementRequestHeaders
public static List<RequestHeader> cleanAndSupplementRequestHeaders(List<RequestHeader> requestHeaders, String contentTypeOdataMetadataValue, boolean hasPayload)
-
cleanAndSupplementRequestHeaders
public static List<RequestHeader> cleanAndSupplementRequestHeaders(RequestOptions options, String contentTypeOdataMetadataValue, boolean hasPayload)
-
getStream
public static InputStream getStream(ContextPath contextPath, RequestOptions options, String base64)
-
createStream
public static Optional<StreamProvider> createStream(ContextPath contextPath, ODataEntityType entity)
-
createStreamForEdmStream
public static Optional<StreamProvider> createStreamForEdmStream(ContextPath contextPath, ODataType item, String fieldName, String base64)
-
uploader
public static Optional<StreamUploaderSingleCall> uploader(ContextPath contextPath, ODataType item, String fieldName, HttpMethod method)
-
putChunk
public static void putChunk(HttpService service, String url, InputStream in, List<RequestHeader> requestHeaders, long startByte, long finishByte, long size, HttpRequestOptions options)
-
sendChunk
public static void sendChunk(HttpMethod method, HttpService service, String url, InputStream in, List<RequestHeader> requestHeaders, long startByte, long finishByte, long size, HttpRequestOptions options)
-
getValue
public static Optional<Object> getValue(UnmappedFields unmappedFields, String name)
-
-