uws.service.actions
Class UWSAction<JL extends JobList<J>,J extends AbstractJob>

java.lang.Object
  extended by uws.service.actions.UWSAction<JL,J>
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AddJob, DestroyJob, GetJobParam, JobSummary, ListJobs, SetJobParam, ShowHomePage

public abstract class UWSAction<JL extends JobList<J>,J extends AbstractJob>
extends java.lang.Object
implements java.io.Serializable

Action of a UWS (i.e. "List Jobs", "Get Job", etc...). An instance of a UWSAction can be added to a given UWS thanks to the method AbstractUWS.addUWSAction(UWSAction).

WARNING: The action of a UWS have, each one, a different name. So be careful about the name of your UWS action ! By default the name of a UWS action is the full java name of the class !

Version:
01/2011
Author:
Grégory Mantelet (CDS)
See Also:
AbstractUWS, Serialized Form

Field Summary
static java.lang.String ADD_JOB
          Name of the UWS action AddJob.
static java.lang.String DESTROY_JOB
          Name of the UWS action DestroyJob.
static java.lang.String GET_JOB_PARAM
          Name of the UWS action GetJobParam.
static java.lang.String HOME_PAGE
          Name of the UWS action ShowHomePage.
static java.lang.String JOB_SUMMARY
          Name of the UWS action JobSummary.
static java.lang.String LIST_JOBS
          Name of the UWS action ListJobs.
static java.lang.String SET_JOB_PARAM
          Name of the UWS action SetJobParam.
protected  AbstractUWS<JL,J> uws
          The UWS on which this action must be applied.
 
Constructor Summary
protected UWSAction(AbstractUWS<JL,J> u)
          Builds a UWSAction.
 
Method Summary
abstract  boolean apply(UWSUrl urlInterpreter, java.lang.String userId, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Applies this UWS action in function of the given request and writes the result in the given response.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getDescription()
          Gets the description of this UWS action.
protected  J getJob(UWSUrl urlInterpreter)
          Extracts the job ID from the given UWS URL and gets the corresponding job from the UWS.
protected  J getJob(UWSUrl urlInterpreter, JL jobsList)
          Extracts the job ID from the given UWS URL and gets the corresponding job from the given jobs list.
protected  JL getJobsList(UWSUrl urlInterpreter)
          Extracts the name of the jobs list from the given UWS URL and gets the jobs list from the UWS.
 java.lang.String getName()
          Gets the name of this UWS action.
 AbstractUWS<JL,J> getUWS()
          Gets the UWS which contains this action.
abstract  boolean match(UWSUrl urlInterpreter, java.lang.String userId, javax.servlet.http.HttpServletRequest request)
          Indicates whether the given request corresponds to this UWS action.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LIST_JOBS

public static final java.lang.String LIST_JOBS
Name of the UWS action ListJobs.

See Also:
Constant Field Values

ADD_JOB

public static final java.lang.String ADD_JOB
Name of the UWS action AddJob.

See Also:
Constant Field Values

DESTROY_JOB

public static final java.lang.String DESTROY_JOB
Name of the UWS action DestroyJob.

See Also:
Constant Field Values

JOB_SUMMARY

public static final java.lang.String JOB_SUMMARY
Name of the UWS action JobSummary.

See Also:
Constant Field Values

GET_JOB_PARAM

public static final java.lang.String GET_JOB_PARAM
Name of the UWS action GetJobParam.

See Also:
Constant Field Values

SET_JOB_PARAM

public static final java.lang.String SET_JOB_PARAM
Name of the UWS action SetJobParam.

See Also:
Constant Field Values

HOME_PAGE

public static final java.lang.String HOME_PAGE
Name of the UWS action ShowHomePage.

See Also:
Constant Field Values

uws

protected final AbstractUWS<JL extends JobList<J>,J extends AbstractJob> uws
The UWS on which this action must be applied.

Constructor Detail

UWSAction

protected UWSAction(AbstractUWS<JL,J> u)
Builds a UWSAction.

Parameters:
u - The UWS which contains this action.
Method Detail

getUWS

public final AbstractUWS<JL,J> getUWS()
Gets the UWS which contains this action.

Returns:
Its UWS.

getName

public java.lang.String getName()

Gets the name of this UWS action. MUST BE UNIQUE !

Note: By default the name of the class is returned (Class.getName()).

Returns:
Its name.

getDescription

public java.lang.String getDescription()

Gets the description of this UWS action.

Note: By default an empty string is returned.

Returns:
Its description.

getJobsList

protected final JL getJobsList(UWSUrl urlInterpreter)
                                           throws UWSException
Extracts the name of the jobs list from the given UWS URL and gets the jobs list from the UWS.

Parameters:
urlInterpreter - The UWS URL which contains the name of the jobs list to get.
Returns:
The corresponding jobs list.
Throws:
UWSException - If there is no jobs list name in the given UWS URL or if no corresponding jobs list can be found in the UWS.
See Also:
UWSUrl.getJobListName(), AbstractUWS.getJobList(String)

getJob

protected final J getJob(UWSUrl urlInterpreter)
                                      throws UWSException
Extracts the job ID from the given UWS URL and gets the corresponding job from the UWS.

Parameters:
urlInterpreter - The UWS URL which contains the ID of the job to get.
Returns:
The corresponding job.
Throws:
UWSException - If no jobs list name or/and job ID can be found in the given UWS URL or if there are no corresponding jobs list and/or job in the UWS.
See Also:
UWSUrl.getJobId(), getJobsList(UWSUrl), JobList.getJob(String)

getJob

protected final J getJob(UWSUrl urlInterpreter,
                         JL jobsList)
                                      throws UWSException
Extracts the job ID from the given UWS URL and gets the corresponding job from the given jobs list.

Parameters:
urlInterpreter - The UWS URL which contains the ID of the job to get.
jobsList - The jobs list which is supposed to contain the job to get.
Returns:
The corresponding job.
Throws:
UWSException - If no job ID can be found in the given UWS URL or if there are no corresponding job in the UWS.
See Also:
UWSUrl.getJobId(), JobList.getJob(String)

match

public abstract boolean match(UWSUrl urlInterpreter,
                              java.lang.String userId,
                              javax.servlet.http.HttpServletRequest request)
                       throws UWSException
Indicates whether the given request corresponds to this UWS action.

Parameters:
urlInterpreter - The UWS URL of the given request.
userId - The user who has sent the given request.
request - The received request.
Returns:
true if the given request corresponds to this UWS action, false otherwise.
Throws:
UWSException - If any error occurs during the tests.

apply

public abstract boolean apply(UWSUrl urlInterpreter,
                              java.lang.String userId,
                              javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws UWSException,
                              java.io.IOException

Applies this UWS action in function of the given request and writes the result in the given response.

Note: You can use the functions getJobsList(UWSUrl), getJob(UWSUrl) and getJob(UWSUrl, JobList) to get more easily the jobs list and/or the job from the given UWS URL !

Parameters:
urlInterpreter - The UWS URL of the given request.
userId - The user who has sent the given request.
request - The received request.
response - The response of the given request (MUST BE UPDATED).
Returns:
true if the actions has been successfully applied, false otherwise.
Throws:
UWSException - If any error occurs during the action application.
java.io.IOException - If there is an error while the result is written in the given response.

equals

public final boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object