Statistics
| Branch: | Revision:

m2u-upass-core / src / my / com / upass / services / ResetTacService.java @ 5:f608e6319b70

History | View | Annotate | Download (1.98 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 5:f608e6319b70 mohd
                        TacBean tb = null;
54 0:02300db8682b hadi
                        for (Integer appId : configsMap.keySet()) {
55 5:f608e6319b70 mohd
                                tb = tacDao.getTacFromStore(userAlias, appId);
56 0:02300db8682b hadi
57
                                if (tb == null) {
58 5:f608e6319b70 mohd
                                        continue;
59 0:02300db8682b hadi
                                }
60 5:f608e6319b70 mohd
61 0:02300db8682b hadi
                                // reset TAC
62
                                TacController tc = UPassFactory.getTacController(tb, configsMap.get(appId));
63
                                tc.ResetTAC();
64
                                tc.getUpdatedObject();
65
66
                                if (tacDao.updateTacToStore(tb)) {
67
                                        rc = Constants.ERR_SUCCESS;
68
69
                                } else {
70
                                        rc = Constants.ERR_UNKNOWN;
71
                                }
72
                        }
73 5:f608e6319b70 mohd
74
                        if(tb == null){
75
                                rc = Constants.ERR_USERALIAS_NOT_FOUND;
76
                        }
77
78 0:02300db8682b hadi
                } catch (Exception e) {
79
                        e.printStackTrace();
80
                }
81
                return rc;
82
        }
83
}