Statistics
| Branch: | Revision:

m2u-upass-core / src / my / com / upass / services / ResetTacService.java @ 56:c05a77f786c8

History | View | Annotate | Download (1.95 KB)

1
/**
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
                                TacBean tb = tacDao.getTacFromStore(userAlias, appId);
55
                                if (tb == null) {
56
                                        continue;
57
                                }
58
                                
59
                                // reset TAC
60
                                TacController tc = UPassFactory.getTacController(tb, configsMap.get(appId));
61
                                tc.ResetTAC();
62
                                tc.getUpdatedObject();
63
                                
64
                                if (tacDao.updateTacToStore(tb)) {
65
                                        return Constants.ERR_SUCCESS;
66

    
67
                                } else {
68
                                        return Constants.ERR_UNKNOWN;
69
                                }
70
                        }
71
                        
72
                        rc = Constants.ERR_USERALIAS_NOT_FOUND;
73
                        
74
                } catch (Exception e) {
75
                        e.printStackTrace();
76
                }
77
                return rc;
78
        }
79
}