Exemplo n.º 1
0
 /**
  * Get the full, heirarchical name of the dataset, which has all parent collection names.
  *
  * @return full, heirarchical name of the dataset, which has all parent collection names.
  */
 public String getFullName() {
   return (parent == null)
       ? name
       : (parent.getFullName() == null || parent.getFullName().length() == 0)
           ? name
           : parent.getFullName() + "/" + name;
 }
Exemplo n.º 2
0
  public void init() throws ServletException {
    super.init();
    // allow = ThreddsConfig.getBoolean("NetcdfSubsetService.allow", true);
    // String radarLevel2Dir = ThreddsConfig.get("NetcdfSubsetService.radarLevel2DataDir",
    // "/data/ldm/pub/native/radar/level2/");
    // if (!allow) return;
    contentPath = ServletUtil.getContentPath();
    rm = new RadarMethods(contentPath, logServerStartup);

    // read in radarCollections.xml catalog
    InvCatalogFactory factory = InvCatalogFactory.getDefaultFactory(false); // no validation
    cat = readCatalog(factory, getPath() + catName, contentPath + getPath() + catName);
    if (cat == null) {
      logServerStartup.info("cat initialization failed");
      return;
    }
    // URI tmpURI = cat.getBaseURI();
    cat.setBaseURI(catURI);
    // get path and location from cat
    List parents = cat.getDatasets();
    for (int i = 0; i < parents.size(); i++) {
      InvDataset top = (InvDataset) parents.get(i);
      datasets = top.getDatasets(); // dataset scans

      for (int j = 0; j < datasets.size(); j++) {
        InvDatasetScan ds = (InvDatasetScan) datasets.get(j);
        if (ds.getPath() != null) {
          dataLocation.put(ds.getPath(), ds.getScanLocation());
          logServerStartup.info("path =" + ds.getPath() + " location =" + ds.getScanLocation());
        }
        ds.setXlinkHref(ds.getPath() + "/dataset.xml");
      }
    }
    logServerStartup.info(getClass().getName() + " initialization complete ");
  } // end init
Exemplo n.º 3
0
  /**
   * Getting invDataset list for a single radar station.
   *
   * @param stnName radar station name
   * @param start of the time
   * @param end of the time
   * @return list of invDataset
   * @throws IOException java io exception
   */
  private DqcRadarDatasetInfo queryRadarStation(String stnName, Date start, Date end)
      throws IOException {
    // http://motherlode.ucar.edu:9080/thredds/idd/radarLevel2?returns=catalog&stn=KFTG&dtime=latest
    StringBuffer queryb = new StringBuffer();

    queryb.append(dqc.getQuery().getUriResolved().toString());
    queryb.append("serviceType=OPENDAP");
    queryb.append("&stn=" + stnName);
    if ((start == null) && (end == null)) {
      queryb.append("&dtime=all");
    } else {
      String stime = DateUtil.getTimeAsISO8601(start);
      String etime = DateUtil.getTimeAsISO8601(end);
      queryb.append("&dateStart=" + stime);
      queryb.append("&dateEnd=" + etime);
    }

    URI catalogURI;
    try {
      catalogURI = new URI(queryb.toString());
    } catch (java.net.URISyntaxException e) {
      throw new IOException("** MalformedURLException on URL <" + ">\n" + e.getMessage() + "\n");
    }

    InvCatalogFactory factory = new InvCatalogFactory("default", false);

    InvCatalogImpl catalog = (InvCatalogImpl) factory.readXML(catalogURI);
    StringBuilder buff = new StringBuilder();
    if (!catalog.check(buff)) {
      throw new IOException("Invalid catalog <" + catalogURI + ">\n" + buff.toString());
    }

    List datasets = catalog.getDatasets();

    InvDataset idata = (InvDataset) datasets.get(0);
    //    List ddate = idata.getDates();

    ArrayList dsets = (ArrayList) idata.getDatasets();

    ArrayList absTimeList = new ArrayList();
    ArrayList dURIList = new ArrayList();
    ArrayList dInvList = new ArrayList();

    for (int i = 0; i < dsets.size(); i++) {
      InvDataset tdata = (InvDataset) dsets.get(i);
      List acess = tdata.getAccess();
      List dates = tdata.getDates();
      InvAccess ia = (InvAccess) acess.get(0);
      URI d = ia.getStandardUri();
      Date date = DateUnit.getStandardOrISO(dates.get(0).toString());
      absTimeList.add(date);
      dURIList.add(new DatasetURIInfo(d, date));
      dInvList.add(new InvDatasetInfo(tdata, date));
    }

    DqcRadarDatasetInfo dri = new DqcRadarDatasetInfo(absTimeList, dURIList, dInvList);

    return dri;
  }
Exemplo n.º 4
0
  /**
   * Getting URI for a single radar station.
   *
   * @param stnName radar station name
   * @param absTime is absolute time
   * @return URI
   * @throws IOException java io exception
   */
  public URI getRadarDatasetURI(String stnName, Date absTime) throws IOException {
    // absTime is a member of  datasetsDateURI
    InvDataset invdata = queryRadarStation(stnName, absTime);
    List<InvAccess> acess = invdata.getAccess();
    InvAccess ia = (InvAccess) acess.get(0);
    URI ui = ia.getStandardUri();

    if (ui == null) {
      throw new IOException("Invalid time selected: " + absTime.toString() + "\n");
    }

    return ui;
  }
Exemplo n.º 5
0
  /**
   * Getting URI for a single radar station.
   *
   * @param stnName radar station name
   * @param productID _more_
   * @param absTime is absolute time
   * @return InvDataset
   * @throws IOException java io exception
   */
  private InvDataset queryRadarStation(String stnName, String productID, Date absTime)
      throws IOException {
    String stime = DateUtil.getTimeAsISO8601(absTime).replaceAll("GMT", "");
    // construct a query like this:
    // http://motherlode.ucar.edu:9080/thredds/idd/radarLevel2?returns=catalog&stn=KFTG&dtime=latest
    StringBuilder queryb = new StringBuilder();
    String baseURI = dsc_location.replaceFirst("/dataset.xml", "?");
    queryb.append(baseURI);
    queryb.append("&stn=" + stnName);
    if (productID != null) {
      queryb.append("&var=" + productID);
    }
    if (absTime == null) {
      queryb.append("&time=present");
    } else {

      queryb.append("&time=" + stime);
    }

    URI catalogURI;

    try {
      catalogURI = new URI(queryb.toString());
    } catch (java.net.URISyntaxException e) {
      throw new IOException("** MalformedURLException on URL <" + ">\n" + e.getMessage() + "\n");
    }

    InvCatalogFactory factory = new InvCatalogFactory("default", false);
    // visad.util.Trace.call1("TDSRadarDatasetCollection.readXML");

    InvCatalogImpl catalog = (InvCatalogImpl) factory.readXML(catalogURI);

    // visad.util.Trace.call2("TDSRadarDatasetCollection.readXML");
    // visad.util.Trace.call1("TDSRadarDatasetCollection.checkCatalog");
    StringBuilder buff = new StringBuilder();
    if (!catalog.check(buff)) {
      throw new IOException("Invalid catalog <" + catalogURI + ">\n" + buff.toString());
    }
    // visad.util.Trace.call2("TDSRadarDatasetCollection.checkCatalog");
    // catalog.writeXML(System.out);  // debugg

    List<InvDataset> datasets = catalog.getDatasets();

    InvDataset idata = (InvDataset) datasets.get(0);
    List<InvDataset> dsets = idata.getDatasets();
    InvDataset tdata = (InvDataset) dsets.get(0);
    return tdata;
  }
Exemplo n.º 6
0
  /**
   * Return the resource control value which indicates that only users with proper permission can
   * access this resource.
   *
   * <p>??? Not sure if the value indicates anything or just set or not set.
   *
   * @return the resource control value for this dataset (inherited from ancestor datasets).
   */
  public String getRestrictAccess() {
    if (restrictAccess != null) return restrictAccess;
    // not found, look in parent
    if (parent != null) return parent.getRestrictAccess();

    return null;
  }
