Class DataRetrievalResponseBase<T>
java.lang.Object
se.liu.ida.hefquin.federation.access.impl.response.DataRetrievalResponseBase<T>
- All Implemented Interfaces:
DataRetrievalResponse<T>
- Direct Known Subclasses:
CachedCardinalityResponse,CardinalityResponseImpl,JSONResponseImpl,RecordsResponseImpl,SolMapsResponseImpl,StringResponseImpl,TPFResponseImpl
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDataRetrievalResponseBase(int errorStatusCode, String errorDescription, Date requestStartTime) Constructs a response for the case that the response was an error message.protectedDataRetrievalResponseBase(int errorStatusCode, String errorDescription, Date requestStartTime, Date retrievalEndTime) Constructs a response for the case that the response was an error message.protectedDataRetrievalResponseBase(Exception exception, Date requestStartTime) Constructs a defective response for the case that an exception was thrown when producing the response.protectedDataRetrievalResponseBase(Exception exception, Date requestStartTime, Date retrievalEndTime) Constructs a defective response for the case that an exception was thrown when producing the response.protectedDataRetrievalResponseBase(T data, Date requestStartTime) Constructs a response with the given data and request start time.protectedDataRetrievalResponseBase(T data, Date requestStartTime, Date retrievalEndTime) Constructs a response with the given data, request start time, and request end time. -
Method Summary
Modifier and TypeMethodDescriptionIn case thatDataRetrievalResponse.isError()istrue, this method returns a short description of the error if available, ornullotherwise.Returns the HTTP status code if the corresponding request resulted in an error, ornullotherwise.In case that issuing the request that was supposed to result in this response failed with an exception or reading the data obtained via the request failed with an exception, this method returns that exception; otherwise it returnsnull.Returns the time at which the corresponding data retrieval request (see) was started.invalid reference
#getRequest()Returns the data retrieved in this response, or throws an exception (UnsupportedOperationDueToRetrievalError) if either the response to the corresponding request was an error message (seeDataRetrievalResponse.isError()) or the response is defective (seeDataRetrievalResponse.isDefective()).Returns the time at which the retrieval of this response was completed.protected voidThrows anUnsupportedOperationDueToRetrievalErrorexception if (DataRetrievalResponse.isError()istrueorDataRetrievalResponse.isDefective()istrue.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface se.liu.ida.hefquin.federation.access.DataRetrievalResponse
getRequestDuration, isDefective, isError
-
Field Details
-
data
-
errorStatusCode
-
errorDescription
-
exception
-
requestStartTime
-
retrievalEndTime
-
-
Constructor Details
-
DataRetrievalResponseBase
Constructs a response with the given data and request start time. The retrieval end time is automatically set to the current time at the moment of construction. This constructor assumes no error occurred.- Parameters:
data- the data contained in this response (must not benull)requestStartTime- the time at which the request was initiated (must not benull)
-
DataRetrievalResponseBase
Constructs a response with the given data, request start time, and request end time. This constructor assumes no error occurred.- Parameters:
data- the data contained in this response (must not benull)requestStartTime- the time at which the request was initiated (must not benull)retrievalEndTime- the time at which the retrieval of this response was completed (must not benull)
-
DataRetrievalResponseBase
protected DataRetrievalResponseBase(int errorStatusCode, String errorDescription, Date requestStartTime) Constructs a response for the case that the response was an error message. The retrieval end time is automatically set to the current time at the moment of construction.- Parameters:
errorStatusCode- the HTTP status code of the error message (must not benull)errorDescription- a short description of the error (may benull)requestStartTime- the time at which the request was initiated (must not benull)
-
DataRetrievalResponseBase
protected DataRetrievalResponseBase(int errorStatusCode, String errorDescription, Date requestStartTime, Date retrievalEndTime) Constructs a response for the case that the response was an error message.- Parameters:
errorStatusCode- the HTTP status code of the error message (must not benull)errorDescription- a short description of the error (may benull)requestStartTime- the time at which the request was initiated (must not benull)retrievalEndTime- the time at which the retrieval of this response was completed (must not benull)
-
DataRetrievalResponseBase
Constructs a defective response for the case that an exception was thrown when producing the response. The retrieval end time is automatically set to the current time at the moment of construction.- Parameters:
exception- the exception (must not benull)requestStartTime- the time at which the request was initiated (must not benull)
-
DataRetrievalResponseBase
protected DataRetrievalResponseBase(Exception exception, Date requestStartTime, Date retrievalEndTime) Constructs a defective response for the case that an exception was thrown when producing the response.- Parameters:
exception- the exception (must not benull)requestStartTime- the time at which the request was initiated (must not benull)retrievalEndTime- the time at which the creation of this response resulted in an exception (must not benull)
-
-
Method Details
-
getResponseData
Description copied from interface:DataRetrievalResponseReturns the data retrieved in this response, or throws an exception (UnsupportedOperationDueToRetrievalError) if either the response to the corresponding request was an error message (seeDataRetrievalResponse.isError()) or the response is defective (seeDataRetrievalResponse.isDefective()).- Specified by:
getResponseDatain interfaceDataRetrievalResponse<T>- Throws:
UnsupportedOperationDueToRetrievalError
-
getErrorStatusCode
Description copied from interface:DataRetrievalResponseReturns the HTTP status code if the corresponding request resulted in an error, ornullotherwise.- Specified by:
getErrorStatusCodein interfaceDataRetrievalResponse<T>
-
getErrorDescription
Description copied from interface:DataRetrievalResponseIn case thatDataRetrievalResponse.isError()istrue, this method returns a short description of the error if available, ornullotherwise.- Specified by:
getErrorDescriptionin interfaceDataRetrievalResponse<T>
-
getException
Description copied from interface:DataRetrievalResponseIn case that issuing the request that was supposed to result in this response failed with an exception or reading the data obtained via the request failed with an exception, this method returns that exception; otherwise it returnsnull. The exception returned by this method (if any) should have a message that contains the right amount of detail to be shown to the user as part of an explanation that the query result produced by HeFQUIN may be incomplete.- Specified by:
getExceptionin interfaceDataRetrievalResponse<T>
-
getRequestStartTime
Description copied from interface:DataRetrievalResponseReturns the time at which the corresponding data retrieval request (see) was started.invalid reference
#getRequest()- Specified by:
getRequestStartTimein interfaceDataRetrievalResponse<T>
-
getRetrievalEndTime
Description copied from interface:DataRetrievalResponseReturns the time at which the retrieval of this response was completed.- Specified by:
getRetrievalEndTimein interfaceDataRetrievalResponse<T>
-
throwExceptionIfNoResponseData
Throws anUnsupportedOperationDueToRetrievalErrorexception if (DataRetrievalResponse.isError()istrueorDataRetrievalResponse.isDefective()istrue. Hence, this method can be used as an initial check in all methods that assume this response contains the requested data (i.e., the response to the corresponding request was an not error message and the response is not defective.
-