Class DomainDAO
- java.lang.Object
-
- dk.netarkivet.harvester.datamodel.DomainDAO
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DomainDAO()
protected constructor for singleton class.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
create(Domain domain)
Create a domain in persistent storage.protected abstract void
create(Connection connection, Domain domain)
Create a domain in persistent storage.void
create(List<Domain> domains)
Create a list of domains in persistent storage.abstract boolean
exists(String domainName)
Check existence of a domain with the given domainName.abstract List<Long>
findUsedConfigurations(Long domainID)
Read the used configurations name + seedslists for the domain.abstract List<AliasInfo>
getAliases(String domain)
Return a list of AliasInfo objects.abstract List<AliasInfo>
getAllAliases()
Get a list of all current alias-relations.abstract List<String>
getAllDomainNames()
abstract Iterator<Domain>
getAllDomains()
Gets list of all domains.abstract 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.abstract int
getCountDomains()
Get the total number of domains available.abstract String
getDefaultDomainConfigurationName(String domainName)
Get the name of the default configuration for the given domain.abstract DomainConfiguration
getDomainConfiguration(String domainName, String configName)
Get the DomainConfiguration given a specific domainName and a configurationName.abstract DomainHistory
getDomainHistory(String domainName)
Get the domainHistory for a specific domain.abstract HarvestInfo
getDomainJobInfo(Job job, String domainName, String configName)
Get the HarvestInfo object for a certain job and DomainConfiguration defined by domainName and configName.abstract List<String>
getDomains(String glob)
Use a glob-like matcher to find a subset of domains.abstract List<String>
getDomains(String glob, String searchField)
Use a glob-like matcher to find a subset of domains.abstract Iterator<Domain>
getDomainsInSnapshotHarvestOrder(Long previousHid)
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.abstract Iterator<HarvestInfo>
getHarvestInfoBasedOnPreviousHarvestDefinition(HarvestDefinition previousHarvestDefinition)
Find all info about results of a harvest definition.abstract HarvestInfo
getHarvestInfoForDomainInHarvest(HarvestDefinition harvestDefinition, Domain domain)
Retrieve HarvestInfo for a given harvestdefinition and domain combination.static DomainDAO
getInstance()
Get the singleton DomainDAO instance.abstract List<TLDInfo>
getTLDs(int level)
Get a list of all TLDs present in the domains table.Iterator<Domain>
iterator()
Gets an iterator of all domains.abstract List<DomainHarvestInfo>
listDomainHarvestInfo(String domainName, String orderBy, boolean asc)
Get a list of info about harvests performed on a given domain.abstract boolean
mayDelete(DomainConfiguration config)
Return whether the given configuration can be deleted.Domain
read(String domainName)
Read a domain from the persistent storage.protected abstract Domain
read(Connection connection, String domainName)
Read a domain from the persistent storage.Domain
readKnown(String domainName)
Read a domain from the persistent storage known to exist.protected abstract Domain
readKnown(Connection connection, String domainName)
Read a domain from the persistent storage known to exist.abstract SparseDomain
readSparse(String domainName)
Read a Domain from Database, and return the domain information as a SparseDomain object.abstract void
renameAndUpdateConfig(Domain domain, DomainConfiguration domainConf, String configOldName)
Rename and update a DomainConfiguration for a specific domain.abstract void
update(Domain domain)
Update information about existing domain information.-
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
-
-
-
-
Method Detail
-
getInstance
public static DomainDAO getInstance()
Get the singleton DomainDAO instance.- Returns:
- the singleton DomainDAO
-
create
public void create(Domain domain)
Create a domain in persistent storage.- Parameters:
domain
- a givenDomain
object.
-
create
public void create(List<Domain> domains)
Create a list of domains in persistent storage.- Parameters:
domains
- a list ofDomain
objects.
-
create
protected abstract void create(Connection connection, Domain domain)
Create a domain in persistent storage.- Parameters:
connection
- a connection to the harvest definition database.domain
- a givenDomain
object.
-
read
public Domain read(String domainName)
Read a domain from the persistent storage.- Parameters:
domainName
- the name of the domain to retrieve- Returns:
- the retrieved Domain
-
readKnown
public Domain readKnown(String domainName)
Read a domain from the persistent storage known to exist.- Parameters:
domainName
- the name of the domain to retrieve- Returns:
- the retrieved Domain
-
read
protected abstract Domain read(Connection connection, String domainName)
Read a domain from the persistent storage.- Parameters:
connection
- a connection to the harvest definition database.domainName
- the name of the domain to retrieve- Returns:
- the retrieved Domain
-
readKnown
protected abstract Domain readKnown(Connection connection, String domainName)
Read a domain from the persistent storage known to exist.- Parameters:
connection
- a connection to the harvest definition database.domainName
- the name of the domain to retrieve- Returns:
- the retrieved Domain
-
exists
public abstract boolean exists(String domainName)
Check existence of a domain with the given domainName.- Parameters:
domainName
- A given domain name.- Returns:
- true if the domain exists, false otherwise.
- Throws:
ArgumentNotValid
- if domainName is null or empty.
-
update
public abstract void update(Domain domain)
Update information about existing domain information.- Parameters:
domain
- the domain to update- Throws:
ArgumentNotValid
- if domain is nullUnknownID
- if the Domain domain has not been added previously to persistent storage.
-
getCountDomains
public abstract int getCountDomains()
Get the total number of domains available.- Returns:
- the total number of registered domains.
-
getAllDomains
public abstract Iterator<Domain> getAllDomains()
Gets list of all domains.- Returns:
- List of all added domains
-
iterator
public Iterator<Domain> iterator()
Gets an iterator of all domains. Implements the Iterable interface.
-
getAllDomainsInSnapshotHarvestOrder
public abstract 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.- Returns:
- List of all added domains
-
getHarvestInfoBasedOnPreviousHarvestDefinition
public abstract Iterator<HarvestInfo> getHarvestInfoBasedOnPreviousHarvestDefinition(HarvestDefinition previousHarvestDefinition)
Find all info about results of a harvest definition.- 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.
-
getDomains
public abstract List<String> getDomains(String glob)
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.
- Parameters:
glob
- A domain name with * and ? wildcards- Returns:
- List of domain names matching the glob, sorted by name.
-
mayDelete
public abstract boolean mayDelete(DomainConfiguration config)
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.- Parameters:
config
- the given configuration- Returns:
- true if the he given configuration can be deleted, false otherwise
-
readSparse
public abstract SparseDomain readSparse(String domainName)
Read a Domain from Database, and return the domain information as a SparseDomain object. We only read information relevant for the GUI listing.- Parameters:
domainName
- a given domain- Returns:
- a SparseDomain.
- Throws:
ArgumentNotValid
- if domainName is null or empty.UnknownID
- if domain does not exist
-
getAliases
public abstract List<AliasInfo> getAliases(String domain)
Return a list of AliasInfo objects. If the given domain is not-null, it should return AliasInfo objects where AliasInfo.aliasOf == domain- Parameters:
domain
- a given domain- Returns:
- a list of AliasInfo objects.
- Throws:
UnknownID
- If the given domain does not exist. (!DomainDAO.exists(domain))ArgumentNotValid
- if domainName is null
-
getAllAliases
public abstract List<AliasInfo> getAllAliases()
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.- Returns:
- a list of all current alias-relations.
-
getTLDs
public abstract List<TLDInfo> getTLDs(int level)
Get a list of all TLDs present in the domains table. IP-numbers registered are counted together.- Parameters:
level
- maximum level of TLD- Returns:
- a list of all TLDs present in the domains table, sorted alphabetically.
-
getDomainJobInfo
public abstract HarvestInfo getDomainJobInfo(Job job, String domainName, String configName)
Get the HarvestInfo object for a certain job and DomainConfiguration defined by domainName and configName.- Parameters:
domainName
- the name of a given domainconfigName
- the name of a given configurationjob
- the job- Returns:
- The HarvestInfo object for a certain job and DomainConfiguration or null, if job has not yet been started.
-
listDomainHarvestInfo
public abstract List<DomainHarvestInfo> listDomainHarvestInfo(String domainName, String orderBy, boolean asc)
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.
- 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 abstract DomainConfiguration getDomainConfiguration(String domainName, String configName)
Get the DomainConfiguration given a specific domainName and a configurationName.- 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
-
getDomainHistory
public abstract DomainHistory getDomainHistory(String domainName)
Get the domainHistory for a specific domain.- Parameters:
domainName
- A name of a specific domain.- Returns:
- the domainHistory for a specific domain.
-
getDomains
public abstract List<String> getDomains(String glob, String searchField)
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.
- 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.
-
findUsedConfigurations
public abstract List<Long> findUsedConfigurations(Long domainID)
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.
- Parameters:
domainID
- The domain to find the configurations for.- Returns:
- The list of ID for the used configurations.
-
renameAndUpdateConfig
public abstract void renameAndUpdateConfig(Domain domain, DomainConfiguration domainConf, String configOldName)
Rename and update a DomainConfiguration for a specific domain.- Parameters:
domain
- The given domaindomainConf
- The given domainConfigconfigOldName
- The old name of the domainConfig
-
getDefaultDomainConfigurationName
public abstract String getDefaultDomainConfigurationName(String domainName)
Get the name of the default configuration for the given domain.- Parameters:
domainName
- a name of a domain- Returns:
- the name of the default configuration for the given domain.
-
getHarvestInfoForDomainInHarvest
public abstract HarvestInfo getHarvestInfoForDomainInHarvest(HarvestDefinition harvestDefinition, Domain domain)
Retrieve HarvestInfo for a given harvestdefinition and domain combination.- 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.
-
getDomainsInSnapshotHarvestOrder
public abstract Iterator<Domain> getDomainsInSnapshotHarvestOrder(Long previousHid)
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.- Parameters:
previousHid
- The harvestDefinitionId of the harvestdefinition that we are continuing. If null, we start from scratch.- Returns:
- List of all added domains
-
-