use of org.apache.sling.hapi.client.ClientException in project sling by apache.
the class AbstractHtmlClientImpl method post.
@Override
public <T extends Document> T post(String url, HttpEntity entity) throws ClientException {
try {
URI absoluteUri = absoluteUri(url);
LOG.info("POST " + absoluteUri);
HttpPost post = new HttpPost(absoluteUri);
post.setEntity(entity);
HttpResponse response = this.execute(post);
return newDocument(EntityUtils.toString(response.getEntity()));
} catch (URISyntaxException e) {
throw new ClientException("Invalid post url " + url, e);
} catch (Exception e) {
throw new ClientException("Could not execute POST request", e);
}
}
use of org.apache.sling.hapi.client.ClientException in project sling by apache.
the class AbstractHtmlClientImpl method delete.
@Override
public <T extends Document> T delete(String url) throws ClientException {
try {
URI absoluteUri = absoluteUri(url);
LOG.info("DELETE " + absoluteUri);
HttpResponse response = this.execute(new HttpDelete(absoluteUri));
return newDocument(response.getEntity().toString());
} catch (URISyntaxException e) {
throw new ClientException("Invalid post url " + url, e);
} catch (Exception e) {
throw new ClientException("Could not execute DELETE request", e);
}
}
use of org.apache.sling.hapi.client.ClientException in project sling by apache.
the class AbstractHtmlClientImpl method get.
@Override
public <T extends Document> T get(String url) throws ClientException {
try {
URI absoluteUri = absoluteUri(url);
LOG.info("GET " + absoluteUri);
HttpResponse response = this.execute(new HttpGet(absoluteUri));
return newDocument(EntityUtils.toString(response.getEntity()));
} catch (URISyntaxException e) {
throw new ClientException("Invalid get url " + url, e);
} catch (Exception e) {
throw new ClientException("Could not execute GET request", e);
}
}
Aggregations