Class DomainDBDAO

  • All Implemented Interfaces:
    DAO, Iterable<Domain>

    public class DomainDBDAO
    extends DomainDAO
    A database-based implementation of the DomainDAO.

    The statements to create the tables are located in:

    • Derby: scripts/sql/createfullhddb.sql
    • MySQL: scripts/sql/createfullhddb.mysql
    • PostgreSQL: scripts/postgresql/netarchivesuite_init.sql
    • Constructor Detail

      • DomainDBDAO

        protected DomainDBDAO()
        Creates a database-based implementation of the DomainDAO. Will check that all schemas have correct versions, and update the ones that haven't.
        Throws:
        IOFailure - on trouble updating tables to new versions, or on tables with wrong versions that we don't know how to change to expected version.
    • Method Detail

      • create

        protected void create​(Connection connection,
                              Domain d)
        Description copied from class: DomainDAO
        Create a domain in persistent storage.
        Specified by:
        create in class DomainDAO
        Parameters:
        connection - a connection to the harvest definition database.
        d - a given Domain object.
      • update

        public void update​(Domain d)
        Description copied from class: DomainDAO
        Update information about existing domain information.
        Specified by:
        update in class DomainDAO
        Parameters:
        d - the domain to update
      • read

        protected Domain read​(Connection c,
                              String domainName)
        Description copied from class: DomainDAO
        Read a domain from the persistent storage.
        Specified by:
        read in class DomainDAO
        Parameters:
        c - a connection to the harvest definition database.
        domainName - the name of the domain to retrieve
        Returns:
        the retrieved Domain
      • readKnown

        protected Domain readKnown​(Connection c,
                                   String domainName)
        Description copied from class: DomainDAO
        Read a domain from the persistent storage known to exist.
        Specified by:
        readKnown in class DomainDAO
        Parameters:
        c - a connection to the harvest definition database.
        domainName - the name of the domain to retrieve
        Returns:
        the retrieved Domain
      • findUsedConfigurations

        public List<Long> findUsedConfigurations​(Long domainID)
        Description copied from class: DomainDAO
        Read the used configurations name + seedslists for the domain. Note that even though a list of DomainConfiguration object are returned, only the name + seeds lists are set.

        A used configuration is the default configuration + configurations used in a active harvest definition.

        Specified by:
        findUsedConfigurations in class DomainDAO
        Parameters:
        domainID - The domain to find the configurations for.
        Returns:
        The list of ID for the used configurations.
      • exists

        public boolean exists​(String domainName)
        Description copied from class: DomainDAO
        Check existence of a domain with the given domainName.
        Specified by:
        exists in class DomainDAO
        Parameters:
        domainName - A given domain name.
        Returns:
        true if the domain exists, false otherwise.
      • getCountDomains

        public int getCountDomains()
        Description copied from class: DomainDAO
        Get the total number of domains available.
        Specified by:
        getCountDomains in class DomainDAO
        Returns:
        the total number of registered domains.
      • getAllDomainsInSnapshotHarvestOrder

        public Iterator<Domain> getAllDomainsInSnapshotHarvestOrder()
        Description copied from class: DomainDAO
        Gets list of all domains in the order expected by snapshot harvest job generation, that is order by template name, then byte limit (descending), then domain name.
        Specified by:
        getAllDomainsInSnapshotHarvestOrder in class DomainDAO
        Returns:
        List of all added domains
      • getDomainsInSnapshotHarvestOrder

        public Iterator<Domain> getDomainsInSnapshotHarvestOrder​(Long hid)
        Description copied from class: DomainDAO
        Gets list of all domains in the order expected by the snapshot harvest job generation, that is order by template name, then byte limit (descending), then domain name.
        Specified by:
        getDomainsInSnapshotHarvestOrder in class DomainDAO
        Parameters:
        hid - The harvestDefinitionId of the harvestdefinition that we are continuing. If null, we start from scratch.
        Returns:
        List of all added domains
      • getDomains

        public List<String> getDomains​(String glob)
        Description copied from class: DomainDAO
        Use a glob-like matcher to find a subset of domains.

        In this simple matcher, * stands for any number of arbitrary characters, and ? stands for one arbitrary character. Including these, the given string must match the entire domain name.

        Specified by:
        getDomains in class DomainDAO
        Parameters:
        glob - A domain name with * and ? wildcards
        Returns:
        List of domain names matching the glob, sorted by name.
      • mayDelete

        public boolean mayDelete​(DomainConfiguration config)
        Description copied from class: DomainDAO
        Return whether the given configuration can be deleted. This should be a fairly lightweight method, but is not likely to be instantaneous. Note that to increase speed, this method may rely on underlying systems to enforce transitive invariants. This means that if this method says a configuration can be deleted, the dao may still reject a delete request. If this method returns false, deletion will however definitely not be allowed.
        Specified by:
        mayDelete in class DomainDAO
        Parameters:
        config - the given configuration
        Returns:
        true if the he given configuration can be deleted, false otherwise
      • getDefaultDomainConfigurationName

        public String getDefaultDomainConfigurationName​(String domainName)
        Description copied from class: DomainDAO
        Get the name of the default configuration for the given domain.
        Specified by:
        getDefaultDomainConfigurationName in class DomainDAO
        Parameters:
        domainName - a name of a domain
        Returns:
        the name of the default configuration for the given domain.
      • readSparse

        public SparseDomain readSparse​(String domainName)
        Description copied from class: DomainDAO
        Read a Domain from Database, and return the domain information as a SparseDomain object. We only read information relevant for the GUI listing.
        Specified by:
        readSparse in class DomainDAO
        Parameters:
        domainName - a given domain
        Returns:
        a SparseDomain.
      • getAliases

        public List<AliasInfo> getAliases​(String domain)
        Description copied from class: DomainDAO
        Return a list of AliasInfo objects. If the given domain is not-null, it should return AliasInfo objects where AliasInfo.aliasOf == domain
        Specified by:
        getAliases in class DomainDAO
        Parameters:
        domain - a given domain
        Returns:
        a list of AliasInfo objects.
      • getAllAliases

        public List<AliasInfo> getAllAliases()
        Description copied from class: DomainDAO
        Get a list of all current alias-relations. The list should be sorted by increasing last-update. This means any expired aliases will be at the start of the list, while un-expired aliases will be at the end.
        Specified by:
        getAllAliases in class DomainDAO
        Returns:
        a list of all current alias-relations.
      • getTLDs

        public List<TLDInfo> getTLDs​(int level)
        Return all TLDs represented by the domains in the domains table. it was asked that a level X TLD belong appear in TLD list where the level is <=X for example bidule.bnf.fr belong to .bnf.fr and to .fr it appear in the level 1 list of TLD and in the level 2 list
        Specified by:
        getTLDs in class DomainDAO
        Parameters:
        level - maximum level of TLD
        Returns:
        a list of TLDs
        See Also:
        DomainDAO.getTLDs(int)
      • getDomainJobInfo

        public HarvestInfo getDomainJobInfo​(Job j,
                                            String domainName,
                                            String configName)
        Description copied from class: DomainDAO
        Get the HarvestInfo object for a certain job and DomainConfiguration defined by domainName and configName.
        Specified by:
        getDomainJobInfo in class DomainDAO
        Parameters:
        j - the job
        domainName - the name of a given domain
        configName - the name of a given configuration
        Returns:
        The HarvestInfo object for a certain job and DomainConfiguration or null, if job has not yet been started.
      • listDomainHarvestInfo

        public List<DomainHarvestInfo> listDomainHarvestInfo​(String domainName,
                                                             String orderBy,
                                                             boolean asc)
        Description copied from class: DomainDAO
        Get a list of info about harvests performed on a given domain.

        Note that harvest info from before the DB DAOs are unreliable, as harvests cannot be told apart and no dates are available.

        Specified by:
        listDomainHarvestInfo in class DomainDAO
        Parameters:
        domainName - Domain to get info for.
        orderBy - The column attribute to order by.
        asc - true if the results should be ordered according to the natural order, false if they are to be sorted in reverse.
        Returns:
        List of DomainHarvestInfo objects with information on that domain.
      • getDomainConfiguration

        public DomainConfiguration getDomainConfiguration​(String domainName,
                                                          String configName)
        Description copied from class: DomainDAO
        Get the DomainConfiguration given a specific domainName and a configurationName.
        Specified by:
        getDomainConfiguration in class DomainDAO
        Parameters:
        domainName - The name of a domain
        configName - The name of a configuration for this domain
        Returns:
        the DomainConfiguration, if the specified configuration exists; otherwise throws UnknownID
      • getHarvestInfoBasedOnPreviousHarvestDefinition

        public Iterator<HarvestInfo> getHarvestInfoBasedOnPreviousHarvestDefinition​(HarvestDefinition previousHarvestDefinition)
        Description copied from class: DomainDAO
        Find all info about results of a harvest definition.
        Specified by:
        getHarvestInfoBasedOnPreviousHarvestDefinition in class DomainDAO
        Parameters:
        previousHarvestDefinition - A harvest definition that has already been run.
        Returns:
        An array of information for all domainconfigurations which were harvested by the given harvest definition.
      • getHarvestInfoForDomainInHarvest

        public HarvestInfo getHarvestInfoForDomainInHarvest​(HarvestDefinition harvestDefinition,
                                                            Domain domain)
        Retrieve HarvestInfo for a given harvestdefinition and domain combination.
        Specified by:
        getHarvestInfoForDomainInHarvest in class DomainDAO
        Parameters:
        harvestDefinition - a given harvestdefinition
        domain - a given domain
        Returns:
        null, if no HarvestInfo found for the given harvestdefinition and domain combination, otherwise it returns the first matching HarvestInfo found and gives a warning if more than one match exist.
      • getDomainHistory

        public DomainHistory getDomainHistory​(String domainName)
        Description copied from class: DomainDAO
        Get the domainHistory for a specific domain.
        Specified by:
        getDomainHistory in class DomainDAO
        Parameters:
        domainName - A name of a specific domain.
        Returns:
        the domainHistory for a specific domain.
      • getDomains

        public List<String> getDomains​(String glob,
                                       String searchField)
        Description copied from class: DomainDAO
        Use a glob-like matcher to find a subset of domains.

        In this simple matcher, * stands for any number of arbitrary characters, and ? stands for one arbitrary character. Including these, the given string must match the entire domain name.

        Specified by:
        getDomains in class DomainDAO
        Parameters:
        glob - A domain name with * and ? wildcards
        searchField - The field in the Domain table to search
        Returns:
        List of domain names matching the glob, sorted by name.
      • renameAndUpdateConfig

        public void renameAndUpdateConfig​(Domain domain,
                                          DomainConfiguration domainConf,
                                          String configOldName)
        Description copied from class: DomainDAO
        Rename and update a DomainConfiguration for a specific domain.
        Specified by:
        renameAndUpdateConfig in class DomainDAO
        Parameters:
        domain - The given domain
        domainConf - The given domainConfig
        configOldName - The old name of the domainConfig