dk.netarkivet.archive.arcrepositoryadmin
Class DatabaseAdmin

java.lang.Object
  extended by dk.netarkivet.archive.arcrepositoryadmin.DatabaseAdmin
All Implemented Interfaces:
Admin

public final class DatabaseAdmin
extends java.lang.Object
implements Admin

The administrator class for the ArcRepository when dealing with an database instead of a file (alternative to AdminData).


Method Summary
 void addEntry(java.lang.String filename, StoreMessage msg, java.lang.String checksum)
          Method for adding an entry for administration.
 void close()
          Close and cleanup of this class.
 java.util.Set<java.lang.String> getAllFileNames()
          Retrieves a set of the names for all the known files.
 java.util.Set<java.lang.String> getAllFileNames(Replica rep, ReplicaStoreState state)
          Retrieves a set with the name of the files with a specific ReplicaStoreState in a specific replica.
 java.lang.String getCheckSum(java.lang.String filename)
          Retrieves the checksum of a given file.
static DatabaseAdmin getInstance()
          Retrieval of a singleton DatabaseAdmin.
 ReplicaStoreState getState(java.lang.String filename, java.lang.String replicaChannelName)
          Returns the ReplicaStoreState of a given file in a specific replica.
 boolean hasEntry(java.lang.String filename)
          Method for telling whether a file entry exists.
 boolean hasReplyInfo(java.lang.String filename)
          Determines whether the StoreMessage of a given file exists.
 boolean hasState(java.lang.String filename, java.lang.String repChannelId)
          Determines whether a given file in a specific replica has a valid replica store state.
 StoreMessage removeReplyInfo(java.lang.String filename)
          Retrieves the StoreMessage of a specific file.
 void setCheckSum(java.lang.String filename, java.lang.String checksum)
          Sets the checksum of a given file.
 void setReplyInfo(java.lang.String filename, StoreMessage msg)
          Assign a StoreMessage to a specific filename.
 void setState(java.lang.String filename, java.lang.String repChannelId, ReplicaStoreState state)
          Sets the store state of an entry to a specific value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DatabaseAdmin getInstance()
Retrieval of a singleton DatabaseAdmin. Ensures that this class is not instantiated multiple times.

Returns:
The current instance of this class.

addEntry

public void addEntry(java.lang.String filename,
                     StoreMessage msg,
                     java.lang.String checksum)
              throws ArgumentNotValid
Method for adding an entry for administration.

Specified by:
addEntry in interface Admin
Parameters:
filename - The name of the file to be stored.
msg - The StoreMessage of the entry.
checksum - The checksum of the entry.
Throws:
ArgumentNotValid - If either the filename or checksum is either null or the empty string.

hasEntry

public boolean hasEntry(java.lang.String filename)
                 throws ArgumentNotValid
Method for telling whether a file entry exists.

Specified by:
hasEntry in interface Admin
Parameters:
filename - The name of the file, the existence of whose entry is to be determined.
Returns:
Whether the entry exists.
Throws:
ArgumentNotValid - If the filename is either null or empty.

getState

public ReplicaStoreState getState(java.lang.String filename,
                                  java.lang.String replicaChannelName)
                           throws ArgumentNotValid
Returns the ReplicaStoreState of a given file in a specific replica.

Specified by:
getState in interface Admin
Parameters:
filename - The name of the file for the ReplicaStoreState.
replicaChannelName - The name of the identification channel for uniquely identifying the replica of for the ReplicaStoreState.
Returns:
The ReplicaStoreState of a given file in a specific replica.
Throws:
ArgumentNotValid - If the filename or the replica id is null or the empty string.

hasState

public boolean hasState(java.lang.String filename,
                        java.lang.String repChannelId)
                 throws ArgumentNotValid
Determines whether a given file in a specific replica has a valid replica store state. By valid means a replica store state other that UNKNOWN_UPLOAD_STATE. TODO Find out if the assumption that all upload states besides UNKNOWN_UPLOAD_STATE are acceptable!

Specified by:
hasState in interface Admin
Parameters:
filename - The name of the file for the ReplicaStoreState.
repChannelId - The identification channel of the replica for the ReplicaStoreState.
Returns:
Whether a given file in a specific replica has a valid store state.
Throws:
ArgumentNotValid - If either the filenames or the replica identification channel is null or the empty string.

setState

public void setState(java.lang.String filename,
                     java.lang.String repChannelId,
                     ReplicaStoreState state)
              throws ArgumentNotValid
Sets the store state of an entry to a specific value.

Specified by:
setState in interface Admin
Parameters:
filename - The name of the file for the entry.
repChannelId - The identification channel of the replica for the entry.
state - The new state for the entry.
Throws:
ArgumentNotValid - If the ReplicaStoreState is null, or if either the filename or the replica identification channel is either null or the empty string.

hasReplyInfo

public boolean hasReplyInfo(java.lang.String filename)
                     throws ArgumentNotValid
Determines whether the StoreMessage of a given file exists.

Specified by:
hasReplyInfo in interface Admin
Parameters:
filename - The name of the file to which the existence of the StoreMessage should be determined.
Returns:
Whether the StoreMessage of the file exists.
Throws:
ArgumentNotValid - If the filename is null or the empty string.

removeReplyInfo

public StoreMessage removeReplyInfo(java.lang.String filename)
                             throws ArgumentNotValid
Retrieves the StoreMessage of a specific file.

Specified by:
removeReplyInfo in interface Admin
Parameters:
filename - The name of the file whose StoreMessage should be retrieved.
Returns:
The StoreMessage corresponding to the file. A null is returned if the corresponding StoreMessage is not found.
Throws:
ArgumentNotValid - If the filename is either null or the empty string.

setReplyInfo

public void setReplyInfo(java.lang.String filename,
                         StoreMessage msg)
                  throws ArgumentNotValid
Assign a StoreMessage to a specific filename. If the filename is already associated with a StoreMessage, then this StoreMessage will be overwritten by the new StoreMessage.

Specified by:
setReplyInfo in interface Admin
Parameters:
filename - The name of the file to have a StoreMessage assigned.
msg - The StoreMessage to be assigned to a file.
Throws:
ArgumentNotValid - If the StoreMessage is null or if the filename is either null or the empty string.

getCheckSum

public java.lang.String getCheckSum(java.lang.String filename)
                             throws ArgumentNotValid
Retrieves the checksum of a given file.

Specified by:
getCheckSum in interface Admin
Parameters:
filename - The name of the file, whose checksum should be retrieved.
Returns:
The checksum of the file.
Throws:
ArgumentNotValid - If the filename is either null or the empty string.

setCheckSum

public void setCheckSum(java.lang.String filename,
                        java.lang.String checksum)
                 throws ArgumentNotValid,
                        IllegalState
Sets the checksum of a given file. It should not be possible to change the checksum in the database through arcrepository.

Specified by:
setCheckSum in interface Admin
Parameters:
filename - The name of the file to have the checksum changed.
checksum - The new checksum for the file.
Throws:
ArgumentNotValid - If either the filename or the checksum is either null or the empty string.
IllegalState - Always, since it is not allowed for arcrepository to change the checksum of a completed upload.

getAllFileNames

public java.util.Set<java.lang.String> getAllFileNames()
Retrieves a set of the names for all the known files.

Specified by:
getAllFileNames in interface Admin
Returns:
A set of the names for all the known file.

getAllFileNames

public java.util.Set<java.lang.String> getAllFileNames(Replica rep,
                                                       ReplicaStoreState state)
                                                throws ArgumentNotValid
Retrieves a set with the name of the files with a specific ReplicaStoreState in a specific replica.

Specified by:
getAllFileNames in interface Admin
Parameters:
rep - The replica where the files belong.
state - The ReplicaStoreState for the files.
Returns:
A set with the names of the files with a specific ReplicaStoreState in a specific replica.
Throws:
ArgumentNotValid - If the Replica or the ReplicaStoreState is null.

close

public void close()
Close and cleanup of this class.

Specified by:
close in interface Admin