|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object uws.UWSToolBox
public class UWSToolBox
Some useful functions for the managing of a UWS service.
Method Summary | |
---|---|
static void |
clearDirectory(java.io.File directory)
Empties the specified directory. |
static void |
clearDirectory(java.lang.String directoryPath)
Empties the specified directory. |
static java.util.Map<java.lang.String,java.lang.String> |
getParameters(java.lang.String queryPart)
Converts the given query part of a HTTP-GET URL to a map of parameters. |
static java.util.Map<java.lang.String,java.lang.String> |
getParamsMap(javax.servlet.http.HttpServletRequest req)
Builds a map of strings with all parameters of the given HTTP request. |
static java.util.Map<java.lang.String,java.lang.String> |
getParamsMap(javax.servlet.http.HttpServletRequest req,
java.lang.String userId)
Builds a map of strings with all parameters of the given HTTP request and adds the given owner ID if not already in the request parameters. |
static java.lang.String |
getQueryPart(java.util.Map<java.lang.String,java.lang.String> parameters)
Converts map of UWS parameters into a string corresponding to the query part of a HTTP-GET URL (i.e. ? |
static java.net.URL |
getServerResource(java.lang.String serverPath,
javax.servlet.http.HttpServletRequest req)
Lets building the absolute URL of any resource available in the root server, from a relative URL. |
static java.lang.String |
getUWSNamespace()
Deprecated. Replaced by a non-static function in XMLSerializer : XMLSerializer.getUWSNamespace() .
It is totally discouraged to use this function. |
static void |
printURL(UWSUrl url)
Displays all the fields of the given UWSUrl. |
static void |
printURL(UWSUrl url,
java.io.OutputStream output)
Displays all the fields of the given UWSUrl in the given output stream. |
static boolean |
publishErrorSummary(AbstractJob j,
java.lang.Exception ex,
ErrorType type,
java.lang.String errorFileUri,
java.lang.String errorsDirectory,
java.lang.String errorFileName)
Sets an error summary corresponding to the given Exception with the given error type. |
static boolean |
publishErrorSummary(AbstractJob j,
java.lang.Exception ex,
ErrorType type,
java.net.URL errorFileUrl,
java.lang.String errorsDirectory,
java.lang.String errorFileName)
Deprecated. Replaced by publishErrorSummary(AbstractJob, Exception, ErrorType, String, String, String) |
static boolean |
publishErrorSummary(AbstractJob j,
java.lang.String msg,
ErrorType type)
Sets an error summary to the given job with the given message and the given error type and sets the phase member to ERROR . |
static AbstractUWS |
restoreUWS(java.io.File restoreFile,
boolean debug)
De-serializes (Java Object de-Serialization) a UWS from the specified file. |
static boolean |
saveUWS(AbstractUWS uws,
java.io.File restoreFile,
boolean debug)
Serializes (Java Object Serialization) the given UWS in the specified file. |
static boolean |
writeErrorFile(java.lang.Exception ex,
java.lang.String errorsDirectory,
java.lang.String errorFileName)
Writes the stack trace of the given exception in the file whose the name and the parent directory are given in parameters. |
static boolean |
writeErrorFile(java.lang.Exception ex,
java.lang.String errorsDirectory,
java.lang.String errorFileName,
boolean overwrite)
Writes the stack trace of the given exception in the file whose the name and the parent directory are given in parameters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static final java.net.URL getServerResource(java.lang.String serverPath, javax.servlet.http.HttpServletRequest req)
Lets building the absolute URL of any resource available in the root server, from a relative URL.
For instance, if the server URL is http://foo.org/uwstuto (and whatever is the current URL):
serverPath
- The relative path to access a server resource.req
- A request of the servlet.
HttpServletRequest.getRequestURL()
,
HttpServletRequest.getContextPath()
,
URL.URL(String)
public static final java.util.Map<java.lang.String,java.lang.String> getParamsMap(javax.servlet.http.HttpServletRequest req)
Builds a map of strings with all parameters of the given HTTP request.
Note: Actually it converts the Map<String, String[]> returned by ServletRequest.getParameterMap()
into a Map<String, String> (the key is put in lower case).
req
- The HTTP request which contains the parameters to extract.
public static final java.util.Map<java.lang.String,java.lang.String> getParamsMap(javax.servlet.http.HttpServletRequest req, java.lang.String userId)
Builds a map of strings with all parameters of the given HTTP request and adds the given owner ID if not already in the request parameters.
Note: Actually it converts the Map<String, String[]> returned by ServletRequest.getParameterMap()
into a Map<String, String>.
req
- The HTTP request which contains the parameters to extract.userId
- The ID of the current user/owner.
public static final java.lang.String getQueryPart(java.util.Map<java.lang.String,java.lang.String> parameters)
parameters
- A Map of parameters.
public static final java.util.Map<java.lang.String,java.lang.String> getParameters(java.lang.String queryPart)
queryPart
- A query part of a HTTP-GET URL.
public static final boolean saveUWS(AbstractUWS uws, java.io.File restoreFile, boolean debug)
uws
- The UWS to serialize.restoreFile
- The file in which the given UWS will be serialized.debug
- true to print a debugging message before and after the serialization, false otherwise.
public static final AbstractUWS restoreUWS(java.io.File restoreFile, boolean debug) throws javax.servlet.ServletException
restoreFile
- The file which has contains the serialization of a UWS.debug
- true to print a debugging message before and after the de-serialization, false otherwise.
javax.servlet.ServletException
- If it is impossible to restore a UWS from the specified file.public static final void clearDirectory(java.lang.String directoryPath)
directoryPath
- The path of the directory to empty.public static final void clearDirectory(java.io.File directory)
Empties the specified directory.
Note: The directory is NOT deleted. Just its content is destroyed.
directory
- The directory which has to be emptied.public static final boolean publishErrorSummary(AbstractJob j, java.lang.String msg, ErrorType type) throws UWSException
ERROR
.
j
- The job to update.msg
- The message of the error summary.type
- The type of the error.
UWSException
- If there is an error when changing the phase or setting the error summary.AbstractJob.error(ErrorSummary)
public static final boolean publishErrorSummary(AbstractJob j, java.lang.Exception ex, ErrorType type, java.lang.String errorFileUri, java.lang.String errorsDirectory, java.lang.String errorFileName) throws java.io.IOException, UWSException
Sets an error summary corresponding to the given Exception with the given error type.
ERROR
.Note: Even if the error file can not be written, the error summary is set to job... but it would have no URI/URL for the details message !
j
- The job to update.ex
- The exception which must be used to generate the error summary.type
- The type of the error.errorFileUri
- The URI/URL at which the content of the error file can be displayed.errorsDirectory
- The parent directory of the generated error file.errorFileName
- The name of the file which must contains the stack trace of the given exception.
java.io.IOException
- If there is an error during the error file writing.
UWSException
- If there is an error when changing the phase or setting the error summary.AbstractJob.error(ErrorSummary)
,
writeErrorFile(Exception, String, String)
public static final boolean writeErrorFile(java.lang.Exception ex, java.lang.String errorsDirectory, java.lang.String errorFileName) throws java.io.IOException
writeErrorFile(Exception, String, String, boolean)
function.
ex
- The exception which has to be used to generate the error file.errorsDirectory
- The directory in which the error file must be created.errorFileName
- The name of the file to create.
java.io.IOException
- If there is an error during the file creation.writeErrorFile(Exception, String, String, boolean)
public static final boolean writeErrorFile(java.lang.Exception ex, java.lang.String errorsDirectory, java.lang.String errorFileName, boolean overwrite) throws java.io.IOException
writeErrorFile(Exception, String, String)
).
ex
- The exception which has to be used to generate the error file.errorsDirectory
- The directory in which the error file must be created.errorFileName
- The name of the file to create.overwrite
- true to overwrite the file if it already exists, false otherwise.
java.io.IOException
- If there is an error during the file creation.public static final void printURL(UWSUrl url)
url
- The UWSUrl which has to be displayed.printURL(UWSUrl, java.io.OutputStream)
public static final void printURL(UWSUrl url, java.io.OutputStream output) throws java.io.IOException
url
- The UWSUrl which has to be displayed.output
- The stream in which the fields of the given UWSUrl has to be displayed.
java.io.IOException
- If there is an error while writing in the given stream.@Deprecated public static final java.lang.String getUWSNamespace()
XMLSerializer
: XMLSerializer.getUWSNamespace()
.
It is totally discouraged to use this function.
XMLSerializer.getUWSNamespace()
@Deprecated public static final boolean publishErrorSummary(AbstractJob j, java.lang.Exception ex, ErrorType type, java.net.URL errorFileUrl, java.lang.String errorsDirectory, java.lang.String errorFileName) throws java.io.IOException, UWSException
publishErrorSummary(AbstractJob, Exception, ErrorType, String, String, String)
Sets an error summary corresponding to the given Exception with the given error type.
ERROR
.Note: Even if the error file can not be written, the error summary is set to job... but it would have no URL for the details message !
j
- The job to update.ex
- The exception which must be used to generate the error summary.type
- The type of the error.errorFileUrl
- The URL at which the content of the error file can be displayed.errorsDirectory
- The parent directory of the generated error file.errorFileName
- The name of the file which must contains the stack trace of the given exception.
java.io.IOException
- If there is an error during the error file writing.
UWSException
- If there is an error when changing the phase or setting the error summary.AbstractJob.error(ErrorSummary)
,
writeErrorFile(Exception, String, String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |