public void testTag() throws Exception { // set Data setData(); Tag tag = createTag("Tag1"); Tag tag2 = createTag("Tag2"); Tag tag3 = createTag("Tag3"); // add tag List<Tag> tags = new ArrayList<Tag>(); tags.add(tag); tags.add(tag2); tags.add(tag3); Topic topic = forumService_.getTopic(categoryId, forumId, topicId, ""); forumService_.addTag(tags, USER_ROOT, topic.getPath()); // get Tags name in topic by root. // List<String> list = forumService_.getTagNameInTopic(USER_ROOT+","+topicId); // Test get tag String id = Utils.TAG + tag.getName(); tag = forumService_.getTag(id); assertNotNull(tag); // Get all tag // assertEquals("All tags size is not 3", 3, forumService_.getAllTags().size()); }
public void testForumAdministration() throws Exception { ForumAdministration administration = createForumAdministration(); forumService_.saveForumAdministration(administration); administration = forumService_.getForumAdministration(); assertNotNull(administration); assertEquals(administration.getForumSortBy(), "forumName"); }
private void killData() throws Exception { List<Category> cats = forumService_.getCategories(); if (cats.size() > 0) { for (Category category : cats) { forumService_.removeCategory(category.getId()); } } }
public void testUserLogin() throws Exception { String[] userIds = new String[] {USER_ROOT, USER_JOHN, USER_DEMO}; for (int i = 0; i < userIds.length; i++) { try { forumService_.getQuickProfile(userIds[i]); } catch (Exception e) { forumService_.saveUserProfile(createdUserProfile(userIds[i]), true, true); } } // Add user login forumService_.userLogin(USER_ROOT); forumService_.userLogin(USER_JOHN); forumService_.userLogin(USER_DEMO); // Get all user online: assertEquals("Get all user online", 3, forumService_.getOnlineUsers().size()); // isOnline assertEquals("John is not Online", forumService_.isOnline(USER_JOHN), true); // get Last Login assertEquals("Demo can't last Login", forumService_.getLastLogin(), USER_DEMO); // userLogout forumService_.userLogout(USER_DEMO); assertEquals("Demo is online", forumService_.isOnline(USER_DEMO), false); }
/* * public void testPoll() throws Exception{ //set Data setData(); Poll poll = createPoll("question to this poll1", new String[]{"option 1", "option 2", "option 3"}); // Save new poll forumService_.savePoll(categoryId, forumId, topicId, poll, true, false); // Get poll assertNotNull(forumService_.getPoll(categoryId, forumId, topicId)); // Set close for poll poll.setIsClosed(true); * forumService_.setClosedPoll(categoryId, forumId, topicId, poll); assertEquals(true, forumService_.getPoll(categoryId, forumId, topicId).getIsClosed()); // Delete poll forumService_.removePoll(categoryId, forumId, topicId); assertNull(forumService_.getPoll(categoryId, forumId, topicId)); } */ public void testGetObject() throws Exception { // set Data setData(); // Test get object by path String topicPath = forumService_.getForumHomePath(); topicPath = categoryId + "/" + forumId + "/" + topicId; assertNotNull(forumService_.getObjectNameByPath(topicPath)); // Test get object by id assertNotNull(forumService_.getObjectNameById(forumId, Utils.FORUM)); }
public void testExportXML() throws Exception { Category cat = createCategory(getId(Utils.CATEGORY)); forumService_.saveCategory(cat, true); cat = forumService_.getCategory(cat.getId()); Forum forum = createdForum(); forumService_.saveForum(cat.getId(), forum, true); forum = forumService_.getForum(cat.getId(), forum.getId()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); forumService_.exportXML( cat.getId(), forum.getId(), new ArrayList<String>(), forum.getPath(), bos, false); assertEquals("can't export Forum into XML file", bos.size() > 0, true); }
private void setData() throws Exception { killData(); Category cat = createCategory(getId(Utils.CATEGORY)); this.categoryId = cat.getId(); forumService_.saveCategory(cat, true); Forum forum = createdForum(); this.forumId = forum.getId(); forumService_.saveForum(categoryId, forum, true); Topic topic = createdTopic("root"); forumService_.saveTopic(categoryId, forumId, topic, true, false, new MessageBuilder()); this.topicId = topic.getId(); }
public void testTopicType() throws Exception { // set Data setData(); TopicType topicType = createTopicType("Musics"); forumService_.saveTopicType(topicType); forumService_.saveTopicType(createTopicType("Dance")); forumService_.saveTopicType(createTopicType("Sing")); topicType = forumService_.getTopicType(topicType.getId()); assertNotSame("Can not save and get Topic type.", topicType.getId(), TopicType.DEFAULT_ID); // Check get All List<TopicType> listTopicType = forumService_.getTopicTypes(); assertEquals( "Can not get all topic type. Size of topicTypes list is not 3.", listTopicType.size(), 3); }
public void testCategory() throws Exception { String[] catIds = new String[] {getId(Utils.CATEGORY), getId(Utils.CATEGORY), getId(Utils.CATEGORY)}; // add category forumService_.saveCategory(createCategory(catIds[0]), true); forumService_.saveCategory(createCategory(catIds[1]), true); forumService_.saveCategory(createCategory(catIds[2]), true); Category category = forumService_.getCategory(catIds[0]); assertNotNull("Category is null", category); // get categories List<Category> categories = forumService_.getCategories(); assertEquals(categories.size(), 3); // update category category.setCategoryName("ReName Category"); forumService_.saveCategory(category, false); Category updatedCat = forumService_.getCategory(catIds[0]); assertEquals("Category name is not change", "ReName Category", updatedCat.getCategoryName()); // test removeCategory for (int i = 0; i < 3; ++i) { forumService_.removeCategory(catIds[i]); } categories = forumService_.getCategories(); assertEquals("Size categories can not equals 0", categories.size(), 0); }
// BookMark public void testBookMark() throws Exception { // set Data setData(); // add bookmark String bookMark = Utils.CATEGORY + "//" + categoryId; forumService_.saveUserBookmark("root", bookMark, true); bookMark = Utils.FORUM + "//" + categoryId + "/" + forumId; forumService_.saveUserBookmark("root", bookMark, true); // get bookmark List<String> bookMarks = new ArrayList<String>(); bookMarks.addAll(forumService_.getBookmarks("root")); assertEquals(bookMarks.size(), 2); }
public void testWatch() throws Exception { // set Data setData(); // addWatch String topicPath = categoryId + "/" + forumId; List<String> values = new ArrayList<String>(); values.add("*****@*****.**"); forumService_.addWatch(1, topicPath, values, "root"); // watch by user List<Watch> watchs = forumService_.getWatchByUser("root"); assertEquals(watchs.get(0).getEmail(), values.get(0)); forumService_.removeWatch(1, topicPath, "/" + values.get(0)); watchs = forumService_.getWatchByUser("root"); assertEquals(watchs.size(), 0); }
protected UserProfile getUserProfile() throws Exception { if (this.userProfile == null) { try { this.userProfile = this.getAncestorOfType(UIForumPortlet.class).getUserProfile(); } catch (Exception e) { ForumService forumService = (ForumService) ExoContainerContext.getCurrentContainer() .getComponentInstanceOfType(ForumService.class); userProfile = forumService.getDefaultUserProfile(UserHelper.getCurrentUser(), ForumUtils.EMPTY_STR); } } return this.userProfile; }
public void testUserProfile() throws Exception { String userName = "******"; UserProfile userProfile = createdUserProfile(userName); // save UserProfile forumService_.saveUserProfile(userProfile, true, true); // getUserInfo userProfile = forumService_.getUserInfo(userName); assertNotNull("Get info UserProfile is null", userProfile); // get Default userProfile = forumService_.getDefaultUserProfile(userName, ""); assertNotNull("Get default UserProfile is null", userProfile); // getUserInformations userProfile = forumService_.getUserInformations(userProfile); assertNotNull("Get informations UserProfile is null", userProfile); // getUserSettingProfile userProfile = forumService_.getUserSettingProfile(userName); assertNotNull("Get Setting UserProfile is not null", userProfile); // saveUserSettingProfile assertEquals("Default AutoWatchMyTopics is false", userProfile.getIsAutoWatchMyTopics(), false); userProfile.setIsAutoWatchMyTopics(true); forumService_.saveUserSettingProfile(userProfile); userProfile = forumService_.getUserSettingProfile(userName); assertEquals( "Edit AutoWatchMyTopics and can't save this property. AutoWatchMyTopics is false", userProfile.getIsAutoWatchMyTopics(), true); // }
private static String getFormatDate(int dateFormat, Date myDate) { if (myDate == null) return ""; String format = (dateFormat == DateFormat.LONG) ? "EEE,MMM dd,yyyy" : "MM/dd/yyyy"; try { String userName = getCurrentUser(); if (!isFieldEmpty(userName)) { org.exoplatform.forum.service.ForumService forumService = (org.exoplatform.forum.service.ForumService) ExoContainerContext.getCurrentContainer() .getComponentInstanceOfType(org.exoplatform.forum.service.ForumService.class); org.exoplatform.forum.service.UserProfile profile = forumService.getUserSettingProfile(userName); format = (dateFormat == DateFormat.LONG) ? profile.getLongDateFormat() : profile.getShortDateFormat(); } } catch (Exception e) { log.debug("No forum settings found for date format. Will use format " + format); } format = format.replaceAll("D", "E"); return TimeConvertUtils.getFormatDate(myDate, format); }
public void testImportXML() throws Exception { Category cat = createCategory(getId(Utils.CATEGORY)); forumService_.saveCategory(cat, true); cat = forumService_.getCategory(cat.getId()); String pathNode = cat.getPath(); assertEquals( "Before import data, category don't have any forum", forumService_.getForums(cat.getId(), "").size(), 0); try { File file = new File(System.getProperty("user.dir") + "/src/test/resources/conf/portal/Data.xml"); String content = FileUtils.readFileToString(file, "UTF-8"); byte currentXMLBytes[] = content.getBytes(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(currentXMLBytes); // Import forum into category forumService_.importXML( pathNode, byteArrayInputStream, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW); assertEquals( "Can't import forum into category", forumService_.getForums(cat.getId(), "").size(), 1); } catch (IOException e) { log.debug("Failed to test importXML", e); } }
@Override public void run() { super.run(); try { ForumService forumService = (ForumService) container.getComponentInstanceOfType(ForumService.class); String masterHost = System.getProperty("tenant.masterhost"); if (masterHost == null) { forumService.updateLoggedinUsers(); } else { String currentLoginRepo = ((RepositoryService) container.getComponentInstanceOfType(RepositoryService.class)) .getCurrentRepository() .getConfiguration() .getName(); forumService.updateLoggedinUsers(currentLoginRepo); } } catch (Exception e) { log_.warn("Period login job can not execute ..."); } if (log_.isDebugEnabled()) { log_.info("\n\nForum Statistic has been updated for logged in user by a period login job"); } }
// Private Message public void testPrivateMessage() throws Exception { ForumPrivateMessage privateMessage = new ForumPrivateMessage(); privateMessage.setFrom("demo"); privateMessage.setIsUnread(false); privateMessage.setName("privateMessage Name"); privateMessage.setMessage("Content privateMessage"); privateMessage.setSendTo("root"); // savePtivateMs forumService_.savePrivateMessage(privateMessage); // get Private Message is SEND_MESSAGE JCRPageList pageList = forumService_.getPrivateMessage("demo", Utils.SEND_MESSAGE); assertNotNull(pageList); assertEquals(pageList.getAvailable(), 1); privateMessage = (ForumPrivateMessage) pageList.getPage(1).get(0); String privateMessageId_SEND = privateMessage.getId(); // get Private Message is RECEIVE_MESSAGE pageList = forumService_.getPrivateMessage("root", Utils.RECEIVE_MESSAGE); assertNotNull(pageList); assertEquals(pageList.getAvailable(), 1); privateMessage = (ForumPrivateMessage) pageList.getPage(1).get(0); String privateMessageId_RECEIVE = privateMessage.getId(); // long t = forumService_.getNewPrivateMessage("root"); assertEquals(t, 1); // Remove PrivateMessage forumService_.removePrivateMessage(privateMessageId_SEND, "demo", Utils.SEND_MESSAGE); pageList = forumService_.getPrivateMessage("demo", Utils.SEND_MESSAGE); assertEquals(pageList.getAvailable(), 0); forumService_.removePrivateMessage(privateMessageId_RECEIVE, "root", Utils.RECEIVE_MESSAGE); pageList = forumService_.getPrivateMessage("root", Utils.RECEIVE_MESSAGE); assertEquals(pageList.getAvailable(), 0); // }
public void testIpBan() throws Exception { // set Data setData(); // set Ip ban String ip = "192.168.1.10"; // save Ip ban forumService_.addBanIP(ip); // get Ip ban List<String> listBans = forumService_.getBanList(); assertEquals("Ip have adding in listBans", listBans.get(0), ip); // addBanIPForum forumService_.addBanIPForum(ip, categoryId + "/" + forumId); // getForumBanList List<String> listIpBanInForum = forumService_.getForumBanList(categoryId + "/" + forumId); assertEquals("Ip add in forum", listIpBanInForum.get(0), ip); // removeBanIPForum forumService_.removeBanIPForum(ip, categoryId + "/" + forumId); listIpBanInForum = forumService_.getForumBanList(categoryId + "/" + forumId); assertEquals("Ip is removed in listIpBanInForum, size is not 0 ", listIpBanInForum.size(), 0); // removeIpBan forumService_.removeBan(ip); listBans = forumService_.getBanList(); assertEquals("Ip is removed in listBans, size is not 0 ", listBans.size(), 0); }
public void testPost() throws Exception { // set Data setData(); List<Post> posts = new ArrayList<Post>(); for (int i = 0; i < 25; ++i) { Post post = createdPost(); posts.add(post); forumService_.savePost(categoryId, forumId, topicId, post, true, new MessageBuilder()); } // getPost assertNotNull(forumService_.getPost(categoryId, forumId, topicId, posts.get(0).getId())); // get ListPost JCRPageList pagePosts = forumService_.getPosts(categoryId, forumId, topicId, "", "", "", "root"); assertEquals( pagePosts.getAvailable(), posts.size() + 1); // size = 26 (first post and new postList) List page1 = pagePosts.getPage(1); assertEquals(page1.size(), 10); List page3 = pagePosts.getPage(3); assertEquals(page3.size(), 6); // getPost by Ip JCRPageList pageIpPosts = forumService_.getListPostsByIP("192.168.1.11", null); assertEquals(pageIpPosts.getAvailable(), 25); // size = 25 (not content first post) // update Post First Post newPost = (Post) pagePosts.getPage(1).get(1); newPost.setMessage("New message"); forumService_.savePost(categoryId, forumId, topicId, newPost, false, new MessageBuilder()); assertEquals( "New message", forumService_.getPost(categoryId, forumId, topicId, newPost.getId()).getMessage()); // test movePost Topic topicnew = createdTopic("root"); forumService_.saveTopic(categoryId, forumId, topicnew, true, false, new MessageBuilder()); topicnew = forumService_.getTopic(categoryId, forumId, topicnew.getId(), "root"); forumService_.movePost( new String[] {newPost.getPath()}, topicnew.getPath(), false, "test mail content", ""); assertNotNull(forumService_.getPost(categoryId, forumId, topicnew.getId(), newPost.getId())); // test remove Post return post assertNotNull(forumService_.removePost(categoryId, forumId, topicnew.getId(), newPost.getId())); assertNull(forumService_.getPost(categoryId, forumId, topicnew.getId(), newPost.getId())); // getViewPost }
public void testForum() throws Exception { String catId = getId(Utils.CATEGORY); Category cat = createCategory(catId); // create new category forumService_.saveCategory(cat, true); // create new forum Forum forum = createdForum(); String forumId = forum.getId(); // add forum forumService_.saveForum(catId, forum, true); // getForum forum = forumService_.getForum(catId, forumId); assertNotNull("Forum is null", forum); // getList Forum // Created 5 new forum, we have total 6 forum. List<Forum> forums = new ArrayList<Forum>(); for (int i = 0; i < 5; i++) { forumService_.saveForum(cat.getId(), createdForum(), true); } forums.addAll(forumService_.getForums(catId, "")); // check size of list forum assertEquals("List forums size not equals 6", forums.size(), 6); // update Forum forum.setForumName("Forum update"); forumService_.saveForum(catId, forum, false); assertEquals(forum.getForumName(), forumService_.getForum(catId, forumId).getForumName()); // modifyForum forum.setIsLock(true); forumService_.modifyForum(forum, 2); forum = forumService_.getForum(catId, forumId); assertEquals(forum.getIsLock(), true); // saveModerateOfForum List<String> list = new ArrayList<String>(); list.add(catId + "/" + forum.getId()); forumService_.saveModerateOfForums(list, "demo", false); forum = forumService_.getForum(catId, forumId); list.clear(); list.addAll(Arrays.asList(forum.getModerators())); assertEquals(list.contains("demo"), true); // test moderator of category. cat.setModerators(new String[] {"admin", "john"}); forumService_.saveCategory(cat, false); forum = forumService_.getForum(catId, forumId); list.clear(); list.addAll(Arrays.asList(forum.getModerators())); // assertEquals("Forum in category can not content moderatort user admin", // list.contains("admin"), true); // test moveForum, Move list Forum from Category 'cat' to Category 'cate' // create new Category Category cate = createCategory(getId(Utils.CATEGORY)); forumService_.saveCategory(cate, true); Category cateNew = forumService_.getCategory(cate.getId()); // move forum forumService_.moveForum(forums, cateNew.getPath()); // get forum in new category forum = forumService_.getForum(cate.getId(), forumId); assertNotNull(forum); // remove Forum and return this Forum for (Forum forum2 : forums) { forumService_.removeForum(cate.getId(), forum2.getId()); } // check remove forums = forumService_.getForumSummaries(catId, ""); assertEquals("List forums can not equals 0", forums.size(), 0); }
public void testForumService() throws Exception { ForumStatistic forumStatistic = new ForumStatistic(); forumService_.saveForumStatistic(forumStatistic); assertNotNull(forumService_); }
public void testTopic() throws Exception { Category cat = createCategory(getId(Utils.CATEGORY)); forumService_.saveCategory(cat, true); Forum forum = createdForum(); forumService_.saveForum(cat.getId(), forum, true); List<String> listTopicId = new ArrayList<String>(); // add 10 Topics List<Topic> list = new ArrayList<Topic>(); Topic topic; for (int i = 0; i < 10; i++) { topic = createdTopic("Owner"); list.add(topic); listTopicId.add(topic.getId()); forumService_.saveTopic(cat.getId(), forum.getId(), topic, true, false, new MessageBuilder()); } topic = list.get(8); // get Topic - topic in position 8 Topic topica = forumService_.getTopic(cat.getId(), forum.getId(), topic.getId(), ""); assertNotNull(topica); // get Topic by path topica = forumService_.getTopicByPath( cat.getId() + "/" + forum.getId() + "/" + topic.getId(), false); assertNotNull(topica); // update Topic topica.setIsSticky(true); topica.setTopicName("topic 8"); forumService_.saveTopic(cat.getId(), forum.getId(), topica, false, false, new MessageBuilder()); assertEquals( "This topic name not is 'topic 8'", "topic 8", forumService_.getTopic(cat.getId(), forum.getId(), topic.getId(), "").getTopicName()); // modifyTopic topica.setIsLock(true); list.clear(); list.add(topica); forumService_.modifyTopic(list, 2); topica = forumService_.getTopic(cat.getId(), forum.getId(), topic.getId(), ""); assertEquals("This topic is open.", topica.getIsLock(), true); // get PageList Topic JCRPageList pagelist = forumService_.getPageTopic(cat.getId(), forum.getId(), "", ""); assertEquals("Available all topics not equals 10.", pagelist.getAvailable(), 10); pagelist.setPageSize(5); List<Topic> listTopic = pagelist.getPage(1); assertEquals("Available page not equals 5", listTopic.size(), 5); assertEquals(pagelist.getAvailablePage(), 2); // get Topic By User topic = createdTopic("demo"); forumService_.saveTopic(cat.getId(), forum.getId(), topic, true, false, new MessageBuilder()); // We have 11 topic: 10 by Owner and 1 by demo pagelist = forumService_.getPageTopicByUser("Owner", true, ""); assertEquals(pagelist.getAvailable(), 10); // auto prune // set 5 topics for old Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(cal.getTimeInMillis() - 2 * 86400000); Node topicNode; for (Topic topic2 : listTopic) { topicNode = root_.getNode(topic2.getPath().replaceFirst("/", "")); topicNode.setProperty(ForumNodeTypes.EXO_LAST_POST_DATE, cal); topicNode.save(); } listTopic = forumService_.getAllTopicsOld(1, forum.getPath()); assertEquals( "Failed to run auto prune. List topic has size not equals 5.", listTopic.size(), 5); // move Topic // move topic from forum to forum 1 Forum forum1 = createdForum(); forumService_.saveForum(cat.getId(), forum1, true); forum1 = forumService_.getForum(cat.getId(), forum1.getId()); List<Topic> topics = new ArrayList<Topic>(); topics.add(topica); forumService_.moveTopic(topics, forum1.getPath(), "", ""); assertNotNull( "Failed to moved topic, topic is null.", forumService_.getTopic(cat.getId(), forum1.getId(), topica.getId(), "")); // test remove Topic return Topic // remove id topic moved in list topicIds. if (listTopicId.contains(topica.getId())) listTopicId.remove(topica.getId()); for (String topicId : listTopicId) { forumService_.removeTopic(cat.getId(), forum.getId(), topicId); } List<Topic> topics2 = forumService_.getTopics(cat.getId(), forum.getId()); assertEquals( "Topics in forum failed to remove. List topic has size more than 1.", topics2.size(), 1); }
public void onEvent( Event<UICommentForm> event, UICommentForm commentForm, final String objectId) throws Exception { String comment = ((UIFormWYSIWYGInput) commentForm.getChildById(commentForm.COMMENT_CONTENT)).getValue(); if (CommonUtils.isEmpty(comment) || !ValidatorDataInput.fckContentIsNotEmpty(comment)) { warning("UICommentForm.msg.comment-is-null"); return; } if (!commentForm.getFAQService().isExisting(commentForm.question_.getPath())) { warning("UIQuestions.msg.comment-id-deleted"); return; } UIAnswersPortlet portlet = commentForm.getAncestorOfType(UIAnswersPortlet.class); UIAnswersContainer answersContainer = portlet.getChild(UIAnswersContainer.class); UIQuestions questions = answersContainer.getChild(UIQuestions.class); comment = CommonUtils.encodeSpecialCharInContent(comment); try { // Create link by Vu Duy Tu. if (FAQUtils.isFieldEmpty(commentForm.question_.getLink())) { commentForm.question_.setLink( FAQUtils.getQuestionURI(commentForm.question_.getId(), false)); } if (commentForm.comment != null) { commentForm.comment.setNew(false); } else { commentForm.comment = new Comment(); commentForm.comment.setNew(true); } commentForm.comment.setComments(comment); // For discuss in forum String topicId = commentForm.question_.getTopicIdDiscuss(); if (topicId != null && topicId.length() > 0) { ForumService forumService = (ForumService) PortalContainer.getInstance().getComponentInstanceOfType(ForumService.class); Topic topic = (Topic) forumService.getObjectNameById( topicId, org.exoplatform.forum.service.Utils.TOPIC); if (topic != null) { String remoteAddr = WebUIUtils.getRemoteIP(); String[] ids = topic.getPath().split("/"); int t = ids.length; String linkForum = FAQUtils.getLinkDiscuss(topicId); String postId = commentForm.comment.getPostId(); if (postId == null || postId.length() == 0) { Post post = new Post(); post.setOwner(commentForm.currentUser_); post.setIcon("ViewIcon"); post.setName("Re: " + commentForm.question_.getQuestion()); post.setMessage(comment); post.setLink(linkForum + "/" + postId); post.setIsApproved(!topic.getIsModeratePost()); post.setRemoteAddr(remoteAddr); try { forumService.savePost( ids[t - 3], ids[t - 2], topicId, post, true, new MessageBuilder()); } catch (Exception e) { event.getSource().log.debug("Saving post fail: ", e); } commentForm.comment.setPostId(post.getId()); } else { try { Post post = forumService.getPost(ids[t - 3], ids[t - 2], topicId, postId); boolean isNew = false; if (post == null) { post = new Post(); isNew = true; post.setOwner(commentForm.currentUser_); post.setIcon("ViewIcon"); post.setName("Re: " + commentForm.question_.getQuestion()); commentForm.comment.setPostId(post.getId()); post.setLink(linkForum + "/" + postId); post.setRemoteAddr(remoteAddr); } else { post.setModifiedBy(commentForm.currentUser_); } post.setIsApproved(!topic.getIsModeratePost()); post.setMessage(comment); forumService.savePost( ids[t - 3], ids[t - 2], topicId, post, isNew, new MessageBuilder()); } catch (Exception e) { event.getSource().log.debug("Saving post fail: ", e); } } } } String language = ""; if (!commentForm.languageSelected.equals(commentForm.question_.getLanguage())) language = commentForm.languageSelected; String currentUser = FAQUtils.getCurrentUser(); commentForm.comment.setCommentBy(currentUser); commentForm.comment.setFullName(FAQUtils.getFullName(null)); commentForm .getFAQService() .saveComment(commentForm.question_.getPath(), commentForm.comment, language); if (!commentForm.languageSelected.equals(commentForm.question_.getLanguage())) { try { questions.updateCurrentLanguage(); } catch (Exception e) { questions.updateQuestionLanguageByLanguage( commentForm.question_.getPath(), commentForm.languageSelected); } } else { questions.updateQuestionLanguageByLanguage( commentForm.question_.getPath(), commentForm.languageSelected); } } catch (Exception e) { event.getSource().log.error("Fail to save action: ", e); warning("UIQuestions.msg.category-id-deleted", false); } portlet.cancelAction(); event.getRequestContext().addUIComponentToUpdateByAjax(answersContainer); }