public interface UWSFileManager
It is particularly useful if you want to organize yourself the results, log or backup file generated and read by a UWS.
LocalUWSFileManager
Modifier and Type | Field and Description |
---|---|
static java.io.File |
TMP_UPLOAD_DIR
Deprecated.
Since 4.4, use
getTmpDirectory() and
setTmpDirectory(File) instead. |
Modifier and Type | Method and Description |
---|---|
boolean |
deleteError(ErrorSummary error,
UWSJob job)
Deletes the error file corresponding to the given job error summary.
|
boolean |
deleteResult(Result result,
UWSJob job)
Deletes the result file corresponding to the given job result's
description.
|
void |
deleteUpload(UploadFile upload)
Delete definitely the specified file, submitted inline in an HTTP
request.
|
java.util.Iterator<java.io.InputStream> |
getAllUserBackupInputs()
Gets an input stream on the backup file of ALL the job owners
(~ UWS user).
|
java.io.InputStream |
getBackupInput()
Gets an input stream on the backup file of the whole UWS.
|
java.io.InputStream |
getBackupInput(JobOwner owner)
Gets an input stream on the backup file of ONLY the given job owner
(~ UWS user).
|
java.io.OutputStream |
getBackupOutput()
Gets an output stream on the backup file of the whole UWS.
|
java.io.OutputStream |
getBackupOutput(JobOwner owner)
Gets an output stream on the backup file of ONLY the given job owner
(~ UWS user).
|
java.io.InputStream |
getErrorInput(ErrorSummary error,
UWSJob job)
Gets an input stream on the error file corresponding to the given error
and job.
|
java.io.OutputStream |
getErrorOutput(ErrorSummary error,
UWSJob job)
Gets an output stream on the error file corresponding to the given error
and job.
|
long |
getErrorSize(ErrorSummary error,
UWSJob job)
Gets the size of the specified error summary file.
|
java.io.InputStream |
getLogInput(UWSLog.LogLevel level,
java.lang.String context)
Gets an input stream on the log file of this UWS.
|
java.io.PrintWriter |
getLogOutput(UWSLog.LogLevel level,
java.lang.String context)
Gets an output stream on the log file of this UWS.
|
java.io.InputStream |
getResultInput(Result result,
UWSJob job)
Gets an input stream on the result file corresponding to the given job
result.
|
java.io.OutputStream |
getResultOutput(Result result,
UWSJob job)
Gets an output stream on the result file corresponding to the given job
result.
|
long |
getResultSize(Result result,
UWSJob job)
Gets the size of the specified result file.
|
java.io.File |
getTmpDirectory()
Get the temporary directory to use in this service.
|
java.io.InputStream |
getUploadInput(UploadFile upload)
Open a stream toward the specified file, submitted inline in an HTTP
request.
|
java.lang.String |
moveUpload(UploadFile upload,
UWSJob destination)
Move the specified file from its current location to a location related
to the given job.
|
java.io.InputStream |
openURI(java.net.URI uri)
Open a stream toward the given URI.
|
boolean |
setTmpDirectory(java.io.File newTmpDir)
Set the temporary directory to use in this service.
|
@Deprecated static final java.io.File TMP_UPLOAD_DIR
getTmpDirectory()
and
setTmpDirectory(File)
instead.Important 1:
Uploaded files should be then moved using UploadFile.move(UWSJob)
when the job creation or update is validated.
Important 2: As qualified above, this directory is temporary. It means that it should be emptied sometimes. It is particularly important because when a delete or move operation fails on uploaded files, no log or error might be published.
Note: The default value is the temporary directory of the system (e.g. \tmp or \var\tmp on Unix/Linux/MacOS, c:\temp on Windows).
java.io.InputStream getLogInput(UWSLog.LogLevel level, java.lang.String context) throws java.io.IOException
level
- Level of the message to log (DEBUG, INFO, WARNING,
ERROR or FATAL).context
- Context of the message to log (UWS, HTTP, JOB, THREAD,
...).java.io.IOException
- If there is an error while opening an input stream
on the log file.java.io.PrintWriter getLogOutput(UWSLog.LogLevel level, java.lang.String context) throws java.io.IOException
Note: The log file must be automatically created if needed.
level
- Level of the message to log (DEBUG, INFO, WARNING,
ERROR or FATAL).context
- Context of the message to log (UWS, HTTP, JOB, THREAD,
...).java.io.IOException
- If there is an error while creating the log file or
while opening an output stream on it.java.io.File getTmpDirectory()
Note: This directory is generally used when files are uploaded in a received HTTP request.
Important: As qualified above, this directory is temporary. It means that it should be sometimes emptied. It is particularly important because when a delete or move operation fails on a files, no log or error might be published and the files would take some space for no more reason.
null
.boolean setTmpDirectory(java.io.File newTmpDir)
Note: This directory is generally used when files are uploaded in a received HTTP request.
Important: As qualified above, this directory is temporary. It means that it should be sometimes emptied. It is particularly important because when a delete or move operation fails on a files, no log or error might be published and the files would take some space for no more reason.
newTmpDir
- The new temporary directory to use.true
if the path of the temporary directory has
been successfully updated,
false
otherwise (e.g. null
, not a
directory, not writable, not readable).java.io.InputStream getUploadInput(UploadFile upload) throws java.io.IOException
upload
- Description of the uploaded file.java.io.IOException
- If any error occurs while opening the stream.java.io.InputStream openURI(java.net.URI uri) throws UnsupportedURIProtocolException, java.io.IOException
Most of the time, the given URI uses the protocol http, https or ftp,
which makes the URI perfectly understandable by URL
which is
then able to open easily a stream (cf URL.openStream()
).
However, a different scheme/protocol could be used ; particularly VO
ones like "ivo" and "vos". It is for these particular cases that this
function has been designed: in order to provide an implementation
supporting additional protocols.
uri
- URI of any resource to read.UnsupporteURIProtocol
- If the protocol is not supported by this
implementation.java.io.IOException
- If another error occurs while opening
the stream.UnsupportedURIProtocolException
void deleteUpload(UploadFile upload) throws java.io.IOException
upload
- Description of the uploaded file.java.io.IOException
- If any error occurs while deleting the file.java.lang.String moveUpload(UploadFile upload, UWSJob destination) throws java.io.IOException
Note: This function is generally used only once: after the HTTP request parsing, when creating or updating a job and only if the action has been accepted.
Important:
This function might not be able to update the location inside the given
UploadFile
. For this reason, it is strongly recommended to not
call directly this function, but to use UploadFile.move(UWSJob)
.
upload
- Description of the uploaded file to move.destination
- Job in which the uploaded file will be used.java.io.IOException
- If any error occurs while moving the file.java.io.InputStream getResultInput(Result result, UWSJob job) throws java.io.IOException
result
- The description of the result file to read.job
- The job of the given result.java.io.IOException
- If there is an error while opening an input stream
on the result file.java.io.OutputStream getResultOutput(Result result, UWSJob job) throws java.io.IOException
Note: The result file must be automatically created if needed.
result
- The description of the result file to write.job
- The job of the given result.java.io.IOException
- If there is an error while creating the result file
or while opening an output stream on it.long getResultSize(Result result, UWSJob job) throws java.io.IOException
result
- Description of the result file whose the size is wanted.job
- The job of the given result.java.io.IOException
- If there is an error while getting the result file
size.boolean deleteResult(Result result, UWSJob job) throws java.io.IOException
result
- The description of the result file to delete.job
- The job of the given result.java.io.IOException
- If there is a grave and unexpected error while
deleting the result file.java.io.InputStream getErrorInput(ErrorSummary error, UWSJob job) throws java.io.IOException
error
- The description of the error file to read.job
- The job of the given error.java.io.IOException
- If there is an error while opening an input stream
on the error file.java.io.OutputStream getErrorOutput(ErrorSummary error, UWSJob job) throws java.io.IOException
Note: The error file must be automatically created if needed.
error
- The description of the error file to write.job
- The job of the given error.java.io.IOException
- If there is an error while creating the error file
or while opening an output stream on it.long getErrorSize(ErrorSummary error, UWSJob job) throws java.io.IOException
error
- Description of the error file whose the size is wanted.job
- The job of the given error.java.io.IOException
- If there is an error while getting the error file
size.boolean deleteError(ErrorSummary error, UWSJob job) throws java.io.IOException
error
- The description of the error file to delete.job
- The job of the given error.java.io.IOException
- If there is a grave and unexpected error while
deleting the error file.java.io.InputStream getBackupInput(JobOwner owner) throws java.lang.IllegalArgumentException, java.io.IOException
owner
- Owner whose the jobs must be fetched from the file on which
the input stream is asked.java.lang.IllegalArgumentException
- If the given owner is null.java.io.IOException
- If there is an error while opening an
input stream on the backup file.java.util.Iterator<java.io.InputStream> getAllUserBackupInputs()
java.io.OutputStream getBackupOutput(JobOwner owner) throws java.lang.IllegalArgumentException, java.io.IOException
Note: The backup file must be automatically created if needed.
owner
- Owner whose the jobs must be saved in the file on which the
output stream is asked.java.lang.IllegalArgumentException
- If the given owner is null.java.io.IOException
- If there is an error while creating the
backup file or while opening an output
stream on it.java.io.InputStream getBackupInput() throws java.io.IOException
java.io.IOException
- If there is an error while opening an input stream
of the backup file.java.io.OutputStream getBackupOutput() throws java.io.IOException
Note: The backup file must be automatically created if needed.
java.io.IOException
- If there is an error while creating the backup file
or while opening an output stream on it.