| 2351 |
varun.gupt |
1 |
package in.shop2020.social.controllers;
|
|
|
2 |
|
|
|
3 |
import java.util.Map;
|
|
|
4 |
import javax.servlet.ServletContext;
|
|
|
5 |
import org.apache.struts2.interceptor.ParameterAware;
|
|
|
6 |
import org.apache.struts2.util.ServletContextAware;
|
|
|
7 |
import org.apache.velocity.context.Context;
|
|
|
8 |
import org.apache.velocity.util.ContextAware;
|
|
|
9 |
|
|
|
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() {
|
|
|
21 |
return "success";
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
public String create() {
|
|
|
25 |
return "success";
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
@Override
|
|
|
29 |
public void setParameters(Map<String, String[]> parameters) {
|
|
|
30 |
this.parameters = parameters;
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
@Override
|
|
|
34 |
public void setServletContext(ServletContext context) {
|
|
|
35 |
this.context = context;
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
public String getParameter(String key) {
|
|
|
39 |
String str = "";
|
|
|
40 |
for (int i = 0; i < this.parameters.get(key).length; i ++) {
|
|
|
41 |
str += this.parameters.get(key)[i];
|
|
|
42 |
}
|
|
|
43 |
return str;
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
public Map<String, String[]> getParameters() {
|
|
|
47 |
return this.parameters;
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
public String getFBPostedJSON() {
|
|
|
51 |
String str = "";
|
|
|
52 |
for(String key: this.parameters.keySet()) {
|
|
|
53 |
str = this.parameters.get(key)[0];
|
|
|
54 |
}
|
|
|
55 |
Base64Encoder decoder = new Base64Encoder();
|
|
|
56 |
byte[] decodedBytes = decoder.decode(str.split("\\.")[1]);
|
|
|
57 |
return new String(decodedBytes);
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
public String test() {
|
|
|
61 |
String[] test = new String[] {"str1", "str2", "str3"};
|
|
|
62 |
String str = "";
|
|
|
63 |
|
|
|
64 |
for (int i = 0; i < test.length; i ++) {
|
|
|
65 |
str += test[i];
|
|
|
66 |
}
|
|
|
67 |
return str;
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
public String getServletContextPath(){
|
|
|
71 |
return context.getContextPath();
|
|
|
72 |
}
|
|
|
73 |
}
|