/** * implement the quartz job interface, which is called by the scheduler when a trigger associated with the job fires. * this quartz job removes course sites that are more than a specified number of terms old. */ public void execute(JobExecutionContext context) throws JobExecutionException { synchronized (this) { log.info("execute()"); String actionStr = CourseSiteRemovalService.Action.remove.equals(action) ? " course sites were removed." : " course sites were unpublished."; if (user == null) { log.error("The scheduled job to remove course sites can not be run with an invalid user. No{}", actionStr); } else { try { // switch the current user to the one specified to run the quartz job Session sakaiSesson = sessionManager.getCurrentSession(); sakaiSesson.setUserId(user.getId()); int numSitesRemoved = courseSiteRemovalService.removeCourseSites(action, numDaysAfterTermEnds); log.info("{}{}", numSitesRemoved, actionStr); } catch (Exception ex) { log.error(ex.getMessage(), ex); } } } }
/** * @return the enum action corresponding to the string or null if the string is not a valid action. * <br/><br/> * @param string the action that is to be parsed. */ private CourseSiteRemovalService.Action getAction(String string) { CourseSiteRemovalService.Action action = null; for (CourseSiteRemovalService.Action a : CourseSiteRemovalService.Action.values()) if (a.toString().equals(string)) action = a; return action; }
/** * @return the enum action corresponding to the string or null if the string is not a valid action. * <br/><br/> * @param string the action that is to be parsed. */ private CourseSiteRemovalService.Action getAction(String string) { CourseSiteRemovalService.Action action = null; for (CourseSiteRemovalService.Action a : CourseSiteRemovalService.Action.values()) if (a.toString().equals(string)) action = a; return action; }