Пример #1
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
Пример #2
0
  /**
   * retrieve all radar stations in this dataset collection
   *
   * @param stsXML_location _more_
   * @return station hashmap
   * @throws IOException _more_
   */
  public HashMap<String, Station> readRadarStations(String stsXML_location) throws IOException {
    SAXBuilder builder;
    Document doc = null;
    XMLEntityResolver jaxp = new XMLEntityResolver(true);
    builder = jaxp.getSAXBuilder();
    HashMap<String, Station> stations = new HashMap<String, Station>();

    try {
      doc = builder.build(stsXML_location);
    } catch (JDOMException e) {
      e.printStackTrace();
    }

    Element rootElem = doc.getRootElement();
    List<Element> children = rootElem.getChildren();
    for (Element child : children) {
      Station s;
      if (null != (s = readStation(child))) {
        stations.put(s.getName(), s);
      }
    }

    return stations;
  }