public class BitpreserveFileState extends Object
Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
log
The logger for this class.
|
Modifier and Type | Method and Description |
---|---|
static String |
makeCheckbox(String command,
String... args)
Create a generic checkbox as used by processMissingRequest.
|
static String |
presentChecksum(List<String> csum,
Locale locale)
Present a list of checksums in a human-readable form.
|
static void |
printChecksumErrorStateForReplica(javax.servlet.jsp.JspWriter out,
Replica replica,
Locale locale)
Print HTML formatted state for checksum errors on a given replica in a given locale.
|
static void |
printFileName(javax.servlet.jsp.JspWriter out,
String filename,
int rowCount,
Locale locale)
Print a table row with a file name and a checkbox to request more info.
|
static void |
printFileState(javax.servlet.jsp.JspWriter out,
PreservationState fs,
Locale locale)
Print a file state table for a file.
|
static void |
printMissingFileStateForReplica(javax.servlet.jsp.JspWriter out,
Replica replica,
Locale locale)
Print HTML formatted state for missing files on a given replica in a given locale.
|
static void |
printToggleCheckboxes(javax.servlet.jsp.JspWriter out,
Locale locale,
int numberOfMissingCheckboxes,
int numberOfUploadableCheckboxes)
Print checkboxes for changing state for files.
|
static PreservationState |
processChecksumRequest(StringBuilder res,
javax.servlet.jsp.PageContext context)
Processes a checksum request.
|
static Map<String,PreservationState> |
processMissingRequest(javax.servlet.jsp.PageContext context,
StringBuilder res)
Processes a missingFiles request.
|
static String |
processUpdateRequest(javax.servlet.jsp.PageContext context)
Extract the name of the replica (parameter Constants.BITARCHIVE_NAME_PARAM) and the type of update requested
(parameter Constants.UPDATE_TYPE_PARAM).
|
protected static final org.slf4j.Logger log
public static String processUpdateRequest(javax.servlet.jsp.PageContext context) throws ArgumentNotValid, ForwardedToErrorPage
context
- the current JSP contextForwardedToErrorPage
- if an unknown bitarchive or update type is posted, or one of the two required
parameters are missing.ArgumentNotValid
- If the context is null.public static Map<String,PreservationState> processMissingRequest(javax.servlet.jsp.PageContext context, StringBuilder res) throws ArgumentNotValid, ForwardedToErrorPage
Parameters of the form Constants.ADD_COMMAND=<bitarchive>##<filename> causes the file to be added to that bitarchive, if it is missing.
Parameters of the form Constants.GET_INFO_COMMAND=<filename> 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).
context
- the current JSP context.res
- the result object. This is updated with result information, and expected to be printed to the
resulting page.ArgumentNotValid
- If the context or res is null.ForwardedToErrorPage
- if the commands have the wrong number of arguments.public static PreservationState processChecksumRequest(StringBuilder res, javax.servlet.jsp.PageContext context) throws ArgumentNotValid
The name of a bitarchive must always be given in parameter Constants.BITARCHIVE_NAME_PARAM.
If parameter Constants.FILENAME_PARAM is given, file info for that file will be returned, and all actions will work on that file.
If parameter Constants.FIX_ADMIN_CHECKSUM_PARAM is given, the admin data checksum will be fixed for the file.
If parameter Constants.CREDENTIALS and Constants.CHECKSUM_PARAM is given, removes and reuploads a file with that checksum in the given bitarchive, using the credentials for authorisation.
res
- the result object. This is updated with result information, and expected to be printed to the
resulting page.context
- the current JSP pagecontext.ArgumentNotValid
- If the context or res is null.public static String makeCheckbox(String command, String... args)
command
- The name of the commandargs
- Arguments to the commandpublic static void printMissingFileStateForReplica(javax.servlet.jsp.JspWriter out, Replica replica, Locale locale) throws IOException
out
- The writer to write state to.replica
- The replica to write state for.locale
- The locale to write state in.IOException
- On IO trouble writing state to the writer.public static void printChecksumErrorStateForReplica(javax.servlet.jsp.JspWriter out, Replica replica, Locale locale) throws IOException
out
- The writer to write state to.replica
- The replica to write state for.locale
- The locale to write state in.IOException
- On IO trouble writing state to the writer.public static void printFileName(javax.servlet.jsp.JspWriter out, String filename, int rowCount, Locale locale) throws IOException
out
- The stream to print to.filename
- The name of the file.rowCount
- The rowcount, used for styling rows.locale
- The current locale for labels.IOException
- On trouble writing to stream.public static void printFileState(javax.servlet.jsp.JspWriter out, PreservationState fs, Locale locale) throws IOException
out
- The stream to print to.fs
- The file state for the file.locale
- The locale to print labels in.IOException
- On trouble printing to a stream.public static void printToggleCheckboxes(javax.servlet.jsp.JspWriter out, Locale locale, int numberOfMissingCheckboxes, int numberOfUploadableCheckboxes) throws IOException
out
- The stream to print the checkboxes to.locale
- The locale of the labels.numberOfMissingCheckboxes
- The total possible number of missing checkboxes.numberOfUploadableCheckboxes
- The total possible number of reestablish checkboxes.IOException
- On trouble printing the checkboxes.public static String presentChecksum(List<String> csum, Locale locale)
csum
- List of checksum stringslocale
- The given locale.Copyright © 2005–2016 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.