Class ServletClient
- java.lang.Object
-
- org.topbraidlive.client.java.impl.ServletClient
-
- All Implemented Interfaces:
UnzipProjectApiFunction
,AddTriplesApiFunction
,ApiFunction
,ExecuteSpinTemplateApiFunction
public final class ServletClient extends Object implements AddTriplesApiFunction, ExecuteSpinTemplateApiFunction, UnzipProjectApiFunction
Client for server functions implemented as servlets.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.topbraidlive.client.java.api.exception.UnzipProjectApiFunction
UnzipProjectApiFunction.OldProject
-
-
Constructor Summary
Constructors Constructor Description ServletClient(ClientConfiguration clientConfiguration, org.apache.http.impl.client.CloseableHttpClient httpClient)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTriples(boolean complete, Uri graphUri, org.apache.jena.shared.PrefixMapping prefixMapping, Iterator<org.apache.jena.graph.Triple> triples)
Add all triples from the given graphprotected org.apache.http.client.methods.CloseableHttpResponse
execute(org.apache.http.client.methods.HttpUriRequest httpUriRequest)
String
executeSpinTemplate(ExecuteSpinTemplateParameters parameters)
Execute a SPIN template.protected org.apache.http.client.methods.CloseableHttpResponse
get(org.apache.http.client.utils.URIBuilder uriBuilder)
protected ClientConfiguration
getClientConfiguration()
protected org.apache.http.impl.client.CloseableHttpClient
getHttpClient()
protected ClientException
newClientException(org.apache.http.HttpResponse httpResponse)
protected org.apache.http.client.utils.URIBuilder
newUriBuilder(String relativeUriPath)
protected org.apache.http.client.methods.CloseableHttpResponse
postForm(List<org.apache.http.NameValuePair> nameValuePairs, org.apache.http.client.utils.URIBuilder uriBuilder)
protected String
toString(org.apache.http.HttpResponse httpResponse)
Convert an HttpResponse to a string, usually for logging.protected String
toString(org.apache.http.HttpResponse httpResponse, String httpResponseEntity)
Convert an HttpResponse to a string, usually for logging.void
unzipProject(Path projectZipFilePath, Optional<UnzipProjectApiFunction.OldProject> oldProject)
Upload a project as a .zip file to the server.protected static RuntimeException
wrap(IOException e)
-
-
-
Constructor Detail
-
ServletClient
public ServletClient(ClientConfiguration clientConfiguration, org.apache.http.impl.client.CloseableHttpClient httpClient)
-
-
Method Detail
-
addTriples
public final void addTriples(boolean complete, Uri graphUri, org.apache.jena.shared.PrefixMapping prefixMapping, Iterator<org.apache.jena.graph.Triple> triples)
Description copied from interface:AddTriplesApiFunction
Add all triples from the given graph- Specified by:
addTriples
in interfaceAddTriplesApiFunction
- Parameters:
complete
- signal whether this is the last batch of triples or notgraphUri
- graph URI to add the triples toprefixMapping
- namespace prefix mappingtriples
- iterator over triples
-
executeSpinTemplate
public final String executeSpinTemplate(ExecuteSpinTemplateParameters parameters)
Description copied from interface:ExecuteSpinTemplateApiFunction
Execute a SPIN template.- Specified by:
executeSpinTemplate
in interfaceExecuteSpinTemplateApiFunction
- Parameters:
parameters
- : parameters object- Returns:
- String comprising the body, encoded in the format specified in parameters
-
unzipProject
public final void unzipProject(Path projectZipFilePath, Optional<UnzipProjectApiFunction.OldProject> oldProject)
Description copied from interface:UnzipProjectApiFunction
Upload a project as a .zip file to the server.- Specified by:
unzipProject
in interfaceUnzipProjectApiFunction
- Parameters:
projectZipFilePath
- path to a .zip file containing the projectoldProject
- delete or update an existing project
-
wrap
protected static final RuntimeException wrap(IOException e)
-
getClientConfiguration
protected final ClientConfiguration getClientConfiguration()
-
execute
protected final org.apache.http.client.methods.CloseableHttpResponse execute(org.apache.http.client.methods.HttpUriRequest httpUriRequest)
-
get
protected final org.apache.http.client.methods.CloseableHttpResponse get(org.apache.http.client.utils.URIBuilder uriBuilder)
-
getHttpClient
protected final org.apache.http.impl.client.CloseableHttpClient getHttpClient()
-
newClientException
protected final ClientException newClientException(org.apache.http.HttpResponse httpResponse) throws IOException
- Throws:
IOException
-
newUriBuilder
protected final org.apache.http.client.utils.URIBuilder newUriBuilder(String relativeUriPath)
-
postForm
protected final org.apache.http.client.methods.CloseableHttpResponse postForm(List<org.apache.http.NameValuePair> nameValuePairs, org.apache.http.client.utils.URIBuilder uriBuilder)
-
toString
protected final String toString(org.apache.http.HttpResponse httpResponse) throws IOException
Convert an HttpResponse to a string, usually for logging.Consumes the entity (body) in order to convert it to a string.
- Throws:
IOException
-
toString
protected final String toString(org.apache.http.HttpResponse httpResponse, String httpResponseEntity) throws IOException
Convert an HttpResponse to a string, usually for logging.Uses an entity (body) that has been previously converted to a string.
- Throws:
IOException
-
-