Subversion Repositories SmartDukaan

Rev

Rev 3125 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3125 Rev 3213
Line 1... Line 1...
1
package in.shop2020.support.utils;
1
package in.shop2020.support.utils;
2
 
2
 
3
import java.util.List;
3
import java.util.List;
4
 
4
 
5
import org.apache.thrift.TException;
5
import org.apache.thrift.TException;
-
 
6
import org.slf4j.Logger;
-
 
7
import org.slf4j.LoggerFactory;
6
 
8
 
7
import in.shop2020.thrift.clients.HelperClient;
9
import in.shop2020.thrift.clients.HelperClient;
8
import in.shop2020.utils.Report;
10
import in.shop2020.utils.Report;
9
 
11
 
10
public class ReportsUtils {
12
public class ReportsUtils {
11
 
13
 
-
 
14
    public static Logger logger = LoggerFactory.getLogger(ReportsUtils.class);
-
 
15
    
12
    public static final String USER_NAME = "username", PASSWORD = "password", ROLE = "role";
16
    public static final String USER_NAME = "username", PASSWORD = "password", ROLE = "role";
13
    
17
    
14
    private static HelperClient hsc;
18
    private static HelperClient hsc;
15
    
19
    
16
    static {
20
    static {
17
        try {
21
        try {
18
            hsc = new HelperClient();
22
            hsc = new HelperClient();
19
        } catch (Exception e) {
23
        } catch (Exception e) {
20
            e.printStackTrace();
24
            logger.error("Unable to initialize connection to the helper service", e);
21
        }
25
        }
22
    }
26
    }
23
    
27
    
24
    public static boolean canAccessReport(long role, String reportStr) {
28
    public static boolean canAccessReport(long role, String reportStr) {
25
        if(reportStr.startsWith("/")) {
29
        if(reportStr.startsWith("/")) {
Line 36... Line 40...
36
    public static List<Report> getReports(long role) {
40
    public static List<Report> getReports(long role) {
37
        List<Report> reports = null;
41
        List<Report> reports = null;
38
        try {
42
        try {
39
            reports = hsc.getClient().getReports(role);
43
            reports = hsc.getClient().getReports(role);
40
        } catch (TException e) {
44
        } catch (TException e) {
41
            e.printStackTrace();
45
            logger.error("Unable to get reports for the role: " + role, e);
42
        }
46
        }
43
        return reports;
47
        return reports;
44
    }
48
    }
45
}
49
}