public Map<String, String> getLatestVersionInfo(String version) {
      int socTimeout = 1; // http socket timeout in seconds
      int connectionTimeout = 3; // http connection timeout in seconds
      Map<String, String> latestVersionInfo = new HashMap<>();

      String versionUrl = "http://www.unidata.ucar.edu/software/thredds/latest.xml";
      try {
        try (HTTPMethod method = HTTPFactory.Get(versionUrl)) {
          HTTPSession httpClient = method.getSession();
          httpClient.setSoTimeout(socTimeout * 1000);
          httpClient.setConnectionTimeout(connectionTimeout * 1000);
          httpClient.setUserAgent("TDS_" + version.replace(" ", ""));
          method.execute();
          InputStream responseIs = method.getResponseBodyAsStream();

          DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
          DocumentBuilder db = dbf.newDocumentBuilder();
          Document dom = db.parse(responseIs);
          Element docEle = dom.getDocumentElement();
          NodeList versionElements = docEle.getElementsByTagName("version");
          if(versionElements != null && versionElements.getLength() > 0) {
            for(int i = 0;i < versionElements.getLength();i++) {
              //get the version element
              Element versionElement = (Element) versionElements.item(i);
              String verType = versionElement.getAttribute("name");
              String verStr = versionElement.getAttribute("value");
              latestVersionInfo.put(verType, verStr);
            }
          }
        }
      } catch (IOException e) {
        startupLog.warn("TdsContext - Could not get latest version information from Unidata.");
      } catch (ParserConfigurationException e) {
        startupLog.error("TdsContext - Error configuring latest version xml parser" + e.getMessage() + ".");
      } catch (SAXException e) {
        startupLog.error("TdsContext - Could not parse latest version information.");
      }
      return latestVersionInfo;
    }
public Map < String , String > getLatestVersionInfo ( String version ) { int socTimeout = 1 ; int connectionTimeout = 3 ; Map < String , String > latestVersionInfo = new HashMap < > ( ) ; String versionUrl = "http://www.unidata.ucar.edu/software/thredds/latest.xml" ; try { try ( HTTPMethod method = HTTPFactory . Get ( versionUrl ) ) { HTTPSession httpClient = method . getSession ( ) ; httpClient . setSoTimeout ( socTimeout * 1000 ) ; httpClient . setConnectionTimeout ( connectionTimeout * 1000 ) ; httpClient . setUserAgent ( "TDS_" + version . replace ( " " , "" ) ) ; method . execute ( ) ; InputStream responseIs = method . getResponseBodyAsStream ( ) ; DocumentBuilderFactory dbf = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder db = dbf . newDocumentBuilder ( ) ; Document dom = db . parse ( responseIs ) ; Element docEle = dom . getDocumentElement ( ) ; NodeList versionElements = docEle . getElementsByTagName ( "version" ) ; if ( versionElements != null && versionElements . getLength ( ) > 0 ) { for ( int i = 0 ; i < versionElements . getLength ( ) ; i ++ ) { Element versionElement = ( Element ) versionElements . item ( i ) ; String verType = versionElement . getAttribute ( "name" ) ; String verStr = versionElement . getAttribute ( "value" ) ; latestVersionInfo . put ( verType , verStr ) ; } } } } catch ( IOException e ) { startupLog . warn ( "TdsContext - Could not get latest version information from Unidata." ) ; } catch ( ParserConfigurationException e ) { startupLog . error ( "TdsContext - Error configuring latest version xml parser" + e . getMessage ( ) + "." ) ; } catch ( SAXException e ) { startupLog . error ( "TdsContext - Could not parse latest version information." ) ; } return latestVersionInfo ; }
Retrieve the latest stable and development versions
available from Unidata. Needs to connect to
http://www.unidata.ucar.edu in order to get the
latest version numbers. The idea is to easily let users
know if the version of TDS they are running is out of
date, as this information is recorded in the
serverStartup.log file.

@return A hashmap containing versionTypes as key (i.e.
"stable", "development") and their corresponding
version numbers (i.e. 4.5.2)