m2u-upass-core / src / my / com / upass / services / ActivateUserService.java @ 36:d0e2afc0c6e6
History | View | Annotate | Download (1.67 KB)
1 | 0:02300db8682b | hadi | /**
|
---|---|---|---|
2 | * Copyright (c) 2010 Penril Datability (M) Sdn Bhd All rights reserved.
|
||
3 | *
|
||
4 | * This software is copyrighted. Under the copyright laws, this software
|
||
5 | * may not be copied, in whole or in part, without prior written consent
|
||
6 | * of Penril Datability (M) Sdn Bhd or its assignees. This software is
|
||
7 | * provided under the terms of a license between Penril Datability (M)
|
||
8 | * Sdn Bhd and the recipient, and its use is subject to the terms of that
|
||
9 | * license.
|
||
10 | */
|
||
11 | |||
12 | package my.com.upass.services; |
||
13 | |||
14 | import java.util.Date; |
||
15 | |||
16 | import my.com.upass.Constants; |
||
17 | import my.com.upass.dao.DAOFactoryProvider; |
||
18 | import my.com.upass.dao.UserDAO; |
||
19 | 23:1281bdc0fb8f | mohd | import my.com.upass.pojo.MinimalUserBean; |
20 | 0:02300db8682b | hadi | |
21 | /**
|
||
22 | * PROGRAMMER: Danniell
|
||
23 | * CHANGE-NO:
|
||
24 | * TASK-NO:
|
||
25 | * DATE CREATED: Dec 28, 2011
|
||
26 | * TAG AS:
|
||
27 | * REASON(S):
|
||
28 | * MODIFICATION:
|
||
29 | */
|
||
30 | |||
31 | /**
|
||
32 | * <Class description>
|
||
33 | */
|
||
34 | public class ActivateUserService |
||
35 | { |
||
36 | public int activateUser (String userAlias) |
||
37 | { |
||
38 | int rc = Constants.ERR_SYSTEM_NOT_READY;
|
||
39 | |||
40 | if (userAlias == null) |
||
41 | { |
||
42 | return Constants.ERR_INVALID_INPUT;
|
||
43 | } |
||
44 | |||
45 | UserDAO userDao; |
||
46 | |||
47 | try
|
||
48 | { |
||
49 | userDao = DAOFactoryProvider.getDAOFactory ().getUserDAO (); |
||
50 | 35:0530df3f1878 | hadi | MinimalUserBean ub = userDao.getUserFromStore (userAlias, null);
|
51 | 0:02300db8682b | hadi | |
52 | if (ub == null) |
||
53 | { |
||
54 | return Constants.ERR_USERALIAS_NOT_FOUND;
|
||
55 | } |
||
56 | |||
57 | ub.setUstate (Constants.UID_STATE_ACTIVE); |
||
58 | ub.setUdateLastActivated (new Date ()); |
||
59 | ub.setPdateLastUsed(new Date ()); |
||
60 | ub.setPerrorCount(0);
|
||
61 | |||
62 | 35:0530df3f1878 | hadi | if (userDao.updateUserToStore (ub, null)) |
63 | 0:02300db8682b | hadi | { |
64 | rc = Constants.ERR_SUCCESS; |
||
65 | } |
||
66 | else
|
||
67 | { |
||
68 | rc = Constants.ERR_UNKNOWN; |
||
69 | } |
||
70 | } |
||
71 | catch (Exception e) |
||
72 | { |
||
73 | e.printStackTrace (); |
||
74 | } |
||
75 | return rc;
|
||
76 | } |
||
77 | } |