/** * Executes job method: Authenticates the user and call the BatchAdminClient to run the job of * jobName. * * @param username * @param token * @param jobName * @return json execution object */ @POST @Path("/{jobName}/run") @Produces(MediaType.APPLICATION_JSON) public Response executesJobs( @CookieParam(value = "user") Cookie userc, @CookieParam(value = "token") String token, @PathParam("jobName") String jobName) { /* * authenticates the user, throw exception if failed */ UserProfile user; try { user = frameworkUserManager.validate(userc, token); if (user == null) { return Response.status(Response.Status.UNAUTHORIZED).entity("Invalid credentials").build(); } } catch (Exception e) { log.error(e); e.printStackTrace(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } JobExecution execution; try { execution = jmanager.executesJobs(jobName); } catch (Exception e) { e.printStackTrace(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } Gson gson = new Gson(); String json = "{\"execution\" : " + gson.toJson(execution) + "}"; log.info(json); return Response.status(Response.Status.OK) .entity(json) .type(MediaType.APPLICATION_JSON) .build(); }