1
2
3
4
5
6
7 package gov.bnl.gums.account;
8
9 import gov.bnl.gums.configuration.Configuration;
10 import gov.bnl.gums.db.ManualAccountMapperDB;
11
12
13
14
15
16
17
18
19
20
21
22 public class ManualAccountMapper extends AccountMapper {
23 static public String getTypeStatic() {
24 return "manual";
25 }
26
27 private ManualAccountMapperDB db;
28 private String persistenceFactory = "";
29
30 public ManualAccountMapper() {
31 super();
32 }
33
34 public ManualAccountMapper(Configuration configuration) {
35 super(configuration);
36 }
37
38 public ManualAccountMapper(Configuration configuration, String name) {
39 super(configuration, name);
40 }
41
42 public AccountMapper clone(Configuration configuration) {
43 ManualAccountMapper accountMapper = new ManualAccountMapper(configuration, new String(getName()));
44 accountMapper.setDescription(new String(getDescription()));
45 accountMapper.setPersistenceFactory(new String(persistenceFactory));
46 return accountMapper;
47 }
48
49 public void createMapping(String userDN, String account) {
50 getDB().createMapping(userDN, account);
51 }
52
53 public ManualAccountMapperDB getDB() {
54 if (db==null)
55 db = getConfiguration().getPersistenceFactory(persistenceFactory).retrieveManualAccountMapperDB( getName() );
56 return db;
57 }
58
59 public java.util.List getMappings() {
60 return getDB().retrieveMappings();
61 }
62
63 public String getPersistenceFactory() {
64 return persistenceFactory;
65 }
66
67 public String getType() {
68 return "manual";
69 }
70
71 public String mapUser(String userDN, boolean createIfDoesNotExist) {
72 return getDB().retrieveMapping(userDN);
73 }
74
75 public boolean removeMapping(String userDN) {
76 return getDB().removeMapping(userDN);
77 }
78
79 public void setPersistenceFactory(String persistanceFactory) {
80 this.persistenceFactory = persistanceFactory;
81 }
82
83 public String toString(String bgColor) {
84 return "<td bgcolor=\""+bgColor+"\"><a href=\"accountMappers.jsp?command=edit&name=" + getName() + "\">" + getName() + "</a></td><td bgcolor=\""+bgColor+"\">" + getType() + "</td><td bgcolor=\""+bgColor+"\"> </td>";
85 }
86
87 public String toXML() {
88 return "\t\t<manualAccountMapper\n"+
89 "\t\t\tname='"+getName()+"'\n"+
90 "\t\t\tdescription='"+getDescription()+"'\n"+
91 "\t\t\tpersistenceFactory='"+persistenceFactory+"'/>\n\n";
92 }
93 }