List of usage examples for org.apache.commons.httpclient HttpException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.twinsoft.convertigo.eclipse.wizards.setup.SetupWizard.java
public void checkConnected(final CheckConnectedCallback callback) { Thread th = new Thread(new Runnable() { public void run() { synchronized (SetupWizard.this) { boolean isConnected = false; String message;// w w w . ja va 2 s. c o m try { String[] urlSource = { "https://c8o.convertigo.net/cems/index.html" }; HttpClient client = prepareHttpClient(urlSource); GetMethod method = new GetMethod(urlSource[0]); int statusCode = client.executeMethod(method); if (statusCode == HttpStatus.SC_OK) { isConnected = true; message = "You are currently online"; } else { message = "Bad response: HTTP status " + statusCode; } } catch (HttpException e) { message = "HTTP failure: " + e.getMessage(); } catch (IOException e) { message = "IO failure: " + e.getMessage(); } catch (Exception e) { message = "Generic failure: " + e.getClass().getSimpleName() + ", " + e.getMessage(); } callback.onCheckConnected(isConnected, message); } } }); th.setDaemon(true); th.setName("SetupWizard.checkConnected"); th.start(); }
From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow2.java
private void findAvailableUpdatesFromTomcat() { installedRow = initialRow;/*from w ww . ja v a2 s .c o m*/ // String url = System.getProperty("remote_components_config_url"); //remote_components_config_url=http://califano11.cgc.cpmc.columbia.edu:8080/componentRepository/deploycomponents.txt GlobalPreferences prefs = GlobalPreferences.getInstance(); String url = prefs.getRCM_URL().trim(); if (url == null || url == "") { log.info("No Remote Component Manager URL configured."); return; } url += "/deploycomponents.txt"; HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setConnectionTimeout(3000); GetMethod method = new GetMethod(url); method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); method.setFollowRedirects(true); try { int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { JOptionPane.showMessageDialog(null, "No updates are available at this time.\nPlease try again later.", "Remote Component Update", JOptionPane.PLAIN_MESSAGE); return; } String deploycomponents = method.getResponseBodyAsString(); // String[] rows = deploycomponents.split("\\r\\n"); String[] folderNameVersions = deploycomponents.split("\\r\\n"); for (int i = 0; i < ccmTableModel.getModelRowCount(); i++) { String localFolderName = ccmTableModel.getResourceFolder(i); String localVersion = ((String) ccmTableModel.getModelValueAt(i, CCMTableModel2.VERSION_INDEX)); Double dLocalVersion = new Double(localVersion); for (int j = 0; j < folderNameVersions.length; j++) { String[] cols = folderNameVersions[j].split(","); String remoteFolderName = cols[0]; String remoteVersion = cols[1]; Double dRemoteVersion = new Double(remoteVersion); if (localFolderName.equalsIgnoreCase(remoteFolderName)) { if (dRemoteVersion.compareTo(dLocalVersion) > 0) { ccmTableModel.setModelValueAt(remoteVersion, i, CCMTableModel2.AVAILABLE_UPDATE_INDEX, CCMTableModel2.NO_VALIDATION); } } } } } catch (HttpException e) { JOptionPane.showMessageDialog(null, "No updates are available at this time.\nPlease try again later.", "Remote Component Update", JOptionPane.PLAIN_MESSAGE); //e.printStackTrace(); return; } catch (IOException e) { JOptionPane.showMessageDialog(null, e.getMessage() + ".\n(" + e.getClass().getName() + ")\nPlease try again later.", "No Update Available", JOptionPane.PLAIN_MESSAGE); //e.printStackTrace(); return; } catch (Exception e) { // IllegalArgumentException JOptionPane.showMessageDialog(null, e.getMessage() + ".", "No Update Available", JOptionPane.PLAIN_MESSAGE); } }