Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Allow NetcdfDataset to open remote NcML Files #801

Merged
merged 1 commit into from
Apr 14, 2017

Conversation

lesserwhirls
Copy link
Collaborator

fixes #800

@cofinoa
Copy link
Contributor

cofinoa commented Apr 13, 2017

@lesserwhirls This PR diverges from how the NCML service type detection is made for the file protocol:

https://github.com/Unidata/thredds/blob/v4.6.8/cdm/src/main/java/ucar/nc2/dataset/NetcdfDataset.java#L697-L708

may be it woul better to do something like this:

    if (svctype == null) {
      //There are several possibilities at this point; all of which
      // require further info to disambiguate
      //  - we have file://<path> or file:<path>; we need to see if
      //    the extension can help, otherwise, start defaulting.
      //  - we have a simple url: e.g. http://... ; contact the server
      if (leadprotocol.equals("file")) {
        svctype = decodePathExtension(trueurl); // look at the path extension
      } else {
          svctype = disambiguateHttp(trueurl);
          if ((svctype == null || svctype == ServiceType.HTTPServer) && decodePathExtension(trueurl)==ServiceType.NCML)
              svctype = ServiceType.NCML;
      }
    }

in case the svctype is null or is HTTPServer, try with decodePathExtension

The other option it's would be to implement your appoach by reading the head and discover the ncml namespace ... or make both just in case.

@lesserwhirls
Copy link
Collaborator Author

Thanks for the feedback @cofinoa!

The idea behind reading the first bit of the file is like the IOSP "fail fast" approach, especially since we would possibly be trying to download something. However, maybe it's not a big deal given we are looking at an NcML file (which are typically small). Things started to get a bit crowded, so I offloaded the code to checkIfRemoteNcml.

@cwardgar cwardgar merged commit cc5851a into Unidata:master Apr 14, 2017
@lesserwhirls lesserwhirls deleted the remotencml branch May 3, 2017 19:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants