dk.netarkivet.archive.webinterface
Class BitpreserveFileStatus

java.lang.Object
  extended by dk.netarkivet.archive.webinterface.BitpreserveFileStatus

public class BitpreserveFileStatus
extends java.lang.Object

Class encapsulating methods for handling web requests for ActiveBitPreservation.


Field Summary
static java.lang.String ADD_COMMAND
           
static java.lang.String GET_INFO_COMMAND
           
static java.lang.String SET_FAILED_COMMAND
           
 
Constructor Summary
BitpreserveFileStatus()
           
 
Method Summary
static long getBACountFiles(Location bitarchive)
          Return the number of files found in the bitarchive.
static long getBACountMissingFiles(Location bitarchive)
          Get the number of missing files in a given bitarchive.
static long getCountWrongFiles(Location bitarchive)
          Get the number of wrong files for a bitarchive.
static java.util.List<java.lang.String> getMissingFilesList(Location bitarchive, javax.servlet.jsp.PageContext context)
          Get a list of missing files in a given bitarchive.
static java.util.List<java.lang.String> getWrongFilesList(Location bitarchive, javax.servlet.jsp.PageContext context)
          Get a list of wrong files in a given bitarchive.
static java.lang.String makeCheckbox(java.lang.String command, java.lang.String... args)
          Create a generic checkbox as used by processMissingRequest.
static void processChecksumRequest(javax.servlet.ServletRequest request, java.lang.StringBuilder res, javax.servlet.jsp.PageContext context)
          Processes a checksum request: Either sets the checksum for a given file ("file" parameter) in the arcrepository (if "fixadminchecksum" parameter is given) or removes and reuploads a file in one bitarchive ("bitarchive" parameter) checking with the checksum and credentials given.
static java.util.Map<java.lang.String,FilePreservationStatus> processMissingRequest(javax.servlet.jsp.PageContext context, java.lang.StringBuilder res, java.util.Map<java.lang.String,java.lang.String[]> params)
          Processes a missingFiles request: Parameters of the form add#### causes the file to be added to that bitarchive.
static void processUpdateRequest(javax.servlet.ServletRequest request, javax.servlet.jsp.PageContext context)
          Extract the name of the bitarchive (parameter 'bitarchive') and whether to update missing files (parameter "findmissingfiles") or checksums (parameter "checksum").
static void removeFileFromMissingFilesList(Location bitarchive, java.lang.String fileName)
          Remove given filename from list of files missing on a given bitarchive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADD_COMMAND

public static final java.lang.String ADD_COMMAND
See Also:
Constant Field Values

SET_FAILED_COMMAND

public static final java.lang.String SET_FAILED_COMMAND
See Also:
Constant Field Values

GET_INFO_COMMAND

public static final java.lang.String GET_INFO_COMMAND
See Also:
Constant Field Values
Constructor Detail

BitpreserveFileStatus

public BitpreserveFileStatus()
Method Detail

processUpdateRequest

public static void processUpdateRequest(javax.servlet.ServletRequest request,
                                        javax.servlet.jsp.PageContext context)
Extract the name of the bitarchive (parameter 'bitarchive') and whether to update missing files (parameter "findmissingfiles") or checksums (parameter "checksum"). Does nothing if parameter 'bitarchive' is not set.

Parameters:
request - the given ServletRequest
context - the current JSP context

processMissingRequest

public static java.util.Map<java.lang.String,FilePreservationStatus> processMissingRequest(javax.servlet.jsp.PageContext context,
                                                                                           java.lang.StringBuilder res,
                                                                                           java.util.Map<java.lang.String,java.lang.String[]> params)
Processes a missingFiles request: Parameters of the form add#### causes the file to be added to that bitarchive. Parameters of the form getInfo## causes checksums to be computed for the file in all bitarchives and the information to be shown in the next update (notice that this information disappears when the page is next reloaded). Parameters of the form setFailed#### updates the arcrepository to consider that file failed in that bitarchive.

Parameters:
context - the current JSP context
res - the result object
params - the given parameters
Returns:
A map of info gathered for files as requested.
Throws:
ForwardedToErrorPage - if the commands have wrong number of arguments

processChecksumRequest

public static void processChecksumRequest(javax.servlet.ServletRequest request,
                                          java.lang.StringBuilder res,
                                          javax.servlet.jsp.PageContext context)
Processes a checksum request: Either sets the checksum for a given file ("file" parameter) in the arcrepository (if "fixadminchecksum" parameter is given) or removes and reuploads a file in one bitarchive ("bitarchive" parameter) checking with the checksum and credentials given.

Parameters:
request - the request
res - the result object
context - the current JSP pagecontext

getBACountFiles

public static long getBACountFiles(Location bitarchive)
Return the number of files found in the bitarchive. If no information found about the bitarchive -1 is returned

Parameters:
bitarchive - the bitarchive to check
Returns:
the number of files found in the bitarchive

getCountWrongFiles

public static long getCountWrongFiles(Location bitarchive)
Get the number of wrong files for a bitarchive.

Parameters:
bitarchive - a bitarchive
Returns:
the number of wrong files for the bitarchive.

getBACountMissingFiles

public static long getBACountMissingFiles(Location bitarchive)
Get the number of missing files in a given bitarchive.

Parameters:
bitarchive - a given bitarchive
Returns:
the number of missing files in the given bitarchive.

getMissingFilesList

public static java.util.List<java.lang.String> getMissingFilesList(Location bitarchive,
                                                                   javax.servlet.jsp.PageContext context)
Get a list of missing files in a given bitarchive.

Parameters:
bitarchive - a given bitarchive
context - the current JSP pagecontext
Returns:
a list of missing files in a given bitarchive.
Throws:
ForwardedToErrorPage - if the file with the list cannot be found.

getWrongFilesList

public static java.util.List<java.lang.String> getWrongFilesList(Location bitarchive,
                                                                 javax.servlet.jsp.PageContext context)
Get a list of wrong files in a given bitarchive.

Parameters:
bitarchive - a bitarchive
context - the current JSP pagecontext
Returns:
a list of wrong files in a given bitarchive.
Throws:
ForwardedToErrorPage - if the file with the list cannot be found.

removeFileFromMissingFilesList

public static void removeFileFromMissingFilesList(Location bitarchive,
                                                  java.lang.String fileName)
Remove given filename from list of files missing on a given bitarchive.

Parameters:
bitarchive - a bitarchive
fileName - a filename

makeCheckbox

public static java.lang.String makeCheckbox(java.lang.String command,
                                            java.lang.String... args)
Create a generic checkbox as used by processMissingRequest.

Parameters:
command - The name of the command
args - Arguments to the command
Returns:
A checkbox with the command and arguments in correct format and with HTML stuff escaped.