TResult - - The expected result class from the JFrog REST endpoint.public abstract class JFrogService<TResult>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected org.jfrog.build.api.util.Log |
log |
protected JFrogServiceResponseType |
responseType |
protected TResult |
result |
protected int |
statusCode |
| Modifier | Constructor and Description |
|---|---|
protected |
JFrogService(org.jfrog.build.api.util.Log log) |
protected |
JFrogService(org.jfrog.build.api.util.Log log,
JFrogServiceResponseType responseType) |
| Modifier and Type | Method and Description |
|---|---|
abstract org.apache.http.client.methods.HttpRequestBase |
createRequest() |
protected void |
ensureRequirements(org.jfrog.build.client.JFrogHttpClient client) |
TResult |
execute(org.jfrog.build.client.JFrogHttpClient client)
Default execution of a service:
1.
|
org.apache.http.Header[] |
getHeaders() |
protected com.fasterxml.jackson.databind.ObjectMapper |
getMapper()
Default ObjectMapper to parse or deserialize JSON content into a Java object.
|
TResult |
getResult() |
int |
getStatusCode() |
protected void |
handleEmptyEntity()
For services with responseType.OBJECT (expected a return value) may
override this function which helps to handle scenarios whereby a response body needs to be read
but do entity is found.
|
protected void |
handleUnsuccessfulResponse(org.apache.http.HttpEntity entity)
Default error handling (E.G.
|
void |
setHeaders(org.apache.http.Header[] headers) |
protected abstract void |
setResponse(java.io.InputStream stream)
Override this in order to parse the service response body (only for services that expect to have body in the response).
|
void |
setResult(TResult result) |
void |
setStatusCode(int statusCode) |
protected static void |
throwException(org.apache.http.HttpEntity entity,
int statusCode) |
protected final org.jfrog.build.api.util.Log log
protected TResult result
protected int statusCode
protected JFrogServiceResponseType responseType
protected JFrogService(org.jfrog.build.api.util.Log log)
protected JFrogService(org.jfrog.build.api.util.Log log,
JFrogServiceResponseType responseType)
protected static void throwException(org.apache.http.HttpEntity entity,
int statusCode)
throws java.io.IOException
java.io.IOExceptionprotected com.fasterxml.jackson.databind.ObjectMapper getMapper()
public TResult getResult()
public void setResult(TResult result)
public int getStatusCode()
public void setStatusCode(int statusCode)
public abstract org.apache.http.client.methods.HttpRequestBase createRequest()
throws java.io.IOException
java.io.IOExceptionprotected abstract void setResponse(java.io.InputStream stream)
throws java.io.IOException
stream - - Inout stream of the response body.java.io.IOExceptionprotected void handleUnsuccessfulResponse(org.apache.http.HttpEntity entity)
throws java.io.IOException
entity - - The returned failure response.java.io.IOExceptionpublic TResult execute(org.jfrog.build.client.JFrogHttpClient client) throws java.io.IOException
client - - http client for sending the request.java.io.IOExceptionprotected void handleEmptyEntity()
throws java.io.IOException
java.io.IOExceptionprotected void ensureRequirements(org.jfrog.build.client.JFrogHttpClient client)
throws java.io.IOException
java.io.IOExceptionpublic org.apache.http.Header[] getHeaders()
public void setHeaders(org.apache.http.Header[] headers)