public abstract class AbstractBridge
extends java.lang.Object
The Bridge is the class responsible for marshalling a query to and from the search service.
Because the bridge holds a connection pool that is expensive to create, it is highly recommended
that the bridge is held in the application memory scope and reused where appropriate.
Do not create a new bridge object for each request as you will incur overhead that will
bring down your UI servers when under heavy load!
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
clientKey |
static java.lang.String |
CLUSTER |
protected static java.lang.String |
COLON |
static int |
DEFAULT_MAX_TRIES |
static int |
DEFAULT_RETRY_TIMEOUT |
protected static java.lang.String |
HTTP |
protected static java.lang.String |
HTTPS |
static java.nio.charset.Charset |
UTF_8 |
| Constructor and Description |
|---|
AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl)
Constructor to create a bridge object that connects to the search api. |
AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl,
boolean compressResponse)
Constructor to create a bridge object that connects to the search api. |
AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl,
boolean compressResponse,
com.groupbyinc.api.config.ConnectionConfiguration config)
Constructor to create a bridge object that connects to the search api. |
AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl,
com.groupbyinc.api.config.ConnectionConfiguration config)
Constructor to create a bridge object that connects to the search api. |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
addHeader(java.util.List<com.groupbyinc.common.apache.http.Header> headers,
java.lang.String key,
java.lang.String value) |
protected static boolean |
containsHeader(java.util.List<com.groupbyinc.common.apache.http.Header> headers,
java.lang.String key) |
protected java.io.InputStream |
fireRequest(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> urlParams,
java.util.Map<java.lang.String,java.lang.String> headers,
java.lang.String body,
boolean returnBinary) |
protected java.io.InputStream |
fireRequest(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> urlParams,
java.lang.String body,
boolean returnBinary) |
com.groupbyinc.common.security.AesContent |
generateSecuredPayload(java.lang.String customerId,
Query query)
Generates a secured payload
|
static com.groupbyinc.common.security.AesContent |
generateSecuredPayload(java.lang.String customerId,
java.lang.String clientKey,
Query query)
Generates a secured payload
|
static com.groupbyinc.common.security.AesContent |
generateSecuredPayload(java.lang.String customerId,
java.lang.String clientKey,
java.lang.String requestJson)
Generates a secured payload
|
protected java.net.URI |
generateURI(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> params,
int tries) |
java.lang.String |
getBridgeRefinementsUrl() |
java.lang.String |
getBridgeUrl() |
java.lang.String |
getClusterBridgeUrl() |
java.util.List<com.groupbyinc.common.apache.http.Header> |
getHeaders() |
protected void |
handleErrorStatus(java.lang.String status,
byte[] bytes,
boolean returnBinary) |
protected com.groupbyinc.api.model.Results |
map(java.io.InputStream data,
boolean returnBinary) |
protected com.groupbyinc.api.model.RefinementsResult |
mapRefinements(java.io.InputStream data,
boolean returnBinary) |
com.groupbyinc.api.model.RefinementsResult |
refinements(Query query,
java.lang.String navigationName)
Connects to the refinements service, parses the response into a model
Retrieves at most 10,000 refinements for the navigation specified. |
com.groupbyinc.api.model.RefinementsResult |
refinements(com.groupbyinc.api.request.RefinementsRequest request) |
com.groupbyinc.api.model.RefinementsResult |
refinements(com.groupbyinc.api.request.RefinementsRequest request,
java.util.Map<java.lang.String,java.lang.String> headers) |
protected static void |
removeHeader(java.util.List<com.groupbyinc.common.apache.http.Header> headers,
java.lang.String key) |
com.groupbyinc.api.model.Results |
search(Query query)
Connects to the search service, parses the response into a model
|
com.groupbyinc.api.model.Results |
search(com.groupbyinc.api.request.Request request) |
com.groupbyinc.api.model.Results |
search(com.groupbyinc.api.request.Request request,
java.util.Map<java.lang.String,java.lang.String> headers) |
protected com.groupbyinc.api.model.Results |
search(java.lang.String clientKey,
java.util.Map<java.lang.String,java.lang.String> headers,
Query query) |
void |
setHeaders(java.util.List<com.groupbyinc.common.apache.http.Header> headers)
Set a list of headers. |
void |
setMaxTries(long maxTries)
Sets the maximum number of times to try a request before returning an error. |
void |
setRetryTimeout(long retryTimeout)
Sets the retry timeout for a failed request. |
void |
shutdown()
Cleanup HTTP connection pool. |
public static final int DEFAULT_RETRY_TIMEOUT
public static final int DEFAULT_MAX_TRIES
public static final java.lang.String CLUSTER
protected static final java.lang.String COLON
protected static final java.lang.String HTTP
protected static final java.lang.String HTTPS
public static final java.nio.charset.Charset UTF_8
protected java.lang.String clientKey
public AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl)
Constructor to create a bridge object that connects to the search api.
JSON Reference:
The key as found in your key management page in the command center
{"clientKey": ""}
clientKey - The key as found in your key management page in the command
center.baseUrl - The base url the bridge is serving on.public AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl,
boolean compressResponse,
com.groupbyinc.api.config.ConnectionConfiguration config)
Constructor to create a bridge object that connects to the search api.
JSON Reference:
The key as found in your key management page in the command center
{"clientKey": ""}
clientKey - The key as found in your key management page in the command
center.baseUrl - The base url the bridge is serving on.compressResponse - true to compress the response content, false to send uncompressed response.config - Configuration for the underlying HttpClient instance.public AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl,
com.groupbyinc.api.config.ConnectionConfiguration config)
Constructor to create a bridge object that connects to the search api.
JSON Reference:
The key as found in your key management page in the command center
{"clientKey": ""}
clientKey - The key as found in your key management page in the command
center.baseUrl - The base url the bridge is serving on.config - Configuration for the underlying HttpClient instance.public AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl,
boolean compressResponse)
Constructor to create a bridge object that connects to the search api.
JSON Reference:
The key as found in your key management page in the command center
{"clientKey": ""}
clientKey - The key as found in your key management page in the command
center.baseUrl - The base url the bridge is serving on.compressResponse - true to compress the response content, false to send uncompressed response.public java.lang.String getClusterBridgeUrl()
public com.groupbyinc.api.model.Results search(Query query) throws java.io.IOException
Connects to the search service, parses the response into a model
query - A query representing the search.java.io.IOExceptionprotected com.groupbyinc.api.model.Results search(java.lang.String clientKey,
java.util.Map<java.lang.String,java.lang.String> headers,
Query query)
throws java.io.IOException
java.io.IOExceptionprotected java.io.InputStream fireRequest(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> urlParams,
java.lang.String body,
boolean returnBinary)
throws java.io.IOException
java.io.IOExceptionprotected java.io.InputStream fireRequest(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> urlParams,
java.util.Map<java.lang.String,java.lang.String> headers,
java.lang.String body,
boolean returnBinary)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getBridgeUrl()
protected com.groupbyinc.api.model.Results map(java.io.InputStream data,
boolean returnBinary)
protected static void addHeader(java.util.List<com.groupbyinc.common.apache.http.Header> headers,
java.lang.String key,
java.lang.String value)
protected static void removeHeader(java.util.List<com.groupbyinc.common.apache.http.Header> headers,
java.lang.String key)
protected static boolean containsHeader(java.util.List<com.groupbyinc.common.apache.http.Header> headers,
java.lang.String key)
protected void handleErrorStatus(java.lang.String status,
byte[] bytes,
boolean returnBinary)
throws java.io.IOException
java.io.IOExceptionprotected java.net.URI generateURI(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> params,
int tries)
throws java.net.URISyntaxException
java.net.URISyntaxExceptionpublic com.groupbyinc.api.model.Results search(com.groupbyinc.api.request.Request request)
throws java.io.IOException
java.io.IOExceptionpublic com.groupbyinc.api.model.Results search(com.groupbyinc.api.request.Request request,
java.util.Map<java.lang.String,java.lang.String> headers)
throws java.io.IOException
java.io.IOExceptionpublic com.groupbyinc.api.model.RefinementsResult refinements(Query query, java.lang.String navigationName) throws java.io.IOException
Connects to the refinements service, parses the response into a model
Retrieves at most 10,000 refinements for the navigation specified.
query - A query representing the search.navigationName - The name of the navigation to get more refinements for.java.io.IOExceptionpublic java.lang.String getBridgeRefinementsUrl()
protected com.groupbyinc.api.model.RefinementsResult mapRefinements(java.io.InputStream data,
boolean returnBinary)
public com.groupbyinc.api.model.RefinementsResult refinements(com.groupbyinc.api.request.RefinementsRequest request)
throws java.io.IOException
java.io.IOExceptionpublic com.groupbyinc.api.model.RefinementsResult refinements(com.groupbyinc.api.request.RefinementsRequest request,
java.util.Map<java.lang.String,java.lang.String> headers)
throws java.io.IOException
java.io.IOExceptionpublic void shutdown()
Cleanup HTTP connection pool.
public void setRetryTimeout(long retryTimeout)
Sets the retry timeout for a failed request.
retryTimeout - the retry timeoutpublic void setMaxTries(long maxTries)
Sets the maximum number of times to try a request before returning an error.
maxTries - the maximum number of request attemptspublic java.util.List<com.groupbyinc.common.apache.http.Header> getHeaders()
public void setHeaders(java.util.List<com.groupbyinc.common.apache.http.Header> headers)
Set a list of headers. Use `getHeaders().add(new BasicHeader())`
headers - The list of headerspublic static com.groupbyinc.common.security.AesContent generateSecuredPayload(java.lang.String customerId,
java.lang.String clientKey,
Query query)
throws java.security.GeneralSecurityException
Generates a secured payload
customerId - The customerId as seen in Command Center. Ensure this is not the subdomain, which can be `customerId-cors.groupbycloud.com`clientKey - The customerId as seen in Command Centerquery - The query to encryptjava.security.GeneralSecurityExceptionpublic static com.groupbyinc.common.security.AesContent generateSecuredPayload(java.lang.String customerId,
java.lang.String clientKey,
java.lang.String requestJson)
throws java.security.GeneralSecurityException
Generates a secured payload
customerId - The customerId as seen in Command Center. Ensure this is not the subdomain, which can be `customerId-cors.groupbycloud.com`clientKey - The customerId as seen in Command CenterrequestJson - The query to encryptjava.security.GeneralSecurityExceptionpublic com.groupbyinc.common.security.AesContent generateSecuredPayload(java.lang.String customerId,
Query query)
throws java.security.GeneralSecurityException
Generates a secured payload
customerId - The customerId as seen in Command Center. Ensure this is not the subdomain, which can be `customerId-cors.groupbycloud.com`query - The query to encryptjava.security.GeneralSecurityExceptionCopyright © 2013–2019 GroupBy Inc.. All rights reserved.