/** * <strong>Compulsory</strong> (unless {@link #setScheduleId(Integer)} is used)<br> * The name of the batch job to launch. It is the "Job Definition" name, and the most important parameter in this form. * * @param applicationName * max length is 100 */ public JobRequest setApplicationName(String applicationName) { if (applicationName == null || applicationName.length() > 100) { throw new JqmInvalidRequestException("Job definition name must be between 1 and 100 characters"); } this.applicationName = applicationName; return this; }
private void validateParameter(String key, String value) { if (key == null || key.isEmpty() || key.length() > 50 || value == null || value.isEmpty() || value.length() > 1000) { throw new JqmInvalidRequestException( "Parameters key must be between 1 and 50 chaarcters, parameter values between 1 and 1000 characters"); } }
@Override public com.enioka.jqm.api.JobDef getJobDefinition(String name) { List<com.enioka.jqm.api.JobDef> res = getJobDefinitionsInternal("jd_select_by_key", name); if (res.isEmpty()) { throw new JqmInvalidRequestException("No job definition named " + name); } return res.get(0); }
@Override public void setScheduleRecurrence(int scheduleId, String cronExpression) { try { target.path("schedule/" + scheduleId + "/cron/" + cronExpression).request().post(null); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public void setSchedulePriority(int scheduleId, int priority) { try { target.path("schedule/" + scheduleId + "/priority/" + priority).request().post(null); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public InputStream getJobLogStdErr(int jobId) { try { return target.path("ji/" + jobId + "/stderr").request().get(InputStream.class); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public InputStream getDeliverableContent(com.enioka.jqm.api.Deliverable d) { try { return target.path("ji/files").request().post(Entity.entity(d, MediaType.APPLICATION_XML), InputStream.class); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public void setJobRunAfter(int jobId, Calendar whenToRun) { try { target.path("ji/" + jobId + "/delay/" + whenToRun.getTimeInMillis()).request().post(null); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public void killJob(int idJob) { try { target.path("ji/killed/" + idJob).request().post(null); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public void pauseRunningJob(int jobId) { try { target.path("ji/running/paused/" + jobId).request().post(null); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public void setJobQueuePosition(int idJob, int position) { try { target.path("ji/" + idJob + "/position/" + position).request().post(null); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public com.enioka.jqm.api.JobInstance getJob(int idJob) { try { return target.path("ji/" + idJob).request().get(JobInstance.class); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException("An internal JQM error occured", e); } }
@Override public void pauseQueuedJob(int idJob) { try { target.path("ji/paused/" + idJob).request().post(null); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public void setScheduleQueue(int scheduleId, int queueId) { try { target.path("schedule/" + scheduleId + "/queue/" + queueId).request().post(null); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public InputStream getDeliverableContent(int d) { try { return target.path("ji/files/" + d).request().get(InputStream.class); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public void cancelJob(int idJob) { try { target.path("ji/cancelled/" + idJob).request().post(null); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public void setJobQueue(int idJob, int idQueue) { try { target.path("q/" + idQueue + "/" + idJob).request().post(null); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public void setJobPriority(int jobId, int priority) { try { target.path("ji/" + jobId + "/priority/" + priority).request().post(null); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public InputStream getJobLogStdOut(int jobId) { try { return target.path("ji/" + jobId + "/stdout").request().get(InputStream.class); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Override public List<com.enioka.jqm.api.Deliverable> getJobDeliverables(int idJob) { try { return target.path("ji/" + idJob + "/files").request().get(new GenericType<List<Deliverable>>() { }); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }