Subversion Repositories SmartDukaan

Rev

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

Rev 2778 Rev 3298
Line 11... Line 11...
11
 
11
 
12
public class CommunityPromotionController implements ParameterAware, ServletContextAware {
12
public class CommunityPromotionController implements ParameterAware, ServletContextAware {
13
 
13
 
14
    protected Map<String, String[]> parameters;
14
    protected Map<String, String[]> parameters;
15
    protected ServletContext context;
15
    protected ServletContext context;
-
 
16
    private String pid;
16
    
17
    
17
    public CommunityPromotionController() {
18
    public CommunityPromotionController() {
18
    }
19
    }
19
 
20
 
20
    public String index()  {
21
    public String index()  {
Line 22... Line 23...
22
        return "success";
23
        return "success";
23
    }
24
    }
24
    
25
    
25
    public String create()  {
26
    public String create()  {
26
    	DataLogger.logSocialData(SocialEventType.COMMUNITY_PROMOTION_VIEWED, "1000");
27
    	DataLogger.logSocialData(SocialEventType.COMMUNITY_PROMOTION_VIEWED, "1000");
-
 
28
    	
-
 
29
    	if (pid != null && pid.equals("bb"))	{
-
 
30
    		return "bb-promo";
-
 
31
    	} else	{
27
        return "success";
32
            return "success";
-
 
33
    	}
28
    }
34
    }
-
 
35
    
-
 
36
    public void setPid(String pid) {
-
 
37
		this.pid = pid;
-
 
38
	}
29
 
39
 
30
    @Override
40
    @Override
31
    public void setParameters(Map<String, String[]> parameters) {
41
    public void setParameters(Map<String, String[]> parameters) {
32
        this.parameters = parameters;
42
        this.parameters = parameters;
33
    }
43
    }
34
 
44
    
35
    @Override
45
    @Override
36
    public void setServletContext(ServletContext context) {
46
    public void setServletContext(ServletContext context) {
37
        this.context = context;
47
        this.context = context;
38
    }
48
    }
39
    
49
    
Line 48... Line 58...
48
    public Map<String, String[]> getParameters()   {
58
    public Map<String, String[]> getParameters()   {
49
        return this.parameters;
59
        return this.parameters;
50
    }
60
    }
51
    
61
    
52
    public String getFBPostedJSON()  {
62
    public String getFBPostedJSON()  {
53
        String str = "";
63
        System.out.println(this.parameters);
-
 
64
 
54
        for(String key: this.parameters.keySet())   {
65
        String str = this.parameters.get("signed_request")[0];
55
            str = this.parameters.get(key)[0];
66
        System.out.println(str);
56
        }
-
 
57
        Base64Encoder decoder = new Base64Encoder();
67
        Base64Encoder decoder = new Base64Encoder();
58
        try {
68
        try {
-
 
69
        	System.out.println(str.split("\\."));
59
            byte[] decodedBytes = decoder.decode(str.split("\\.")[1]);
70
            byte[] decodedBytes = decoder.decode(str.split("\\.")[1]);
60
            return new String(decodedBytes);
71
            String s = new String(decodedBytes).trim();
-
 
72
            String encodedString = decoder.encode(s.getBytes());
-
 
73
            System.out.println(encodedString);
-
 
74
            System.out.println(encodedString.equals(str));
-
 
75
            System.out.println(s);
-
 
76
            return s;
61
        }
77
        }
62
        catch (ArrayIndexOutOfBoundsException e) {
78
        catch (ArrayIndexOutOfBoundsException e) {
63
            e.printStackTrace();
79
            e.printStackTrace();
64
            return "{}";
80
            return "{}";
65
        }
81
        }