1 25 package org.nemesis.forum; 26 27 import java.util.Iterator ; 28 import java.util.PropertyResourceBundle ; 29 30 import org.apache.commons.logging.Log; 31 import org.apache.commons.logging.LogFactory; 32 import org.nemesis.forum.proxy.ForumFactoryProxy; 33 import org.nemesis.forum.exception.ForumAlreadyExistsException; 34 import org.nemesis.forum.exception.ForumNotFoundException; 35 import org.nemesis.forum.exception.UnauthorizedException; 36 37 64 public abstract class ForumFactory { 65 66 static protected Log log = LogFactory.getLog(ForumFactory.class); 67 68 private static Object initLock = new Object (); 69 70 private static ForumFactory factory = null; 72 73 private static String Impl = 74 (String ) ((PropertyResourceBundle ) PropertyResourceBundle.getBundle("org.nemesis.forum.config")).getObject("ForumFactory.class"); 75 76 84 public static ForumFactory getInstance(Authorization authorization) { 85 if (authorization == null) { 87 return null; 88 } 89 if (factory == null) { 90 synchronized (initLock) { 91 if (factory == null) { 92 93 try { 94 Class c = Class.forName(Impl); 96 factory = (ForumFactory) c.newInstance(); 97 } catch (Exception e) { 98 log.fatal("Failed to load ForumFactory class " + Impl + ". forum cannot function normally.", e); 99 100 return null; 101 } 102 } 103 } 104 } 105 106 ForumFactoryProxy proxy = new ForumFactoryProxy(factory, authorization, factory.getPermissions(authorization)); 110 return proxy; 111 } 112 113 122 public abstract Forum createForum(String name, String description) throws UnauthorizedException, ForumAlreadyExistsException; 123 124 132 public abstract Forum getForum(int forumID) throws ForumNotFoundException, UnauthorizedException; 133 134 142 public abstract Forum getForum(String name) throws ForumNotFoundException, UnauthorizedException; 143 144 151 public abstract int getForumCount(); 152 153 171 public abstract Iterator forums(); 172 173 177 178 public abstract Iterator forumsModeration(); 179 180 190 public abstract void deleteForum(Forum forum) throws UnauthorizedException; 191 192 195 public abstract ProfileManager getProfileManager(); 196 197 204 207 213 public abstract int[] usersWithPermission(int permissionType) throws UnauthorizedException; 214 215 221 public abstract int[] groupsWithPermission(int permissionType) throws UnauthorizedException; 222 223 230 public abstract ForumPermissions getPermissions(Authorization authorization); 231 232 241 public abstract boolean hasPermission(int type); 242 } 243 | Popular Tags |