1 5 package org.exoplatform.services.organization.ldap; 6 7 8 9 import java.util.ArrayList ; 10 import java.util.Collection ; 11 import java.util.List ; 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 39 public class OrganizationServiceLDAPImpl 40 implements OrganizationService, Startable { 41 42 44 UserLDAPHandler userLDAPHandler_; 45 UserProfileLDAPHandler userProfileLDAPHandler_; 46 GroupLDAPHandler groupLDAPHandler_; 47 MembershipLDAPHandler membershipLDAPHandler_; 48 MembershipTypeLDAPHandler membershipTypeLDAPHandler_; 49 50 private List 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 (); 65 } 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 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 { 100 userLDAPHandler_.createUser(user); 101 } 102 103 final public void saveUser(User user) throws Exception { 104 userLDAPHandler_.saveUser(user); 105 } 106 107 final public User removeUser(String user) throws Exception { 108 return userLDAPHandler_.removeUser(user); 109 } 110 111 final public User findUserByName(String userName) throws Exception { 112 return userLDAPHandler_.findUserByName(userName); 113 } 114 115 public PageList getUserPageList(int pageSize) throws Exception { 116 return userLDAPHandler_.getUserPageList(pageSize); 117 } 118 119 final public PageList findUsers(Query query) throws Exception { 120 return userLDAPHandler_.findUsers(query); 121 } 122 123 final public PageList findUsersByGroup(String groupId) throws Exception { 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 { 136 userProfileLDAPHandler_.saveUserProfile(profile); 137 } 138 139 final public UserProfile removeUserProfile(String user) throws Exception { 140 return userProfileLDAPHandler_.removeUserProfile(user); 141 } 142 143 final public UserProfile findUserProfileByName(String userName) 144 throws Exception { 145 return userProfileLDAPHandler_.findUserProfileByName(userName); 146 } 147 148 final public Collection findUserProfiles() throws Exception { 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 { 161 groupLDAPHandler_.createGroup(group); 162 } 163 164 final public void addChild(Group parent, Group child) throws Exception { 165 groupLDAPHandler_.addChild(parent, child); 166 } 167 168 final public void saveGroup(Group group) throws Exception { 169 groupLDAPHandler_.saveGroup(group); 170 } 171 172 final public Group removeGroup(Group group) throws Exception { 173 return groupLDAPHandler_.removeGroup(group); 174 } 175 176 final public Collection findGroupByMembership( 177 String userName, 178 String membershipType) 179 throws Exception { 180 return groupLDAPHandler_.findGroupByMembership( 181 userName, 182 membershipType); 183 } 184 185 final public Group findGroupByName(String groupName) throws Exception { 186 return groupLDAPHandler_.findGroupByName(groupName); 187 } 188 189 public Group findGroupById(String groupId) throws Exception { 190 return groupLDAPHandler_.findGroupById(groupId); 191 } 192 193 final public Collection findGroups(Group parent) throws Exception { 194 return groupLDAPHandler_.findGroups(parent); 195 } 196 197 final public Collection findGroupsOfUser(String user) throws Exception { 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 { 210 membershipLDAPHandler_.createMembership(m); 211 } 212 213 final public void linkMembership( 214 String userName, 215 Group group, 216 Membership m) 217 throws Exception { 218 membershipLDAPHandler_.linkMembership(userName, group, m); 219 } 220 221 final public void saveMembership(Membership m) throws Exception { 222 membershipLDAPHandler_.saveMembership(m); 223 } 224 225 final public Membership removeMembership(String id) throws Exception { 226 return membershipLDAPHandler_.removeMembership(id); 227 } 228 229 public Membership findMembershipByUserGroupAndType( 230 String userName, 231 String groupId, 232 String type) 233 throws Exception { 234 return membershipLDAPHandler_.findMembershipByUserGroupAndType( 235 userName, 236 groupId, 237 type); 238 } 239 240 final public Collection findMembershipsByUserAndGroup( 241 String userName, 242 String groupId) 243 throws Exception { 244 return membershipLDAPHandler_.findMembershipsByUserAndGroup( 245 userName, 246 groupId); 247 } 248 249 final public Collection findMembershipsByUser(String userName) 250 throws Exception { 251 return membershipLDAPHandler_.findMembershipsByUser(userName); 252 } 253 254 final public Collection findMembershipsByGroup(Group group) 255 throws Exception { 256 return membershipLDAPHandler_.findMembershipsByGroup(group); 257 } 258 259 final public Membership findMembership(String id) throws Exception { 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 { 269 return membershipTypeLDAPHandler_.createMembershipType(mt); 270 } 271 272 final public MembershipType saveMembershipType(MembershipType mt) 273 throws Exception { 274 return membershipTypeLDAPHandler_.saveMembershipType(mt); 275 } 276 277 final public MembershipType findMembershipType(String name) 278 throws Exception { 279 return membershipTypeLDAPHandler_.findMembershipType(name); 280 } 281 282 final public MembershipType removeMembershipType(String name) 283 throws Exception { 284 return membershipTypeLDAPHandler_.removeMembershipType(name); 285 } 286 287 final public Collection findMembershipTypes() throws Exception { 288 return membershipTypeLDAPHandler_.findMembershipTypes(); 289 } 290 291 public boolean authenticate(String username, String password) throws Exception { 292 return true ; 293 } 294 } | Popular Tags |