private String postComment( String projectId, String entityId, String text, String name, String email) { if (projectId == null) throw new RuntimeException("projectId == null"); if (Str.isBlank(text)) throw new RuntimeException("Comment is empty."); Project project = projectDao.getById(projectId); AEntity entity = daoService.getById(entityId); Comment comment = commentDao.postComment(entity, "<nowiki>" + text + "</nowiki>", name, email, true); String message = "New comment posted"; if (!Str.isBlank(name)) message += " by " + name; subscriptionService.notifySubscribers(entity, message, project, email); project.updateHomepage(entity, true); String reference = ((ReferenceSupport) entity).getReference(); String label = ((LabelSupport) entity).getLabel(); ProjectEvent event = projectEventDao.postEvent( project, comment.getAuthorName() + " commented on " + reference + " " + label, entity); if (Str.isEmail(email)) subscriptionService.subscribe(email, entity); transactionService.commit(); webApplication.sendToConversationsByProject(project, event); return "<h2>Comment posted</h2><p>Thank you for your comment! It will be visible in a few minutes.</p><p>Back to <strong>" + KunagiUtl.createExternalRelativeHtmlAnchor(entity) + "</strong>.</p>"; }