Skip to content
Snippets Groups Projects
Commit 81c567c8 authored by gmantele's avatar gmantele
Browse files

[UWS] Fix HTTP request for job destruction.

Until now, it was possible to destroy the job by posting ACTION=DELETE
with a URL like below:

    {root-uws}/{job-list}/{job-id}/foo/bar

That is completely wrong. The correct URL for this action must always be:

    {root-uws}/{job-list}/{job-id}

This commit fixes this error in UWSServlet and UWSService.
parent fdf1d1ea
No related branches found
No related tags found
No related merge requests found
...@@ -398,16 +398,16 @@ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory ...@@ -398,16 +398,16 @@ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory
uwsAction = UWSAction.ADD_JOB; uwsAction = UWSAction.ADD_JOB;
doAddJob(requestUrl, req, resp, user); doAddJob(requestUrl, req, resp, user);
}// DESTROY JOB:
else if (requestUrl.hasJobList() && requestUrl.hasJob() && requestUrl.getAttributes().length == 0 && UWSToolBox.hasParameter(UWSJob.PARAM_ACTION, UWSJob.ACTION_DELETE, req, false)){
uwsAction = UWSAction.DESTROY_JOB;
doDestroyJob(requestUrl, req, resp, user);
}// SET JOB's UWS STANDARD PARAMETER }// SET JOB's UWS STANDARD PARAMETER
else if (requestUrl.hasJobList() && requestUrl.hasJob() && requestUrl.getAttributes().length == 1 && requestUrl.getAttributes()[0].toLowerCase().matches(UWSParameters.UWS_RW_PARAMETERS_REGEXP) && UWSToolBox.hasParameter(requestUrl.getAttributes()[0], req, false)){ else if (requestUrl.hasJobList() && requestUrl.hasJob() && requestUrl.getAttributes().length == 1 && requestUrl.getAttributes()[0].toLowerCase().matches(UWSParameters.UWS_RW_PARAMETERS_REGEXP) && UWSToolBox.hasParameter(requestUrl.getAttributes()[0], req, false)){
uwsAction = UWSAction.SET_UWS_PARAMETER; uwsAction = UWSAction.SET_UWS_PARAMETER;
doSetUWSParameter(requestUrl, req, resp, user); doSetUWSParameter(requestUrl, req, resp, user);
}// DESTROY JOB:
else if (requestUrl.hasJobList() && requestUrl.hasJob() && UWSToolBox.hasParameter(UWSJob.PARAM_ACTION, UWSJob.ACTION_DELETE, req, false)){
uwsAction = UWSAction.DESTROY_JOB;
doDestroyJob(requestUrl, req, resp, user);
}// SET JOB PARAMETER: }// SET JOB PARAMETER:
else if (requestUrl.hasJobList() && requestUrl.hasJob() && (!requestUrl.hasAttribute() || requestUrl.getAttributes().length == 1 && requestUrl.getAttributes()[0].equalsIgnoreCase(UWSJob.PARAM_PARAMETERS)) && UWSToolBox.getNbParameters(req) > 0){ else if (requestUrl.hasJobList() && requestUrl.hasJob() && (!requestUrl.hasAttribute() || requestUrl.getAttributes().length == 1 && requestUrl.getAttributes()[0].equalsIgnoreCase(UWSJob.PARAM_PARAMETERS)) && UWSToolBox.getNbParameters(req) > 0){
uwsAction = UWSAction.SET_JOB_PARAM; uwsAction = UWSAction.SET_JOB_PARAM;
......
...@@ -16,7 +16,7 @@ package uws.service.actions; ...@@ -16,7 +16,7 @@ package uws.service.actions;
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Copyright 2012-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI) * Astronomisches Rechen Institut (ARI)
*/ */
...@@ -43,7 +43,7 @@ import uws.service.log.UWSLog.LogLevel; ...@@ -43,7 +43,7 @@ import uws.service.log.UWSLog.LogLevel;
* The response of this action is a redirection to the jobs list.</p> * The response of this action is a redirection to the jobs list.</p>
* *
* @author Gr&eacute;gory Mantelet (CDS;ARI) * @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 4.1 (04/2015) * @version 4.2 (09/2017)
*/ */
public class DestroyJob extends UWSAction { public class DestroyJob extends UWSAction {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -71,6 +71,7 @@ public class DestroyJob extends UWSAction { ...@@ -71,6 +71,7 @@ public class DestroyJob extends UWSAction {
* <ul> * <ul>
* <li>a job list name is specified in the given UWS URL <i>(<u>note:</u> the existence of the jobs list is not checked)</i>,</li> * <li>a job list name is specified in the given UWS URL <i>(<u>note:</u> the existence of the jobs list is not checked)</i>,</li>
* <li>a job ID is given in the UWS URL <i>(<u>note:</u> the existence of the job is not checked)</i>,</li> * <li>a job ID is given in the UWS URL <i>(<u>note:</u> the existence of the job is not checked)</i>,</li>
* <li>no job attribute is specified in the URL <i>(i.e. {uws-root}/{jobs}/{job-id})</i>,</li>
* <li>the HTTP method is HTTP-DELETE...</li> * <li>the HTTP method is HTTP-DELETE...</li>
* <li>...<b>or</b> the HTTP method is HTTP-POST <b>and</b> there is the parameter {@link UWSJob#PARAM_ACTION PARAM_ACTION} (=ACTION) with the value {@link UWSJob#ACTION_DELETE ACTION_DELETE} (=DELETE).</li> * <li>...<b>or</b> the HTTP method is HTTP-POST <b>and</b> there is the parameter {@link UWSJob#PARAM_ACTION PARAM_ACTION} (=ACTION) with the value {@link UWSJob#ACTION_DELETE ACTION_DELETE} (=DELETE).</li>
* </ul> * </ul>
...@@ -79,7 +80,7 @@ public class DestroyJob extends UWSAction { ...@@ -79,7 +80,7 @@ public class DestroyJob extends UWSAction {
*/ */
@Override @Override
public boolean match(UWSUrl urlInterpreter, JobOwner user, HttpServletRequest request) throws UWSException{ public boolean match(UWSUrl urlInterpreter, JobOwner user, HttpServletRequest request) throws UWSException{
return urlInterpreter.hasJobList() && urlInterpreter.hasJob() && (request.getMethod().equalsIgnoreCase("delete") || (request.getMethod().equalsIgnoreCase("post") && UWSToolBox.hasParameter(UWSJob.PARAM_ACTION, UWSJob.ACTION_DELETE, request, false))); return urlInterpreter.hasJobList() && urlInterpreter.hasJob() && urlInterpreter.getAttributes().length == 0 && (request.getMethod().equalsIgnoreCase("delete") || (request.getMethod().equalsIgnoreCase("post") && UWSToolBox.hasParameter(UWSJob.PARAM_ACTION, UWSJob.ACTION_DELETE, request, false)));
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment