01: /**
02: *
03: * Bonita
04: * Copyright (C) 1999 Bull S.A.
05: * Bull 68 route de versailles 78434 Louveciennes Cedex France
06: * Further information: bonita@objectweb.org
07: *
08: * This library is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Lesser General Public
10: * License as published by the Free Software Foundation; either
11: * version 2.1 of the License, or any later version.
12: *
13: * This library is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * Lesser General Public License for more details.
17: *
18: * You should have received a copy of the GNU Lesser General Public
19: * License along with this library; if not, write to the Free Software
20: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21: * USA
22: *
23: *
24: --------------------------------------------------------------------------
25: * $Id: LdapGroupMembers.java,v 1.3 2005/07/06 12:26:51 blachonm Exp $
26: *
27: --------------------------------------------------------------------------
28: */package hero.mapper;
29:
30: import hero.util.HeroException;
31: import hero.interfaces.BnRoleLocal;
32:
33: // Use of BnLdap session Bean
34: import hero.interfaces.BnLdap;
35: import hero.interfaces.BnLdapHome;
36: import hero.interfaces.BnLdapUtil;
37: import java.util.*;
38:
39: public class LdapGroupMembers implements hero.mapper.RoleMapperI {
40:
41: public Collection searchMembers(Object b, BnRoleLocal n,
42: String userName) throws HeroException {
43:
44: String roleName = n.getName();
45: String projectName = n.getBnProject().getName();
46: //System.out.println("[Search Group Members] BnRole name:"+roleName + " - Project name = " + projectName);
47: ArrayList al = null;
48:
49: BnLdapHome home = null;
50: try {
51: home = BnLdapUtil.getHome();
52: } catch (Exception e) {
53: System.err.println("Cannot lookup BnLdapHome: " + e);
54: System.exit(2);
55: }
56:
57: BnLdap t1 = null;
58: try {
59: // logs trace
60: //System.out.println("Create a bean bnLdap");
61: t1 = home.create();
62: } catch (Exception e) {
63: throw new HeroException("Cannot create BnLdapBean : " + e);
64: }
65: try {
66: al = (ArrayList) t1.getGroupMembers(roleName);
67: } catch (Exception e) {
68: throw new HeroException(
69: "Error getting group members for group: "
70: + roleName + " " + e.getMessage());
71: }
72: return al;
73:
74: }
75:
76: }
|