1
2
3
4
5
6
7
8
9 package com.buckosoft.PicMan.business.common;
10
11 import org.apache.commons.logging.Log;
12 import org.apache.commons.logging.LogFactory;
13
14 import com.buckosoft.BSAccount.BSAccountMan;
15 import com.buckosoft.BSAccount.domain.BSAccount;
16 import com.buckosoft.BSAccount.domain.BSAccountUser;
17 import com.buckosoft.BSAccount.web.BSAccountUserWebSession;
18 import com.buckosoft.PicMan.db.DatabaseFacade;
19 import com.buckosoft.PicMan.domain.User;
20
21
22
23
24
25
26 public class UserFactory implements com.buckosoft.BSAccount.domain.UserFactory {
27 protected final static boolean DEBUG = false;
28 protected final Log logger = LogFactory.getLog(getClass());
29
30 @SuppressWarnings("unused")
31 private BSAccountMan bsAccountMan = null;
32
33 private DatabaseFacade dbf;
34
35
36
37
38 public void setDatabase(DatabaseFacade dbf) { this.dbf = dbf; }
39
40
41
42
43
44 public void setBsAccountMan(BSAccountMan bsAccountMan) {
45 this.bsAccountMan = bsAccountMan;
46 }
47
48
49
50
51 public BSAccountUser getNewUser() {
52 if (DEBUG)
53 logger.info("getNewUser()");
54 return(new User(null));
55 }
56
57
58
59
60 public BSAccountUserWebSession getNewUserWebSession(BSAccountUser user) {
61 return(new BSAccountUserWebSession(user));
62 }
63
64
65
66
67 public BSAccountUser getUser(BSAccount account) {
68 if (DEBUG)
69 logger.info("getUser: " + account == null ? "account = null" : "account userid=" + account.getUserId());
70 if (account == null)
71 return(null);
72 User user = null;
73 user = dbf.getUser(account.getUserId());
74 if (user == null)
75 return(new User(account));
76 user.setAccount(account);
77 return(user);
78 }
79
80 }