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

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


                recipientEmails.add(email);
                recipientTOs.add(userDataBinder.getUserTO(recipient));
            }
        }

        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.findAllSyncopeConfs());
        model.put("recipients", recipientTOs);
        model.put("events", notification.getEvents());

        String htmlBody;
        String textBody;
        try {
            htmlBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "mailTemplates/"
                    + notification.getTemplate() + ".html.vm", SyncopeConstants.DEFAULT_ENCODING, model);
            textBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "mailTemplates/"
                    + notification.getTemplate() + ".txt.vm", SyncopeConstants.DEFAULT_ENCODING, 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 storeExec(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

     * Mark NotificationTask with provided id as executed.
     *
     * @param taskId task to be updated
     */
    public void setTaskExecuted(final Long taskId) {
        NotificationTask task = taskDAO.find(taskId);
        task.setExecuted(true);
        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

       
        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.findAllSyncopeConfs());

        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 storeExec(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

     * Mark NotificationTask with provided id as executed.
     *
     * @param taskId task to be updated
     */
    public void setTaskExecuted(final Long taskId) {
        NotificationTask task = taskDAO.find(taskId);
        task.setExecuted(true);
        taskDAO.save(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", 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

     *
     * @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

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.