m2u-upass-core / src / my / com / upass / services / ResetTacService.java @ 70:be137fe903ee
History | View | Annotate | Download (1.95 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.Map; |
||
15 | |||
16 | import my.com.upass.ConfigBean; |
||
17 | import my.com.upass.Constants; |
||
18 | import my.com.upass.UPassControllerV2; |
||
19 | import my.com.upass.dao.DAOFactoryProvider; |
||
20 | import my.com.upass.dao.UserTacDAO; |
||
21 | import my.com.upass.factory.UPassFactory; |
||
22 | import my.com.upass.pojo.TacBean; |
||
23 | import my.com.upass.tac.TacController; |
||
24 | |||
25 | /**
|
||
26 | * PROGRAMMER: Danniell
|
||
27 | * CHANGE-NO:
|
||
28 | * TASK-NO:
|
||
29 | * DATE CREATED: Dec 28, 2011
|
||
30 | * TAG AS:
|
||
31 | * REASON(S):
|
||
32 | * MODIFICATION:
|
||
33 | */
|
||
34 | |||
35 | /**
|
||
36 | * <Class description>
|
||
37 | */
|
||
38 | public class ResetTacService { |
||
39 | |||
40 | private UPassControllerV2 upc;
|
||
41 | |||
42 | public ResetTacService(UPassControllerV2 upc) {
|
||
43 | this.upc = upc;
|
||
44 | } |
||
45 | |||
46 | public int resetTAC(String userAlias) { |
||
47 | |||
48 | int rc = Constants.ERR_SYSTEM_NOT_READY;
|
||
49 | try {
|
||
50 | UserTacDAO tacDao = DAOFactoryProvider.getDAOFactory().getUserTacDAO(); |
||
51 | |||
52 | final Map<Integer, ConfigBean> configsMap = upc.getConfigurationsMap(); |
||
53 | for (Integer appId : configsMap.keySet()) { |
||
54 | 8:1982e43e6686 | mohd | TacBean tb = tacDao.getTacFromStore(userAlias, appId); |
55 | 0:02300db8682b | hadi | if (tb == null) { |
56 | 5:f608e6319b70 | mohd | continue;
|
57 | 0:02300db8682b | hadi | } |
58 | 5:f608e6319b70 | mohd | |
59 | 0:02300db8682b | hadi | // reset TAC
|
60 | TacController tc = UPassFactory.getTacController(tb, configsMap.get(appId)); |
||
61 | tc.ResetTAC(); |
||
62 | tc.getUpdatedObject(); |
||
63 | 8:1982e43e6686 | mohd | |
64 | 0:02300db8682b | hadi | if (tacDao.updateTacToStore(tb)) {
|
65 | 8:1982e43e6686 | mohd | return Constants.ERR_SUCCESS;
|
66 | 0:02300db8682b | hadi | |
67 | } else {
|
||
68 | 8:1982e43e6686 | mohd | return Constants.ERR_UNKNOWN;
|
69 | 0:02300db8682b | hadi | } |
70 | } |
||
71 | 5:f608e6319b70 | mohd | |
72 | 8:1982e43e6686 | mohd | rc = Constants.ERR_USERALIAS_NOT_FOUND; |
73 | 5:f608e6319b70 | mohd | |
74 | 0:02300db8682b | hadi | } catch (Exception e) { |
75 | e.printStackTrace(); |
||
76 | } |
||
77 | return rc;
|
||
78 | } |
||
79 | } |