1
2
3
4 package net.smartlab.web.auth.handlers;
5
6 import java.util.Map;
7
8 import org.apache.commons.beanutils.BeanUtils;
9
10 import net.smartlab.web.BusinessException;
11 import net.smartlab.web.auth.User;
12 import net.smartlab.web.auth.User.Status;
13
14
15
16
17 public class BusinessObjectAssociationRegistrationHandler extends AbstractAssociationRegistrationHandler {
18
19 public static final String BUSINESS_OBJECT_ASSOCIATION_KEY = "BUSINESS_OBJECT_ASSOCIATION_KEY";
20
21
22
23
24
25
26
27
28 protected User associate(Map parameters, User user) throws BusinessException {
29 user.setProperty(BUSINESS_OBJECT_ASSOCIATION_KEY, (String)parameters.get(BUSINESS_OBJECT_ASSOCIATION_KEY));
30
31 domain.updateUser(user);
32 return user;
33 }
34
35
36
37
38
39
40
41 protected User updateUser(Map parameters, User user) throws BusinessException {
42 if (user == null || user.getId() == 0) {
43
44 user = new User();
45 try {
46 BeanUtils.populate(user, parameters);
47 } catch (Exception e) {
48 throw new BusinessException("Error inserting user", e);
49 }
50 }
51 user.setStatus(Status.PENDING);
52
53 domain.updateUser(user);
54 return user;
55 }
56
57
58
59
60
61
62 public void destroy() throws Exception {
63
64 }
65
66
67
68
69
70
71 public void init(Map parameters) throws Exception {
72
73 }
74 }