1
2
3
4
5
6
7
8
9
10
11 package gov.bnl.gums.hostToGroup;
12
13 import gov.bnl.gums.configuration.Configuration;
14
15 import java.lang.ref.SoftReference;
16 import java.util.*;
17
18
19
20
21
22
23
24
25
26
27
28
29 public abstract class HostToGroupMapping {
30 private List groupToAccountMappers = new ArrayList();
31 private SoftReference configurationRef = null;
32 private String name = "";
33 private String description = "";
34
35
36
37
38
39
40
41 public HostToGroupMapping() {
42 }
43
44
45
46
47
48
49 public HostToGroupMapping(Configuration configuration) {
50 this.configurationRef = new SoftReference(configuration);
51 }
52
53
54
55
56
57
58 public HostToGroupMapping(Configuration configuration, String name) {
59 this.configurationRef = new SoftReference(configuration);
60 this.name = name;
61 }
62
63
64
65
66
67 public void addGroupToAccountMapping(String groupToAccountMapping) {
68 this.groupToAccountMappers.add(groupToAccountMapping);
69 }
70
71
72
73
74
75
76
77 public abstract HostToGroupMapping clone(Configuration configuration);
78
79
80
81
82
83
84 public boolean containsGroupToAccountMapping(String groupToAccountMappingQuery) {
85 Iterator groupMapperIt = groupToAccountMappers.iterator();
86 while(groupMapperIt.hasNext()) {
87 String groupToAccountMapping = (String)groupMapperIt.next();
88 if(groupToAccountMapping.equals(groupToAccountMappingQuery))
89 return true;
90 }
91 return false;
92 }
93
94
95
96
97
98
99 public Configuration getConfiguration() {
100 if (configurationRef==null)
101 return null;
102 return (Configuration)configurationRef.get();
103 }
104
105
106
107
108
109
110 public String getDescription() {
111 return description;
112 }
113
114
115
116
117 public List getGroupToAccountMappings() {
118 return Collections.unmodifiableList(groupToAccountMappers);
119 }
120
121
122
123
124
125
126 public String getName() {
127 return name;
128 }
129
130
131
132
133
134
135
136 public abstract boolean isInGroup(String hostname);
137
138
139
140
141
142
143 public void setConfiguration(Configuration configuration) {
144 this.configurationRef = new SoftReference(configuration);
145 }
146
147
148
149
150
151
152 public void setDescription(String description) {
153 this.description = description;
154 }
155
156
157
158
159
160
161 public void setName(String name) {
162 this.name = name;
163 }
164
165
166
167
168
169
170 public abstract String toXML();
171 }