1
2
3
4
5
6
7 package gov.bnl.gums;
8
9 import java.util.*;
10 import org.apache.commons.logging.*;
11
12 /*** Holds the configuration of GUMS, including which policies will be used
13 * for which hosts, which database layer is going to be used and so on.
14 * <p>
15 * The configuration object will be constructed programmatically by reading
16 * an xml file.
17 *
18 * @author Gabriele Carcassi
19 */
20 public class Configuration {
21 private Log log = LogFactory.getLog(Configuration.class);
22
23 private List hostGroup = new ArrayList();
24 private Map groupMapping = new Hashtable();
25 private Map persistenceFactories = new Hashtable();
26 private List userGroups = new ArrayList();
27 private UserGroup adminGroup;
28
29 /***
30 * Returns the list of all the hostGroups defined in the configuration.
31 * @return a List of HostGroup objects.
32 */
33 public List getHostGroup() {
34 return hostGroup;
35 }
36
37 /***
38 * Returns all the group mappings defined in the configuration,
39 * indexed by their name property.
40 * @return a Map from String (names) to GroupMapper objects.
41 */
42 public Map getGroupMapping() {
43 return groupMapping;
44 }
45
46 /***
47 * Returns all the persistence factories defined in the configuration,
48 * indexed by their name property.
49 * @return a Map from String (names) to PersistenceFactory objects.
50 */
51 public Map getPersistenceFactories() {
52
53 return persistenceFactories;
54 }
55
56 /***
57 * Returns a list of all the user groups defined in the configuration file.
58 * <p>
59 * @return a list of UserGroup objects.
60 */
61 public List getAllGroups() {
62 return userGroups;
63 }
64
65 /***
66 * Adds a persistence factory to the configuration.
67 * @param factory a PersistenceFactory object.
68 */
69 public void addPersistenceFactory(PersistenceFactory factory) {
70 log.trace("Adding persistenceFactory to the configuration: " + factory);
71 persistenceFactories.put(factory.getName(), factory);
72 }
73
74 /***
75 * Adds a group mapping to the configuration.
76 * @param group a GroupMapper object.
77 */
78 public void addGroupMapping(GroupMapper group) {
79 log.trace("Adding groupMapping to the configuration: " + group);
80 groupMapping.put(group.getName(), group);
81 if (!userGroups.contains(group.getGroup())) {
82 userGroups.add(group.getGroup());
83 }
84 }
85
86 /***
87 * Addes a host group to the configuation.
88 * @param mapping the HostGroup
89 */
90 public void addHostGroup(HostGroup mapping) {
91 log.trace("Adding hostGroup to the configuration: " + mapping);
92 hostGroup.add(mapping);
93 }
94
95 /***
96 * Getter for property adminGroup.
97 * @return Value of property adminGroup.
98 */
99 public UserGroup getAdminGroup() {
100
101 return this.adminGroup;
102 }
103
104 /***
105 * Setter for property adminGroup.
106 * @param adminGroup New value of property adminGroup.
107 */
108 public void setAdminGroup(UserGroup adminGroup) {
109 log.trace("Changing the admin group: " + adminGroup);
110 this.adminGroup = adminGroup;
111 }
112
113 /***
114 * Holds value of property errorOnMissedMapping.
115 */
116 private boolean errorOnMissedMapping;
117
118 /***
119 * Getter for property errorOnMissedMapping.
120 * @return Value of property errorOnMissedMapping.
121 */
122 public boolean isErrorOnMissedMapping() {
123 return this.errorOnMissedMapping;
124 }
125
126 /***
127 * Setter for property errorOnMissedMapping.
128 * @param errorOnMissedMapping New value of property errorOnMissedMapping.
129 */
130 public void setErrorOnMissedMapping(boolean errorOnMissedMapping) {
131 this.errorOnMissedMapping = errorOnMissedMapping;
132 }
133 }