use of org.apache.http.conn.HttpHostConnectException in project tdi-studio-se by Talend.
the class RestClient method executePostRequest.
private int executePostRequest(String apiURI, UrlEncodedFormEntity entity) {
try {
HttpPost postRequest = new HttpPost(bonitaURI + apiURI);
postRequest.setEntity(entity);
HttpResponse response = httpClient.execute(postRequest, httpContext);
return consumeResponse(response, true);
} catch (HttpHostConnectException e) {
throw new RuntimeException("Bonita bundle may not have been started, or the URL is invalid. Please verify hostname and port number. URL used is: " + BONITA_URI, e);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
use of org.apache.http.conn.HttpHostConnectException in project sling by apache.
the class SimpleHttpDistributionTransport method retrievePackage.
@Nullable
public RemoteDistributionPackage retrievePackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionRequest distributionRequest, @Nonnull DistributionTransportContext distributionContext) throws DistributionException {
log.debug("pulling from {}", distributionEndpoint.getUri());
try {
URI distributionURI = RequestUtils.appendDistributionRequest(distributionEndpoint.getUri(), distributionRequest);
Executor executor = getExecutor(distributionContext);
// TODO : add queue parameter
InputStream inputStream = HttpTransportUtils.fetchNextPackage(executor, distributionURI, httpConfiguration);
if (inputStream == null) {
return null;
}
try {
final DistributionPackage responsePackage = packageBuilder.readPackage(resourceResolver, inputStream);
responsePackage.getInfo().put(PACKAGE_INFO_PROPERTY_ORIGIN_URI, distributionURI);
log.debug("pulled package with info {}", responsePackage.getInfo());
return new DefaultRemoteDistributionPackage(responsePackage, executor, distributionURI);
} finally {
IOUtils.closeQuietly(inputStream);
}
} catch (HttpHostConnectException e) {
log.debug("could not connect to {} - skipping", distributionEndpoint.getUri());
} catch (Exception ex) {
log.error("cannot retrieve packages", ex);
}
return null;
}
Aggregations