* history item will be created.
*
* @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
*/
public void execute(JobExecutionContext context) throws JobExecutionException {
ResourceOperationSchedule schedule = null;
Subject loggedInSubject = null;
try {
JobDetail jobDetail = context.getJobDetail();
int triggerTimes = 1;
if (context.getTrigger() instanceof SimpleTrigger) {
SimpleTrigger trigger = (SimpleTrigger) context.getTrigger();
triggerTimes = trigger.getTimesTriggered();
} else {
// Cron Trigger
}
OperationManagerLocal operationManager = LookupUtil.getOperationManager();
updateOperationScheduleEntity(jobDetail, context.getNextFireTime(), operationManager);
// retrieve the stored schedule using the overlord so it succeeds no matter what
schedule = operationManager.getResourceOperationSchedule(getOverlord(), jobDetail);
// Login the schedule's subject so its assigned a session, so our security tests pass.
// Create a new session even if user is logged in elsewhere, we don't want to attach to that user's session
loggedInSubject = getUserWithSession(schedule.getSubject(), false);
schedule.setSubject(loggedInSubject);
// for the security check, can the user who scheduled the operation in the first
// place still have the authority to execute it against the resource in question
operationManager.getResourceOperationSchedule(schedule.getSubject(), jobDetail);
ResourceOperationHistory resourceHistory = null;
if (triggerTimes==1) { // On 1st fire use the already provided history.
resourceHistory = findOperationHistory(jobDetail.getName(),jobDetail.getGroup(),operationManager, schedule);
if (resourceHistory.getStartedTime()>0) {