use of org.eclipse.vorto.core.api.repository.CheckInModelException in project vorto by eclipse.
the class RestClient method executePost.
public <Result> Result executePost(String query, HttpEntity content, final Function<String, Result> responseConverter) throws ClientProtocolException, IOException {
ProxyConfiguration proxyProvider = getProxyConfiguration();
CloseableHttpClient client = HttpClients.custom().setDefaultCredentialsProvider(proxyProvider.credentialsProvider).build();
HttpUriRequest request = RequestBuilder.post().setConfig(proxyProvider.requestConfig).setUri(createQuery(query)).addHeader(createSecurityHeader()).setEntity(content).build();
return client.execute(request, new DefaultResponseHandler<Result>() {
@Override
public Result handleSuccess(HttpResponse response) throws ClientProtocolException, IOException {
return responseConverter.apply(IOUtils.toString(response.getEntity().getContent()));
}
@Override
protected Result handleFailure(HttpResponse response) throws ClientProtocolException, IOException {
throw new CheckInModelException("Error in uploading file to remote repository");
}
});
}
Aggregations