|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.uploader.UploaderUtils
public final class UploaderUtils
Utilities for exhibit uploader.
| Nested Class Summary | |
|---|---|
static class |
UploaderUtils.BatchUploadClientRequest
Encapsulated immutable upload request from batch-upload client. |
| Field Summary | |
|---|---|
static int |
BATCH_UPLOAD_BUFSIZE
Size of (large) buffers used for I/O efficiency; strictly positive. |
static char |
BATCH_UPLOAD_MSG_TERMINATOR
Terminator (7-bit ASCII) character byte for all messages. |
| Constructor Summary | |
|---|---|
private |
UploaderUtils()
Prevent creation of instances. |
| Method Summary | |
|---|---|
static int |
computeLengthOfRequestFromBatchUploadClient(ExhibitStaticAttr esa,
ROByteArray hashMD5,
java.lang.String description)
Compute length of upload request for given exhibit. |
static UploaderUtils.BatchUploadClientRequest |
decodeRequestFromBatchUploadClient(java.io.InputStream is)
Decode an upload request from a batch client and return details. |
static java.lang.String |
decodeResponseToBatchUploadClient(java.io.InputStream is)
Decode response to batch upload client from server. |
static java.lang.String |
makeSelectBody(java.lang.String[] values,
java.lang.String[] labels,
java.lang.String selected)
Make body of select HTML select statement, marking any extant value as selected. |
static java.lang.String |
quoteHTMLArg(java.lang.String s)
Puts double quotes round any tag attribute value that needs them. |
static void |
sendRequestFromBatchUploadClient(java.io.OutputStream os,
ExhibitStaticAttr esa,
ROByteArray hashMD5,
java.lang.String description,
java.io.InputStream exhibitData,
java.util.concurrent.atomic.AtomicLong progress)
Send upload request and data from batch client to server. |
static void |
sendResponseToBatchUploadClient(SimpleLoggerIF logger,
java.io.OutputStream os,
boolean isOK,
java.lang.String exhibitName,
java.lang.String detail)
Send response to batch upload client. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int BATCH_UPLOAD_BUFSIZE
public static final char BATCH_UPLOAD_MSG_TERMINATOR
| Constructor Detail |
|---|
private UploaderUtils()
| Method Detail |
|---|
public static java.lang.String makeSelectBody(java.lang.String[] values,
java.lang.String[] labels,
java.lang.String selected)
values - the values returned by the select itemlabels - (optional) the text values shown for the select itemsselected - if equal to one of the values[] entries then that
item is marked as selected
public static final java.lang.String quoteHTMLArg(java.lang.String s)
throws java.lang.IllegalArgumentException
If this does not need to change the input it is returned as is.
TODO: jUnit tests
s - non-null, unquoted HTML tag attribute value.
java.lang.IllegalArgumentException - impossible to form tag
public static void sendResponseToBatchUploadClient(SimpleLoggerIF logger,
java.io.OutputStream os,
boolean isOK,
java.lang.String exhibitName,
java.lang.String detail)
throws java.io.IOException
This routine does not close the output stream when done.
This routine does not flush the output stream when done; the caller should possibly do so itself.
logger - os - stream to write to; never nullisOK - if true then this is an "OK" response,
else a "FAIL" responseexhibitName - the syntatically-correct name of the exhibit upload
to which this response applies, or null for before the first uploaddetail - the optional extra information on the failure;
null/"" if to be omitted
java.io.IOException - in case of error writing to the stream
public static java.lang.String decodeResponseToBatchUploadClient(java.io.InputStream is)
throws java.io.IOException
If this detects malformed input then it will throw an IOException.
java.io.IOException - on problem reading the input stream
or on a fail response
public static int computeLengthOfRequestFromBatchUploadClient(ExhibitStaticAttr esa,
ROByteArray hashMD5,
java.lang.String description)
public static void sendRequestFromBatchUploadClient(java.io.OutputStream os,
ExhibitStaticAttr esa,
ROByteArray hashMD5,
java.lang.String description,
java.io.InputStream exhibitData,
java.util.concurrent.atomic.AtomicLong progress)
throws java.io.IOException
The exhibit hash serves two purposes:
This routine does not close the output stream when done.
This routine does not flush the output stream when done; the caller should possibly do so itself. The routine may flush the output from time to time, eg after writing a large block.
If the caller supplies a null esa/hash/datastream then we send a request up the wire for a zero-length exhibit upload, which is treated as a request to drop the connection (the client should drop it after sending this).
This can update a progress monitor value while it is working.
progress - if non-null, is set to the amount of bytes uploaded
so far,
and -1 before any bytes have been uploaded
(and Long.MAX_VALUE after we have finished while buffered data xfers)
java.io.IOException - in case of error sending data to the output stream;
if this occurs then the output stream should be closed and discarded
public static UploaderUtils.BatchUploadClientRequest decodeRequestFromBatchUploadClient(java.io.InputStream is)
throws java.io.IOException
(The timestamp in the returned ExhibitStaticAttr currently contains no useful data.)
In case of failure this throws an IOException and the input stream should be discarded as being in an unknown state.
A zero length is treated as a request from the client to drop the connection and we return null in this case.
java.io.IOException - in case of error in input
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||