Esempio n. 1
0
  /**
   * Display package name and version information for javax.mail.internet.
   *
   * <p>This example is a bit artificial, since examining the version of a jar from Sun Microsystems
   * is unusual.
   *
   * @return _more_
   * @throws IOException _more_
   */
  private static HashMap<String, String> getBuildInfo() throws IOException {
    GribVariableRenamer renamer = new GribVariableRenamer();
    HashMap<String, String> buildInfo = new HashMap<String, String>();

    Enumeration<URL> resources =
        renamer.getClass().getClassLoader().getResources("META-INF/MANIFEST.MF");
    while (resources.hasMoreElements()) {
      try {
        Manifest manifest = new Manifest(resources.nextElement().openStream());
        Attributes attrs = manifest.getMainAttributes();
        if (attrs != null) {
          String implTitle = attrs.getValue("Implementation-Title");
          if ((implTitle != null) && (implTitle.contains("ncIdv"))) {
            buildInfo.put("version", attrs.getValue("Implementation-Version"));
            String strDate = attrs.getValue("Built-On");

            CalendarDate cd = CalendarDate.parseISOformat(null, strDate);
            buildInfo.put("buildDate", cd.toString());

            break;
          }
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return buildInfo;
  }
Esempio n. 2
0
 /**
  * @param threddsURI
  * @param startDate
  * @param endDate
  * @param dataVarShortNames
  * @param stationNames
  * @param gridDataset
  * @param gridBbox
  */
 public void setOperationGetObs(
     String threddsURI,
     CalendarDate startDate,
     CalendarDate endDate,
     List<String> dataVarShortNames,
     String[] stationNames,
     boolean gridDataset,
     LatLonRect gridBbox,
     FeatureType ftype) {
   // set url info
   setOperationMethods((Element) getObs.getElementsByTagName("ows:HTTP").item(0), threddsURI);
   // set info for get observation operation
   // get our parameters that need to be filled
   Element eventtime = null, offering = null, observedproperty = null, procedure = null;
   NodeList nodes = getObs.getElementsByTagName("ows:Parameter");
   for (int i = 0; i < nodes.getLength(); i++) {
     Element elem = (Element) nodes.item(i);
     if (elem.getAttribute("name").equalsIgnoreCase("offering")) {
       offering = elem;
     } else if (elem.getAttribute("name").equalsIgnoreCase("observedProperty")) {
       observedproperty = elem;
     } else if (elem.getAttribute("name").equalsIgnoreCase("eventTime")) {
       eventtime = elem;
     } else if (elem.getAttribute("name").equalsIgnoreCase("procedure")) {
       procedure = elem;
     }
   }
   // set eventtime
   if (eventtime != null && endDate != null && startDate != null) {
     Element allowedValues = getDocument().createElement("ows:AllowedValues");
     eventtime.appendChild(allowedValues);
     Element range = getDocument().createElement("ows:Range");
     allowedValues.appendChild(range);
     // min value
     Element min = getDocument().createElement("ows:MinimumValue");
     min.setTextContent(startDate.toString());
     allowedValues.appendChild(min);
     // max value
     Element max = getDocument().createElement("ows:MaximumValue");
     max.setTextContent(endDate.toString());
     allowedValues.appendChild(max);
   }
   // set observedProperty parameter
   if (observedproperty != null) {
     Element allowedValues = getDocument().createElement("ows:AllowedValues");
     observedproperty.appendChild(allowedValues);
     for (String name : dataVarShortNames) {
       Element value = getDocument().createElement("ows:value");
       value.setTextContent(name);
       allowedValues.appendChild(value);
     }
   }
   // set offering parameter - list of station names
   if (offering != null && stationNames != null) {
     Element aV = getDocument().createElement("ows:AllowedValues");
     offering.appendChild(aV);
     // add network-all as an offering
     Element network = document.createElement("ows:Value");
     network.setTextContent("network-all");
     aV.appendChild(network);
     for (String name : stationNames) {
       Element value = getDocument().createElement("ows:Value");
       value.setTextContent(name);
       aV.appendChild(value);
     }
   }
   // set procedure parameter - list of procedures
   // add allowed values node
   Element allowedValues = getDocument().createElement("ows:AllowedValues");
   procedure.appendChild(allowedValues);
   // add network-all value
   Element na = getDocument().createElement("ows:Value");
   na.setTextContent(SOSBaseRequestHandler.getGMLNetworkAll());
   allowedValues.appendChild(na);
   for (String stationName : stationNames) {
     Element elem = getDocument().createElement("ows:Value");
     elem.setTextContent(SOSBaseRequestHandler.getGMLName(stationName));
     allowedValues.appendChild(elem);
     for (String senName : dataVarShortNames) {
       Element sElem = getDocument().createElement("ows:Value");
       sElem.setTextContent(SOSBaseRequestHandler.getSensorGMLName(stationName, senName));
       allowedValues.appendChild(sElem);
     }
   }
   // set additional response formats, supported
   switch (ftype) {
     case STATION:
       // add new ioos response format for TimeSeries data
       NodeList nlist = getObs.getElementsByTagName("ows:Parameter");
       for (int n = 0; n < nlist.getLength(); n++) {
         Element elm = (Element) nlist.item(n);
         if ("responseFormat".equals(elm.getAttribute("name"))) {
           Element av = (Element) elm.getElementsByTagName("ows:AllowedValues").item(0);
           Element rf = document.createElement("ows:Value");
           rf.setTextContent("text/xml;subtype=\"om/1.0.0/profiles/ioos_sos/1.0\"");
           av.appendChild(rf);
         }
       }
       break;
   }
   // add lat and lon as parameters if we are a grid dataset
   if (gridDataset) addLatLonParameters(getObs, gridBbox);
 }