Class DomainDBDAO
- java.lang.Object
-
- dk.netarkivet.harvester.datamodel.DomainDAO
-
- dk.netarkivet.harvester.datamodel.DomainDBDAO
-
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 Summary
Constructors Modifier Constructor Description protected
DomainDBDAO()
Creates a database-based implementation of the DomainDAO.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
create(Connection connection, Domain d)
Create a domain in persistent storage.boolean
exists(String domainName)
Check existence of a domain with the given domainName.List<Long>
findUsedConfigurations(Long domainID)
Read the used configurations name + seedslists for the domain.List<AliasInfo>
getAliases(String domain)
Return a list of AliasInfo objects.List<AliasInfo>
getAllAliases()
Get a list of all current alias-relations.List<String>
getAllDomainNames()
Iterator<Domain>
getAllDomains()
Gets list of all domains.Iterator<Domain>
getAllDomainsInSnapshotHarvestOrder()
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.int
getCountDomains()
Get the total number of domains available.String
getDefaultDomainConfigurationName(String domainName)
Get the name of the default configuration for the given domain.DomainConfiguration
getDomainConfiguration(String domainName, String configName)
Get the DomainConfiguration given a specific domainName and a configurationName.DomainHistory
getDomainHistory(String domainName)
Get the domainHistory for a specific domain.HarvestInfo
getDomainJobInfo(Job j, String domainName, String configName)
Get the HarvestInfo object for a certain job and DomainConfiguration defined by domainName and configName.List<String>
getDomains(String glob)
Use a glob-like matcher to find a subset of domains.List<String>
getDomains(String glob, String searchField)
Use a glob-like matcher to find a subset of domains.Iterator<Domain>
getDomainsInSnapshotHarvestOrder(Long hid)
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.Iterator<HarvestInfo>
getHarvestInfoBasedOnPreviousHarvestDefinition(HarvestDefinition previousHarvestDefinition)
Find all info about results of a harvest definition.HarvestInfo
getHarvestInfoForDomainInHarvest(HarvestDefinition harvestDefinition, Domain domain)
Retrieve HarvestInfo for a given harvestdefinition and domain combination.List<TLDInfo>
getTLDs(int level)
Return all TLDs represented by the domains in the domains table.List<DomainHarvestInfo>
listDomainHarvestInfo(String domainName, String orderBy, boolean asc)
Get a list of info about harvests performed on a given domain.boolean
mayDelete(DomainConfiguration config)
Return whether the given configuration can be deleted.protected Domain
read(Connection c, String domainName)
Read a domain from the persistent storage.protected Domain
readKnown(Connection c, String domainName)
Read a domain from the persistent storage known to exist.SparseDomain
readSparse(String domainName)
Read a Domain from Database, and return the domain information as a SparseDomain object.void
renameAndUpdateConfig(Domain domain, DomainConfiguration domainConf, String configOldName)
Rename and update a DomainConfiguration for a specific domain.void
update(Domain d)
Update information about existing domain information.-
Methods inherited from class dk.netarkivet.harvester.datamodel.DomainDAO
create, create, getInstance, iterator, read, readKnown
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
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.
-
update
public void update(Domain d)
Description copied from class:DomainDAO
Update information about existing domain information.
-
read
protected Domain read(Connection c, String domainName)
Description copied from class:DomainDAO
Read a domain from the persistent storage.
-
readKnown
protected Domain readKnown(Connection c, String domainName)
Description copied from class:DomainDAO
Read a domain from the persistent storage known to exist.
-
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 ofDomainConfiguration
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 classDomainDAO
- 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.
-
getCountDomains
public int getCountDomains()
Description copied from class:DomainDAO
Get the total number of domains available.- Specified by:
getCountDomains
in classDomainDAO
- Returns:
- the total number of registered domains.
-
getAllDomains
public Iterator<Domain> getAllDomains()
Description copied from class:DomainDAO
Gets list of all domains.- Specified by:
getAllDomains
in classDomainDAO
- Returns:
- List of all added 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 classDomainDAO
- 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 classDomainDAO
- 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 classDomainDAO
- 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.
-
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 classDomainDAO
- 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 classDomainDAO
- 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 classDomainDAO
- 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 classDomainDAO
- 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 classDomainDAO
- 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 classDomainDAO
- Parameters:
j
- the jobdomainName
- the name of a given domainconfigName
- 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 classDomainDAO
- 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 classDomainDAO
- Parameters:
domainName
- The name of a domainconfigName
- 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 classDomainDAO
- 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 classDomainDAO
- Parameters:
harvestDefinition
- a given harvestdefinitiondomain
- 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 classDomainDAO
- 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 classDomainDAO
- Parameters:
glob
- A domain name with * and ? wildcardssearchField
- 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 classDomainDAO
- Parameters:
domain
- The given domaindomainConf
- The given domainConfigconfigOldName
- The old name of the domainConfig
-
getAllDomainNames
public List<String> getAllDomainNames()
- Specified by:
getAllDomainNames
in classDomainDAO
-
-