private static void isValid(StringReturnCode created, String lang) { created.setOk(false); if (getAmcUrl() == null || getAmcUrl().length() <= 0) { created.setMessage( PropertiesLoaderProvider.getMessages() .getString("dashboard.amc.url.unavailable.reason.notempty")); created.setOk(false); return; } URL url = null; HttpURLConnection con = null; int state = -1; try { url = new URL(getAmcServerLocationUrl()); con = (HttpURLConnection) url.openConnection(); state = con.getResponseCode(); if (state == 200) { created.setOk(true); } else if (state == 404) { created.setOk(false); created.setMessage( PropertiesLoaderProvider.getMessages(lang) .getString("dashboard.amc.url.unavailable.reason.notrunning")); } } catch (Exception ex) { created.setMessage( PropertiesLoaderProvider.getMessages(lang) .getString("dashboard.amc.url.unavailable.reason.notsetcorrectly")); created.setOk(false); } finally { con.disconnect(); } }
private static String getAmcUrl() { return PropertiesLoaderProvider.getInstance().getString("amc.serverlocationurl"); }