Execute individual task of schedule file
@param
@return
439986
public function task($script) {

		if(false === is_string($script)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($script)), E_USER_ERROR);
		}

		$script = sprintf('%s%s%s.php', Path :: get('schedule'), Application :: get(['prefix', 'schedule']), NameConvert :: toCamelcase($script, true));

		//Check if script is readable
		if(false === is_readable($script)) {
			return trigger_error(sprintf('Script "%s" is not a readable Schedule file', (string) $script));
		}

		//Include script
		require_once($script);

		//Create new instance
		$file 		= new File($script);
		$classname 	= $file -> entity() -> getName();
		$class 		= new $classname();
			
		//Check if needed constants are defined
		foreach(['TIME', 'ENABLED'] as $constant) {
			
			if(false === defined($classname . '::' . $constant)) {
				return trigger_error(sprintf('Missing constant "%s" in Schedule "%s" class', $constant, $classname));
			}
		}

		//Check if schedule has start method
		if(false === is_callable([$class, 'start'])) {
			return trigger_error(sprintf('Missing methode start in Schedule "%s" class', $classname));
		}

		//If the current schedule is enabled
		if(true === $class :: ENABLED) {

			$run = $this -> checkRun($class :: TIME);

			if(true === $run) {

				ob_start();

				//Capture return ouput 
				$data 						= [];
				$data[$classname]['start']  = date('Y-m-d H:i:s');
				$data[$classname]['return'] = (string) $class -> start();
				$data[$classname]['echo'] 	= ob_get_clean();
				$data[$classname]['end']  	= date('Y-m-d H:i:s');

				//Check if the current schedule has the complete method
				if(true === is_callable([$class, 'complete'])) {
					$class -> complete($data[$classname]);
				}

				//Write to log
				$logger = $this -> getLogger();
				$logger -> setDirectory(Path :: get('log-schedule'));
				$logger -> write(json_encode($data));
			}
		}
	}
1002450
@Override
	public void executeJob(String groupName, String jobName) throws SchedulerException {
		if (!config.isExecuteJobAllowed()) {
			LOGGER.warn("not allowed to execute any job");
			return;
		}
		scheduler.triggerJob(new JobKey(jobName, groupName));
	}
414145
public <V> ScheduledFuture<V> schedule(Callable<V> callable, TemporalAccessor time)
    {
        ensureWaiterRunning();
        log(logLevel, "schedule(%s, %s)", callable, time);
        RunnableScheduledFutureImpl future = new RunnableScheduledFutureImpl(callable, Instant.from(time), null, false);
        delayQueue.add(future);
        return future;
    }
1113056
private void populateRecurringTask(Record record, RecurringTask task) throws MPXJException
   {
      //System.out.println(record);
      task.setStartDate(record.getDateTime(1));
      task.setFinishDate(record.getDateTime(2));
      task.setDuration(RecurrenceUtility.getDuration(m_projectFile.getProjectProperties(), record.getInteger(3), record.getInteger(4)));
      task.setOccurrences(record.getInteger(5));
      task.setRecurrenceType(RecurrenceUtility.getRecurrenceType(record.getInteger(6)));
      task.setUseEndDate(NumberHelper.getInt(record.getInteger(8)) == 1);
      task.setWorkingDaysOnly(NumberHelper.getInt(record.getInteger(9)) == 1);
      task.setWeeklyDaysFromBitmap(RecurrenceUtility.getDays(record.getString(10)), RecurrenceUtility.RECURRING_TASK_DAY_MASKS);

      RecurrenceType type = task.getRecurrenceType();
      if (type != null)
      {
         switch (task.getRecurrenceType())
         {
            case DAILY:
            {
               task.setFrequency(record.getInteger(13));
               break;
            }

            case WEEKLY:
            {
               task.setFrequency(record.getInteger(14));
               break;
            }

            case MONTHLY:
            {
               task.setRelative(NumberHelper.getInt(record.getInteger(11)) == 1);
               if (task.getRelative())
               {
                  task.setFrequency(record.getInteger(17));
                  task.setDayNumber(record.getInteger(15));
                  task.setDayOfWeek(RecurrenceUtility.getDay(record.getInteger(16)));
               }
               else
               {
                  task.setFrequency(record.getInteger(19));
                  task.setDayNumber(record.getInteger(18));
               }
               break;
            }

            case YEARLY:
            {
               task.setRelative(NumberHelper.getInt(record.getInteger(12)) != 1);
               if (task.getRelative())
               {
                  task.setDayNumber(record.getInteger(20));
                  task.setDayOfWeek(RecurrenceUtility.getDay(record.getInteger(21)));
                  task.setMonthNumber(record.getInteger(22));
               }
               else
               {
                  task.setYearlyAbsoluteFromDate(record.getDateTime(23));
               }
               break;
            }
         }
      }

      //System.out.println(task);
   }
