/** * 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()"); if (user == null) { log.error("The scheduled job to remove course sites can not be run with an invalid user. No courses were removed."); } 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 + " course sites were removed."); } catch (Exception ex) { log.error(ex.getMessage()); } } } }
/** * 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); } } } }