Package org.apache.synapse.task

Examples of org.apache.synapse.task.TaskDescription


        List<TaskDescription> taskDescriptions = new ArrayList<TaskDescription>();
        Iterator<TaskDescription> iterator = schedulingManager.getAllTaskDescriptions(
                getConfigContext());

        while (iterator.hasNext()) {
            TaskDescription taskDescription = iterator.next();
            if (taskDescription != null) {
                taskDescriptions.add(taskDescription);
            }
        }
        if (log.isDebugEnabled()) {
View Full Code Here


     */
    private static TaskDescription validateAndCreate(
            OMElement taskElement) throws TaskManagementException {

        validateTaskElement(taskElement);
        TaskDescription taskDescription =
                TaskDescriptionFactory.createTaskDescription(taskElement, TASK_OM_NAMESPACE);
        validateTaskDescription(taskDescription);
        if (log.isDebugEnabled()) {
            log.debug("Task Description : " + taskDescription);
        }
View Full Code Here

        Iterator iterator = element.getChildrenWithLocalName("task");
        while (iterator.hasNext()) {
            OMElement taskElement = (OMElement) iterator.next();
            if (taskElement != null) {
                TaskDescription taskDescription = TaskDescriptionFactory.createTaskDescription(
                        taskElement, TASK_OM_NAMESPACE);
                if (taskDescription != null) {
                    descriptions.add(taskDescription);
                }
            }
View Full Code Here

        String startTimeStr = request.getParameter("startTime");
        if (startTimeStr == null || "".equals(startTimeStr)) {
            handleException("Task starting time cannot be null or empty");
        }

        TaskDescription taskDescription = new TaskDescription();
        taskDescription.setName(taskName.trim());
        taskDescription.setTaskClass(taskClass.trim());
        taskDescription.setGroup(taskGroup.trim());
        taskDescription.setDescription("Test Task Description");

        String[] timeContents = startTimeStr.split("-");
        int year = Integer.parseInt(timeContents[0]);
        int month = Integer.parseInt(timeContents[1]);
        int day = Integer.parseInt(timeContents[2]);

        long startTime = new Date(year, month, day).getTime();
        taskDescription.setStartTime(new Date(startTime));

        String trigger = request.getParameter("taskTrigger");
        if (trigger != null && !"".equals(trigger)) {
            if ("simple".equals(trigger)) {


                String interval = request.getParameter("triggerInterval");
                if (interval != null && !"".equals(interval)) {
                    try {
                        taskDescription.setInterval(Long.parseLong(interval.trim()) * 1000);
                    } catch (NumberFormatException e) {
                        handleException("Invalid value for interval (Expected type is long) : " +
                                interval);
                    }
                }

                String count = request.getParameter("triggerCount");
                if (count != null && !"".equals(count)) {
                    try {
                        taskDescription.setCount(Integer.parseInt(count.trim()));
                    } catch (NumberFormatException e) {
                        handleException("Invalid value for Count (Expected type is int) : " +
                                count);
                    }
                }

            } else if ("cron".equals(trigger)) {

                String cron = request.getParameter("triggerCron");
                if (cron != null && !"".equals(cron)) {
                    taskDescription.setCron(cron.trim());
                } else {
                    handleException("Cron expression cannot be empty for cron trigger");
                }
            }
        } else {
View Full Code Here

        List<TaskDescription> taskDescriptions = new ArrayList<TaskDescription>();

        Iterator<TaskDescription> iterator = functionSchedulingManager.getAllTaskDescriptions(getConfigContext());
        while (iterator.hasNext()) {
            TaskDescription taskDescription = iterator.next();
            if (taskDescription != null) {
                taskDescriptions.add(taskDescription);
            }
        }
        if (log.isDebugEnabled()) {
View Full Code Here

                                                     SynapseEnvironment synapseEnvironment) {

        if (log.isDebugEnabled()) {
            log.debug("Returning a Startup : " + name + " from the configuration");
        }
        TaskDescription taskDescription =
                synapseEnvironment.getTaskManager().
                        getTaskDescriptionRepository().getTaskDescription(name);
        if (taskDescription != null) {
            if (log.isDebugEnabled()) {
                log.debug("Returning a TaskDescription : " + taskDescription);
View Full Code Here

            List<TaskDescription> taskDescriptions = new ArrayList<TaskDescription>();

            Iterator<TaskDescription> iterator =
                    StartupUtils.getAllTaskDescriptions(getSynapseEnvironment());
            while (iterator.hasNext()) {
                TaskDescription taskDescription = iterator.next();
                if (taskDescription != null) {
                    taskDescriptions.add(taskDescription);
                }
            }
            if (log.isDebugEnabled()) {
View Full Code Here

        }
        Iterator iterator = taskRoot.getChildElements();
        while (iterator.hasNext()) {
            OMElement taskElement = (OMElement) iterator.next();
            if (taskElement != null) {
                TaskDescription taskDescription = TaskDescriptionFactory.createTaskDescription(
                        taskElement, TASK_OM_NAMESPACE);
                if (taskDescription != null) {
                    descriptions.add(taskDescription);
                }
            }
View Full Code Here

        validateTaskElement(taskElement);

        if (log.isDebugEnabled()) {
            log.debug("Retrieved Task Configuration : " + returnElement);
        }
        TaskDescription taskDescription = TaskDescriptionFactory.createTaskDescription(taskElement,
                TASK_OM_NAMESPACE);
        if (log.isDebugEnabled()) {
            log.debug("Retrieved Task : " + taskDescription);
        }
        validateTaskDescription(taskDescription);
        taskDescription.setInterval(taskDescription.getInterval()/1000);
        return taskDescription;
    }
View Full Code Here

        String taskClass = request.getParameter("taskClass");
        if (taskClass == null || "".equals(taskClass)) {
            handleException("Task Class cannot be null or empty");
        }

        TaskDescription taskDescription = new TaskDescription();
        taskDescription.setName(name.trim());
        taskDescription.setGroup(group.trim());
        taskDescription.setTaskClass(taskClass.trim());

        String trigger = request.getParameter("taskTrigger");

        if (trigger != null && !"".equals(trigger)) {
            if ("simple".equals(trigger)) {


                String interval = request.getParameter("triggerInterval");
                if (interval != null && !"".equals(interval)) {
                    try {
                        taskDescription.setInterval(Long.parseLong(interval.trim()) * 1000);
                    } catch (NumberFormatException e) {
                        handleException("Invalid value for interval (Expected type is long) : " +
                                interval);
                    }

                }

                String count = request.getParameter("triggerCount");
                if (count != null && !"".equals(count)) {
                    try {
                        taskDescription.setCount(Integer.parseInt(count.trim()));
                    } catch (NumberFormatException e) {
                        handleException("Invalid value for Count (Expected type is int) : " +
                                count);
                    }
                }

            } else if ("cron".equals(trigger)) {

                String cron = request.getParameter("triggerCron");
                if (cron != null && !"".equals(cron)) {
                    taskDescription.setCron(cron.trim());
                } else {
                    handleException("Cron expression cannot be empty for cron trigger");
                }
            }
        } else {
            handleException("No Trigger has been selected");
        }

        String pinnedServers = request.getParameter("pinnedServers");
        if (pinnedServers != null || !"".equals(pinnedServers)) {
            StringTokenizer st = new StringTokenizer(pinnedServers, " ,");
            List<String> pinnedServersList = new ArrayList<String>();
            while (st.hasMoreTokens()) {
                String token = st.nextToken();
                if (token.length() != 0) {
                    pinnedServersList.add(token);
                }
            }
            taskDescription.setPinnedServers(pinnedServersList);
        }

        String propertyCount = request.getParameter("propertyCount");
        if (propertyCount != null && !"".equals(propertyCount)) {

            try {

                int propCount = Integer.parseInt(propertyCount.trim());
                if (log.isDebugEnabled()) {
                    log.debug("Number of properties : " + propCount);
                }

                for (int i = 0; i < propCount; i++) {

                    String id = "property_name_hidden" + String.valueOf(i);
                    String propName = request.getParameter(id);

                    if (propName != null && !"".equals(propName)) {

                        String propertyType = request.getParameter("propertyTypeSelection" +
                                String.valueOf(i));

                        if ("literal".equals(propertyType)) {

                            String value = request.getParameter("textField" + String.valueOf(i));

                            if (log.isDebugEnabled()) {
                                log.debug("[ Property Name : " + name + " ]" +
                                        "[ Property Value : " + value + " ]");
                            }

                            if (value != null && !"".equals(value)) {

                                OMElement propElem = FACTORY.createOMElement("property",
                                        TASK_OM_NAMESPACE);
                                OMNamespace nullNS = FACTORY.createOMNamespace("", "");
                                propElem.addAttribute("name", propName.trim(), nullNS);
                                propElem.addAttribute("value", value.trim(), nullNS);
                                taskDescription.addProperty(propElem);
                            }

                        } else if ("xml".equals(propertyType)) {

                            String value = request.getParameter("textArea" + String.valueOf(i));

                            if (log.isDebugEnabled()) {
                                log.debug("[ Property Name : " + name + " ][ Property Value : " +
                                        value + " ]");
                            }

                            if (value != null && !"".equals(value)) {

                                OMElement propElem = FACTORY.createOMElement("property",
                                        TASK_OM_NAMESPACE);
                                OMNamespace nullNS = FACTORY.createOMNamespace("", "");
                                propElem.addAttribute("name", propName.trim(), nullNS);
                                try {
                                    propElem.addChild(createOMElement(value.trim()));
                                } catch (Throwable e) {
                                    handleException("Invalid XML has been provided " +
                                            "for property : " + propName);
                                }
                                taskDescription.addProperty(propElem);
                            }
                        }
                    }
                }
            } catch (NumberFormatException ignored) {
View Full Code Here

TOP

Related Classes of org.apache.synapse.task.TaskDescription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.