Exemplo n.º 7
0
  /**
   * tds radar dataset collection factory
   *
   * @param ds _more_
   * @param dsc_location _more_
   * @param errlog _more_
   * @return any foctory
   * @throws IOException _more_
   * @throws java.net.URISyntaxException _more_
   */
  public static TDSRadarDatasetCollection factory(
      InvDataset ds, String dsc_location, StringBuffer errlog)
      throws IOException, java.net.URISyntaxException {

    // URI catalogURI = new URI(dsc_location);
    // this.docURI =    catalogURI;
    return factory(ds.getDocumentation("summary"), dsc_location, errlog);
  }
Exemplo n.º 8
0
  /**
   * Find the named service declared in this dataset or one of its parents.
   *
   * @param name match this name
   * @return first service that matches the given name, or null if none found.
   */
  public InvService findService(String name) {
    if (name == null) return null;

    // search local (but expanded) services
    for (InvService p : services) {
      if (p.getName().equals(name)) return p;
    }

    // not found, look in parent
    if (parent != null) return parent.findService(name);
    return (catalog == null) ? null : catalog.findService(name);
  }
Exemplo n.º 9
0
  /**
   * _more_
   *
   * @param stnName _more_
   * @param productID _more_
   * @param absTime _more_
   * @return _more_
   * @throws IOException _more_
   */
  public URI getRadarDatasetURI(String stnName, String productID, Date absTime) throws IOException {
    // absTime is a member of  datasetsDateURI

    if (productID == null) {
      return getRadarDatasetURI(stnName, absTime);
    }

    InvDataset invdata = queryRadarStation(stnName, productID, absTime);
    /*  List dsets = idata.getDatasets();
    int siz = dsets.size();
    if(siz != 1)
        return null;

    InvDataset invdata = (InvDataset)dsets.get(0);     */
    List acess = invdata.getAccess();
    InvAccess ia = (InvAccess) acess.get(0);
    URI ui = ia.getStandardUri();

    if (ui == null) {
      throw new IOException("Invalid time selected: " + absTime.toString() + "\n");
    }

    return ui;
  }
Exemplo n.º 10
0
  /**
   * Getting URI for a single radar station.
   *
   * @param stnName radar station name
   * @param absTime is absolute time
   * @return InvDataset
   * @throws IOException java io exception
   */
  private InvDataset queryRadarStation(String stnName, Date absTime) throws IOException {
    String stime = DateUtil.getTimeAsISO8601(absTime);
    // construct a query like this:
    // http://motherlode.ucar.edu:9080/thredds/idd/radarLevel2?returns=catalog&stn=KFTG&dtime=latest
    StringBuffer queryb = new StringBuffer();

    queryb.append(dqc.getQuery().getUriResolved().toString());
    queryb.append("serviceType=OPENDAP");
    queryb.append("&stn=" + stnName);
    queryb.append("&dtime=" + stime);

    URI catalogURI;

    try {
      catalogURI = new URI(queryb.toString());
    } catch (java.net.URISyntaxException e) {
      throw new IOException("** MalformedURLException on URL <" + ">\n" + e.getMessage() + "\n");
    }

    InvCatalogFactory factory = new InvCatalogFactory("default", false);

    InvCatalogImpl catalog = (InvCatalogImpl) factory.readXML(catalogURI);

    StringBuilder buff = new StringBuilder();
    if (!catalog.check(buff)) {
      throw new IOException("Invalid catalog <" + catalogURI + ">\n" + buff.toString());
    }

    List datasets = catalog.getDatasets();

    InvDataset idata = (InvDataset) datasets.get(0);
    ArrayList dsets = (ArrayList) idata.getDatasets();

    InvDataset tdata = (InvDataset) dsets.get(0);
    return tdata;
  }
