Search in sources :

Example 1 with TaskException

use of org.wso2.carbon.ntask.common.TaskException in project carbon-business-process by wso2.

the class TaskCleanupSchedulerUtil method initTaskCleanupJob.

/**
 * Initialises the task clean up task.
 *
 * @throws HumanTaskServerException :
 */
public static void initTaskCleanupJob() throws HumanTaskServerException {
    HumanTaskServerConfiguration serverConfig = HumanTaskCleanupSchedulerServiceComponent.getHumanTaskServer().getServerConfig();
    if (serverConfig.isTaskCleanupEnabled()) {
        try {
            log.info("Initialising the task cleanup service.....");
            HumanTaskCleanupSchedulerServiceComponent.getTaskService().registerTaskType(HumanTaskConstants.HUMANTASK_TASK_TYPE);
            TaskManager taskManager = HumanTaskCleanupSchedulerServiceComponent.getTaskService().getTaskManager(HumanTaskConstants.HUMANTASK_TASK_TYPE);
            TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo();
            triggerInfo.setCronExpression(serverConfig.getTaskCleanupCronExpression());
            triggerInfo.setDisallowConcurrentExecution(true);
            Map<String, String> propertyMap = new LinkedHashMap<String, String>();
            TaskInfo taskInfo = new TaskInfo(HumanTaskConstants.HUMANTASK_CLEANUP_JOB, RemovableTaskCleanupJob.class.getName(), propertyMap, triggerInfo);
            taskManager.registerTask(taskInfo);
            taskManager.rescheduleTask(HumanTaskConstants.HUMANTASK_CLEANUP_JOB);
        } catch (TaskException ex) {
            String errMsg = "Error occurred while registering task type : " + HumanTaskConstants.HUMANTASK_TASK_TYPE;
            throw new HumanTaskServerException(errMsg, ex);
        }
    }
}
Also used : TaskInfo(org.wso2.carbon.ntask.core.TaskInfo) TaskManager(org.wso2.carbon.ntask.core.TaskManager) TaskException(org.wso2.carbon.ntask.common.TaskException) HumanTaskServerException(org.wso2.carbon.humantask.core.engine.HumanTaskServerException) HumanTaskServerConfiguration(org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration) RemovableTaskCleanupJob(org.wso2.carbon.humantask.cleanup.scheduler.ntask.RemovableTaskCleanupJob) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1 RemovableTaskCleanupJob (org.wso2.carbon.humantask.cleanup.scheduler.ntask.RemovableTaskCleanupJob)1 HumanTaskServerConfiguration (org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration)1 HumanTaskServerException (org.wso2.carbon.humantask.core.engine.HumanTaskServerException)1 TaskException (org.wso2.carbon.ntask.common.TaskException)1 TaskInfo (org.wso2.carbon.ntask.core.TaskInfo)1 TaskManager (org.wso2.carbon.ntask.core.TaskManager)1