Package org.apache.syncope.core.persistence.beans

Examples of org.apache.syncope.core.persistence.beans.NotificationTask


            } else {
                recipientEmails.add(email);
            }
        }

        NotificationTask task = new NotificationTask();
        task.setTraceLevel(notification.getTraceLevel());
        task.setRecipients(recipientEmails);
        task.setSender(notification.getSender());
        task.setSubject(notification.getSubject());

        final Map<String, Object> model = new HashMap<String, Object>();
        model.put("user", userDataBinder.getUserTO(user));

        String htmlBody;
        String textBody;
        try {
            htmlBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "mailTemplates/"
                    + notification.getTemplate() + ".html.vm", model);
            textBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "mailTemplates/"
                    + notification.getTemplate() + ".txt.vm", model);
        } catch (VelocityException e) {
            LOG.error("Could not get mail body", e);

            htmlBody = "";
            textBody = "";
        }
        task.setTextBody(textBody);
        task.setHtmlBody(htmlBody);

        return task;
    }
View Full Code Here


            } else {
                recipientEmails.add(email);
            }
        }

        NotificationTask task = new NotificationTask();
        task.setTraceLevel(notification.getTraceLevel());
        task.setRecipients(recipientEmails);
        task.setSender(notification.getSender());
        task.setSubject(notification.getSubject());

        final Map<String, Object> model = new HashMap<String, Object>();
        model.put("user", userDataBinder.getUserTO(user));
        model.put("syncopeConf", this.findAll());

        String htmlBody;
        String textBody;
        try {
            htmlBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "mailTemplates/"
                    + notification.getTemplate() + ".html.vm", "UTF-8", model);
            textBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "mailTemplates/"
                    + notification.getTemplate() + ".txt.vm", "UTF-8", model);
        } catch (VelocityException e) {
            LOG.error("Could not get mail body", e);

            htmlBody = "";
            textBody = "";
        }
        task.setTextBody(textBody);
        task.setHtmlBody(htmlBody);

        return task;
    }
View Full Code Here

     *
     * @param execution task execution.
     * @return merged task execution.
     */
    public TaskExec storeExecAndUpdateLatestExecStatus(final TaskExec execution) {
        NotificationTask task = taskDAO.find(execution.getTask().getId());
        task.addExec(execution);
        task.setLatestExecStatus(execution.getStatus());
        task = taskDAO.save(task);
        // NotificationTasks always have a single execution at most
        return task.getExecs().get(0);
    }
View Full Code Here

     * Update latest execution status of a NotificationTask.
     *
     * @param execution task execution
     */
    public void updateLatestExecStatus(final TaskExec execution) {
        NotificationTask task = taskDAO.find(execution.getTask().getId());
        task.setLatestExecStatus(execution.getStatus());
        taskDAO.save(task);
    }
View Full Code Here

        LOG.debug("Sleeping again...");
    }

    private boolean hasToBeRegistered(final TaskExec execution) {
        NotificationTask task = (NotificationTask) execution.getTask();

        // True if either failed and failures have to be registered, or if ALL
        // has to be registered.
        return (Status.valueOf(execution.getStatus()) == Status.NOT_SENT
                && task.getTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal())
                || task.getTraceLevel() == TraceLevel.ALL;
    }
View Full Code Here

            } else {
                recipientEmails.add(email);
            }
        }

        NotificationTask task = new NotificationTask();
        task.setTraceLevel(notification.getTraceLevel());
        task.setRecipients(recipientEmails);
        task.setSender(notification.getSender());
        task.setSubject(notification.getSubject());

        final Map<String, Object> model = new HashMap<String, Object>();
        model.put("user", userDataBinder.getUserTO(user));
        model.put("syncopeConf", this.findAll());

        String htmlBody;
        String textBody;
        try {
            htmlBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "mailTemplates/"
                    + notification.getTemplate() + ".html.vm", "UTF-8", model);
            textBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "mailTemplates/"
                    + notification.getTemplate() + ".txt.vm", "UTF-8", model);
        } catch (VelocityException e) {
            LOG.error("Could not get mail body", e);

            htmlBody = "";
            textBody = "";
        }
        task.setTextBody(textBody);
        task.setHtmlBody(htmlBody);

        return task;
    }
View Full Code Here

        LOG.debug("Sleeping again...");
    }

    private boolean hasToBeRegistered(final TaskExec execution) {
        NotificationTask task = (NotificationTask) execution.getTask();

        // True if either failed and failures have to be registered, or if ALL
        // has to be registered.
        return (Status.valueOf(execution.getStatus()) == Status.NOT_SENT
                && task.getTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal())
                || task.getTraceLevel() == TraceLevel.ALL;
    }
View Full Code Here

     *
     * @param execution task execution.
     * @return merged task execution.
     */
    public TaskExec storeExecAndUpdateLatestExecStatus(final TaskExec execution) {
        NotificationTask task = taskDAO.find(execution.getTask().getId());
        task.addExec(execution);
        task.setExecuted(true);
        task = taskDAO.save(task);
        // NotificationTasks always have a single execution at most
        return task.getExecs().get(0);
    }
View Full Code Here

     * @param taskId task id
     * @param status status
     * @return number of task executions
     */
    public long countExecutionsWithStatus(final Long taskId, final String status) {
        NotificationTask task = taskDAO.find(taskId);
        long count = 0;
        for (TaskExec taskExec : task.getExecs()) {
            if (status == null) {
                if (taskExec.getStatus() == null) {
                    count++;
                }
            } else if (status.equals(taskExec.getStatus())) {
View Full Code Here

        for (int i = 0; i < 10; i++) {
            notificationJob.execute(null);
        }

        // 6. get NotificationTask, count number of executions
        NotificationTask foundTask = null;
        for (NotificationTask task : taskDAO.findAll(NotificationTask.class)) {
            if (sender.equals(task.getSender())) {
                foundTask = task;
            }
        }
        assertNotNull(foundTask);
        assertEquals(6, notificationManager.countExecutionsWithStatus(foundTask.getId(),
                NotificationJob.Status.NOT_SENT.name()));

        // 7. start mail server again
        startGreenMail();
View Full Code Here

TOP

Related Classes of org.apache.syncope.core.persistence.beans.NotificationTask

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.