Class EthosErrorsClient
- java.lang.Object
-
- com.ellucian.ethos.integration.client.EthosClient
-
- com.ellucian.ethos.integration.client.errors.EthosErrorsClient
-
public class EthosErrorsClient extends EthosClient
An EthosClient used to to perform Create, Read, and Delete operations for Error objects, using the Ethos Integration errors service.The preferred way to instantiate this class is via the
EthosClientBuilder
.- Since:
- 0.0.1
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_ERROR_PAGE_SIZE
The default page size (limit) when paging for errors.static String
HDR_REMAINING_COUNT
The remaining count header found in the EthosResponse.static String
HDR_TOTAL_COUNT
The total count header found in the EthosResponse.-
Fields inherited from class com.ellucian.ethos.integration.client.EthosClient
ethosResponseBuilder, httpProtocolClientBuilder, responseHandler, token
-
-
Constructor Summary
Constructors Constructor Description EthosErrorsClient(String apiKey, Integer connectionTimeout, Integer connectionRequestTimeout, Integer socketTimeout)
Constructs an EthosErrorClient using the given API key.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
calculateNumberOfPages(int totalErrorCount, int pageSize, int offset)
Calculates the number of pages given the input params.void
delete(String id)
Delete the Error with the given ID from your tenant.protected List<EthosResponse>
doPaging(int totalCount, int pageSize, int offset)
Intended to be used internally within the SDK.EthosResponse
get()
Get an initial array (page) of Errors from the tenant associated with the access token.List<EthosResponse>
getAllErrors()
Gets all of the errors for the given tenant per access token.List<EthosError>
getAllErrorsAsEthosErrors()
Gets all of the errors for the given tenant per access token, as a list of EthosErrors.List<com.fasterxml.jackson.databind.JsonNode>
getAllErrorsAsJsonNodes()
Gets all of the errors for the given tenant per access token, as a list of JsonNodes.List<String>
getAllErrorsAsStrings()
Gets all of the errors for the given tenant per access token, as a list of Strings in JSON format.List<EthosResponse>
getAllErrorsWithPageSize(int pageSize)
Gets all of the errors for the given tenant per access token using the given page size.List<com.fasterxml.jackson.databind.JsonNode>
getAllErrorsWithPageSizeAsJsonNodes(int pageSize)
Gets all of the errors for the given tenant per access token using the given page size, as a list of JsonNodes.List<String>
getAllErrorsWithPageSizeAsStrings(int pageSize)
Gets all of the errors for the given tenant per access token using the given page size, as a list of strings in JSON format.List<EthosError>
getAsEthosErrors()
Get an initial list of EthosErrors from the tenant associated with the access token.com.fasterxml.jackson.databind.JsonNode
getAsJsonNode()
Gets an initial array (page) of Errors from the tenant associated with the access token, as a JsonNode.String
getAsString()
Gets an initial array (page) of Errors from the tenant associated with the access token, as a string.EthosResponse
getById(String id)
Get a single Error from your tenant, using the given ID.EthosError
getByIdAsEthosError(String id)
Get a single error as an EthosError object, using the given ID.com.fasterxml.jackson.databind.JsonNode
getByIdAsJsonNode(String id)
Get a single error as a JsonNode object, using the given ID.String
getByIdAsString(String id)
Get a single error as a string in JSON format, using the given ID.List<EthosResponse>
getErrorsFromOffset(int offset)
Gets all of the errors for the given tenant per access token from the given offset.List<EthosError>
getErrorsFromOffsetAsEthosErrors(int offset)
Gets all of the errors for the given tenant per access token from the given offset, as a list of EthosErrors.List<com.fasterxml.jackson.databind.JsonNode>
getErrorsFromOffsetAsJsonNodes(int offset)
Gets all of the errors for the given tenant per access token from the given offset, as a list of JsonNodes.List<String>
getErrorsFromOffsetAsStrings(int offset)
Gets all of the errors for the given tenant per access token from the given offset, as a list of strings in JSON format.List<EthosResponse>
getErrorsFromOffsetWithPageSize(int offset, int pageSize)
Gets all of the errors for the given tenant per access token from the given offset, using the given pageSize.List<com.fasterxml.jackson.databind.JsonNode>
getErrorsFromOffsetWithPageSizeAsJsonNodes(int offset, int pageSize)
Gets all of the errors for the given tenant per access token from the given offset, using the given pageSize, as a list of JsonNodes.List<String>
getErrorsFromOffsetWithPageSizeAsStrings(int offset, int pageSize)
Gets all of the errors for the given tenant per access token from the given offset, using the given pageSize, as a list of strings in JSON format.int
getTotalErrorCount()
Gets the total number of errors according to the 'x-total-count' response header for the given tenant per access token.EthosResponse
post(EthosError error)
Create the given Error in your tenant with a POST request to the Ethos Integration errors service.-
Methods inherited from class com.ellucian.ethos.integration.client.EthosClient
delete, get, get, getAccessToken, getAutoRefresh, getExpirationMinutes, getHttpClient, getRegion, head, post, put, setAutoRefresh, setExpirationMinutes, setRegion, submitRequest
-
-
-
-
Field Detail
-
DEFAULT_ERROR_PAGE_SIZE
public static final int DEFAULT_ERROR_PAGE_SIZE
The default page size (limit) when paging for errors.- See Also:
- Constant Field Values
-
HDR_TOTAL_COUNT
public static final String HDR_TOTAL_COUNT
The total count header found in the EthosResponse.- See Also:
- Constant Field Values
-
HDR_REMAINING_COUNT
public static final String HDR_REMAINING_COUNT
The remaining count header found in the EthosResponse. This value is equal to the total count minus the page size of the given request/response.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EthosErrorsClient
public EthosErrorsClient(String apiKey, Integer connectionTimeout, Integer connectionRequestTimeout, Integer socketTimeout)
Constructs an EthosErrorClient using the given API key.Note that the preferred way to get an instance of this class is through the
EthosClientFactory
.- Parameters:
apiKey
- A valid API key from Ethos Integration. This is required to be a valid 36 character GUID string. If it is null, empty, or not in a valid GUID format, then anIllegalArgumentException
will be thrown.connectionTimeout
- The timeout in seconds for a connection to be established.connectionRequestTimeout
- The timeout in seconds when requesting a connection from the Apache connection manager.socketTimeout
- The timeout in seconds when waiting for data between consecutive data packets.
-
-
Method Detail
-
get
public EthosResponse get() throws IOException
Get an initial array (page) of Errors from the tenant associated with the access token.- Returns:
- An EthosResponse containing an array of errors in the content body.
- Throws:
IOException
- if there is an error making the HTTP request
-
getAsJsonNode
public com.fasterxml.jackson.databind.JsonNode getAsJsonNode() throws IOException
Gets an initial array (page) of Errors from the tenant associated with the access token, as a JsonNode.- Returns:
- A JsonNode containing child nodes for each error.
- Throws:
IOException
- Propagated if it is thrown by containing methods.
-
getAsString
public String getAsString() throws IOException
Gets an initial array (page) of Errors from the tenant associated with the access token, as a string.- Returns:
- A string of errors in JSON format.
- Throws:
IOException
- Propagated if it is thrown by containing methods.
-
getAsEthosErrors
public List<EthosError> getAsEthosErrors() throws IOException
Get an initial list of EthosErrors from the tenant associated with the access token.- Returns:
- An initial list of EthosErrors.
- Throws:
IOException
- Thrown if there is an error making the HTTP request.
-
getById
public EthosResponse getById(String id) throws IOException
Get a single Error from your tenant, using the given ID.- Parameters:
id
- The ID of the Error to get. This is a required parameter. If it is null or empty, then anIllegalArgumentException
will be thrown.- Returns:
- An EthosResponse containing the error in the content body.
- Throws:
IOException
- if there is an error making the HTTP request
-
getByIdAsEthosError
public EthosError getByIdAsEthosError(String id) throws IOException
Get a single error as an EthosError object, using the given ID.- Parameters:
id
- The ID of the Error to get. This is a required parameter. If it is null or empty, then anIllegalArgumentException
will be thrown.- Returns:
- An EthosError representing the error for the given ID.
- Throws:
IOException
- Propagated from the methods called in this method.
-
getByIdAsJsonNode
public com.fasterxml.jackson.databind.JsonNode getByIdAsJsonNode(String id) throws IOException
Get a single error as a JsonNode object, using the given ID.- Parameters:
id
- The ID of the Error to get. This is a required parameter. If it is null or empty, then anIllegalArgumentException
will be thrown.- Returns:
- An JsonNode containing the error for the given ID.
- Throws:
IOException
- Propagated from the methods called in this method.
-
getByIdAsString
public String getByIdAsString(String id) throws IOException
Get a single error as a string in JSON format, using the given ID.- Parameters:
id
- The ID of the Error to get. This is a required parameter. If it is null or empty, then anIllegalArgumentException
will be thrown.- Returns:
- A String for the given error in JSON format.
- Throws:
IOException
- Propagated from the methods called in this method.
-
getAllErrors
public List<EthosResponse> getAllErrors() throws IOException
Gets all of the errors for the given tenant per access token.- Returns:
- A list of EthosResponses where each ethosResponse in the list contains a page of errors.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getAllErrorsAsJsonNodes
public List<com.fasterxml.jackson.databind.JsonNode> getAllErrorsAsJsonNodes() throws IOException
Gets all of the errors for the given tenant per access token, as a list of JsonNodes.- Returns:
- A list of JsonNodes where each JsonNode in the list contains a page of errors.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getAllErrorsAsStrings
public List<String> getAllErrorsAsStrings() throws IOException
Gets all of the errors for the given tenant per access token, as a list of Strings in JSON format.- Returns:
- A list of strings where each string in the list contains a page of errors.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getAllErrorsAsEthosErrors
public List<EthosError> getAllErrorsAsEthosErrors() throws IOException
Gets all of the errors for the given tenant per access token, as a list of EthosErrors.- Returns:
- A list of EthosErrors where each EthosError in the list is for an individual error.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getAllErrorsWithPageSize
public List<EthosResponse> getAllErrorsWithPageSize(int pageSize) throws IOException
Gets all of the errors for the given tenant per access token using the given page size.- Parameters:
pageSize
- The limit number of errors to include in each page of errors returned.- Returns:
- A list of EthosResponses where each ethosResponse in the list contains a page of errors and each page contains up to the number of errors specified as the page size.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getAllErrorsWithPageSizeAsJsonNodes
public List<com.fasterxml.jackson.databind.JsonNode> getAllErrorsWithPageSizeAsJsonNodes(int pageSize) throws IOException
Gets all of the errors for the given tenant per access token using the given page size, as a list of JsonNodes.- Parameters:
pageSize
- The limit number of errors to include in each page of errors returned.- Returns:
- A list of JsonNodes where each JsonNode in the list contains a page of errors and each page contains up to the number of errors specified as the page size.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getAllErrorsWithPageSizeAsStrings
public List<String> getAllErrorsWithPageSizeAsStrings(int pageSize) throws IOException
Gets all of the errors for the given tenant per access token using the given page size, as a list of strings in JSON format.- Parameters:
pageSize
- The limit number of errors to include in each page of errors returned.- Returns:
- A list of strings where each string in the list contains a page of errors and each page contains up to the number of errors specified as the page size.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getErrorsFromOffset
public List<EthosResponse> getErrorsFromOffset(int offset) throws IOException
Gets all of the errors for the given tenant per access token from the given offset. Uses the default page size.- Parameters:
offset
- The 0 based index from which to begin paging for errors.- Returns:
- A list of EthosResponses where each EthosResponse in the list contains a page of errors starting from the given offset.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getErrorsFromOffsetAsJsonNodes
public List<com.fasterxml.jackson.databind.JsonNode> getErrorsFromOffsetAsJsonNodes(int offset) throws IOException
Gets all of the errors for the given tenant per access token from the given offset, as a list of JsonNodes. Uses the default page size.- Parameters:
offset
- The 0 based index from which to begin paging for errors.- Returns:
- A list of JsonNodes where each JsonNode in the list contains a page of errors starting from the given offset.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getErrorsFromOffsetAsStrings
public List<String> getErrorsFromOffsetAsStrings(int offset) throws IOException
Gets all of the errors for the given tenant per access token from the given offset, as a list of strings in JSON format. Uses the default page size.- Parameters:
offset
- The 0 based index from which to begin paging for errors.- Returns:
- A list of strings where each string in the list contains a page of errors starting from the given offset.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getErrorsFromOffsetAsEthosErrors
public List<EthosError> getErrorsFromOffsetAsEthosErrors(int offset) throws IOException
Gets all of the errors for the given tenant per access token from the given offset, as a list of EthosErrors.- Parameters:
offset
- The 0 based index from which to begin paging for errors.- Returns:
- A list of EthosErrors starting from the given offset.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getErrorsFromOffsetWithPageSize
public List<EthosResponse> getErrorsFromOffsetWithPageSize(int offset, int pageSize) throws IOException
Gets all of the errors for the given tenant per access token from the given offset, using the given pageSize.- Parameters:
offset
- The 0 based index from which to begin paging for errors.pageSize
- The limit number of errors to include in each page of errors returned.- Returns:
- A list of EthosResponses where each EthosResponse in the list contains a page of errors up to the given pageSize, starting from the given offset.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getErrorsFromOffsetWithPageSizeAsJsonNodes
public List<com.fasterxml.jackson.databind.JsonNode> getErrorsFromOffsetWithPageSizeAsJsonNodes(int offset, int pageSize) throws IOException
Gets all of the errors for the given tenant per access token from the given offset, using the given pageSize, as a list of JsonNodes.- Parameters:
offset
- The 0 based index from which to begin paging for errors.pageSize
- The limit number of errors to include in each page of errors returned.- Returns:
- A list of JsonNodes where each JsonNode in the list contains a page of errors up to the given pageSize, starting from the given offset.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
getErrorsFromOffsetWithPageSizeAsStrings
public List<String> getErrorsFromOffsetWithPageSizeAsStrings(int offset, int pageSize) throws IOException
Gets all of the errors for the given tenant per access token from the given offset, using the given pageSize, as a list of strings in JSON format.- Parameters:
offset
- The 0 based index from which to begin paging for errors.pageSize
- The limit number of errors to include in each page of errors returned.- Returns:
- A list of strings where each string in the list contains a page of errors up to the given pageSize, starting from the given offset.
- Throws:
IOException
- Propagated if thrown interacting with the Ethos Errors API.
-
doPaging
protected List<EthosResponse> doPaging(int totalCount, int pageSize, int offset) throws IOException
Intended to be used internally within the SDK.
Handles paging for errors. If the given pageSize is <= 0, the default page size is used. If the offset is < 0, 0 will be used for the offset.- Parameters:
totalCount
- The total count of errors for the given tenant per access token.pageSize
- The number of errors to include in each page (EthosResponse) of the list returned.offset
- The 0 based index from which to begin paging for errors. To get all errors, the offset should be 0.- Returns:
- A list of
EthosResponse
s where eachEthosResponse
in the list represents a page, beginning from the given offset index. - Throws:
IOException
- Propagates this exception if it occurs when making the call in theEthosClient
.
-
calculateNumberOfPages
public int calculateNumberOfPages(int totalErrorCount, int pageSize, int offset)
Calculates the number of pages given the input params. Input param values are not validated, so specifying invalid negative values could produce unpredictable results. A 0 value is valid for the offset, but not for the other params.The calculation is as follows:
double numPages = Math.ceil( (Double.valueOf(totalErrorCount) - Double.valueOf(offset)) / Double.valueOf(pageSize) );
The numPages returned value is cast to an int.- Parameters:
totalErrorCount
- The total number of errors.pageSize
- The limit number of errors to include in each page of errors returned.offset
- The 0 based index from which to begin paging for errors.- Returns:
- The number of pages calculated from the given input params.
-
post
public EthosResponse post(EthosError error) throws IOException
Create the given Error in your tenant with a POST request to the Ethos Integration errors service.- Parameters:
error
- An Error object to create. This is a required parameter. If it is null, then anIllegalArgumentException
will be thrown.- Returns:
- An EthosResponse containing the response payload from the errors service in the content body.
- Throws:
IOException
- Propagates this exception if it occurs when making the call in theEthosClient
.
-
delete
public void delete(String id) throws IOException
Delete the Error with the given ID from your tenant.- Parameters:
id
- The ID of the Error to delete. This is a required parameter. If it is null or empty, then anIllegalArgumentException
will be thrown.- Throws:
IOException
- Propagates this exception if it occurs when making the call in theEthosClient
.
-
getTotalErrorCount
public int getTotalErrorCount() throws IOException
Gets the total number of errors according to the 'x-total-count' response header for the given tenant per access token.- Returns:
- The total number of errors for the given tenant, or 0 if the 'x-total-count' header is not found.
- Throws:
IOException
- Propagates this exception if it occurs when making the call in theEthosClient
.
-
-