1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package net.sf.hermesftp.usermanager.model;
26
27 import java.util.ArrayList;
28 import java.util.Collections;
29 import java.util.List;
30
31 /***
32 * Data Model for the user manager configuration.
33 *
34 * @author Lars Behnke
35 */
36 public class UserManagerData {
37
38 private GroupDataList groupDataList;
39
40 private List<UserData> userData;
41
42 /***
43 * Getter method for the java bean <code>groupData</code>.
44 *
45 * @return Returns the value of the java bean <code>groupData</code>.
46 */
47 public GroupDataList getGroupData() {
48 if (groupDataList == null) {
49 groupDataList = new GroupDataList();
50 }
51 return groupDataList;
52 }
53
54 /***
55 * Getter method for the java bean <code>userData</code>.
56 *
57 * @return Returns the value of the java bean <code>userData</code>.
58 */
59 public List<UserData> getUserData() {
60 if (userData == null) {
61 userData = Collections.synchronizedList(new ArrayList<UserData>());
62 }
63 return userData;
64 }
65
66 /***
67 * Returns the user object by the username.
68 *
69 * @param username The user's name.
70 * @return The user object.
71 */
72 public UserData getUserData(String username) {
73 username = username.trim();
74 for (UserData user : getUserData()) {
75 if (user.getUid().equals(username)) {
76 return user;
77 }
78 }
79 return null;
80 }
81
82 /***
83 * Returns the group object by the group name.
84 *
85 * @param groupname The group's name.
86 * @return The group object.
87 */
88 public GroupData getGroupData(String groupname) {
89 return groupDataList.getGroup(groupname.trim());
90 }
91
92 }