use of eu.bcvsolutions.idm.core.scheduler.jaxb.IdmScheduledTaskType in project CzechIdMng by bcvsolutions.
the class AbstractScheduledTaskInitializer method initScheduledTask.
/**
* Method initial default long running tasks. Task will be loaded from
* resources.
*
* @param tasksInputStream
*/
protected void initScheduledTask(InputStream tasksInputStream) {
if (tasksInputStream == null) {
LOG.warn("For module: [{}] is empty parameter 'tasksInputStream', skip init tasks for this module.", getModule());
}
Unmarshaller jaxbUnmarshaller = null;
//
try {
jaxbUnmarshaller = jaxbContext.createUnmarshaller();
} catch (JAXBException e) {
throw new ResultCodeException(CoreResultCode.XML_JAXB_INIT_ERROR, e);
}
try {
IdmScheduledTasksType tasks = (IdmScheduledTasksType) jaxbUnmarshaller.unmarshal(tasksInputStream);
List<Task> allExistingTasks = schedulerService.getAllTasks();
if (tasks != null) {
for (IdmScheduledTaskType taskType : tasks.getTasks()) {
try {
Task task = typeToTask(taskType);
LOG.debug("Task with type [{}] is successfully initialized. Try to save.", taskType.getTaskType());
if (existSimilarTask(task, allExistingTasks)) {
LOG.debug("Task with type [{}] already exist, skip save this task.", taskType.getTaskType());
continue;
}
LOG.info("Create new task with type [{}].", taskType.getTaskType());
task = schedulerService.createTask(task);
createAndSaveTriggers(task, taskType);
} catch (ClassNotFoundException e) {
LOG.error("Scheduled task with task type [{}] can't be init. Skip this task. Error message: [{}]", taskType.getTaskType(), e.getMessage());
}
}
}
} catch (JAXBException e) {
LOG.error("Scheduled task type validation failed, file name: {}, module: {}, error message: {}", getTasksXmlPath(), getModule(), e.getLocalizedMessage());
}
}
use of eu.bcvsolutions.idm.core.scheduler.jaxb.IdmScheduledTaskType in project CzechIdMng by bcvsolutions.
the class BaseScheduledTaskInitializer method initScheduledTask.
/**
* Method initial default long running tasks. Task will be loaded from
* resources.
*
* @param tasksInputStream
*/
protected void initScheduledTask(InputStream tasksInputStream) {
if (tasksInputStream == null) {
LOG.warn("For module: [{}] is empty parameter 'tasksInputStream', skip init tasks for this module.", getModule());
}
Unmarshaller jaxbUnmarshaller = null;
//
try {
jaxbUnmarshaller = jaxbContext.createUnmarshaller();
} catch (JAXBException e) {
throw new ResultCodeException(CoreResultCode.XML_JAXB_INIT_ERROR, e);
}
try {
IdmScheduledTasksType tasks = (IdmScheduledTasksType) jaxbUnmarshaller.unmarshal(tasksInputStream);
List<Task> allExistingTasks = schedulerService.getAllTasks();
if (tasks != null) {
for (IdmScheduledTaskType taskType : tasks.getTasks()) {
try {
Task task = typeToTask(taskType);
LOG.debug("Task with type [{}] is successfully initialized. Try to save.", taskType.getTaskType());
if (existSimilarTask(task, allExistingTasks)) {
LOG.debug("Task with type [{}] already exist, skip save this task.", taskType.getTaskType());
continue;
}
LOG.info("Create new task with type [{}].", taskType.getTaskType());
task = schedulerService.createTask(task);
createAndSaveTriggers(task, taskType);
} catch (ClassNotFoundException e) {
LOG.error("Scheduled task with task type [{}] can't be init. Skip this task. Error message: [{}]", taskType.getTaskType(), e.getMessage());
}
}
}
} catch (JAXBException e) {
LOG.error("Scheduled task type validation failed, file name: {}, module: {}, error message: {}", getTasksXmlPath(), getModule(), e.getLocalizedMessage());
}
}
Aggregations