Class CatalogUtil

java.lang.Object
ucar.unidata.util.CatalogUtil

public class CatalogUtil extends Object
A set of utilities for dealing with Thredds catalogs
Version:
$Revision: 1.68 $Date: 2007/07/09 22:59:58 $
Author:
IDV development team
  • Field Details

  • Constructor Details

    • CatalogUtil

      public CatalogUtil()
  • Method Details

    • getVersion

      public static double getVersion(Element node)
      A utility to get the version from the catalog root.
      Parameters:
      node - The xml node
      Returns:
      The version
    • haveChildDatasets

      public static boolean haveChildDatasets(Element node)
    • haveChildCatalogs

      public static boolean haveChildCatalogs(Element node)
    • getServiceType

      public static String getServiceType(Element serviceNode)
      Find the service type attribute for the given service node. This is thredds version specific - looking for either "servicetype" attribute or "type" attr.
      Parameters:
      serviceNode - The service node to look for the service type.
      Returns:
      The service type attribute or null if not found.
    • getTitleFromDataset

      public static String getTitleFromDataset(Element datasetNode)
      Assemble the String title for the given dataset. We look for the first two "name" attributes in the xml tree and concatenate them (If found).
      Parameters:
      datasetNode - The dataset node we are looking at.
      Returns:
      The title for this dataset node. (may be null).
    • errorMessage

      public static void errorMessage(String msg)
      Log the error
      Parameters:
      msg - the error message
    • findServiceNodeForDataset

      public static Element findServiceNodeForDataset(Element datasetNode, boolean showErrors, String type)
      Find the service xml element for the given dataset node. First, we look for any service nodes contained by the dataset node. If not found then we find the service name from the dataset node. If no service name attrbiute is found then print an error and return null. Now, we search the xml tree under the root node to find a service node with the given name. If not found then print an error and return null.
      Parameters:
      datasetNode - The dataset node to look for a service node for.
      showErrors - Do we tell the user if there was an error
      type - service type
      Returns:
      Return the service node or null if not found.
    • findBaseForDataset

      public static String findBaseForDataset(Element datasetNode, Element root)
      Find the base url attribute from the service that the given datasetNode is associated with.
      Parameters:
      datasetNode - The dataset node we are looking for a base url for.
      root -
      Returns:
      The base url for the given dataset node.
    • findDataTypeForDataset

      public static String findDataTypeForDataset(Element datasetNode, Element root, double version, boolean firstCall)
      Recurse up the DOM tree, looking for a dataset that contains a dataType attribute. We also look at "access" nodes contained by the dataset node.
      Parameters:
      datasetNode - The dataset node we are looking at.
      root - The root of the xml tree
      version - The catalog versioninvalid input: '<'
      firstCall - Is this the leaf node
      Returns:
      The name of the service that provides this dataset.
    • getAbsoluteUrl

      public static String getAbsoluteUrl(Element serviceNode, String urlPath)
      Find the base url for the given service node. If not found print an error and return null. If found then look for the "suffix" attribute of the service node. If found append it to the urlPath. Return the base concatenated with the urlPath.
      Parameters:
      serviceNode - The service node for the given urlPath.
      urlPath - The tail end of the absolute url.
      Returns:
      The full url path.
    • getUrlPath

      public static String getUrlPath(Element datasetNode)
      Lookup and return the urlPath defined for the given datasetNode.
      Parameters:
      datasetNode - The dataset node we are looking at.
      Returns:
      The url path for the dataset node.
    • getResolverData

      public static Object[] getResolverData(String resolverUrl, Hashtable properties)
      This reads the xml pointed to by the given resolverUrl. It flags an error if the url is bad, the xml is bad, the xml contains 0 dataset nodes, the xml contains more than one dataset node. It returns an array of object which contain:
              Object[] {newXmlRoot, datasetNode, serviceNode, url}
        
      Parameters:
      resolverUrl - The url pointing to the resolver catalog.
      properties - The properties
      Returns:
      Array of root element, dataset node, service node and the absolute url of the data.
    • resolveUrl

      public static String resolveUrl(String resolverUrl, Hashtable properties)
      The given resolverUrl should return a catalog that holds one dataset. This method returns the absolute url that that catalog holds. If the given properties is no null then this will also try to extract the title from the xml and will put the PROP_TITLE into the properties.
      Parameters:
      resolverUrl - The url pointing to the resolved catalog.
      properties - To put the title into.
      Returns:
      The absolute url that the resolverUrl resolves to (may be null).
    • addServiceProperties

      public static void addServiceProperties(Element datasetNode, Hashtable properties, String urlPath)
      Add any service urls to the properties
      Parameters:
      datasetNode - data set node
      properties - properties
      urlPath - base url
    • generateHtml

      public static int generateHtml(Element root, Element datasetNode, int cnt, String bundleTemplate, String jnlpTemplate)
      Generate an html representation of the catalog
      Parameters:
      root - Root of the catalog
      datasetNode - The data set node we are looking at
      cnt - The current count of the data set nodes we have processed
      bundleTemplate - The bundle template we generate the bundle from
      jnlpTemplate - The jnlp template
      Returns:
      The current count