Skip to content

Commit

Permalink
impl new feature
Browse files Browse the repository at this point in the history
Issue #870
  • Loading branch information
rsoika committed Aug 23, 2024
1 parent 2924a68 commit 648890e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,30 @@ public void deleteJob(String id) throws AccessDeniedException {
}
}

/**
* Method to restart an existing job.
*
* The method first tries to cancel a running timer and than creates a new one
* @param id
*/
public void restartJobByID(String id) {
logger.info("...Restart AdminP Job: "+id);
// try to cancel...
ItemCollection job = cancelTimer(id);
if (job!=null) {
String jobtype = job.getItemValueString("job");
int interval = job.getItemValueInteger("numInterval");
Calendar cal = Calendar.getInstance();
Date terminationDate = cal.getTime();
// restart timer...
Timer timer = timerService.createTimer(terminationDate, (interval * 1000),
job.getUniqueID());
logger.info("Job " + jobtype + " (" + timer.getInfo().toString() + ") restarted... ");
} else {
logger.info("Restart failed - unable to load job with id: "+id);
}
}

/**
* This method processes the timeout event. The method loads the corresponding
* job description (adminp entity) and delegates the processing to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,20 @@ public Response putJob(XMLDocument xmlworkitem) {
}
}


/**
* Restarts a Job by ID
*
* @param id
* @return
*/
@GET
@Path("/jobs/restart/{id}")
public Response restartJob(@PathParam("id") String id) {
adminPService.restartJobByID(id);
return Response.status(Response.Status.OK).build();
}

/**
* This method deletes an entity
*
Expand Down

0 comments on commit 648890e

Please sign in to comment.