Package ucar.unidata.util
Class CatalogUtil
java.lang.Object
ucar.unidata.util.CatalogUtil
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Attribute name for the xml attribute "action "static final String
Attribute name for the xml attribute "base "static final String
Xml attribute name for the url where the doc came fromstatic final String
Xml attribute name for the data set groupstatic final String
Xml attribute name for the data set idstatic final String
Attribute name for the xml attribute "dataType "static final String
Attribute name for the xml attribute "ID "static final String
Attribute name for the xml attribute "inherited "static final String
static final String
Attribute name for the xml attribute "name "static final String
Attribute name for the xml attribute "serverID "static final String
Attribute name for the xml attribute "serviceName "static final String
Attribute name for the xml attribute "serviceType "static final String
Attribute name for the xml attribute "suffix "static final String
Attribute name for the xml attribute "type "static final String
Attribute name for the xml node "units"static final String
Attribute name for the xml attribute "url "static final String
Attribute name for the xml attribute "urlPath "static final String
Attribute name for the xml attribute "value "static final String
Attribute name for the xml attribute "version "static final String
Attribute name for the xml attribute "xlink:href "static final String
Attribute name for the xml attribute "xlink:title "static final String
More clear than then doing (String)nullstatic final String
Property name for the annotations server urlstatic final String
Property name for the url of the catalogstatic final String
Property name for the data set groupstatic final String
Property name for the data set idstatic final String
This needs to be the same as unidata.data.DataSourcestatic final String
This needs to be the same as unidata.data.DataSource.PROP_TITLEstatic final String
Service type value for the adde servicestatic final String
Service type value for the compound servicestatic final String
Service type value for the dods servicestatic final String
Service type value for the compound servicestatic final String
Service type value for the wcs servicestatic final String
Service type value for the OPeNDAP servicestatic final String
Service name of the special resolver service.static final String
Tag name for the xml node "access"static final String
Tag name for the xml node "catalog"static final String
Tag name for the xml node "catalogRef"static final String
Tag name for the xml node "collection"static final String
contactstatic final String
Tag name for the xml node "dataset"static final String
_more_static final String
Tag name for the xml node "dataType"static final String
_more_static final String
Tag name for the xml node "docparent"static final String
Tag name for the xml node "documentation"static final String
xml tag namestatic final String
_more_static final String
_more_static final String
xml tag namestatic final String
Tag name for the xml node "metadata"static final String
namestatic final String
xml tag namestatic final String
Tag name for the xml node "property"static final String
Tag name for the xml node "queryCapability"static final String
Tag name for the xml node "server "static final String
Tag name for the xml node "service "static final String
Tag name for the xml node "serviceName"static final String
xml tag namestatic final String
_more_static final String
_more_static final String
xml tag namestatic final double
Value for the thredds catalog v0.4static final double
Value for the thredds catalog v0.5static final double
Value for the thredds catalog v0.6static final double
Value for the thredds catalog v1.0static final String
Xml attribute name for the data set idstatic final String
Xml attribute value for the rights documentationstatic final String
Xml attribute value for the summary documentation -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addServiceProperties
(Element datasetNode, Hashtable properties, String urlPath) Add any service urls to the propertiesstatic void
errorMessage
(String msg) Log the errorstatic String
findBaseForDataset
(Element datasetNode, Element root) Find the base url attribute from the service that the given datasetNode is associated with.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.static Element
findServiceNodeForDataset
(Element datasetNode, boolean showErrors, String type) Find the service xml element for the given dataset node.static int
generateHtml
(Element root, Element datasetNode, int cnt, String bundleTemplate, String jnlpTemplate) Generate an html representation of the catalogstatic String
getAbsoluteUrl
(Element serviceNode, String urlPath) Find the base url for the given service node.static Object[]
getResolverData
(String resolverUrl, Hashtable properties) This reads the xml pointed to by the given resolverUrl.static String
getServiceType
(Element serviceNode) Find the service type attribute for the given service node.static String
getTitleFromDataset
(Element datasetNode) Assemble the String title for the given dataset.static String
getUrlPath
(Element datasetNode) Lookup and return the urlPath defined for the given datasetNode.static double
getVersion
(Element node) A utility to get the version from the catalog root.static boolean
haveChildCatalogs
(Element node) static boolean
haveChildDatasets
(Element node) static String
resolveUrl
(String resolverUrl, Hashtable properties) The given resolverUrl should return a catalog that holds one dataset.
-
Field Details
-
PROP_TITLE
This needs to be the same as unidata.data.DataSource.PROP_TITLE- See Also:
-
PROP_SERVICE_HTTP
This needs to be the same as unidata.data.DataSource- See Also:
-
PROP_CATALOGURL
Property name for the url of the catalog- See Also:
-
PROP_DATASETID
Property name for the data set id- See Also:
-
PROP_DATASETGROUP
Property name for the data set group- See Also:
-
PROP_ANNOTATIONSERVER
Property name for the annotations server url- See Also:
-
ATTR_CATALOGURL
Xml attribute name for the url where the doc came from- See Also:
-
ATTR_DATASETGROUP
Xml attribute name for the data set group- See Also:
-
ATTR_DATASETID
Xml attribute name for the data set id- See Also:
-
ATTR_METADATATYPE
- See Also:
-
VALUE_ANNOTATIONSERVER
Xml attribute name for the data set id- See Also:
-
VALUE_SUMMARY
Xml attribute value for the summary documentation- See Also:
-
VALUE_RIGHTS
Xml attribute value for the rights documentation- See Also:
-
NULL_STRING
More clear than then doing (String)null -
SERVICE_RESOLVER
Service name of the special resolver service. If a data set has a resolver service then the url of the data set actually points to a resolver service which will give back a catalog that contains the actual data set- See Also:
-
SERVICE_COMPOUND
Service type value for the compound service- See Also:
-
SERVICE_FILE
Service type value for the compound service- See Also:
-
SERVICE_HTTP
Service type value for the wcs service- See Also:
-
SERVICE_DODS
Service type value for the dods service- See Also:
-
SERVICE_ADDE
Service type value for the adde service- See Also:
-
SERVICE_OPENDAP
Service type value for the OPeNDAP service- See Also:
-
THREDDS_VERSION_0_4
public static final double THREDDS_VERSION_0_4Value for the thredds catalog v0.4- See Also:
-
THREDDS_VERSION_0_5
public static final double THREDDS_VERSION_0_5Value for the thredds catalog v0.5- See Also:
-
THREDDS_VERSION_0_6
public static final double THREDDS_VERSION_0_6Value for the thredds catalog v0.6- See Also:
-
THREDDS_VERSION_1_0
public static final double THREDDS_VERSION_1_0Value for the thredds catalog v1.0- See Also:
-
TAG_LATLONBOX
xml tag name- See Also:
-
TAG_NORTH
xml tag name- See Also:
-
TAG_SOUTH
xml tag name- See Also:
-
TAG_EAST
xml tag name- See Also:
-
TAG_WEST
xml tag name- See Also:
-
TAG_NAME
name- See Also:
-
TAG_CONTACT
contact- See Also:
-
TAG_GEOSPATIALCOVERAGE
_more_- See Also:
-
TAG_TIMECOVERAGE
_more_- See Also:
-
TAG_START
_more_- See Also:
-
TAG_END
_more_- See Also:
-
TAG_DATASIZE
_more_- See Also:
-
TAG_DATE
_more_- See Also:
-
TAG_ACCESS
Tag name for the xml node "access"- See Also:
-
TAG_DOCUMENTATION
Tag name for the xml node "documentation"- See Also:
-
TAG_DOCPARENT
Tag name for the xml node "docparent"- See Also:
-
TAG_CATALOG
Tag name for the xml node "catalog"- See Also:
-
TAG_CATALOGREF
Tag name for the xml node "catalogRef"- See Also:
-
TAG_COLLECTION
Tag name for the xml node "collection"- See Also:
-
TAG_DATASET
Tag name for the xml node "dataset"- See Also:
-
TAG_DATATYPE
Tag name for the xml node "dataType"- See Also:
-
TAG_METADATA
Tag name for the xml node "metadata"- See Also:
-
TAG_QUERYCAPABILITY
Tag name for the xml node "queryCapability"- See Also:
-
TAG_SERVER
Tag name for the xml node "server "- See Also:
-
TAG_SERVICE
Tag name for the xml node "service "- See Also:
-
TAG_SERVICENAME
Tag name for the xml node "serviceName"- See Also:
-
ATTR_UNITS
Attribute name for the xml node "units"- See Also:
-
TAG_PROPERTY
Tag name for the xml node "property"- See Also:
-
ATTR_ACTION
Attribute name for the xml attribute "action "- See Also:
-
ATTR_DATATYPE
Attribute name for the xml attribute "dataType "- See Also:
-
ATTR_BASE
Attribute name for the xml attribute "base "- See Also:
-
ATTR_ID
Attribute name for the xml attribute "ID "- See Also:
-
ATTR_INHERITED
Attribute name for the xml attribute "inherited "- See Also:
-
ATTR_NAME
Attribute name for the xml attribute "name "- See Also:
-
ATTR_VALUE
Attribute name for the xml attribute "value "- See Also:
-
ATTR_SERVERID
Attribute name for the xml attribute "serverID "- See Also:
-
ATTR_SERVICENAME
Attribute name for the xml attribute "serviceName "- See Also:
-
ATTR_SERVICETYPE
Attribute name for the xml attribute "serviceType "- See Also:
-
ATTR_SUFFIX
Attribute name for the xml attribute "suffix "- See Also:
-
ATTR_TYPE
Attribute name for the xml attribute "type "- See Also:
-
ATTR_URL
Attribute name for the xml attribute "url "- See Also:
-
ATTR_URLPATH
Attribute name for the xml attribute "urlPath "- See Also:
-
ATTR_VERSION
Attribute name for the xml attribute "version "- See Also:
-
ATTR_XLINK_HREF
Attribute name for the xml attribute "xlink:href "- See Also:
-
ATTR_XLINK_TITLE
Attribute name for the xml attribute "xlink:title "- See Also:
-
-
Constructor Details
-
CatalogUtil
public CatalogUtil()
-
-
Method Details
-
getVersion
A utility to get the version from the catalog root.- Parameters:
node
- The xml node- Returns:
- The version
-
haveChildDatasets
-
haveChildCatalogs
-
getServiceType
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
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
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 errortype
- service type- Returns:
- Return the service node or null if not found.
-
findBaseForDataset
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 treeversion
- The catalog versioninvalid input: '<'firstCall
- Is this the leaf node- Returns:
- The name of the service that provides this dataset.
-
getAbsoluteUrl
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
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
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
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
Add any service urls to the properties- Parameters:
datasetNode
- data set nodeproperties
- propertiesurlPath
- 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 catalogdatasetNode
- The data set node we are looking atcnt
- The current count of the data set nodes we have processedbundleTemplate
- The bundle template we generate the bundle fromjnlpTemplate
- The jnlp template- Returns:
- The current count
-