List of usage examples for org.apache.commons.httpclient ConnectTimeoutException getMessage
public String getMessage()
From source file:org.artifactory.cli.rest.RestClient.java
/** * Executes a configured HTTP// w ww . j a va2s. co m * * @param uri Target URL * @param method Method to execute * @param expectedStatus Expected return status * @param expectedResultType Expected response media type * @param timeout Request timeout * @param credentials For authentication * @throws Exception */ private static byte[] executeMethod(String uri, HttpMethod method, int expectedStatus, String expectedResultType, int timeout, Credentials credentials, boolean printStream) throws IOException { try { getHttpClient(uri, timeout, credentials).executeMethod(method); checkStatus(uri, expectedStatus, method); Header contentTypeHeader = method.getResponseHeader("content-type"); if (contentTypeHeader != null) { //Check result content type String contentType = contentTypeHeader.getValue(); checkContentType(uri, expectedResultType, contentType); } return analyzeResponse(method, printStream); } catch (SSLException ssle) { throw new RemoteCommandException("\nThe host you are trying to reach does not support SSL."); } catch (ConnectTimeoutException cte) { throw new RemoteCommandException("\n" + cte.getMessage()); } catch (UnknownHostException uhe) { throw new RemoteCommandException("\nThe host of the specified URL: " + uri + " could not be found.\n" + "Please make sure you have specified the correct path. The default should be:\n" + "http://myhost:8081/artifactory/api/system"); } catch (ConnectException ce) { throw new RemoteCommandException("\nCannot not connect to: " + uri + ". " + "Please make sure to specify a valid host (--host <host>:<port>) or URL (--url http://...)."); } catch (NoRouteToHostException nrthe) { throw new RemoteCommandException("\nCannot reach: " + uri + ".\n" + "Please make sure that the address is valid and that the port is open (firewall, router, etc')."); } finally { method.releaseConnection(); } }
From source file:pl.nask.hsn2.service.urlfollower.WebClientWorker.java
@Override public final void run() { String workerUrl = workerDispatcher.getUrlForProcessing(); try {/*from w w w . j a v a2s.c om*/ initializeWebClient(); processTheUrl(workerUrl); } catch (ConnectTimeoutException e) { LOGGER.warn("Connection timeout for URL '{}'", workerUrl); LOGGER.debug(e.getMessage(), e); workerDispatcher.requestFailed(e); } catch (org.apache.http.conn.ConnectTimeoutException e) { LOGGER.warn("Connection timeout: {}", e.getMessage()); LOGGER.debug("Connection timeout stacktrace: {}", e); workerDispatcher.requestFailed(e); } catch (SocketTimeoutException e) { LOGGER.warn("Socket timeout for URL '{}'", workerUrl); LOGGER.debug(e.getMessage(), e); workerDispatcher.requestFailed(e); } catch (UnknownHostException e) { LOGGER.warn("Unknown host: {}", e.getMessage()); LOGGER.debug("Unknown host stacktrace: {}", e); workerDispatcher.requestFailed("Unknown host: " + e.getMessage()); } catch (IOException e) { LOGGER.warn("IOException: {}", e.getMessage()); LOGGER.debug("IOException for URL '{}' with stacktrace: {}", workerUrl, e); workerDispatcher.requestFailed(e); } catch (TimeoutException e) { LOGGER.warn(e.getMessage()); LOGGER.debug(e.getMessage(), e); workerDispatcher.requestFailed(e); } catch (Exception e) { LOGGER.error("Exception for URL '{}'", workerUrl, e); workerDispatcher.requestFailed(e); } finally { closeAllWindows(); latch.countDown(); } }