Package adams.flow.rest.dex
Class DataExchangeHelper
- java.lang.Object
-
- adams.flow.rest.dex.DataExchangeHelper
-
public class DataExchangeHelper extends Object
Helper class for communicating with a Data Exchange server.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description DataExchangeHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static adams.core.base.BaseURL
buildURL(adams.core.base.BaseURL server, String path)
Builds the actual URL to use.static byte[]
download(String token, adams.core.base.BaseURL server, AbstractClientAuthentication auth, adams.core.MessageCollection errors)
Downloads the data associated with the token.protected static com.github.fracpete.requests4j.request.Request
initRequest(adams.core.base.BaseURL server, AbstractClientAuthentication auth, adams.core.MessageCollection errors)
static adams.flow.container.HttpRequestResult
remove(String token, adams.core.base.BaseURL server, AbstractClientAuthentication auth, adams.core.MessageCollection errors)
Removes the data associated with the token.static String
upload(byte[] data, adams.core.base.BaseURL server, AbstractClientAuthentication auth, adams.core.MessageCollection errors)
Uploads the file to the data exchange server.static String
upload(File file, adams.core.base.BaseURL server, AbstractClientAuthentication auth, adams.core.MessageCollection errors)
Uploads the file to the data exchange server.
-
-
-
Method Detail
-
initRequest
protected static com.github.fracpete.requests4j.request.Request initRequest(adams.core.base.BaseURL server, AbstractClientAuthentication auth, adams.core.MessageCollection errors)
-
upload
public static String upload(File file, adams.core.base.BaseURL server, AbstractClientAuthentication auth, adams.core.MessageCollection errors)
Uploads the file to the data exchange server.- Parameters:
file
- the file to uploadserver
- the server to upload toauth
- the authentication to use, needs to have the flow context seterrors
- for collecting errors- Returns:
- the token, null in case of error
-
upload
public static String upload(byte[] data, adams.core.base.BaseURL server, AbstractClientAuthentication auth, adams.core.MessageCollection errors)
Uploads the file to the data exchange server.- Parameters:
data
- the data to uploadserver
- the server to upload toauth
- the authentication to use, needs to have the flow context seterrors
- for collecting errors- Returns:
- the token, null in case of error
-
download
public static byte[] download(String token, adams.core.base.BaseURL server, AbstractClientAuthentication auth, adams.core.MessageCollection errors)
Downloads the data associated with the token.- Parameters:
token
- the token to use for downloadingserver
- the server to connect toauth
- the authentication to useerrors
- for collecting errors- Returns:
- the data, null in case of an error
-
remove
public static adams.flow.container.HttpRequestResult remove(String token, adams.core.base.BaseURL server, AbstractClientAuthentication auth, adams.core.MessageCollection errors)
Removes the data associated with the token.- Parameters:
token
- the token to remove the data forserver
- the server to connect toauth
- the authentication to useerrors
- for collecting errors- Returns:
- the request response, null in case of an error
-
buildURL
public static adams.core.base.BaseURL buildURL(adams.core.base.BaseURL server, String path)
Builds the actual URL to use.- Parameters:
server
- the server URLpath
- the path to append to the server's URL- Returns:
- the complete URL
-
-