comparison software/mpdl-services/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainSchedulerListener.java @ 23:e845310098ba

diverse Korrekturen
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 27 Nov 2012 12:35:19 +0100
parents
children
comparison
equal deleted inserted replaced
22:6a45a982c333 23:e845310098ba
1 package de.mpg.mpiwg.berlin.mpdl.cms.scheduler;
2
3 import java.util.logging.Logger;
4 import org.quartz.JobDataMap;
5 import org.quartz.JobDetail;
6 import org.quartz.JobExecutionContext;
7 import org.quartz.JobExecutionException;
8 import org.quartz.JobListener;
9
10 import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
11
12 public class CmsChainSchedulerListener implements JobListener {
13 private static Logger LOGGER = Logger.getLogger(CmsDocJob.class.getName());
14
15 public String getName() {
16 return "MpdlJobChainingListener";
17 }
18
19 public void jobToBeExecuted(JobExecutionContext inContext) {
20 }
21
22 public void jobExecutionVetoed(JobExecutionContext inContext) {
23 String message = "Quartz: JobChainingListener: Job execution was vetoed.";
24 LOGGER.fine(message);
25 }
26
27 public void jobWasExecuted(JobExecutionContext inContext, JobExecutionException inException) {
28 // after finishing his job it tries to schedule the next operation (if there is one in the queue)
29 CmsDocOperation docOperation = null;
30 try {
31 CmsChainScheduler mpdlChainScheduler = CmsChainScheduler.getInstance();
32 docOperation = getDocOperation(inContext);
33 mpdlChainScheduler.finishOperation(docOperation);
34 } catch (ApplicationException e) {
35 if (docOperation != null) {
36 docOperation.setErrorMessage(e.getMessage());
37 }
38 LOGGER.severe(e.getMessage());
39 }
40 }
41
42 private CmsDocOperation getDocOperation(JobExecutionContext context) {
43 CmsDocOperation docOperation = null;
44 if (context != null) {
45 JobDetail job = context.getJobDetail();
46 JobDataMap parameters = job.getJobDataMap();
47 docOperation = (CmsDocOperation) parameters.get("operation");
48 }
49 return docOperation;
50 }
51
52
53 }