public class CableDBClient extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
PROPERTIES_FILENAME
Name of the properties file
|
static String |
PROPERTY_NAME_BASE_URL
Name of the Base REST service URL property
|
static String |
PROPERTY_NAME_PASSWORD
Name of the password property
|
static String |
PROPERTY_NAME_USERNAME
Name of the username property
|
| Constructor and Description |
|---|
CableDBClient(Properties userProperties)
Constructs the instance of the client and loads properties from
PROPERTIES_FILENAME file found on class
path. |
| Modifier and Type | Method and Description |
|---|---|
String |
buildUrl(String... path)
Builds a url with the base path and the path parameter specified as parameter
|
CableResource |
createCableResource()
For development purposes.
|
String |
getBaseURL() |
protected static javax.ws.rs.core.UriBuilder |
getBuilder(String url,
javax.ws.rs.core.MultivaluedMap<String,Object> queryParameters)
This has been moved to a separate method so that it can be called from Unit Tests.
|
String |
getPassword() |
ClosableResponse |
getResponse(String url)
Requests JSON type data from URL.
|
ClosableResponse |
getResponse(String url,
javax.ws.rs.core.MultivaluedMap<String,Object> queryParameters)
Requests JSON type data from URL.
|
ClosableResponse |
getResponse(String url,
String paramName,
Object paramValue)
Requests JSON type data from URL using a query string parameter.
|
String |
getUserName() |
static void |
main(String[] args)
For development purposes.
|
public static final String PROPERTY_NAME_BASE_URL
public static final String PROPERTY_NAME_USERNAME
public static final String PROPERTY_NAME_PASSWORD
public static final String PROPERTIES_FILENAME
public CableDBClient(@Nullable Properties userProperties)
Constructs the instance of the client and loads properties from PROPERTIES_FILENAME file found on class
path. All values can be overridden by setting the system properties, but that has to be done before this class is
loaded.
Configurable properties are PROPERTY_NAME_BASE_URL, PROPERTY_NAME_USERNAME,
PROPERTY_NAME_PASSWORD
userProperties - optional (can be null) properties file that contains configurable propertiespublic ClosableResponse getResponse(String url, @Nullable javax.ws.rs.core.MultivaluedMap<String,Object> queryParameters)
Method is thread-safe.
url - to send requestqueryParameters - optional list of query parameters to use in requestIllegalStateException - if either the username or password not setprotected static javax.ws.rs.core.UriBuilder getBuilder(String url, @Nullable javax.ws.rs.core.MultivaluedMap<String,Object> queryParameters)
url - the base service URL to usequeryParameters - a list of parameters to use for building the URLpublic ClosableResponse getResponse(String url)
Method is thread-safe.
url - to send requestIllegalStateException - if either the username or password not setpublic ClosableResponse getResponse(String url, String paramName, Object paramValue)
Method is thread-safe.
url - to send request toparamName - query string parameter name to setparamValue - query string parameter value to setIllegalStateException - if either the username or password are not setIllegalArgumentException - if either paramName or paramValue are nullpublic String buildUrl(String... path)
path - the sub-path of the base urlpublic String getBaseURL()
public String getUserName()
public String getPassword()
public CableResource createCableResource()
CableResource objectpublic static void main(String[] args)
args - command line parametersCopyright © 2025 European Spallation Source. All rights reserved.