tds/src/main/java/thredds/core/DatasetManager.java
public GridDataset openGridDataset(HttpServletRequest req, HttpServletResponse res, String reqPath) throws IOException {
    // first look for a feature collection
    DataRootManager.DataRootMatch match = dataRootManager.findDataRootMatch(reqPath);
    if ((match != null) && (match.dataRoot.getFeatureCollection() != null)) {
      // see if its under resource control
      if (!resourceAuthorized(req, res, match.dataRoot.getRestrict()))
        return null;

      FeatureCollectionRef featCollection = match.dataRoot.getFeatureCollection();
      if (log.isDebugEnabled()) log.debug("  -- DatasetHandler found FeatureCollection= " + featCollection);

      InvDatasetFeatureCollection fc = featureCollectionCache.get(featCollection);
      GridDataset gds = fc.getGridDataset(match.remaining);
      if (gds == null) throw new FileNotFoundException(reqPath);
      return gds;
    }

    // fetch it as a NetcdfFile; this deals with possible NcML
    NetcdfFile ncfile = openNetcdfFile(req, res, reqPath);
    if (ncfile == null) return null;

    NetcdfDataset ncd = null;
    try {
      // Convert to NetcdfDataset
      ncd = NetcdfDataset.wrap(ncfile, NetcdfDataset.getDefaultEnhanceMode());
      return new ucar.nc2.dt.grid.GridDataset(ncd);


    } catch (Throwable t) {
      if (ncd == null)
        ncfile.close();
      else
        ncd.close();

      if (t instanceof IOException)
        throw (IOException) t;

      String msg = ncd == null ? "Problem wrapping NetcdfFile in NetcdfDataset" : "Problem creating GridDataset from NetcdfDataset";
      log.error("openGridDataset(): " + msg, t);
      throw new IOException(msg + t.getMessage());
    }
  }
public GridDataset openGridDataset(HttpServletRequest req, HttpServletResponse res, String reqPath) throws IOException {
    // first look for a feature collection
    DataRootManager.DataRootMatch match = dataRootManager.findDataRootMatch(reqPath);
    if ((match != null) && (match.dataRoot.getFeatureCollection() != null)) {
      // see if its under resource control
      if (!resourceAuthorized(req, res, match.dataRoot.getRestrict()))
        return null;

      FeatureCollectionRef featCollection = match.dataRoot.getFeatureCollection();
      if (log.isDebugEnabled()) log.debug("  -- DatasetHandler found FeatureCollection= " + featCollection);

      InvDatasetFeatureCollection fc = featureCollectionCache.get(featCollection);
      GridDataset gds = fc.getGridDataset(match.remaining);
      if (gds == null) throw new FileNotFoundException(reqPath);
      return gds;
    }

    // fetch it as a NetcdfFile; this deals with possible NcML
    NetcdfFile ncfile = openNetcdfFile(req, res, reqPath);
    if (ncfile == null) return null;

    NetcdfDataset ncd = null;
    try {
      // Convert to NetcdfDataset
      ncd = NetcdfDataset.wrap(ncfile, NetcdfDataset.getDefaultEnhanceMode());
      return new ucar.nc2.dt.grid.GridDataset(ncd);


    } catch (Throwable t) {
      if (ncd == null)
        ncfile.close();
      else
        ncd.close();

      if (t instanceof IOException)
        throw (IOException) t;

      String msg = ncd == null ? "Problem wrapping NetcdfFile in NetcdfDataset" : "Problem creating GridDataset from NetcdfDataset";
      log.error("openGridDataset(): " + msg, t);
      throw new IOException(msg + t.getMessage());
    }
  }
public GridDataset openGridDataset ( HttpServletRequest req , HttpServletResponse res , String reqPath ) throws IOException { // first look for a feature collection DataRootManager . DataRootMatch match = dataRootManager . findDataRootMatch ( reqPath ) ; if ( ( match != null ) && ( match . dataRoot . getFeatureCollection ( ) != null ) ) { // see if its under resource control if ( ! resourceAuthorized ( req , res , match . dataRoot . getRestrict ( ) ) ) return null ; FeatureCollectionRef featCollection = match . dataRoot . getFeatureCollection ( ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "  -- DatasetHandler found FeatureCollection= " + featCollection ) ; InvDatasetFeatureCollection fc = featureCollectionCache . get ( featCollection ) ; GridDataset gds = fc . getGridDataset ( match . remaining ) ; if ( gds == null ) throw new FileNotFoundException ( reqPath ) ; return gds ; } // fetch it as a NetcdfFile; this deals with possible NcML NetcdfFile ncfile = openNetcdfFile ( req , res , reqPath ) ; if ( ncfile == null ) return null ; NetcdfDataset ncd = null ; try { // Convert to NetcdfDataset ncd = NetcdfDataset . wrap ( ncfile , NetcdfDataset . getDefaultEnhanceMode ( ) ) ; return new ucar . nc2 . dt . grid . GridDataset ( ncd ) ; } catch ( Throwable t ) { if ( ncd == null ) ncfile . close ( ) ; else ncd . close ( ) ; if ( t instanceof IOException ) throw ( IOException ) t ; String msg = ncd == null ? "Problem wrapping NetcdfFile in NetcdfDataset" : "Problem creating GridDataset from NetcdfDataset" ; log . error ( "openGridDataset(): " + msg , t ) ; throw new IOException ( msg + t . getMessage ( ) ) ; } }
return null means request has been handled, and calling routine should exit without further processing
return null means request has been handled and calling routine should exit without further processing