legacy/src/main/java/thredds/catalog/query/DqcFactory.java
public QueryCapability readXML(String uriString) throws IOException {

    // get URI
    URI uri;
    try {
      uri = new URI(uriString);
    } catch (URISyntaxException e) {
      throw new MalformedURLException(e.getMessage());
    }

    // check if its cached
    if (diskCache != null) {
      File file = diskCache.getCacheFile(uriString);
      if (file != null) {
        HttpURLConnection conn = null;

        try {
          URL url = uri.toURL();
          conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("GET");
          conn.setIfModifiedSince(file.lastModified());

          int code = conn.getResponseCode();
          if (code == HttpURLConnection.HTTP_OK) {
            java.io.InputStream is = conn.getInputStream();
            if (is != null) {
              try (FileOutputStream fout = new FileOutputStream(file)) {
                  IO.copyB(is, fout, buffer_size);  // cache it
              }
              try (InputStream fin = new BufferedInputStream( new FileInputStream(file), 50000)) {
                return readXML(fin, uri);
              }
            }

          } else {
            // use file
            try (FileInputStream fin = new FileInputStream(file)) {
              return readXML(fin, uri);
            }
          }

        } finally {

          if (conn != null)
            conn.disconnect();
        }

      } // has file

      // no file - read and cache
      IO.readURLtoFileWithExceptions(uriString, file, buffer_size);
      try (InputStream fin = new BufferedInputStream(
              new FileInputStream(file), 50000)) {
        return readXML(fin, uri);
      }

    } // has diskCache

    // otherwise just open the URL
    warnMessages.setLength(0);
    errMessages.setLength(0);
    fatalMessages.setLength(0);

    Document doc = null;
    try {
      doc = builder.build(uriString);
    } catch (JDOMException e) {
      fatalMessages.append(e.getMessage()); // makes it invalid
    }

    return readXML(doc, uri);
  }
public QueryCapability readXML(String uriString) throws IOException {

    // get URI
    URI uri;
    try {
      uri = new URI(uriString);
    } catch (URISyntaxException e) {
      throw new MalformedURLException(e.getMessage());
    }

    // check if its cached
    if (diskCache != null) {
      File file = diskCache.getCacheFile(uriString);
      if (file != null) {
        HttpURLConnection conn = null;

        try {
          URL url = uri.toURL();
          conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("GET");
          conn.setIfModifiedSince(file.lastModified());

          int code = conn.getResponseCode();
          if (code == HttpURLConnection.HTTP_OK) {
            java.io.InputStream is = conn.getInputStream();
            if (is != null) {
              try (FileOutputStream fout = new FileOutputStream(file)) {
                  IO.copyB(is, fout, buffer_size);  // cache it
              }
              try (InputStream fin = new BufferedInputStream( new FileInputStream(file), 50000)) {
                return readXML(fin, uri);
              }
            }

          } else {
            // use file
            try (FileInputStream fin = new FileInputStream(file)) {
              return readXML(fin, uri);
            }
          }

        } finally {

          if (conn != null)
            conn.disconnect();
        }

      } // has file

      // no file - read and cache
      IO.readURLtoFileWithExceptions(uriString, file, buffer_size);
      try (InputStream fin = new BufferedInputStream(
              new FileInputStream(file), 50000)) {
        return readXML(fin, uri);
      }

    } // has diskCache

    // otherwise just open the URL
    warnMessages.setLength(0);
    errMessages.setLength(0);
    fatalMessages.setLength(0);

    Document doc = null;
    try {
      doc = builder.build(uriString);
    } catch (JDOMException e) {
      fatalMessages.append(e.getMessage()); // makes it invalid
    }

    return readXML(doc, uri);
  }
public QueryCapability readXML ( String uriString ) throws IOException { // get URI URI uri ; try { uri = new URI ( uriString ) ; } catch ( URISyntaxException e ) { throw new MalformedURLException ( e . getMessage ( ) ) ; } // check if its cached if ( diskCache != null ) { File file = diskCache . getCacheFile ( uriString ) ; if ( file != null ) { HttpURLConnection conn = null ; try { URL url = uri . toURL ( ) ; conn = ( HttpURLConnection ) url . openConnection ( ) ; conn . setRequestMethod ( "GET" ) ; conn . setIfModifiedSince ( file . lastModified ( ) ) ; int code = conn . getResponseCode ( ) ; if ( code == HttpURLConnection . HTTP_OK ) { java . io . InputStream is = conn . getInputStream ( ) ; if ( is != null ) { try ( FileOutputStream fout = new FileOutputStream ( file ) ) { IO . copyB ( is , fout , buffer_size ) ; // cache it } try ( InputStream fin = new BufferedInputStream ( new FileInputStream ( file ) , 50000 ) ) { return readXML ( fin , uri ) ; } } } else { // use file try ( FileInputStream fin = new FileInputStream ( file ) ) { return readXML ( fin , uri ) ; } } } finally { if ( conn != null ) conn . disconnect ( ) ; } } // has file // no file - read and cache IO . readURLtoFileWithExceptions ( uriString , file , buffer_size ) ; try ( InputStream fin = new BufferedInputStream ( new FileInputStream ( file ) , 50000 ) ) { return readXML ( fin , uri ) ; } } // has diskCache // otherwise just open the URL warnMessages . setLength ( 0 ) ; errMessages . setLength ( 0 ) ; fatalMessages . setLength ( 0 ) ; Document doc = null ; try { doc = builder . build ( uriString ) ; } catch ( JDOMException e ) { fatalMessages . append ( e . getMessage ( ) ) ; // makes it invalid } return readXML ( doc , uri ) ; }
Create an QueryCapability from an XML document at a named URL.
check dqc.isValid, dqc.getErrorMessages() to see if ok.
If Disk caching is set, cache the dqc and check IfModifiedSince.

@param uriString : the URI name that the XML doc is at.
@return an QueryCapability object
@throws IOException on failure
Create an QueryCapability from an XML document at a named URL . check dqc . isValid dqc . getErrorMessages () to see if ok . If Disk caching is set cache the dqc and check IfModifiedSince .