diff --git a/dotCMS/src/main/java/com/dotcms/rest/api/v1/job/JobQueueResource.java b/dotCMS/src/main/java/com/dotcms/rest/api/v1/job/JobQueueResource.java index d650845ca9b5..a4421cd53400 100644 --- a/dotCMS/src/main/java/com/dotcms/rest/api/v1/job/JobQueueResource.java +++ b/dotCMS/src/main/java/com/dotcms/rest/api/v1/job/JobQueueResource.java @@ -14,6 +14,7 @@ import java.util.Set; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import javax.ws.rs.BeanParam; import javax.ws.rs.Consumes; import javax.ws.rs.DefaultValue; @@ -54,14 +55,14 @@ public JobQueueResource(WebResource webResource, JobQueueHelper helper, @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) public Response createJob( - @Context HttpServletRequest request, + @Context HttpServletRequest request, @Context final HttpServletResponse response, @PathParam("queueName") String queueName, @BeanParam JobParams form) throws JsonProcessingException, DotDataException { final var initDataObject = new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); @@ -79,14 +80,14 @@ public Response createJob( @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response createJob( - @Context HttpServletRequest request, + @Context HttpServletRequest request, @Context final HttpServletResponse response, @PathParam("queueName") String queueName, Map parameters) throws DotDataException { final var initDataObject = new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); @@ -102,11 +103,12 @@ public Response createJob( @GET @Path("/queues") @Produces(MediaType.APPLICATION_JSON) - public ResponseEntityView> getQueues(@Context HttpServletRequest request) { + public ResponseEntityView> getQueues( + @Context HttpServletRequest request, @Context final HttpServletResponse response) { new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); return new ResponseEntityView<>(helper.getQueueNames()); @@ -115,14 +117,14 @@ public ResponseEntityView> getQueues(@Context HttpServletRequest req @GET @Path("/{jobId}/status") @Produces(MediaType.APPLICATION_JSON) - public ResponseEntityView getJobStatus(@Context HttpServletRequest request, - @PathParam("jobId") String jobId) - throws DotDataException { + public ResponseEntityView getJobStatus( + @Context HttpServletRequest request, @Context final HttpServletResponse response, + @PathParam("jobId") String jobId) throws DotDataException { new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); @@ -134,12 +136,13 @@ public ResponseEntityView getJobStatus(@Context HttpServletRequest request, @Path("/{jobId}/cancel") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.WILDCARD) - public ResponseEntityView cancelJob(@Context HttpServletRequest request, + public ResponseEntityView cancelJob( + @Context HttpServletRequest request, @Context final HttpServletResponse response, @PathParam("jobId") String jobId) throws DotDataException { new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); helper.cancelJob(jobId); @@ -149,14 +152,15 @@ public ResponseEntityView cancelJob(@Context HttpServletRequest request, @GET @Path("/{queueName}/active") @Produces(MediaType.APPLICATION_JSON) - public ResponseEntityView activeJobs(@Context HttpServletRequest request, + public ResponseEntityView activeJobs( + @Context HttpServletRequest request, @Context final HttpServletResponse response, @PathParam("queueName") String queueName, @QueryParam("page") @DefaultValue("1") int page, @QueryParam("pageSize") @DefaultValue("20") int pageSize) { new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); final JobPaginatedResult result = helper.getActiveJobs(queueName, page, pageSize); @@ -165,13 +169,14 @@ public ResponseEntityView activeJobs(@Context HttpServletReq @GET @Produces(MediaType.APPLICATION_JSON) - public ResponseEntityView listJobs(@Context HttpServletRequest request, + public ResponseEntityView listJobs( + @Context HttpServletRequest request, @Context final HttpServletResponse response, @QueryParam("page") @DefaultValue("1") int page, @QueryParam("pageSize") @DefaultValue("20") int pageSize) { new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); final JobPaginatedResult result = helper.getJobs(page, pageSize); @@ -181,13 +186,14 @@ public ResponseEntityView listJobs(@Context HttpServletReque @GET @Path("/active") @Produces(MediaType.APPLICATION_JSON) - public ResponseEntityView activeJobs(@Context HttpServletRequest request, + public ResponseEntityView activeJobs( + @Context HttpServletRequest request, @Context final HttpServletResponse response, @QueryParam("page") @DefaultValue("1") int page, @QueryParam("pageSize") @DefaultValue("20") int pageSize) { new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); final JobPaginatedResult result = helper.getActiveJobs(page, pageSize); @@ -197,13 +203,14 @@ public ResponseEntityView activeJobs(@Context HttpServletReq @GET @Path("/completed") @Produces(MediaType.APPLICATION_JSON) - public ResponseEntityView completedJobs(@Context HttpServletRequest request, + public ResponseEntityView completedJobs( + @Context HttpServletRequest request, @Context final HttpServletResponse response, @QueryParam("page") @DefaultValue("1") int page, @QueryParam("pageSize") @DefaultValue("20") int pageSize) { new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); final JobPaginatedResult result = helper.getCompletedJobs(page, pageSize); @@ -214,13 +221,13 @@ public ResponseEntityView completedJobs(@Context HttpServlet @Path("/successful") @Produces(MediaType.APPLICATION_JSON) public ResponseEntityView successfulJobs( - @Context HttpServletRequest request, + @Context HttpServletRequest request, @Context final HttpServletResponse response, @QueryParam("page") @DefaultValue("1") int page, @QueryParam("pageSize") @DefaultValue("20") int pageSize) { new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); final JobPaginatedResult result = helper.getSuccessfulJobs(page, pageSize); @@ -230,13 +237,14 @@ public ResponseEntityView successfulJobs( @GET @Path("/canceled") @Produces(MediaType.APPLICATION_JSON) - public ResponseEntityView canceledJobs(@Context HttpServletRequest request, + public ResponseEntityView canceledJobs( + @Context HttpServletRequest request, @Context final HttpServletResponse response, @QueryParam("page") @DefaultValue("1") int page, @QueryParam("pageSize") @DefaultValue("20") int pageSize) { new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); final JobPaginatedResult result = helper.getCanceledJobs(page, pageSize); @@ -246,13 +254,14 @@ public ResponseEntityView canceledJobs(@Context HttpServletR @GET @Path("/failed") @Produces(MediaType.APPLICATION_JSON) - public ResponseEntityView failedJobs(@Context HttpServletRequest request, + public ResponseEntityView failedJobs( + @Context HttpServletRequest request, @Context final HttpServletResponse response, @QueryParam("page") @DefaultValue("1") int page, @QueryParam("pageSize") @DefaultValue("20") int pageSize) { new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); final JobPaginatedResult result = helper.getFailedJobs(page, pageSize); @@ -262,13 +271,14 @@ public ResponseEntityView failedJobs(@Context HttpServletReq @GET @Path("/abandoned") @Produces(MediaType.APPLICATION_JSON) - public ResponseEntityView abandonedJobs(@Context HttpServletRequest request, + public ResponseEntityView abandonedJobs( + @Context HttpServletRequest request, @Context final HttpServletResponse response, @QueryParam("page") @DefaultValue("1") int page, @QueryParam("pageSize") @DefaultValue("20") int pageSize) { new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init(); final JobPaginatedResult result = helper.getAbandonedJobs(page, pageSize); @@ -279,13 +289,14 @@ public ResponseEntityView abandonedJobs(@Context HttpServlet @Path("/{jobId}/monitor") @Produces(SseFeature.SERVER_SENT_EVENTS) @SuppressWarnings("java:S1854") // jobWatcher assignment is needed for cleanup in catch blocks - public EventOutput monitorJob(@Context HttpServletRequest request, + public EventOutput monitorJob( + @Context HttpServletRequest request, @Context final HttpServletResponse response, @PathParam("jobId") String jobId) { new InitBuilder(webResource) .requiredBackendUser(true) .requiredFrontendUser(false) - .requestAndResponse(request, null) + .requestAndResponse(request, response) .rejectWhenNoUser(true) .init();