Class InvCatalogImpl


  • public class InvCatalogImpl
    extends InvCatalog
    Concrete implementation of a Thredds catalog object. Use this when you are constructing or modifying.
    See Also:
    InvCatalog
    • Constructor Detail

      • InvCatalogImpl

        public InvCatalogImpl​(String name,
                              String version,
                              URI baseURI)
        Construct an InvCatalog. You must call finish() after all objects are added.
        Parameters:
        name - : catalog name.
        version - : catalog version.
        baseURI - : catalog base URI (external).
      • InvCatalogImpl

        public InvCatalogImpl​(String name,
                              String version,
                              DateType expires,
                              URI baseURI)
        Construct an InvCatalog. You must call finish() after all objects are added.
        Parameters:
        name - : catalog name.
        version - : catalog version.
        expires - : date/time catalog expires.
        baseURI - : catalog base URI (external).
    • Method Detail

      • subset

        public void subset​(InvDataset ds)
        Deprecated.
        in favor of thredds.catalog.util.DeepCopyUtils.subsetCatalogOnDataset
        Munge this catalog so the given dataset is the top catalog.
        Specified by:
        subset in class InvCatalog
        Parameters:
        ds - make this top; must be existing dataset in this catalog.
      • filter

        public void filter​(DatasetFilter filter)
        Munge this catalog to remove any dataset that doesnt pass through the filter.
        Specified by:
        filter in class InvCatalog
        Parameters:
        filter - remove datasets that dont pass this filter.
      • finish

        public boolean finish()
        Finish constructing after all elements have been added or modified. This routine will do any needed internal consistency work. Its ok to call multiple times.
        Returns:
        true if successful.
      • removeDatasetByID

        public void removeDatasetByID​(InvDatasetImpl ds)
        Find the dataset in this catalog by its ID. If found, remove it.
        Parameters:
        ds - Remove this dataset from the hash
      • addDataset

        public void addDataset​(InvDatasetImpl ds)
        Add Dataset (1.0)
        Parameters:
        ds - add this dataset
      • removeDataset

        public boolean removeDataset​(InvDatasetImpl ds)
        Remove the given dataset from this catalog if it is a direct child of this catalog.
        Parameters:
        ds - remove this dataset
        Returns:
        true if found and removed
      • replaceDataset

        public boolean replaceDataset​(InvDatasetImpl remove,
                                      InvDatasetImpl add)
        Replace the given dataset if it is a nested dataset.
        Parameters:
        remove - - the dataset element to be removed
        add - - the dataset element to be added
        Returns:
        true on success
      • addProperty

        public void addProperty​(InvProperty p)
        Add Property (1.0)
        Parameters:
        p - add this property
      • addService

        public void addService​(InvService s)
        Add Service (1.0)
        Parameters:
        s - add this service
      • setDataset

        public void setDataset​(InvDatasetImpl ds)
        Deprecated.
        Use addDataset() instead; datamodel now allows multiple top level datasets.
        Add top-level InvDataset to this catalog.
      • getCreateFrom

        public String getCreateFrom()
        String describing how the catalog was created, for debugging.
        Returns:
        how the catalog was created, for debugging
      • setCreateFrom

        public void setCreateFrom​(String createFrom)
        Set how the catalog was created, for debugging.
        Parameters:
        createFrom - how the catalog was created, for debugging
      • setBaseURI

        public void setBaseURI​(URI baseURI)
        Set the catalog base URI. Its used to resolve relative URLS.
        Parameters:
        baseURI - set to this
      • getBaseURI

        public URI getBaseURI()
        Returns:
        the catalog base URI.
      • setExpires

        public void setExpires​(DateType expiresDate)
        Set the expires date after which the catalog is no longer valid.
        Parameters:
        expiresDate - a DateType representing the date after which the catlog is no longer valid.
      • hasFatalError

        public boolean hasFatalError()
        Check if there is a fatal error and catalog should not be used.
        Returns:
        true if catalog not useable.
      • appendErrorMessage

        public void appendErrorMessage​(String message,
                                       boolean isInvalid)
        Append an error message to the message log. Call check() to get the log when everything is done.
        Parameters:
        message - append this message to log
        isInvalid - true if this is a fatal error.
      • check

        public boolean check​(StringBuilder out,
                             boolean show)
        Check internal data structures.
        Specified by:
        check in class InvCatalog
        Parameters:
        out - : print errors here
        show - : print messages for each object (debug)
        Returns:
        true if no fatal consistency errors.
      • getLog

        public String getLog()
      • dump

        public String dump()
        Debugging: dump entire data structure.
        Returns:
        String representation.
      • writeXML

        public void writeXML​(OutputStream os)
                      throws IOException
        Write the catalog as an XML document to the specified stream.
        Parameters:
        os - write to this OutputStream
        Throws:
        IOException - on an error.
      • writeXML

        public void writeXML​(OutputStream os,
                             boolean raw)
                      throws IOException
        Write the catalog as an XML document to the specified stream.
        Parameters:
        os - write to this OutputStream
        raw - if true, write original (server) version, else write client version
        Throws:
        IOException - on an error.
      • getDatasetRoots

        public List<DataRootConfig> getDatasetRoots()
        Get dataset roots.
        Returns:
        List of InvProperty. May be empty, may not be null.
      • addDatasetRoot

        public void addDatasetRoot​(DataRootConfig root)
        Add Dataset Root, key = path, value = location.
        Parameters:
        root - add a dataset root
      • equals

        public boolean equals​(Object o)
        InvCatalogImpl elements with same values are equal.
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Override Object.hashCode() to implement equals.
        Overrides:
        hashCode in class Object
      • isStatic

        public boolean isStatic()
      • setStatic

        public void setStatic​(boolean aStatic)