Class InvDatasetScan


  • public class InvDatasetScan
    extends InvCatalogRef
    Represents server-side information on how to scan a collection of datasets for catalog generation.

    Used by the THREDDS Data Server (TDS) to automatically generate catalogs.

    Typically built from the information given by a datasetScan element in a TDS config catalog.

    Usage notes:

    1. The static methods setContext() and setCatalogServletName() should only be called once per web application instance. For instance, in your HttpServlet implementations init() method.
    2. The method setScanLocation() should not be used; it is "public by accident".

    Should be thread safe except that the above two usage notes are not enforced.

    • Constructor Detail

      • InvDatasetScan

        public InvDatasetScan​(InvCatalogImpl catalog,
                              InvDatasetImpl parent,
                              String name,
                              String path,
                              String scanLocation,
                              String filter,
                              boolean addDatasetSize,
                              String addLatest,
                              boolean sortOrderIncreasing,
                              String datasetNameMatchPattern,
                              String startTimeSubstitutionPattern,
                              String duration)
        Constructor. Old stuff.
        Parameters:
        catalog - parent catalog
        parent - parent dataset
        name - dataset name
        path - url path
        scanLocation - scan this directory
        filter - RegExp match on name
        addDatasetSize - add a size element
        addLatest - add a latest element
        sortOrderIncreasing - sort
        datasetNameMatchPattern - dataset naming
        startTimeSubstitutionPattern - time range using the file name
        duration - time range using the file name
      • InvDatasetScan

        public InvDatasetScan​(InvCatalogImpl catalog,
                              InvDatasetImpl parent,
                              String name,
                              String path,
                              String scanLocation,
                              CrawlableDatasetFilter filter,
                              boolean addDatasetSize,
                              String addLatest,
                              boolean sortOrderIncreasing,
                              String datasetNameMatchPattern,
                              String startTimeSubstitutionPattern,
                              String duration)
        Constructor. Used by InvDatasetFeatureCollection
        Parameters:
        catalog - parent catalog
        parent - parent dataset
        name - dataset name
        path - url path
        scanLocation - scan this directory
        filter - CrawlableDatasetFilter, may be null
        addDatasetSize - add a size element
        addLatest - add a latest element
        sortOrderIncreasing - sort
        datasetNameMatchPattern - dataset naming
        startTimeSubstitutionPattern - time range using the file name
        duration - time range using the file name
    • Method Detail

      • setContext

        public static void setContext​(String c)
      • setCatalogServletName

        public static void setCatalogServletName​(String catServletName)
      • getPath

        public String getPath()
      • getScanLocation

        public String getScanLocation()
      • setScanLocation

        public void setScanLocation​(String scanLocation)
        Resets the location being scanned (DO NOT USE THIS METHOD, "public by accident").

        Used by DataRootHandler to allow scanning an aliased directory ("content").

        Parameters:
        scanLocation - the scan location.
      • getCrDsClassName

        public String getCrDsClassName()
      • getCrDsConfigObj

        public Object getCrDsConfigObj()
      • getAddDatasetSize

        public boolean getAddDatasetSize()
      • isValid

        public boolean isValid()
      • getInvalidMessage

        public String getInvalidMessage()
      • translatePathToLocation

        public String translatePathToLocation​(String dsPath)
        Return the CrawlableDataset path/location that corresponds to the given dataset path. The given dataset path must start with the datasetScan path for this InvDatasetScan, if not, a null is returned.
        Parameters:
        dsPath - a datasetScan dsPath that
        Returns:
        the CrawlableDataset path that corresponds to the given dataset path or null.
      • requestCrawlableDataset

        public CrawlableDataset requestCrawlableDataset​(String path)
                                                 throws IOException
        Return the CrawlableDataset for the given path, null if this InvDatasetScan does not allow (filters out) the requested CrawlableDataset.

        This method can handle requests for regular datasets and proxy datasets.

        Parameters:
        path - the path of the requested CrawlableDataset
        Returns:
        the CrawlableDataset for the given path or null if the path is not allowed by this InvDatasetScan.
        Throws:
        IOException - if an I/O error occurs while locating the children datasets.
        IllegalArgumentException - if the given path is not a descendant of (or the same as) this InvDatasetScan collection level.
      • makeCatalogForDirectory

        public InvCatalogImpl makeCatalogForDirectory​(String orgPath,
                                                      URI catURI)
        Try to build a catalog for the given path by scanning the location associated with this InvDatasetScan. The given path must start with the path of this InvDatasetScan.
        Parameters:
        orgPath - the part of the baseURI that is the path
        catURI - the base URL for the catalog, used to resolve relative URLs.
        Returns:
        the catalog for this path (uses version 1.1) or null if build unsuccessful.
      • makeProxyDsResolverCatalog

        public InvCatalogImpl makeProxyDsResolverCatalog​(String path,
                                                         URI baseURI)
        Try to build a catalog for the given resolver path by scanning the location associated with this InvDatasetScan. The given path must start with the path of this InvDatasetScan and refer to a resolver ProxyDatasetHandler that is part of this InvDatasetScan.
        Parameters:
        path - the part of the baseURI that is the path
        baseURI - the base URL for the catalog, used to resolve relative URLs.
        Returns:
        the resolver catalog for this path (uses version 1.1) or null if build unsuccessful.
      • makeLatestCatalogForDirectory

        public InvCatalog makeLatestCatalogForDirectory​(String orgPath,
                                                        URI baseURI)
        Deprecated.
        Instead use makeProxyDsResolver() which provides more general proxy dataset handling.
        Try to build a catalog for the given path by scanning the location associated with this InvDatasetScan. The given path must start with the path of this InvDatasetScan.
        Parameters:
        orgPath - the part of the baseURI that is the path
        baseURI - the base URL for the catalog, used to resolve relative URLs.
        Returns:
        the catalog for this path (uses version 1.1) or null if build unsuccessful.
      • isRead

        public boolean isRead()
        Overrides:
        isRead in class InvCatalogRef
        Returns:
        true the referenced catalog has been read