D. How to customize a UWS ?

4. Request interpretation

In A.2. Writing the servlet you have seen that at each request, you have only one thing to do: just call the method executeRequest(HttpServletRequest, HttpServletResponse). This method is able to interpret any HTTP request and to execute the corresponding UWS action.

How does it work ?

When a request is sent to the servlet, it is forwarded to the UWS thanks to the method executeRequest(HttpServletRequest, HttpServletResponse). To interpret the received request, the UWS does three things:

  1. Interpret the URL,
  2. Identify the user,
  3. Look for the corresponding UWS action.

To interpret the URL the method load(HttpServletRequest) of the object UWSUrl is called. This class is explained in more details in the next page (D.5. The UWS URL interpretation), but what you have to known is it lets simplifying the given request so that extracting the UWS URI (/{jobListName}/{jobName}/{jobAttributes}...). This simplification will help to determine which UWS action must be executed.

The identification of the user may be important for some UWS actions like displaying a jobs list. It is done by the function extractUserId(UWSUrl, HttpServletRequest) of UserIdentifier, explained previously in D.3. User Identification.

Finally to determine the corresponding UWS action, we loop on the list of all the available actions. Indeed a UWS can also be viewed as a set of actions. Each action is represented by an extension of the abstract class UWSAction. Only two functions of this class interest us here (but if you want more information, see D.6. Actions):

The first function is used in the loop to choose the UWS action corresponding to the received request, whereas the second one is called on the found action. If no matching action can be found, a UWSException is thrown.

executeRequest(HttpServletRequest, HttpServletResponse) returns a boolean: true if the found action has been successfully executed, false otherwise.

How to customize ?

All steps of the request interpretation have been designed to be customizable independently. So theoretically you have to override the method or to extend the class which correspond to what you want to customize. For that you need to look at the corresponding part of this tutorial:

Only if you have to add some operations to the current request interpretation or if you want completely replace it, you would have to override executeRequest(HttpServletRequest, HttpServletResponse).