public class UWSService extends java.lang.Object implements UWS
This class implements directly the interface UWS
and so, it represents the core of a UWS service.
Using this class is very simple! An instance must be created by providing at a factory - UWSFactory
- and a file manager - UWSFileManager
.
This creation must be done in the init() function of a HttpServlet
. Then, still in init(), at least one job list must be created.
Finally, in order to ensure that all requests are interpreted by the UWS service, they must be sent to the created UWSService
in the function
executeRequest(HttpServletRequest, HttpServletResponse)
.
Here is an example of what should look like the servlet class:
public class MyUWSService extends HttpServlet { private UWS uws; public void init(ServletConfig config) throws ServletException { try{ // Create the UWS service: uws = new UWSService(new MyUWSFactory(), new LocalUWSFileManager(new File(config.getServletContext().getRealPath("UWSFiles")))); // Create at least one job list (otherwise no job can be started): uws.addJobList("jobList"); }catch(UWSException ue){ throw new ServletException("Can not initialize the UWS service!", ue); } } public void destroy(){ if (uws != null) uws.destroy(); } public void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException{ try{ service.executeRequest(request, response); }catch(UWSException ue){ response.sendError(ue.getHttpErrorCode(), ue.getMessage()); } } }
All standard UWS actions are already implemented in this class. However, it is still possible to modify their implementation and/or to add or remove some actions.
A UWS action is actually implemented here by a class extending the abstract class UWSAction
. Here is the full list of all
the available and already implemented actions:
To add an action, you should use the function addUWSAction(UWSAction)
, to remove one removeUWSAction(int)
or removeUWSAction(String)
.
Note that this last function takes a String parameter. This parameter is the name of the UWS action to remove. Indeed, each UWS action must have an internal
name representing the action. Thus, it is possible to replace a UWS action implementation by using the function replaceUWSAction(UWSAction)
; this
function will replace the action having the same name as the given action.
In addition of all the actions listed above, a last action is automatically added: ShowHomePage
. This is the action which will display the home page of
the UWS service. It is called when the root resource of the web service is asked. To change it, you can either overwrite this action
(see replaceUWSAction(UWSAction)
) or set an home page URL with the function setHomePage(String)
(the parameter is a URI pointing on either
a local or a remote resource) or setHomePage(URL, boolean)
.
Modifier and Type | Field and Description |
---|---|
protected UWSBackupManager |
backupManager
Lets saving and/or restoring the whole UWS.
|
protected UWSSerializer |
choosenSerializer
The serializer chosen during the last call of
executeRequest(HttpServletRequest, HttpServletResponse) . |
protected java.lang.String |
defaultSerializer
The MIME type of the default serialization format.
|
protected java.lang.String |
description
Description of this UWS.
|
protected ServiceErrorWriter |
errorWriter
Lets writing/formatting any exception/throwable in a HttpServletResponse.
|
protected UWSAction |
executedAction
The action executed during the last call of
executeRequest(HttpServletRequest, HttpServletResponse) . |
protected UWSFactory |
factory
Factory which lets creating the UWS jobs and their thread.
|
protected UWSFileManager |
fileManager
Lets managing all UWS files (i.e.
|
protected java.lang.String |
homePage
URL of the home page.
|
protected java.lang.String |
homePageMimeType
MIME type of the custom home page.
|
protected boolean |
homeRedirection
Indicates whether the home page must be a copy or a redirection to the given URL.
|
protected static java.lang.String |
lastRequestID
Last generated request ID.
|
protected UWSLog |
logger
Lets logging info/debug/warnings/errors about this UWS.
|
protected java.util.Map<java.lang.String,JobList> |
mapJobLists
List of all managed jobs lists.
|
protected java.lang.String |
name
Name of this UWS.
|
protected RequestParser |
requestParser
Lets extract all parameters from an HTTP request, whatever is its content-type.
|
protected java.util.Map<java.lang.String,UWSSerializer> |
serializers
List of available serializers.
|
protected UWSUrl |
urlInterpreter
The "interpreter" of UWS URLs.
|
protected UserIdentifier |
userIdentifier
The object to use to extract the user ID from the received request.
|
protected java.util.Vector<UWSAction> |
uwsActions
List of UWS actions (i.e.
|
protected BlockingPolicy |
waitPolicy
Strategy to use for the blocking/wait process concerning the
JobSummary action. |
REQ_ATTRIBUTE_ID, REQ_ATTRIBUTE_JOB_DESCRIPTION, REQ_ATTRIBUTE_PARAMETERS, REQ_ATTRIBUTE_USER, STANDARD_ID, VERSION
Constructor and Description |
---|
UWSService(UWSFactory jobFactory,
UWSFileManager fileManager)
Builds a UWS (the base URI will be extracted at the first request directly from the request itself).
|
UWSService(UWSFactory jobFactory,
UWSFileManager fileManager,
java.lang.String baseURI)
Builds a UWS with its base UWS URI.
|
UWSService(UWSFactory jobFactory,
UWSFileManager fileManager,
UWSLog logger)
Builds a UWS (the base URI will be extracted at the first request directly from the request itself).
|
UWSService(UWSFactory jobFactory,
UWSFileManager fileManager,
UWSLog logger,
java.lang.String baseURI)
Builds a UWS with its base UWS URI.
|
UWSService(UWSFactory jobFactory,
UWSFileManager fileManager,
UWSLog logger,
UWSUrl urlInterpreter)
Builds a UWS with the given UWS URL interpreter.
|
UWSService(UWSFactory jobFactory,
UWSFileManager fileManager,
UWSUrl urlInterpreter)
Builds a UWS with the given UWS URL interpreter.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addJobList(JobList jl)
Adds a jobs list to this UWS.
|
boolean |
addSerializer(UWSSerializer serializer)
Adds a serializer to this UWS
|
boolean |
addUWSAction(int indAction,
UWSAction action)
Lets inserting the given action at the given position in the actions list of this UWS.
|
boolean |
addUWSAction(UWSAction action)
Lets adding the given action to this UWS.
|
void |
destroy()
End properly this UWS: jobs should be backuped (if this feature is enable), timers and threads should be stopped,
open files and database connections should be closed, etc...
|
void |
destroyAllJobLists()
Destroys all managed jobs lists.
|
boolean |
destroyJobList(JobList jl)
Destroys the given jobs list.
|
boolean |
destroyJobList(java.lang.String name)
Destroys the specified jobs list.
|
boolean |
executeRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Executes the given request according to the IVOA Proposed Recommendation of 2010-02-10.
|
protected java.lang.String |
generateRequestID(javax.servlet.http.HttpServletRequest request)
Generate a unique ID for the given request.
|
UWSBackupManager |
getBackupManager()
Gets its backup manager.
|
java.lang.String |
getBaseURI()
Gets the base UWS URL.
|
UWSSerializer |
getChoosenSerializer()
Gets the serializer choosen during the last call of
getSerializer(String) . |
java.lang.String |
getDefaultSerializer()
Gets the MIME type of the serializer to use by default.
|
java.lang.String |
getDescription()
Gets the description of this UWS.
|
ServiceErrorWriter |
getErrorWriter()
Gets the object used to write/format any error in a HttpServletResponse.
|
UWSAction |
getExecutedAction()
Gets the UWS action executed during the last call of
executeRequest(HttpServletRequest, HttpServletResponse) . |
UWSFactory |
getFactory()
Gets its job factory.
|
UWSFileManager |
getFileManager()
Gets its file manager.
|
java.lang.String |
getHomePage()
Gets the URL of the resource which must be used as home page of this UWS.
|
java.lang.String |
getHomePageMimeType()
Get the MIME type of the custom home page.
|
JobList |
getJobList(java.lang.String name)
Gets the jobs list whose the name matches exactly the given one.
|
UWSLog |
getLogger()
Gets the logger of this UWS.
|
java.lang.String |
getName()
Gets the name of this UWS.
|
int |
getNbJobList()
Gets the number of managed jobs lists.
|
int |
getNbSerializers()
Gets the total number of serializers available in this UWS.
|
int |
getNbUWSActions()
Gets the number of actions this UWS has.
|
RequestParser |
getRequestParser()
Get its HTTP request parser.
|
UWSSerializer |
getSerializer(java.lang.String mimeTypes)
Gets the serializer whose the MIME type is the same as the given one.
|
java.util.Iterator<UWSSerializer> |
getSerializers()
Gets an iterator of the list of all serializers available in this UWS.
|
UWSUrl |
getUrlInterpreter()
Gets the object which is able to interpret and to build any UWS URL.
|
UserIdentifier |
getUserIdentifier()
Gets the object which lets extracting the user ID from a HTTP request.
|
UWSAction |
getUWSAction(java.lang.String actionName)
Gets the action of this UWS which has the same name as the given one.
|
java.util.Iterator<UWSAction> |
getUWSActions()
Gets all actions of this UWS.
|
BlockingPolicy |
getWaitPolicy()
Get the currently used strategy for the blocking behavior of the
Job Summary action.
|
java.lang.String |
getXsltURL()
Gets the URL of the XSLT style-sheet that the XML serializer of this UWS is using.
|
boolean |
hasSerializerFor(java.lang.String mimeType)
Tells whether this UWS has already a serializer with the given MIME type.
|
boolean |
isDefaultHomePage()
Indicates whether the current home page is the default one (the UWS serialization)
or if it has been specified manually using
setHomePage(URL, boolean) . |
boolean |
isHomePageRedirection()
Tells whether a redirection to the specified home page must be done or not.
|
java.util.Iterator<JobList> |
iterator()
An iterator on the jobs lists list.
|
void |
redirect(java.lang.String url,
javax.servlet.http.HttpServletRequest request,
JobOwner user,
java.lang.String uwsAction,
javax.servlet.http.HttpServletResponse response)
Sends a redirection (with the HTTP status code 303) to the given URL/URI into the given response.
|
UWSSerializer |
removeSerializer(java.lang.String mimeType)
Removes the serializer whose the MIME type is the same as the given one.
|
UWSAction |
removeUWSAction(int indAction)
Removes the specified action from this UWS.
|
UWSAction |
removeUWSAction(java.lang.String actionName)
Removes the action of this UWS which has the same name as the given one.
|
UWSAction |
replaceUWSAction(UWSAction action)
Replaces the action which has the same name that the given action.
|
void |
sendError(java.lang.Throwable error,
javax.servlet.http.HttpServletRequest request,
java.lang.String reqID,
JobOwner user,
java.lang.String uwsAction,
javax.servlet.http.HttpServletResponse response)
Fills the response with the given error.
|
void |
sendError(UWSException error,
javax.servlet.http.HttpServletRequest request,
java.lang.String reqID,
JobOwner user,
java.lang.String uwsAction,
javax.servlet.http.HttpServletResponse response)
Fills the response with the given error.
|
void |
setBackupManager(UWSBackupManager backupManager)
Sets its backup manager.
|
void |
setDefaultHomePage()
Forgets the home page specified by using
setHomePage(URL, boolean) - if any -
and go back to the default home page (XML format). |
void |
setDefaultSerializer(java.lang.String mimeType)
Sets the MIME of the serializer to use by default.
|
void |
setDescription(java.lang.String description)
Sets the description of this UWS.
|
void |
setErrorWriter(ServiceErrorWriter errorWriter)
Sets the object used to write/format any error in a HttpServletResponse.
|
void |
setHomePage(java.lang.String homePageURI)
Sets the URI of the resource which must be used as home page of this UWS.
|
void |
setHomePage(java.net.URL homePageUrl,
boolean redirect)
Sets the URL of the resource which must be used as home page of this UWS.
|
void |
setHomePageMimeType(java.lang.String mime)
Set the MIME type of the custom home page.
|
void |
setName(java.lang.String name)
Sets the name of this UWS.
|
void |
setUrlInterpreter(UWSUrl urlInterpreter)
Sets the UWS URL interpreter to use in this UWS.
|
void |
setUserIdentifier(UserIdentifier identifier)
Sets the object which lets extracting the use ID from a received request.
|
boolean |
setUWSAction(int indAction,
UWSAction action)
Replaces the specified action by the given action.
|
void |
setWaitPolicy(BlockingPolicy waitPolicy)
Set the strategy to use for the blocking behavior of the
Job Summary action.
|
boolean |
setXsltURL(java.lang.String xsltPath)
Sets the URL of the XSLT style-sheet that the XML serializer of this UWS must use.
|
protected java.lang.String name
protected java.lang.String description
protected final java.util.Map<java.lang.String,JobList> mapJobLists
protected UWSUrl urlInterpreter
protected final java.util.Map<java.lang.String,UWSSerializer> serializers
protected java.lang.String defaultSerializer
protected UWSSerializer choosenSerializer
executeRequest(HttpServletRequest, HttpServletResponse)
.protected java.lang.String homePage
protected boolean homeRedirection
protected java.lang.String homePageMimeType
protected final java.util.Vector<UWSAction> uwsActions
protected UWSAction executedAction
executeRequest(HttpServletRequest, HttpServletResponse)
.protected UserIdentifier userIdentifier
protected final UWSFactory factory
protected final UWSFileManager fileManager
protected UWSBackupManager backupManager
protected UWSLog logger
protected final RequestParser requestParser
protected ServiceErrorWriter errorWriter
protected BlockingPolicy waitPolicy
JobSummary
action.
If NULL, the standard strategy will be used: wait exactly the time asked by the user (or indefinitely if none is specified).
protected static java.lang.String lastRequestID
public UWSService(UWSFactory jobFactory, UWSFileManager fileManager) throws UWSException
Builds a UWS (the base URI will be extracted at the first request directly from the request itself).
By default, this UWS has 2 serialization formats: XML (XMLSerializer
) and JSON (JSONSerializer
).
All the default actions of a UWS are also already implemented.
However, you still have to create at least one job list !
note: since no logger is provided, a default one is set automatically (see DefaultUWSLog
).
jobFactory
- Object which lets creating the UWS jobs managed by this UWS and their thread/task.fileManager
- Object which lets managing all files managed by this UWS (i.e. log, result, backup, error, ...).java.lang.NullPointerException
- If at least one of the parameters is null.UWSException
- If unable to create a request parser using the factory (see UWSFactory.createRequestParser(UWSFileManager)
).UWSService(UWSFactory, UWSFileManager, UWSLog)
public UWSService(UWSFactory jobFactory, UWSFileManager fileManager, UWSLog logger) throws UWSException
Builds a UWS (the base URI will be extracted at the first request directly from the request itself).
By default, this UWS has 2 serialization formats: XML (XMLSerializer
) and JSON (JSONSerializer
).
All the default actions of a UWS are also already implemented.
However, you still have to create at least one job list !
jobFactory
- Object which lets creating the UWS jobs managed by this UWS and their thread/task.fileManager
- Object which lets managing all files managed by this UWS (i.e. log, result, backup, error, ...).logger
- Object which lets printing any message (error, info, debug, warning).java.lang.NullPointerException
- If at least one of the parameters is null.UWSException
- If unable to create a request parser using the factory (see UWSFactory.createRequestParser(UWSFileManager)
).public UWSService(UWSFactory jobFactory, UWSFileManager fileManager, java.lang.String baseURI) throws UWSException
Builds a UWS with its base UWS URI.
note: since no logger is provided, a default one is set automatically (see DefaultUWSLog
).
jobFactory
- Object which lets creating the UWS jobs managed by this UWS and their thread/task.fileManager
- Object which lets managing all files managed by this UWS (i.e. log, result, backup, error, ...).baseURI
- Base UWS URI.UWSException
- If the given URI is null or empty.UWSService(UWSFactory, UWSFileManager, UWSLog, String)
public UWSService(UWSFactory jobFactory, UWSFileManager fileManager, UWSLog logger, java.lang.String baseURI) throws UWSException
jobFactory
- Object which lets creating the UWS jobs managed by this UWS and their thread/task.fileManager
- Object which lets managing all files managed by this UWS (i.e. log, result, backup, error, ...).logger
- Object which lets printing any message (error, info, debug, warning).baseURI
- Base UWS URI.UWSException
- If the given URI is null or empty.UWSUrl.UWSUrl(String)
public UWSService(UWSFactory jobFactory, UWSFileManager fileManager, UWSUrl urlInterpreter) throws UWSException
Builds a UWS with the given UWS URL interpreter.
note: since no logger is provided, a default one is set automatically (see DefaultUWSLog
).
jobFactory
- Object which lets creating the UWS jobs managed by this UWS and their thread/task.fileManager
- Object which lets managing all files managed by this UWS (i.e. log, result, backup, error, ...).urlInterpreter
- The UWS URL interpreter to use in this UWS.UWSException
- If unable to create a request parser using the factory (see UWSFactory.createRequestParser(UWSFileManager)
).UWSService(UWSFactory, UWSFileManager, UWSLog, UWSUrl)
public UWSService(UWSFactory jobFactory, UWSFileManager fileManager, UWSLog logger, UWSUrl urlInterpreter) throws UWSException
jobFactory
- Object which lets creating the UWS jobs managed by this UWS and their thread/task.fileManager
- Object which lets managing all files managed by this UWS (i.e. log, result, backup, error, ...).logger
- Object which lets printing any message (error, info, debug, warning).urlInterpreter
- The UWS URL interpreter to use in this UWS.UWSException
- If unable to create a request parser using the factory (see UWSFactory.createRequestParser(UWSFileManager)
).public void destroy()
UWS
End properly this UWS: jobs should be backuped (if this feature is enable), timers and threads should be stopped, open files and database connections should be closed, etc... In brief, this function should release all used resources.
IMPORTANT: This function should be called only when the JVM or the Web Application Server is stopping.
Note:
A call to this function may prevent this instance of UWS
to execute any subsequent HTTP request, or the behavior
would be unpredictable.
public UWSLog getLogger()
UWS
Gets the logger of this UWS.
note:A UWS logger is used to watch the HTTP requests received by the UWS and their responses.
The activity of the UWS is also logged and particularly the life of the different jobs and their threads.
A default implementation is available: DefaultUWSLog
.
public final ServiceErrorWriter getErrorWriter()
public final void setErrorWriter(ServiceErrorWriter errorWriter)
Sets the object used to write/format any error in a HttpServletResponse.
Note: Nothing is done if the given writer is NULL !
errorWriter
- The new error writer/formatter.public final java.lang.String getName()
UWS
public final void setName(java.lang.String name)
name
- Its new name.public final java.lang.String getDescription()
UWS
getDescription
in interface UWS
public final void setDescription(java.lang.String description)
description
- Its new description.public final java.lang.String getBaseURI()
UWSUrl.getBaseURI()
public final UWSUrl getUrlInterpreter()
UWS
Gets the object which is able to interpret and to build any UWS URL.
It MUST be loaded with the root URL of this UWS: see UWSUrl.load(javax.servlet.http.HttpServletRequest)
and UWSUrl.load(java.net.URL)
.
note: This getter is particularly used to serialize the jobs lists and their jobs.
getUrlInterpreter
in interface UWS
public final void setUrlInterpreter(UWSUrl urlInterpreter)
urlInterpreter
- Its new UWS URL interpreter (may be null. In this case, it will be created from the next request ; see executeRequest(HttpServletRequest, HttpServletResponse)
).public final UserIdentifier getUserIdentifier()
Gets the object which lets extracting the user ID from a HTTP request.
note:If the returned user identifier is NULL, no job should have an owner.
getUserIdentifier
in interface UWS
public final void setUserIdentifier(UserIdentifier identifier)
identifier
- The UserIdentifier to use (may be null).public final UWSFactory getFactory()
UWS
Gets its job factory.
note: This objects is the only one to know how to extract job parameters from an HTTP request,
how to create a job and how to create its respective thread. A partial implementation which answers to
the 2 first questions is available: AbstractUWSFactory
getFactory
in interface UWS
public final UWSFileManager getFileManager()
UWS
Gets its file manager.
note: A file manager tells to a UWS how to create, read and write the different managed files
(i.e. log, result, errors, backup). A default implementation is available: LocalUWSFileManager
.
getFileManager
in interface UWS
public final UWSBackupManager getBackupManager()
UWS
Gets its backup manager.
note: This object should be used at the initialization of the UWS to restore a previous "session" (see UWSBackupManager.restoreAll()
)
and must be used each time the list of jobs of a user (see UWSBackupManager.saveOwner(uws.job.user.JobOwner)
) or all the jobs of this UWS must be saved (see UWSBackupManager.saveAll()
).
getBackupManager
in interface UWS
public final void setBackupManager(UWSBackupManager backupManager)
Sets its backup manager.
This manager will be called at each user action to save only its own jobs list by calling UWSBackupManager.saveOwner(JobOwner)
.
backupManager
- Its new backup manager.public final RequestParser getRequestParser()
UWS
Get its HTTP request parser.
note: This parser is the only one to be able to extract UWS and TAP parameters from any HTTP request.
Its behavior is adapted in function of the used HTTP method and of the content-type. A default implementation is
provided by the UWS library: UWSRequestParser
.
getRequestParser
in interface UWS
public final BlockingPolicy getWaitPolicy()
This strategy lets decide how long a WAIT request must block a HTTP request. With a such policy, the waiting time specified by the user may be modified.
public final void setWaitPolicy(BlockingPolicy waitPolicy)
This strategy lets decide whether a WAIT request must block a HTTP request and how long. With a such policy, the waiting time specified by the user may be modified.
waitPolicy
- The WAIT strategy to use,
or NULL if the default one (i.e. wait the time
specified by the user ;
if no time is specified the HTTP request may be
blocked indefinitely) must be used.public final java.lang.String getHomePage()
public final boolean isHomePageRedirection()
public final void setHomePage(java.net.URL homePageUrl, boolean redirect)
homePageUrl
- The URL of the home page (may be null).redirect
- true if a redirection to the specified resource must be done
or false to copy it.public final void setHomePage(java.lang.String homePageURI)
Sets the URI of the resource which must be used as home page of this UWS.
A redirection will always be done on the specified resource.homePageURI
- The URL of the home page.public final boolean isDefaultHomePage()
setHomePage(URL, boolean)
.public final void setDefaultHomePage()
setHomePage(URL, boolean)
- if any -
and go back to the default home page (XML format).public final java.lang.String getHomePageMimeType()
Get the MIME type of the custom home page.
By default, it is the same as the default home page: "text/html".
Note:
This function has a sense only if the HOME PAGE resource of this UWS service
is still the default home page (i.e. ShowHomePage
).
public final void setHomePageMimeType(java.lang.String mime)
Set the MIME type of the custom home page.
A NULL value will be considered as "text/html".
Note:
This function has a sense only if the HOME PAGE resource of this UWS service
is still the default home page (i.e. ShowHomePage
).
mime
- MIME type of the custom home page.public final java.lang.String getDefaultSerializer()
public final void setDefaultSerializer(java.lang.String mimeType) throws UWSException
mimeType
- The MIME type (only one).UWSException
- If there is no serializer with this MIME type available in this UWS.public final boolean addSerializer(UWSSerializer serializer)
Adds a serializer to this UWS
WARNING: If there is already a serializer with the same MIME type (see UWSSerializer.getMimeType()
) in this UWS ,
it should be replaced by the given one !
serializer
- The serializer to add.public final boolean hasSerializerFor(java.lang.String mimeType)
mimeType
- A MIME type (only one).public final int getNbSerializers()
public final java.util.Iterator<UWSSerializer> getSerializers()
public final UWSSerializer getSerializer(java.lang.String mimeTypes) throws UWSException
UWS
Gets the serializer whose the MIME type is the same as the given one.
Note: If this UWS has no corresponding serializer, a default one should be returned !
getSerializer
in interface UWS
mimeTypes
- The MIME type of the searched serializer (may be more than one MIME types
- comma separated ; see the format of the Accept header of a HTTP-Request).UWSException
- If there is no corresponding serializer AND if the default serializer of this UWS can not be found.AcceptHeader.AcceptHeader(String)
,
AcceptHeader.getOrderedMimeTypes()
public final UWSSerializer getChoosenSerializer()
getSerializer(String)
.public final UWSSerializer removeSerializer(java.lang.String mimeType)
mimeType
- MIME type of the serializer to remove.public final java.lang.String getXsltURL()
public final boolean setXsltURL(java.lang.String xsltPath)
xsltPath
- The new XSLT URL.public final java.util.Iterator<JobList> iterator()
iterator
in interface java.lang.Iterable<JobList>
Iterable.iterator()
public final JobList getJobList(java.lang.String name)
UWS
getJobList
in interface UWS
name
- Name of the jobs list to get.public final int getNbJobList()
UWS
getNbJobList
in interface UWS
public final boolean addJobList(JobList jl)
addJobList
in interface UWS
jl
- The jobs list to add.JobList.setUWS(UWS)
,
UWS.addJobList(JobList)
public final boolean destroyJobList(java.lang.String name)
UWS
Destroys the specified jobs list.
note: After the call of this function, the UWS reference of the given jobs list should be removed (see JobList.setUWS(UWS)
).
destroyJobList
in interface UWS
name
- Name of the jobs list to destroy.public boolean destroyJobList(JobList jl)
jl
- The jobs list to destroy.JobList.clear()
,
JobList.setUWS(UWS)
public final void destroyAllJobLists()
destroyJobList(String)
public final boolean addUWSAction(UWSAction action)
Lets adding the given action to this UWS.
WARNING: The action will be added at the end of the actions list of this UWS. That means, it will be evaluated (call of
the method UWSAction.match(UWSUrl, JobOwner, HttpServletRequest)
) lastly !
action
- The UWS action to add.public final boolean addUWSAction(int indAction, UWSAction action) throws java.lang.ArrayIndexOutOfBoundsException
Lets inserting the given action at the given position in the actions list of this UWS.
indAction
- The index where the given action must be inserted.action
- The action to add.java.lang.ArrayIndexOutOfBoundsException
- If the given index is incorrect (index < 0 || index >= uwsActions.size()).public final boolean setUWSAction(int indAction, UWSAction action) throws java.lang.ArrayIndexOutOfBoundsException
indAction
- Index of the action to replace.action
- The replacer.java.lang.ArrayIndexOutOfBoundsException
- If the index is incorrect (index < 0 || index >= uwsActions.size()).public final UWSAction replaceUWSAction(UWSAction action)
action
- The replacer.public final int getNbUWSActions()
public final UWSAction getUWSAction(java.lang.String actionName)
actionName
- The name of the searched action.public final java.util.Iterator<UWSAction> getUWSActions()
public final UWSAction getExecutedAction()
executeRequest(HttpServletRequest, HttpServletResponse)
.public final UWSAction removeUWSAction(int indAction) throws java.lang.ArrayIndexOutOfBoundsException
indAction
- The index of the UWS action to remove.java.lang.ArrayIndexOutOfBoundsException
- If the given index is incorrect (index < 0 || index >= uwsActions.size()).public final UWSAction removeUWSAction(java.lang.String actionName)
actionName
- The name of the UWS to remove.protected java.lang.String generateRequestID(javax.servlet.http.HttpServletRequest request)
Generate a unique ID for the given request.
By default, a timestamp is returned.
request
- Request whose an ID is asked.public boolean executeRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws UWSException, java.io.IOException
Executes the given request according to the IVOA Proposed Recommendation of 2010-02-10. The result is returned in the given response.
Here is the followed algorithm:
UWSUrl.load(HttpServletRequest)
)UserIdentifier.extractUserId(UWSUrl, HttpServletRequest)
)UWSAction.match(UWSUrl, JobOwner, HttpServletRequest)
and UWSAction.apply(UWSUrl, JobOwner, HttpServletRequest, HttpServletResponse)
)request
- The UWS request.response
- The response of this request which will be edited by the found UWS actions.UWSException
- If no action matches or if any error has occurred while applying the found action.java.io.IOException
- If it is impossible to write in the given HttpServletResponse
.UWSUrl.UWSUrl(HttpServletRequest)
,
UWSUrl.load(HttpServletRequest)
,
UserIdentifier.extractUserId(UWSUrl, HttpServletRequest)
,
UWSAction.match(UWSUrl, JobOwner, HttpServletRequest)
,
UWSAction.apply(UWSUrl, JobOwner, HttpServletRequest, HttpServletResponse)
public void redirect(java.lang.String url, javax.servlet.http.HttpServletRequest request, JobOwner user, java.lang.String uwsAction, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, UWSException
Sends a redirection (with the HTTP status code 303) to the given URL/URI into the given response.
url
- The redirection URL/URI.request
- The HttpServletRequest
which may be used to make a redirection.user
- The user which executes the given request.uwsAction
- The UWS action corresponding to the given request.response
- The HttpServletResponse
which must contain all information to make a redirection.java.io.IOException
- If there is an error during the redirection.UWSException
- If there is any other error.public final void sendError(UWSException error, javax.servlet.http.HttpServletRequest request, java.lang.String reqID, JobOwner user, java.lang.String uwsAction, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, UWSException
Fills the response with the given error. The HTTP status code is set in function of the error code of the given UWSException.
If the error code is UWSException.SEE_OTHER
this method calls redirect(String, HttpServletRequest, JobOwner, String, HttpServletResponse)
.
Otherwise the function HttpServletResponse.sendError(int, String)
is called.
error
- The error to send/display.request
- The request which has caused the given error (not used by default).reqID
- ID of the request.user
- The user which executes the given request.uwsAction
- The UWS action corresponding to the given request.response
- The response in which the error must be published.java.io.IOException
- If there is an error when calling redirect(String, HttpServletRequest, JobOwner, String, HttpServletResponse)
or HttpServletResponse.sendError(int, String)
.UWSException
- If there is an error when calling redirect(String, HttpServletRequest, JobOwner, String, HttpServletResponse)
.redirect(String, HttpServletRequest, JobOwner, String, HttpServletResponse)
,
sendError(Throwable, HttpServletRequest, String, JobOwner, String, HttpServletResponse)
public final void sendError(java.lang.Throwable error, javax.servlet.http.HttpServletRequest request, java.lang.String reqID, JobOwner user, java.lang.String uwsAction, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
Fills the response with the given error.
The stack trace of the error is printed on the standard output and then the function
HttpServletResponse.sendError(int, String)
is called with the HTTP status code is UWSException.INTERNAL_SERVER_ERROR
and the message of the given exception.
error
- The error to send/display.request
- The request which has caused the given error (not used by default).reqID
- ID of the request.user
- The user which executes the given request.uwsAction
- The UWS action corresponding to the given request.response
- The response in which the error must be published.java.io.IOException
- If there is an error when calling HttpServletResponse.sendError(int, String)
.ServiceErrorWriter.writeError(Throwable, HttpServletResponse, HttpServletRequest, String, JobOwner, String)