public Post getPost(Node postNode) throws Exception { Post postNew = new Post(); PropertyReader reader = new PropertyReader(postNode); postNew.setId(postNode.getName()); postNew.setPath(postNode.getPath()); postNew.setOwner(reader.string(ForumNodeTypes.EXO_OWNER)); postNew.setCreatedDate(reader.date(ForumNodeTypes.EXO_CREATED_DATE)); postNew.setModifiedBy(reader.string(ForumNodeTypes.EXO_MODIFIED_BY)); postNew.setModifiedDate(reader.date(ForumNodeTypes.EXO_MODIFIED_DATE)); postNew.setEditReason(reader.string(ForumNodeTypes.EXO_EDIT_REASON)); postNew.setName(reader.string(ForumNodeTypes.EXO_NAME)); postNew.setMessage(reader.string(ForumNodeTypes.EXO_MESSAGE)); postNew.setRemoteAddr(reader.string(ForumNodeTypes.EXO_REMOTE_ADDR)); postNew.setIcon(reader.string(ForumNodeTypes.EXO_ICON)); postNew.setLink(reader.string(ForumNodeTypes.EXO_LINK)); postNew.setIsApproved(reader.bool(ForumNodeTypes.EXO_IS_APPROVED)); postNew.setIsHidden(reader.bool(ForumNodeTypes.EXO_IS_HIDDEN)); postNew.setIsActiveByTopic(reader.bool(ForumNodeTypes.EXO_IS_ACTIVE_BY_TOPIC)); postNew.setUserPrivate(reader.strings(ForumNodeTypes.EXO_USER_PRIVATE)); postNew.setNumberAttach(reader.l(ForumNodeTypes.EXO_NUMBER_ATTACH)); if (postNew.getNumberAttach() > 0) { postNew.setAttachments(getAttachmentsByNode(postNode)); } return postNew; }
private Topic getTopic(Node topicNode) throws Exception { if (topicNode == null) return null; Topic topicNew = new Topic(); PropertyReader reader = new PropertyReader(topicNode); topicNew.setId(topicNode.getName()); topicNew.setPath(topicNode.getPath()); topicNew.setIcon(reader.string(ForumNodeTypes.EXO_ICON)); topicNew.setTopicType(reader.string(ForumNodeTypes.EXO_TOPIC_TYPE, " ")); topicNew.setTopicName(reader.string(ForumNodeTypes.EXO_NAME)); topicNew.setOwner(reader.string(ForumNodeTypes.EXO_OWNER)); topicNew.setCreatedDate(reader.date(ForumNodeTypes.EXO_CREATED_DATE)); topicNew.setDescription(reader.string(ForumNodeTypes.EXO_DESCRIPTION)); topicNew.setLastPostBy(reader.string(ForumNodeTypes.EXO_LAST_POST_BY)); topicNew.setLastPostDate(reader.date(ForumNodeTypes.EXO_LAST_POST_DATE)); topicNew.setIsSticky(reader.bool(ForumNodeTypes.EXO_IS_STICKY)); if (topicNode.getParent().getProperty(ForumNodeTypes.EXO_IS_LOCK).getBoolean()) topicNew.setIsLock(true); else topicNew.setIsLock(topicNode.getProperty(ForumNodeTypes.EXO_IS_LOCK).getBoolean()); topicNew.setIsClosed(reader.bool(ForumNodeTypes.EXO_IS_CLOSED)); topicNew.setIsApproved(reader.bool(ForumNodeTypes.EXO_IS_APPROVED)); topicNew.setIsActive(reader.bool(ForumNodeTypes.EXO_IS_ACTIVE)); topicNew.setIsWaiting(reader.bool(ForumNodeTypes.EXO_IS_WAITING)); topicNew.setIsActiveByForum(reader.bool(ForumNodeTypes.EXO_IS_ACTIVE_BY_FORUM)); topicNew.setIsPoll(reader.bool(ForumNodeTypes.EXO_IS_POLL)); topicNew.setPostCount(reader.l(ForumNodeTypes.EXO_POST_COUNT)); topicNew.setViewCount(reader.l(ForumNodeTypes.EXO_VIEW_COUNT)); topicNew.setNumberAttachment(reader.l(ForumNodeTypes.EXO_NUMBER_ATTACHMENTS)); topicNew.setUserVoteRating(reader.strings(ForumNodeTypes.EXO_USER_VOTE_RATING)); topicNew.setVoteRating(reader.d(ForumNodeTypes.EXO_VOTE_RATING)); // update more properties for topicNew. topicNew.setModifiedBy(reader.string(ForumNodeTypes.EXO_MODIFIED_BY)); topicNew.setModifiedDate(reader.date(ForumNodeTypes.EXO_MODIFIED_DATE)); topicNew.setIsModeratePost(reader.bool(ForumNodeTypes.EXO_IS_MODERATE_POST)); topicNew.setIsNotifyWhenAddPost( reader.string(ForumNodeTypes.EXO_IS_NOTIFY_WHEN_ADD_POST, null)); topicNew.setLink(reader.string(ForumNodeTypes.EXO_LINK)); topicNew.setTagId(reader.strings(ForumNodeTypes.EXO_TAG_ID)); topicNew.setCanView(reader.strings(ForumNodeTypes.EXO_CAN_VIEW, new String[] {})); topicNew.setCanPost(reader.strings(ForumNodeTypes.EXO_CAN_POST, new String[] {})); if (topicNode.isNodeType(ForumNodeTypes.EXO_FORUM_WATCHING)) topicNew.setEmailNotification( reader.strings(ForumNodeTypes.EXO_EMAIL_WATCHING, new String[] {})); try { if (topicNew.getNumberAttachment() > 0) { // String idFirstPost = topicNode.getName().replaceFirst(Utils.TOPIC, Utils.POST); // Node FirstPostNode = topicNode.getNode(idFirstPost); // topicNew.setAttachments(getAttachmentsByNode(FirstPostNode)); } } catch (Exception e) { // log.debug("Failed to set attachments in topicNew.", e); } return topicNew; }
private UserProfile getUserProfile(Node profileNode) throws Exception { UserProfile userProfile = new UserProfile(); userProfile.setUserId(profileNode.getName()); PropertyReader reader = new PropertyReader(profileNode); userProfile.setScreenName( reader.string( ForumNodeTypes.EXO_SCREEN_NAME, reader.string(ForumNodeTypes.EXO_FULL_NAME, profileNode.getName()))); userProfile.setFullName(reader.string(ForumNodeTypes.EXO_FULL_NAME)); userProfile.setFirstName(reader.string(ForumNodeTypes.EXO_FIRST_NAME)); userProfile.setLastName(reader.string(ForumNodeTypes.EXO_LAST_NAME)); userProfile.setEmail(reader.string(ForumNodeTypes.EXO_EMAIL)); userProfile.setUserRole(reader.l(ForumNodeTypes.EXO_USER_ROLE)); userProfile.setUserTitle(reader.string(ForumNodeTypes.EXO_USER_TITLE, "")); userProfile.setSignature(reader.string(ForumNodeTypes.EXO_SIGNATURE)); userProfile.setTotalPost(reader.l(ForumNodeTypes.EXO_TOTAL_POST)); userProfile.setTotalTopic(reader.l(ForumNodeTypes.EXO_TOTAL_TOPIC)); userProfile.setBookmark(reader.strings(ForumNodeTypes.EXO_BOOKMARK)); userProfile.setLastLoginDate(reader.date(ForumNodeTypes.EXO_LAST_LOGIN_DATE)); userProfile.setJoinedDate(reader.date(ForumNodeTypes.EXO_JOINED_DATE)); userProfile.setLastPostDate(reader.date(ForumNodeTypes.EXO_LAST_POST_DATE)); userProfile.setIsDisplaySignature(reader.bool(ForumNodeTypes.EXO_IS_DISPLAY_SIGNATURE)); userProfile.setIsDisplayAvatar(reader.bool(ForumNodeTypes.EXO_IS_DISPLAY_AVATAR)); userProfile.setShortDateFormat( reader.string(ForumNodeTypes.EXO_SHORT_DATEFORMAT, userProfile.getShortDateFormat())); userProfile.setLongDateFormat( reader.string(ForumNodeTypes.EXO_LONG_DATEFORMAT, userProfile.getLongDateFormat())); userProfile.setTimeFormat( reader.string(ForumNodeTypes.EXO_TIME_FORMAT, userProfile.getTimeFormat())); userProfile.setMaxPostInPage(reader.l(ForumNodeTypes.EXO_MAX_POST, 10)); userProfile.setMaxTopicInPage(reader.l(ForumNodeTypes.EXO_MAX_TOPIC, 10)); userProfile.setIsShowForumJump(reader.bool(ForumNodeTypes.EXO_IS_SHOW_FORUM_JUMP, true)); userProfile.setModerateForums( reader.strings(ForumNodeTypes.EXO_MODERATE_FORUMS, new String[] {})); userProfile.setModerateCategory( reader.strings(ForumNodeTypes.EXO_MODERATE_CATEGORY, new String[] {})); userProfile.setNewMessage(reader.l(ForumNodeTypes.EXO_NEW_MESSAGE)); userProfile.setTimeZone(reader.d(ForumNodeTypes.EXO_TIME_ZONE)); userProfile.setIsBanned(reader.bool(ForumNodeTypes.EXO_IS_BANNED)); userProfile.setBanUntil(reader.l(ForumNodeTypes.EXO_BAN_UNTIL)); userProfile.setBanReason(reader.string(ForumNodeTypes.EXO_BAN_REASON, "")); userProfile.setBanCounter(Integer.parseInt(reader.string(ForumNodeTypes.EXO_BAN_COUNTER, "0"))); userProfile.setBanReasonSummary( reader.strings(ForumNodeTypes.EXO_BAN_REASON_SUMMARY, new String[] {})); userProfile.setCreatedDateBan(reader.date(ForumNodeTypes.EXO_CREATED_DATE_BAN)); return userProfile; }
private ForumPrivateMessage getPrivateMessage(Node messageNode) throws Exception { ForumPrivateMessage message = new ForumPrivateMessage(); message.setId(messageNode.getName()); PropertyReader reader = new PropertyReader(messageNode); message.setFrom(reader.string(ForumNodeTypes.EXO_FROM)); message.setSendTo(reader.string(ForumNodeTypes.EXO_SEND_TO)); message.setName(reader.string(ForumNodeTypes.EXO_NAME)); message.setMessage(reader.string(ForumNodeTypes.EXO_MESSAGE)); message.setReceivedDate(reader.date(ForumNodeTypes.EXO_RECEIVED_DATE)); message.setIsUnread(reader.bool(ForumNodeTypes.EXO_IS_UNREAD)); message.setType(reader.string(ForumNodeTypes.EXO_TYPE)); return message; }