Exemplo n.º 11
0
  /**
   * Getting invDataset list for a single radar station.
   *
   * @param stnName radar station name
   * @param productID _more_
   * @param start of the time
   * @param end of the time
   * @return list of invDataset
   * @throws IOException java io exception
   */
  private TDSRadarDatasetInfo queryRadarStation(
      String stnName, String productID, Date start, Date end) throws IOException {
    // http://motherlode.ucar.edu:9080/thredds/idd/radarLevel2?returns=catalog&stn=KFTG&dtime=latest
    StringBuilder queryb = new StringBuilder();
    String baseURI = dsc_location.replaceFirst("/dataset.xml", "?");
    queryb.append(baseURI);
    queryb.append("stn=" + stnName);
    if (productID != null) {
      queryb.append("&var=" + productID);
    }
    if ((start == null) && (end == null)) {
      queryb.append("&time=present");
    } else if (end == null) {
      String stime = DateUtil.getTimeAsISO8601(start).replaceAll("GMT", "");
      queryb.append("&time_start=" + stime);
      queryb.append("&time_end=present");
    } else {
      String stime = DateUtil.getTimeAsISO8601(start).replaceAll("GMT", "");
      String etime = DateUtil.getTimeAsISO8601(end).replaceAll("GMT", "");
      queryb.append("&time_start=" + stime);
      queryb.append("&time_end=" + etime);
    }

    URI catalogURI;
    try {
      catalogURI = new URI(queryb.toString());
    } catch (java.net.URISyntaxException e) {
      throw new IOException("** MalformedURLException on URL <" + ">\n" + e.getMessage() + "\n");
    }

    InvCatalogFactory factory = new InvCatalogFactory("default", false);

    // visad.util.Trace.call1("TDSRadarDatasetCollection.readXML");
    InvCatalogImpl catalog = (InvCatalogImpl) factory.readXML(catalogURI);
    // visad.util.Trace.call2("TDSRadarDatasetCollection.readXML");
    StringBuilder buff = new StringBuilder();
    // visad.util.Trace.call1("TDSRadarDatasetCollection.checkCatalog");
    if (!catalog.check(buff)) {
      throw new IOException("Invalid catalog <" + catalogURI + ">\n" + buff.toString());
    }
    // visad.util.Trace.call2("TDSRadarDatasetCollection.checkCatalog");

    List<InvDataset> datasets = catalog.getDatasets();

    InvDataset idata = (InvDataset) datasets.get(0);

    List<InvDataset> dsets = idata.getDatasets();

    List<Date> absTimeList = new ArrayList<Date>();
    List<DatasetURIInfo> dURIList = new ArrayList<DatasetURIInfo>();
    List<InvDatasetInfo> dInvList = new ArrayList<InvDatasetInfo>();

    // visad.util.Trace.call1("TDSRadarDatasetCollection.getLists");
    for (InvDataset tdata : dsets) {
      List<InvAccess> acess = tdata.getAccess();
      List<DateType> dates = tdata.getDates();
      InvAccess ia = (InvAccess) acess.get(0);
      URI d = ia.getStandardUri();
      Date date = ((DateType) dates.get(0)).getDate();
      absTimeList.add(date);
      dURIList.add(new DatasetURIInfo(d, date));
      dInvList.add(new InvDatasetInfo(tdata, date));
    }
    // visad.util.Trace.call2("TDSRadarDatasetCollection.getLists");

    TDSRadarDatasetInfo dri = new TDSRadarDatasetInfo(absTimeList, dURIList, dInvList);

    return dri;
  }
Exemplo n.º 12
0
 /**
  * _more_
  *
  * @param ds _more_
  * @param dqc_location _more_
  * @param errlog _more_
  * @return _more_
  * @throws IOException _more_
  */
 public static DqcRadarDatasetCollection factory(
     InvDataset ds, String dqc_location, StringBuffer errlog) throws IOException {
   return factory(ds.getDocumentation("summary"), dqc_location, errlog);
 }
Exemplo n.º 13
0
 /**
  * Get containing catalog.
  *
  * @return containing catalog.
  */
 public InvCatalog getParentCatalog() {
   if (catalog != null) return catalog;
   return (parent != null) ? parent.getParentCatalog() : null;
 }
Exemplo n.º 14
0
 /**
  * Find an immediate child dataset by its name.
  *
  * @param name match on this name
  * @return dataset if found or null if not exist.
  */
 public InvDatasetImpl findDatasetByName(String name) {
   for (InvDataset ds : getDatasets()) {
     if (ds.getName().equals(name)) return (InvDatasetImpl) ds;
   }
   return null;
 }