Subversion Repositories SmartDukaan

Rev

Rev 1941 | Rev 3213 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1941 ankur.sing 1
package in.shop2020.support.utils;
2
 
3
import java.util.List;
4
 
5
import org.apache.thrift.TException;
6
 
3125 rajveer 7
import in.shop2020.thrift.clients.HelperClient;
1941 ankur.sing 8
import in.shop2020.utils.Report;
9
 
10
public class ReportsUtils {
11
 
12
    public static final String USER_NAME = "username", PASSWORD = "password", ROLE = "role";
13
 
3125 rajveer 14
    private static HelperClient hsc;
1941 ankur.sing 15
 
16
    static {
17
        try {
3125 rajveer 18
            hsc = new HelperClient();
1941 ankur.sing 19
        } catch (Exception e) {
20
            e.printStackTrace();
21
        }
22
    }
23
 
24
    public static boolean canAccessReport(long role, String reportStr) {
25
        if(reportStr.startsWith("/")) {
26
            reportStr = reportStr.substring(1, reportStr.length());
27
        }
28
        List<Report> reports = getReports(role);
29
        for(Report r : reports) {
30
            if(r.getController().equals(reportStr))
31
                return true;
32
        }
33
        return false;
34
    }
35
 
36
    public static List<Report> getReports(long role) {
37
        List<Report> reports = null;
38
        try {
39
            reports = hsc.getClient().getReports(role);
40
        } catch (TException e) {
41
            e.printStackTrace();
42
        }
43
        return reports;
44
    }
45
}