KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > organization > ldap > OrganizationServiceLDAPImpl


1 /**
2  * Copyright 2001-2004 The eXo Platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  **/

5 package org.exoplatform.services.organization.ldap;
6
7
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.Collection JavaDoc;
11 import java.util.List JavaDoc;
12
13 import org.exoplatform.commons.utils.PageList;
14 import org.exoplatform.services.organization.Group;
15 import org.exoplatform.services.organization.GroupEventListener;
16 import org.exoplatform.services.organization.Membership;
17 import org.exoplatform.services.organization.MembershipEventListener;
18 import org.exoplatform.services.organization.MembershipType;
19 import org.exoplatform.services.organization.OrganizationService;
20 import org.exoplatform.services.organization.OrganizationServiceListener;
21 import org.exoplatform.services.organization.Query;
22 import org.exoplatform.services.organization.User;
23 import org.exoplatform.services.organization.UserEventListener;
24 import org.exoplatform.services.organization.UserProfile;
25 import org.exoplatform.services.organization.UserProfileEventListener;
26 import org.exoplatform.services.organization.impl.GroupImpl;
27 import org.exoplatform.services.organization.impl.MembershipImpl;
28 import org.exoplatform.services.organization.impl.MembershipTypeImpl;
29 import org.exoplatform.services.organization.impl.UserImpl;
30 import org.exoplatform.services.organization.impl.UserProfileImpl;
31 import org.picocontainer.Startable;
32
33 /**
34  * Created y the eXo platform team
35  * User: Daniel Summer
36  * Date: 28 august 2004
37  *
38  */

