jobDetail.setDurability(true);
    public void execute(Map transientVars, Map args, PropertySet ps) {        try {            WorkflowEntry entry = (WorkflowEntry) transientVars.get("entry");            WorkflowContext context = (WorkflowContext) transientVars.get("context");            log.info("Starting to schdule job for WF #" + entry.getId());            int triggerId = TextUtils.parseInt((String) args.get("triggerId"));            String jobName = (String) args.get("jobName");            String triggerName = (String) args.get("triggerName");            String groupName = (String) args.get("groupName");            String username = (String) args.get("username");            String password = (String) args.get("password");            boolean txHack = TextUtils.parseBoolean((String) args.get("txHack"));            if (username == null) {                username = context.getCaller();            }            String cronExpression = (String) args.get("cronExpression");            jobName = jobName + ":" + entry.getId();            triggerName = triggerName + ":" + entry.getId();            groupName = groupName + ":" + entry.getId();            String schedulerName = (String) args.get("schedulerName");            Scheduler s;            SchedulerFactory factory = new StdSchedulerFactory();            if ((schedulerName == null) || ("".equals(schedulerName.trim()))) {                s = factory.getScheduler();            } else {                s = factory.getScheduler(schedulerName);            }            if (TextUtils.parseBoolean((String) args.get("schedulerStart"))) {                log.info("Starting Quartz Job Scheduler");                s.start();            }            Class jobClass;            String jobClassArg = (String) args.get("jobClass");            if (jobClassArg != null) {                jobClass = Class.forName(jobClassArg);            } else if (TextUtils.parseBoolean((String) args.get("local"))) {                jobClass = LocalWorkflowJob.class;            } else {                jobClass = WorkflowJob.class;            }            JobDetail jobDetail = new JobDetail(jobName, groupName, jobClass);            Trigger trigger;            if (cronExpression == null) {                long now = System.currentTimeMillis();                // get start date - default is now                Date startDate = null;                try {                    String start = (String) args.get("startOffset");                    if (s != null) {                        startDate = new Date(now + Long.parseLong(start));                    }                } catch (NumberFormatException e) {                }                if (startDate == null) {                    startDate = new Date(now);                }                // get end date - default is null                Date endDate = null;                try {                    String end = (String) args.get("endOffset");                    if (s != null) {                        startDate = new Date(now + Long.parseLong(end));                    }                } catch (NumberFormatException e) {                }                // get the repeat amount - default is 0                int repeat = 0;                try {                    String r = (String) args.get("repeat");                    if (r != null) {                        if (r.equalsIgnoreCase("REPEAT_INDEFINITELY")) {                            repeat = SimpleTrigger.REPEAT_INDEFINITELY;                        } else {                            repeat = TextUtils.parseInt(r);                        }                    }                } catch (NumberFormatException e) {                }                // get repeat delay - default is 0                long delay = 0;                try {                    String rd = (String) args.get("repeatDelay");                    if (rd != null) {                        delay = Long.parseLong(rd);                    }                } catch (NumberFormatException e) {                }                trigger = new SimpleTrigger(triggerName, groupName, jobName, groupName, startDate, endDate, repeat, delay);            } else {                trigger = new CronTrigger(triggerName, groupName, jobName, groupName, cronExpression);            }            JobDataMap dataMap = new JobDataMap();            dataMap.put("triggerId", triggerId);            dataMap.put("entryId", entry.getId());            dataMap.put("username", username);            dataMap.put("password", password);            jobDetail.setJobDataMap(dataMap);            trigger.setJobName(jobDetail.getName());            trigger.setJobGroup(jobDetail.getGroup());            if (txHack && !s.isPaused() && !s.isShutdown()) {                s.pause();                try {                    s.addJob(jobDetail, true);                    s.scheduleJob(trigger);                } catch (SchedulerException e) {                    throw e;                } finally {                    s.start();                }            } else {                s.addJob(jobDetail, true);                s.scheduleJob(trigger);            }            log.info("Job scheduled");        } catch (Exception e) {            log.error("Error scheduling job", e);        }    }