Search in sources :

Example 1 with JaffaSchedulerFrameworkException

use of org.jaffa.modules.scheduler.services.JaffaSchedulerFrameworkException in project jaffa-framework by jaffa-projects.

the class TaskMaintenanceComponent method initDropDownCodes.

/**
 * This will retrieve the set of codes for dropdowns, if any are required
 * @throws ApplicationExceptions This will be thrown in case any invalid data has been set.
 * @throws FrameworkException Indicates some system error.
 */
protected void initDropDownCodes() throws ApplicationExceptions, FrameworkException {
    ApplicationExceptions appExps = null;
    CodeHelperInDto input = null;
    if (getBusinessObjectXML() != null && getTaskType() != null) {
        Task task = SchedulerConfiguration.getInstance().getTask(getTaskType());
        if (task != null && task.getDataBean() != null) {
            try {
                setBusinessObject(JAXBHelper.unmarshalPayload(getBusinessObjectXML(), task.getDataBean()));
            } catch (JAXBException e) {
                log.error("A task has not been configured for the dataBean " + task.getDataBean(), e);
                throw new JaffaSchedulerFrameworkException(JaffaSchedulerFrameworkException.MISSING_TASK_FOR_DATA_BEAN, new Object[] { task.getDataBean() }, e);
            } catch (ClassNotFoundException e) {
                log.error("A task has not been configured for the dataBean " + task.getDataBean(), e);
                throw new JaffaSchedulerFrameworkException(JaffaSchedulerFrameworkException.MISSING_TASK_FOR_DATA_BEAN, new Object[] { task.getDataBean() }, e);
            }
        }
    }
    // Initialize the taskType DropDown
    m_taskTypeCodes = new TreeSet<String>();
    if (getBusinessObject() != null) {
        try {
            Task task = SchedulerConfiguration.getInstance().getTaskByDataBean(getBusinessObject().getClass().getName());
            if (task != null)
                m_taskTypeCodes.add(task.getType());
        } catch (ClassNotFoundException e) {
            log.error("A task has not been configured for the dataBean " + getBusinessObject().getClass().getName(), e);
            throw new JaffaSchedulerFrameworkException(JaffaSchedulerFrameworkException.MISSING_TASK_FOR_DATA_BEAN, new Object[] { getBusinessObject().getClass().getName() }, e);
        }
    } else {
        Task[] tasks = SchedulerConfiguration.getInstance().getTasks();
        if (tasks != null) {
            for (Task task : tasks) {
                if (task.isAutoCreateDataBean() && SchedulerBrowser.hasBrowseTaskAccess(task.getType()))
                    m_taskTypeCodes.add(task.getType());
            }
        }
    }
}
Also used : CodeHelperInDto(org.jaffa.components.codehelper.dto.CodeHelperInDto) Task(org.jaffa.modules.scheduler.services.configdomain.Task) ScheduledTask(org.jaffa.modules.scheduler.services.ScheduledTask) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) JAXBException(javax.xml.bind.JAXBException) JaffaSchedulerFrameworkException(org.jaffa.modules.scheduler.services.JaffaSchedulerFrameworkException)

Aggregations

JAXBException (javax.xml.bind.JAXBException)1 CodeHelperInDto (org.jaffa.components.codehelper.dto.CodeHelperInDto)1 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)1 JaffaSchedulerFrameworkException (org.jaffa.modules.scheduler.services.JaffaSchedulerFrameworkException)1 ScheduledTask (org.jaffa.modules.scheduler.services.ScheduledTask)1 Task (org.jaffa.modules.scheduler.services.configdomain.Task)1