39 public class OrganizationServiceLDAPImpl
40     implements OrganizationService, Startable {
41
42     //private LDAPServiceContainer ldapServiceContainer_;
43

44     UserLDAPHandler userLDAPHandler_;
45     UserProfileLDAPHandler userProfileLDAPHandler_;
46     GroupLDAPHandler groupLDAPHandler_;
47     MembershipLDAPHandler membershipLDAPHandler_;
48     MembershipTypeLDAPHandler membershipTypeLDAPHandler_;
49
50     private List JavaDoc listeners_;
51
52     public OrganizationServiceLDAPImpl(
53         UserLDAPHandler userLDAPHandler,
54         GroupLDAPHandler groupLDAPHandler,
55         MembershipLDAPHandler membershipLDAPHandler,
56         MembershipTypeLDAPHandler membershipTypeLDAPHandler,
57         UserProfileLDAPHandler userProfileLDAPHandler) {
58
59         userLDAPHandler_ = userLDAPHandler;
60         userProfileLDAPHandler_ = userProfileLDAPHandler;
61         groupLDAPHandler_ = groupLDAPHandler;
62         membershipLDAPHandler_ = membershipLDAPHandler;
63         membershipTypeLDAPHandler_ = membershipTypeLDAPHandler;
64         listeners_ = new ArrayList JavaDoc();
65         //ldapServiceContainer_ = ldapServiceContainer;
66
}
67
68     public void start() {
69         for (int i = 0; i < listeners_.size(); i++) {
70             OrganizationServiceListener listener =
71                 (OrganizationServiceListener) listeners_.get(i);
72             listener.inititalize(this);
73         }
74     }
75
76     public void stop() {
77     }
78
79     synchronized public void addListener(OrganizationServiceListener listener) {
80         listeners_.add(listener);
81     }
82
83     synchronized public void removeListener(OrganizationServiceListener listener) {
84         listeners_.remove(listener);
85     }
86
87     public User createUserInstance() {
88         return new UserImpl();
89     }
90
91     final public List JavaDoc getUserEventListeners() {
92         return userLDAPHandler_.getUserEventListeners();
93     }
94
95     public void addUserEventListener(UserEventListener listener) {
96         userLDAPHandler_.addUserEventListener(listener);
97     }
98
99     final public void createUser(User user) throws Exception JavaDoc {
100         userLDAPHandler_.createUser(user);
101     }
102
103     final public void saveUser(User user) throws Exception JavaDoc {
104         userLDAPHandler_.saveUser(user);
105     }
106
107     final public User removeUser(String JavaDoc user) throws Exception JavaDoc {
108         return userLDAPHandler_.removeUser(user);
109     }
110
111     final public User findUserByName(String JavaDoc userName) throws Exception JavaDoc {
112         return userLDAPHandler_.findUserByName(userName);
113     }
114
115     public PageList getUserPageList(int pageSize) throws Exception JavaDoc {
116         return userLDAPHandler_.getUserPageList(pageSize);
117     }
118
119     final public PageList findUsers(Query query) throws Exception JavaDoc {
120         return userLDAPHandler_.findUsers(query);
121     }
122
123     final public PageList findUsersByGroup(String JavaDoc groupId) throws Exception JavaDoc {
124         return userLDAPHandler_.findUsersByGroup(groupId);
125     }
126
127     public void addUserProfileEventListener(UserProfileEventListener listener) {
128         userProfileLDAPHandler_.addUserProfileEventListener(listener);
129     }
130
131     final public UserProfile createUserProfileInstance() {
132         return new UserProfileImpl();
133     }
134
135     final public void saveUserProfile(UserProfile profile) throws Exception JavaDoc {
136         userProfileLDAPHandler_.saveUserProfile(profile);
137     }
138
139     final public UserProfile removeUserProfile(String JavaDoc user) throws Exception JavaDoc {
140         return userProfileLDAPHandler_.removeUserProfile(user);
141     }
142
143     final public UserProfile findUserProfileByName(String JavaDoc userName)
144         throws Exception JavaDoc {
145         return userProfileLDAPHandler_.findUserProfileByName(userName);
146     }
147
148     final public Collection JavaDoc findUserProfiles() throws Exception JavaDoc {
149         return userProfileLDAPHandler_.findUserProfiles();
150     }
151
152     public void addGroupEventListener(GroupEventListener listener) {
153         groupLDAPHandler_.addGroupEventListener(listener);
154     }
155
156     final public Group createGroupInstance() {
157         return new GroupImpl();
158     }
159
160     final public void createGroup(Group group) throws Exception JavaDoc {
161         groupLDAPHandler_.createGroup(group);
162     }
163
164     final public void addChild(Group parent, Group child) throws Exception JavaDoc {
165         groupLDAPHandler_.addChild(parent, child);
166     }
167
168     final public void saveGroup(Group group) throws Exception JavaDoc {
169         groupLDAPHandler_.saveGroup(group);
170     }
171
172     final public Group removeGroup(Group group) throws Exception JavaDoc {
173         return groupLDAPHandler_.removeGroup(group);
174     }
175
176     final public Collection JavaDoc findGroupByMembership(
177         String JavaDoc userName,
178         String JavaDoc membershipType)
179         throws Exception JavaDoc {
180         return groupLDAPHandler_.findGroupByMembership(
181             userName,
182             membershipType);
183     }
184
185     final public Group findGroupByName(String JavaDoc groupName) throws Exception JavaDoc {
186         return groupLDAPHandler_.findGroupByName(groupName);
187     }
188
189     public Group findGroupById(String JavaDoc groupId) throws Exception JavaDoc {
190         return groupLDAPHandler_.findGroupById(groupId);
191     }
192
193     final public Collection JavaDoc findGroups(Group parent) throws Exception JavaDoc {
194         return groupLDAPHandler_.findGroups(parent);
195     }
196
197     final public Collection JavaDoc findGroupsOfUser(String JavaDoc user) throws Exception JavaDoc {
198         return groupLDAPHandler_.findGroupsOfUser(user);
199     }
200
201     public void addMembershipEventListener(MembershipEventListener listener) {
202         membershipLDAPHandler_.addMembershipEventListener(listener);
203     }
204
205     final public Membership createMembershipInstance() {
206         return new MembershipImpl();
207     }
208
209     final public void createMembership(Membership m) throws Exception JavaDoc {
210         membershipLDAPHandler_.createMembership(m);
211     }
212
213     final public void linkMembership(
214         String JavaDoc userName,
215         Group group,
216         Membership m)
217         throws Exception JavaDoc {
218         membershipLDAPHandler_.linkMembership(userName, group, m);
219     }
220
221     final public void saveMembership(Membership m) throws Exception JavaDoc {
222         membershipLDAPHandler_.saveMembership(m);
223     }
224
225     final public Membership removeMembership(String JavaDoc id) throws Exception JavaDoc {
226         return membershipLDAPHandler_.removeMembership(id);
227     }
228
229     public Membership findMembershipByUserGroupAndType(
230         String JavaDoc userName,
231         String JavaDoc groupId,
232         String JavaDoc type)
233         throws Exception JavaDoc {
234         return membershipLDAPHandler_.findMembershipByUserGroupAndType(
235             userName,
236             groupId,
237             type);
238     }
239
240     final public Collection JavaDoc findMembershipsByUserAndGroup(
241         String JavaDoc userName,
242         String JavaDoc groupId)
243         throws Exception JavaDoc {
244         return membershipLDAPHandler_.findMembershipsByUserAndGroup(
245             userName,
246             groupId);
247     }
248
249     final public Collection JavaDoc findMembershipsByUser(String JavaDoc userName)
250         throws Exception JavaDoc {
251         return membershipLDAPHandler_.findMembershipsByUser(userName);
252     }
253
254     final public Collection JavaDoc findMembershipsByGroup(Group group)
255         throws Exception JavaDoc {
256         return membershipLDAPHandler_.findMembershipsByGroup(group);
257     }
258
259     final public Membership findMembership(String JavaDoc id) throws Exception JavaDoc {
260         return membershipLDAPHandler_.findMembership(id);
261     }
262
263     final public MembershipType createMembershipTypeInstance() {
264         return new MembershipTypeImpl();
265     }
266
267     final public MembershipType createMembershipType(MembershipType mt)
268         throws Exception JavaDoc {
269         return membershipTypeLDAPHandler_.createMembershipType(mt);
270     }
271
272     final public MembershipType saveMembershipType(MembershipType mt)
273         throws Exception JavaDoc {
274         return membershipTypeLDAPHandler_.saveMembershipType(mt);
275     }
276
277     final public MembershipType findMembershipType(String JavaDoc name)
278         throws Exception JavaDoc {
279         return membershipTypeLDAPHandler_.findMembershipType(name);
280     }
281
282     final public MembershipType removeMembershipType(String JavaDoc name)
283         throws Exception JavaDoc {
284         return membershipTypeLDAPHandler_.removeMembershipType(name);
285     }
286
287     final public Collection JavaDoc findMembershipTypes() throws Exception JavaDoc {
288         return membershipTypeLDAPHandler_.findMembershipTypes();
289     }
290   
291   public boolean authenticate(String JavaDoc username, String JavaDoc password) throws Exception JavaDoc {
292     return true ;
293   }
294 }
Popular Tags