Subversion Repositories SmartDukaan

Rev

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

package in.shop2020.social.controllers;

import java.util.Map;
import javax.servlet.ServletContext;
import org.apache.struts2.interceptor.ParameterAware;
import org.apache.struts2.util.ServletContextAware;
import org.apache.velocity.context.Context;
import org.apache.velocity.util.ContextAware;

import com.thoughtworks.xstream.core.util.Base64Encoder;

public class CommunityPromotionController implements ParameterAware, ServletContextAware {

    protected Map<String, String[]> parameters;
    protected ServletContext context;
    
    public CommunityPromotionController() {
    }

    public String index()  {
        return "success";
    }
    
    public String create()  {
        return "success";
    }

    @Override
    public void setParameters(Map<String, String[]> parameters) {
        this.parameters = parameters;
    }

    @Override
    public void setServletContext(ServletContext context) {
        this.context = context;
    }
    
    public String getParameter(String key)    {
        String str = "";
        for (int i = 0; i < this.parameters.get(key).length; i ++)  {
            str += this.parameters.get(key)[i];
        }
        return str;
    }
    
    public Map<String, String[]> getParameters()   {
        return this.parameters;
    }
    
    public String getFBPostedJSON()  {
        String str = "";
        for(String key: this.parameters.keySet())   {
            str = this.parameters.get(key)[0];
        }
        Base64Encoder decoder = new Base64Encoder();
        byte[] decodedBytes = decoder.decode(str.split("\\.")[1]);
        return new String(decodedBytes);
    }
    
    public String test()  {
        String[] test = new String[] {"str1", "str2", "str3"};
        String str = "";
        
        for (int i = 0; i < test.length; i ++)  {
            str += test[i];
        }
        return str;
    }
    
    public String getServletContextPath(){
        return context.getContextPath();
    }
}