/** * Create a work flow task for the new content created and send a email to the corresponding role * moderator users * * @param contentlet The content * @param user The user that add the content * @param moderatorRole The role to assign the work flow * @throws DotDataException * @throws DotDataException */ public static void createWorkFlowTask(Contentlet contentlet, String userId, String moderatorRole) throws DotDataException { User user = getUserFromId(userId); StringBuffer changeHist = new StringBuffer("Task Added<br>"); WorkflowTask task = new WorkflowTask(); changeHist.append("Title: " + UtilHTML.escapeHTMLSpecialChars(contentlet.getTitle()) + "<br>"); task.setTitle( "A new content titled: " + UtilHTML.escapeHTMLSpecialChars(contentlet.getTitle()) + " has been posted."); task.setDescription( "A new content titled \"" + UtilHTML.escapeHTMLSpecialChars(contentlet.getTitle().trim()) + "\" has been posted by " + UtilHTML.escapeHTMLSpecialChars(user.getFullName()) + " (" + user.getEmailAddress() + ")"); changeHist.append( "Description: " + UtilHTML.escapeHTMLSpecialChars(task.getDescription()) + "<br>"); Role role = roleAPI.loadRoleByKey(moderatorRole); task.setBelongsTo(role.getId()); task.setAssignedTo("Nobody"); task.setModDate(new Date()); task.setCreationDate(new Date()); task.setCreatedBy(user.getUserId()); task.setStatus(WorkflowStatuses.OPEN.toString()); changeHist.append("Due Date: " + UtilMethods.dateToHTMLDate(task.getDueDate()) + " -> <br>"); task.setDueDate(null); task.setWebasset(contentlet.getInode()); // HibernateUtil.saveOrUpdate(task); // Save the work flow comment WorkflowComment taskComment = new WorkflowComment(); taskComment.setComment(task.getDescription()); taskComment.setCreationDate(new Date()); taskComment.setPostedBy(user.getUserId()); HibernateUtil.saveOrUpdate(taskComment); relAPI.addRelationship(task.getInode(), taskComment.getInode(), "child"); // Save the work flow history WorkflowHistory hist = new WorkflowHistory(); hist.setChangeDescription("Task Creation"); hist.setCreationDate(new Date()); hist.setMadeBy(user.getUserId()); HibernateUtil.saveOrUpdate(hist); relAPI.addRelationship(task.getInode(), hist.getInode(), "child"); // WorkflowEmailUtil.sendWorkflowChangeEmails (task, "New user content has been submitted", "New // Task", null); }