JCRDataStorage implements DataStorage, ForumNodeTypes { public void addRolePlugin(ComponentPlugin plugin) throws Exception { if (plugin instanceof RoleRulesPlugin) { rulesPlugins.add((RoleRulesPlugin) plugin); } } JCRDataStorage();  JCRDataStorage(KSDataLocation dataLocator); @Managed @ManagedDescription("repository for forum storage") String getRepository(); @Managed @ManagedDescription("workspace for the forum storage") String getWorkspace(); @Managed @ManagedDescription("data path for forum storage") String getPath(); void addPlugin(ComponentPlugin plugin); void addRolePlugin(ComponentPlugin plugin); void addInitialDefaultDataPlugin(ComponentPlugin plugin); void addInitialDataPlugin(ComponentPlugin plugin); void addCalculateModeratorEventListener(); void addDeletedUserCalculateListener(); void initCategoryListener(); void initAutoPruneSchedules(); boolean isAdminRole(String userName); void setDefaultAvatar(String userName); ForumAttachment getUserAvatar(String userName); void saveUserAvatar(String userId, ForumAttachment fileAttachment); void saveForumAdministration(ForumAdministration forumAdministration); ForumAdministration getForumAdministration(); SortSettings getForumSortSettings(); SortSettings getTopicSortSettings(); void initDataPlugin(); void initDefaultData(); List<Category> getCategories(); Category getCategory(String categoryId); String[] getPermissionTopicByCategory(String categoryId, String type); void saveCategory(Category category, boolean isNew); void saveModOfCategory(List<String> moderatorCate, String userId, boolean isAdd); void calculateModerator(String nodePath, boolean isNew); void registerListenerForCategory(String path); void unRegisterListenerForCategory(String path); void unRegisterListenerForCategory(SessionProvider sProvider, String path); Category removeCategory(String categoryId); List<Forum> getForums(String categoryId, String strQuery); List<Forum> getForumSummaries(String categoryId, String strQuery); Forum getForum(String categoryId, String forumId); void modifyForum(Forum forum, int type); void saveForum(String categoryId, Forum forum, boolean isNew); void saveModerateOfForums(List<String> forumPaths, String userName, boolean isDelete); Forum removeForum(String categoryId, String forumId); void moveForum(List<Forum> forums, String destCategoryPath); JCRPageList getPageTopic(String categoryId, String forumId, String strQuery, String strOrderBy); LazyPageList<Topic> getTopicList(String categoryId, String forumId, String xpathConditions, String strOrderBy, int pageSize); List<Topic> getTopics(String categoryId, String forumId); void setViewCountTopic(String path, String userRead); Topic getTopic(String categoryId, String forumId, String topicId, String userRead); Topic getTopicSummary(String topicPath, boolean isLastPost); Topic getTopicByPath(String topicPath, boolean isLastPost); Topic getTopicUpdate(Topic topic, boolean isSummary); Topic getTopicNode(Node topicNode); JCRPageList getPageTopicOld(long date, String forumPatch); List<Topic> getAllTopicsOld(long date, String forumPatch); long getTotalTopicOld(long date, String forumPatch); JCRPageList getPageTopicByUser(String userName, boolean isMod, String strOrderBy); void modifyTopic(List<Topic> topics, int type); void saveTopic(String categoryId, String forumId, Topic topic, boolean isNew, boolean isMove, MessageBuilder messageBuilder); void updateUserProfileInfo(String name); Topic removeTopic(String categoryId, String forumId, String topicId); void moveTopic(List<Topic> topics, String destForumPath, String mailContent, String link); long getLastReadIndex(String path, String isApproved, String isHidden, String userLogin); JCRPageList getPostForSplitTopic(String topicPath); JCRPageList getPosts(String categoryId, String forumId, String topicId, String isApproved, String isHidden, String strQuery, String userLogin); long getAvailablePost(String categoryId, String forumId, String topicId, String isApproved, String isHidden, String userLogin); JCRPageList getPagePostByUser(String userName, String userId, boolean isMod, String strOrderBy); Post getPost(String categoryId, String forumId, String topicId, String postId); JCRPageList getListPostsByIP(String ip, String strOrderBy); Post getPost(Node postNode); void savePost(String categoryId, String forumId, String topicId, Post post, boolean isNew, MessageBuilder messageBuilder); void modifyPost(List<Post> posts, int type); Post removePost(String categoryId, String forumId, String topicId, String postId); void movePost(String[] postPaths, String destTopicPath, boolean isCreatNewTopic, String mailContent, String link); void mergeTopic(String srcTopicPath, String destTopicPath, String mailContent, String link); void addTag(List<Tag> tags, String userName, String topicPath); void unTag(String tagId, String userName, String topicPath); Tag getTag(String tagId); List<String> getTagNameInTopic(String userAndTopicId); List<String> getAllTagName(String keyValue, String userAndTopicId); List<Tag> getAllTags(); List<Tag> getMyTagInTopic(String[] tagIds); JCRPageList getTopicByMyTag(String userIdAndtagId, String strOrderBy); void saveTag(Tag newTag); JCRPageList getPageListUserProfile(); JCRPageList searchUserProfile(String userSearch); UserProfile getDefaultUserProfile(String userName, String ip); UserProfile updateUserProfileSetting(UserProfile userProfile); String getScreenName(String userName); UserProfile getUserSettingProfile(String userName); void saveUserSettingProfile(UserProfile userProfile); UserProfile getLastPostIdRead(UserProfile userProfile, String isOfForum); void saveLastPostIdRead(String userId, String[] lastReadPostOfForum, String[] lastReadPostOfTopic); List<String> getUserModerator(String userName, boolean isModeCate); void saveUserModerator(String userName, List<String> ids, boolean isModeCate); UserProfile getUserInfo(String userName); List<UserProfile> getQuickProfiles(List<String> userList); UserProfile getQuickProfile(String userName); UserProfile getUserInformations(UserProfile userProfile); void saveUserProfile(UserProfile newUserProfile, boolean isOption, boolean isBan); UserProfile getUserProfileManagement(String userName); void saveUserBookmark(String userName, String bookMark, boolean isNew); void saveCollapsedCategories(String userName, String categoryId, boolean isAdd); void saveReadMessage(String messageId, String userName, String type); JCRPageList getPrivateMessage(String userName, String type); long getNewPrivateMessage(String userName); void savePrivateMessage(ForumPrivateMessage privateMessage); void removePrivateMessage(String messageId, String userName, String type); ForumSubscription getForumSubscription(String userId); void saveForumSubscription(ForumSubscription forumSubscription, String userId); ForumStatistic getForumStatistic(); void saveForumStatistic(ForumStatistic forumStatistic); Object getObjectNameByPath(String path); Object getObjectNameById(String id, String type); List<ForumLinkData> getAllLink(String strQueryCate, String strQueryForum); List<ForumSearch> getQuickSearch(String textQuery, String type_, String pathQuery, String userId, List<String> listCateIds, List<String> listForumIds, List<String> forumIdsOfModerator); List<ForumSearch> getAdvancedSearch(ForumEventQuery eventQuery, List<String> listCateIds, List<String> listForumIds); void addWatch(int watchType, String path, List<String> values, String currentUser); void removeWatch(int watchType, String path, String values); void updateEmailWatch(List<String> listNodeId, String newEmailAdd, String userId); List<Watch> getWatchByUser(String userId); Iterator<SendMessageInfo> getPendingMessages(); void updateForum(String path); SendMessageInfo getMessageInfo(String name); List<ForumSearch> getJobWattingForModerator(String[] paths); int getJobWattingForModeratorByUser(String userId); void sendNotificationMessage(ForumPrivateMessage message); NodeIterator search(String queryString); void evaluateActiveUsers(String strQuery); Object exportXML(String categoryId, String forumId, List<String> objectIds, String nodePath, ByteArrayOutputStream bos, boolean isExportAll); void importXML(String nodePath, ByteArrayInputStream bis, int typeImport); void updateTopicAccess(String userId, String topicId); void updateForumAccess(String userId, String forumId); List<String> getBookmarks(String userName); List<String> getBanList(); boolean addBanIP(String ip); void removeBan(String ip); List<String> getForumBanList(String forumId); boolean addBanIPForum(String ip, String forumId); void removeBanIPForum(String ip, String forumId); void updateStatisticCounts(long topicCount, long postCount); PruneSetting getPruneSetting(String forumPath); List<PruneSetting> getAllPruneSetting(); void savePruneSetting(PruneSetting pruneSetting); void runPrune(String forumPath); void runPrune(PruneSetting pSetting); long checkPrune(PruneSetting pSetting); List<TopicType> getTopicTypes(); TopicType getTopicType(String Id); void saveTopicType(TopicType topicType); void removeTopicType(String topicTypeId); JCRPageList getPageTopicByType(String type); InputStream createForumRss(String objectId, String link); InputStream createUserRss(String userId, String link); boolean populateUserProfile(User user, UserProfile profileTemplate, boolean isNew); String getLatestUser(); void updateLastLoginDate(String userId); List<Post> getRecentPostsForUser(String userName, int number); List<Post> getNewPosts(int number); boolean deleteUserProfile(String userId); void calculateDeletedUser(String userName); List<InitializeForumPlugin> getDefaultPlugins(); List<RoleRulesPlugin> getRulesPlugins(); Map<String, String> getServerConfig(); KSDataLocation getDataLocation(); void setDataLocator(KSDataLocation dataLocator);  }
@Test public void testAddRolePlugin() throws Exception { storage.addRolePlugin(null); AssertUtils.assertEmpty(storage.getRulesPlugins()); ComponentPlugin plugin = mock(ComponentPlugin.class); storage.addRolePlugin(plugin); AssertUtils.assertEmpty(storage.getRulesPlugins()); InitParams params = new InitParams(); KernelUtils.addValueParam(params, "role", "ADMIN"); KernelUtils.addValuesParam(params, "rules", "rule1", "rule2"); storage.addRolePlugin(new RoleRulesPlugin(params)); AssertUtils.assertNotEmpty(storage.getRulesPlugins()); }