940410
@Override
    public ScheduledFuture<?> schedule(Runnable task, Date startTime) {
        long initialDelay = startTime.getTime() - System.currentTimeMillis();
        try {
            return this.scheduledExecutor.schedule(decorateTask(task, false), initialDelay, TimeUnit.MILLISECONDS);
        } catch (RejectedExecutionException ex) {
            throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task,
                    ex);
        }
    }
65425
@Override
    public void execute() {
        logger = new DITAOTAntLogger(getProject());
        logger.info(message);

        new Properties();
        //ensure tempdir is absolute
        if (!tempdir.isAbsolute()) {
            tempdir = new File(basedir, tempdir.getPath()).getAbsoluteFile();
        }
        //ensure outdir is absolute
        if (!outputdir.isAbsolute()) {
            outputdir = new File(basedir, outputdir.getPath()).getAbsoluteFile();
        }
        //ensure inputmap is absolute
        if (!new File(inputmap).isAbsolute()) {
            inputmap = new File(tempdir, inputmap).getAbsolutePath();
        }

        final Job job = getJob(tempdir, getProject());

        final LangParser parser = new LangParser();

        try {

            final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
            final SAXParser saxParser = saxParserFactory.newSAXParser();
            //parse the user input file(usually a map)
            saxParser.parse(inputmap, parser);
            String langCode = parser.getLangCode();
            if (!StringUtils.isEmptyString(langCode)) {
                setActiveProjectProperty("htmlhelp.locale", langCode);
            } else {
                //parse topic files
                for (final FileInfo f: job.getFileInfo()) {
                    if (ATTR_FORMAT_VALUE_DITA.equals(f.format)) {
                        final File topicFile = new File(tempdir, f.file.getPath());
                        if (topicFile.exists()) {
                            saxParser.parse(topicFile, parser);
                            langCode = parser.getLangCode();
                            if (!StringUtils.isEmptyString(langCode)) {
                                setActiveProjectProperty("htmlhelp.locale", langCode);
                                break;
                            }
                        }
                    }
                }
                //no lang is set
                if (StringUtils.isEmptyString(langCode)) {
                    //use default lang code
                    setActiveProjectProperty("htmlhelp.locale", "en-us");
                }
            }



        } catch (final Exception e) {
            /* Since an exception is used to stop parsing when the search
             * is successful, catch the exception.
             */
            if (e.getMessage() != null &&
                    e.getMessage().equals("Search finished")) {
                System.out.println("Lang search finished");
            } else {
                e.printStackTrace();
            }
        }
    }
293002
protected boolean scheduleImpl(Runnable task,
                                 ClassLoader loader,
                                 long expireTime,
                                 boolean isPriority,
                                 boolean isQueueIfFull,
                                 boolean isWakeScheduler)
  {
    Objects.requireNonNull(task);
    
    RunnableItem taskItem = new RunnableItem(task, loader);
    
    return schedule(taskItem);
  }
722922
private Task taskToBeRescheduled(Task task) {
        Task taskToBeRetried = task.copy();
        taskToBeRetried.setTaskId(IDGenerator.generate());
        taskToBeRetried.setRetriedTaskId(task.getTaskId());
        taskToBeRetried.setStatus(SCHEDULED);
        taskToBeRetried.setRetryCount(task.getRetryCount() + 1);
        taskToBeRetried.setRetried(false);
        taskToBeRetried.setPollCount(0);
        taskToBeRetried.setCallbackAfterSeconds(0);
        task.setRetried(true);
        return taskToBeRetried;
    }
1071364
public String schedule(TriggerTask task) {
        if (getCurrentScheduler() == null) {
            throw new IllegalStateException("New scheduler should be crea");
        }
        ScheduledFuture<?> future = getCurrentScheduler().schedule(task.getRunnable(), task.getTrigger());
        String id = Schedulers.getUUID();
        runningSchedullers.put(id, future);
        Schedulers.increaseNoOfRunningSchedullers();
        setCurrentScheduler(null);
        return id;
    }
1092940
public String schedule(Trigger trigger, Runnable task) {
        ScheduledFuture<?> future = getCurrentScheduler().schedule(task, trigger);
        String id = Schedulers.getUUID();
        runningSchedullers.put(id, future);
        Schedulers.increaseNoOfRunningSchedullers();
        setCurrentScheduler(null);
        return id;
    }
