首页 > IT职业 > IT生活 > Jive笔记7 -- Jive的硬伤 (转)
public IteratorProxy(int type, Iterator iterator, Authorization authorization, ForumPeRmissions permissions) { this.iterator = iterator; this.authorization = authorization; this.permissions = permissions; // Load the appropriate proxy factory depending on the type of object // that we're iterating through. Each proxy factory is responsible // for checking that the user has permission to view the object, and // then wrapping it with an appropriate proxy. switch (type) { // CATEGORY case JiveGlobals.FORUM_CATEGORY: // Create a class that wraps forums with proxies. proxyFactory = new ProxyFactory() { public Object createProxy(Object obj, Authorization auth, ForumPermissions perms) { ForumCategory category = (ForumCategory)obj; // Create a new permissions object with the combination // of the permissions of this object and tempPermissions. int parentPerms = perms.toInt(); // Never inherit the show category permission. ForumPermissions newPerms = new ForumPermissions( ForumPermissions.setBit(parentPerms, ForumPermissions.SHOW_CATEGORY, false)); ForumPermissions catPerms = category.getPermissions(auth); newPerms = new ForumPermissions(catPerms, newPerms); // Return the object if the user has permission. if (newPerms.get(ForumPermissions.READ_FORUM) || newPerms.get(ForumPermissions.SHOW_CATEGORY) || newPerms.get(ForumPermissions.MODERATE_MESSAGES) || newPerms.get(ForumPermissions.MODERATE_THREADS) || newPerms.get(ForumPermissions.FORUM_ADMIN) || newPerms.get(ForumPermissions.CATEGORY_ADMIN) || newPerms.get(ForumPermissions.SYSTEM_ADMIN)) { return new ForumCategoryProxy(category, auth, newPerms); } // Otherwise return null. else { return null; } } }; break;
public Object getNextElement() { while (iterator.hasNext()) { Object element = proxyFactory.createProxy(iterator.next(), authorization, permissions); if (element != null) { return element; } } return null; }
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10752019/viewspace-958270/ ,如需转载,请注明出处,否则将追究法律责任。