コード例 #1
0
  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();
    }
  }
コード例 #2
0
 public static StringReturnCode testAmcServerLocationURL(
     final StringReturnCode created, String lang) {
   String url = getAmcUrl();
   created.setObject(url);
   isValid(created, lang);
   return created;
 }