1 17 18 19 20 package org.apache.lenya.ac.file; 21 22 import java.io.File ; 23 import java.util.HashMap ; 24 import java.util.Map ; 25 26 import org.apache.lenya.ac.AccessControlException; 27 import org.apache.lenya.ac.Group; 28 import org.apache.lenya.ac.GroupManager; 29 import org.apache.lenya.ac.Item; 30 31 34 public final class FileGroupManager extends FileItemManager implements GroupManager { 35 36 private static Map instances = new HashMap (); 37 38 44 private FileGroupManager(File configurationDirectory) throws AccessControlException { 45 super(configurationDirectory); 46 } 47 48 56 public static FileGroupManager instance(File configurationDirectory) 57 throws AccessControlException { 58 assert configurationDirectory != null; 59 60 if (!instances.containsKey(configurationDirectory)) { 61 instances.put(configurationDirectory, new FileGroupManager(configurationDirectory)); 62 } 63 64 return (FileGroupManager) instances.get(configurationDirectory); 65 } 66 67 72 public Group[] getGroups() { 73 Item[] items = super.getItems(); 74 Group[] groups = new Group[items.length]; 75 for (int i = 0; i < groups.length; i++) { 76 groups[i] = (Group) items[i]; 77 } 78 return groups; 79 } 80 81 87 public void add(Group group) throws AccessControlException { 88 super.add(group); 89 } 90 91 97 public void remove(Group group) throws AccessControlException { 98 super.remove(group); 99 } 100 101 107 public Group getGroup(String groupId) { 108 return (Group) getItem(groupId); 109 } 110 111 protected static final String SUFFIX = ".gml"; 112 113 116 protected String getSuffix() { 117 return SUFFIX; 118 } 119 120 } 121 | Popular Tags |