1283561
@Override
    public void execute() throws TaskExecutionFailedException {
        String account = bitTask.getAccount();
        String storeId = bitTask.getStoreId();
        String spaceId = bitTask.getSpaceId();
        log.info("starting space comparison where account={} storeId={} spaceId={}",
                 account,
                 storeId,
                 spaceId);

        File spaceListing = null;
        try {

            //write out space listing to file, counting all the items in the process.
            spaceListing = File.createTempFile("spaces", ".txt");
            int count = 0;
            try (BufferedWriter writer = new BufferedWriter(new FileWriter(spaceListing))) {
                Iterator<String> it = store.getSpaceContents(spaceId, null);
                while (it.hasNext()) {
                    if (count > 0) {
                        writer.write("\n");
                    }
                    writer.write(it.next());
                    count++;
                }
                writer.close();
            }

            //load the set of content ids
            WriteOnlyStringSet set = new WriteOnlyStringSet(count);
            try (BufferedReader reader = new BufferedReader(new FileReader(spaceListing))) {
                String contentId = null;
                while ((contentId = reader.readLine()) != null) {
                    set.add(contentId);
                }
            }

            // iterate current non-deleted manifest items
            Iterator<ManifestItem> manifestIterator =
                this.manifestStore.getItems(account, storeId, spaceId, false);

            while (manifestIterator.hasNext()) {
                // if not in storage provider
                ManifestItem item = manifestIterator.next();

                String contentId = item.getContentId();
                if (set.contains(contentId)) {
                    // reset missingInStorageProvider flag to false if true.
                    if (item.isMissingFromStorageProvider()) {
                        manifestStore.updateMissingFromStorageProviderFlag(account,
                                                                           storeId,
                                                                           spaceId,
                                                                           contentId,
                                                                           false);
                    }
                } else {
                    log.debug("no content found in storage provider for manifest item: {}", item);
                    if (!item.isDeleted()) {
                        // is missingInStorageProvider flag true?
                        if (item.isMissingFromStorageProvider()) {
                            this.bitLogStore
                                .write(account,
                                       storeId,
                                       spaceId,
                                       contentId,
                                       new Date(),
                                       storageProviderType,
                                       BitIntegrityResult.ERROR,
                                       null,
                                       null,
                                       item.getContentChecksum(),
                                       "Content item is in the manifest "
                                       + "but not in the storage provider in "
                                       + "the course of the last two bit integrity runs.");

                        } else {
                            manifestStore
                                .updateMissingFromStorageProviderFlag(account,
                                                                      storeId,
                                                                      spaceId,
                                                                      contentId,
                                                                      true);
                        }
                    }

                }
            }

        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            throw new TaskExecutionFailedException("failed to complete task: "
                                                   + ex.getMessage(), ex);
        } finally {
            if (spaceListing != null && spaceListing.exists()) {
                spaceListing.delete();
            }
        }
    }
436460
@Override
	public JobExecutionResult execute(String jobName) throws Exception {
		if (executor == null) {
			startNewSession();
		}

		Plan p = createProgramPlan(jobName);

		// Session management is disabled, revert this commit to enable
		//p.setJobId(jobID);
		//p.setSessionTimeout(sessionTimeout);

		JobExecutionResult result = executor.executePlan(p);

		this.lastJobExecutionResult = result;
		return result;
	}
1041082
public static Process executeFile(final String fileName) {
		try {
			final String command = "cmd /c \"" + fileName + "\"";
			logger.info(command);
			return Runtime.getRuntime().exec(command);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
1261652
@Override
    public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
        ScheduledExecutorService executor = getScheduledExecutor();
        try {
            ErrorHandler errorHandlerLocal = this.errorHandler != null ? this.errorHandler : TaskUtils
                    .getDefaultErrorHandler(true);
            return new ReschedulingRunnable(task, trigger, executor, errorHandlerLocal).schedule();
        } catch (RejectedExecutionException ex) {
            throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
        }
    }
1194269
public static String schedule(String schedulingPattern, Task task) {
		return scheduler.schedule(schedulingPattern, task);
	}
503792
public Runnable function() {
        return new Runnable() {
            @Override
            public void run() {
                try {
                    method.invoke(scheduled);
                } catch (IllegalAccessException e) {
                    WisdomTaskScheduler.getLogger().error("Error while accessing to the scheduled method {}.{}",
                            scheduled.getClass().getName(), method.getName(), e);
                } catch (InvocationTargetException e) {
                    WisdomTaskScheduler.getLogger().error("Error in scheduled method {}.{}",
                            scheduled.getClass().getName(), method.getName(), e);
                }
            }
        };
    }
1078081
public Scheduler schedule(String id, String pattern, Runnable task) {
		return schedule(id, new CronPattern(pattern), new RunnableTask(task));
	}