01: /*
02: * UserHandler.java
03: *
04: * Created on June 22, 2004, 5:44 PM
05: */
06:
07: package org.manentia.kasai.group;
08:
09: import java.util.Collection;
10: import java.util.List;
11:
12: import org.manentia.kasai.Group;
13: import org.manentia.kasai.exceptions.AlreadyExistsException;
14: import org.manentia.kasai.exceptions.DataAccessException;
15: import org.manentia.kasai.exceptions.DoesntExistsException;
16: import org.manentia.kasai.exceptions.InvalidAttributesException;
17:
18: import com.manentia.commons.xml.XMLException;
19:
20: /**
21: *
22: * @author rzuasti
23: */
24: public class GroupHandler {
25: private static GroupHandler instance;
26:
27: private GroupHandler() {
28: }
29:
30: public static synchronized GroupHandler getInstance() {
31: if (instance == null) {
32: instance = new GroupHandler();
33: }
34:
35: return instance;
36: }
37:
38: public void addUserToGroup(String login, String group)
39: throws DoesntExistsException, DataAccessException,
40: XMLException {
41: GroupDAOFactory.getInstance().createDAO().addUserToGroup(login,
42: group);
43: }
44:
45: public boolean checkUserBelongsToGroup(String user, String group)
46: throws DataAccessException {
47: return GroupDAOFactory.getInstance().createDAO()
48: .checkUserBelongsToGroup(user, group);
49: }
50:
51: public void create(Group group) throws InvalidAttributesException,
52: AlreadyExistsException, DataAccessException, XMLException {
53: GroupDAOFactory.getInstance().createDAO().create(group);
54: }
55:
56: public void delete(String group) throws DataAccessException {
57: GroupDAOFactory.getInstance().createDAO().delete(group);
58: }
59:
60: public void deleteUserFromGroup(String login, String group)
61: throws DataAccessException {
62: GroupDAOFactory.getInstance().createDAO().deleteUserFromGroup(
63: login, group);
64: }
65:
66: public List list(String idGroup, String description, int blocked,
67: int system, String login) throws DataAccessException,
68: XMLException {
69: return GroupDAOFactory.getInstance().createDAO().list(idGroup,
70: description, blocked, system, login);
71: }
72:
73: public Collection listUsersNotInGroup(String group)
74: throws DataAccessException, XMLException {
75: return GroupDAOFactory.getInstance().createDAO()
76: .listUsersNotInGroup(group);
77: }
78:
79: public Group read(String group) throws DataAccessException,
80: XMLException {
81: return GroupDAOFactory.getInstance().createDAO().read(group);
82: }
83:
84: public void update(Group group) throws InvalidAttributesException,
85: DataAccessException, XMLException {
86: GroupDAOFactory.getInstance().createDAO().update(group);
87: }
88:
89: public void update(Group group, String[] members)
90: throws InvalidAttributesException, DataAccessException,
91: XMLException {
92: GroupDAOFactory.getInstance().createDAO()
93: .update(group, members);
94: }
95: }
|