/** * Creates a new job on the Links Discovery Component. * * @param id the job identifier associated with this instance. * @return a response which includes the info of the new job. * @since 1.0 */ @POST @Path("/jobs") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response newJob( @Context final HttpServletRequest request, @FormParam("jobid") final Integer jobid) { LOGGER.debug(MessageCatalog._00021_NEW_JOB_REQUEST); if (jobid == null) { LOGGER.error(MessageCatalog._00022_MISSING_INPUT_PARAM, "jobid"); return Response.status(Status.BAD_REQUEST).build(); } // Get configuration parameters final DBConnectionManager dbConn = (DBConnectionManager) context.getAttribute("db"); final JobConfiguration jobConf = dbConn.getJobConfiguration(jobid); if (jobConf == null) { LOGGER.error(MessageCatalog._00023_JOB_CONFIGURATION_NOT_FOUND, jobid); return Response.status(Status.BAD_REQUEST).build(); } final DDBBParams ddbbParams = new DDBBParams(); ddbbParams.setUsername(context.getInitParameter("ddbb.username")); ddbbParams.setPassword(context.getInitParameter("ddbb.password")); ddbbParams.setDriverClassName(context.getInitParameter("ddbb.driverClassName")); ddbbParams.setUrl(context.getInitParameter("ddbb.url")); // Program linking processes final LinksDiscovery linksDisc = new LinksDiscovery(); final Job job = linksDisc.programLinkingProcesses(jobConf, dbConn, ddbbParams); return Response.created(uriInfo.getAbsolutePathBuilder().build()).entity(job).build(); }
/** * Gets job info. * * @param id the job identifier associated with this instance. * @return a response which includes the info of the job. * @since 1.0 */ @GET @Path("/jobs/{jobid}") @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getJob( @Context final HttpServletRequest request, @PathParam("jobid") final Integer jobid) { LOGGER.debug(MessageCatalog._00025_GET_JOB_REQUEST); if (jobid == null) { LOGGER.error(MessageCatalog._00022_MISSING_INPUT_PARAM, "jobid"); return Response.status(Status.BAD_REQUEST).build(); } final DBConnectionManager dbConn = (DBConnectionManager) context.getAttribute("db"); final Job job = dbConn.getJob(jobid); return Response.status(Response.Status.ACCEPTED).entity(job).build(); }