Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
2351 varun.gupt 1
package in.shop2020.social.controllers;
2
 
2778 varun.gupt 3
import in.shop2020.datalogger.SocialEventType;
4
import in.shop2020.utils.DataLogger;
5
 
2351 varun.gupt 6
import java.util.Map;
7
import javax.servlet.ServletContext;
8
import org.apache.struts2.interceptor.ParameterAware;
9
import org.apache.struts2.util.ServletContextAware;
10
import com.thoughtworks.xstream.core.util.Base64Encoder;
11
 
12
public class CommunityPromotionController implements ParameterAware, ServletContextAware {
13
 
14
    protected Map<String, String[]> parameters;
15
    protected ServletContext context;
16
 
17
    public CommunityPromotionController() {
18
    }
19
 
20
    public String index()  {
2778 varun.gupt 21
    	DataLogger.logSocialData(SocialEventType.COMMUNITY_PROMOTION_VIEWED, "1000");
2351 varun.gupt 22
        return "success";
23
    }
24
 
25
    public String create()  {
2778 varun.gupt 26
    	DataLogger.logSocialData(SocialEventType.COMMUNITY_PROMOTION_VIEWED, "1000");
2351 varun.gupt 27
        return "success";
28
    }
29
 
30
    @Override
31
    public void setParameters(Map<String, String[]> parameters) {
32
        this.parameters = parameters;
33
    }
34
 
35
    @Override
36
    public void setServletContext(ServletContext context) {
37
        this.context = context;
38
    }
39
 
40
    public String getParameter(String key)    {
41
        String str = "";
42
        for (int i = 0; i < this.parameters.get(key).length; i ++)  {
43
            str += this.parameters.get(key)[i];
44
        }
45
        return str;
46
    }
47
 
48
    public Map<String, String[]> getParameters()   {
49
        return this.parameters;
50
    }
51
 
52
    public String getFBPostedJSON()  {
53
        String str = "";
54
        for(String key: this.parameters.keySet())   {
55
            str = this.parameters.get(key)[0];
56
        }
57
        Base64Encoder decoder = new Base64Encoder();
2468 varun.gupt 58
        try {
59
            byte[] decodedBytes = decoder.decode(str.split("\\.")[1]);
60
            return new String(decodedBytes);
61
        }
62
        catch (ArrayIndexOutOfBoundsException e) {
63
            e.printStackTrace();
64
            return "{}";
65
        }
2351 varun.gupt 66
    }
67
 
68
    public String test()  {
69
        String[] test = new String[] {"str1", "str2", "str3"};
70
        String str = "";
71
 
72
        for (int i = 0; i < test.length; i ++)  {
73
            str += test[i];
74
        }
75
        return str;
76
    }
77
 
78
    public String getServletContextPath(){
79
        return context.getContextPath();
80
    }
81
}