Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
317 ashish 1
/**
2
 * 
3
 */
4
package in.shop2020.serving.controllers;
5
 
375 ashish 6
import in.shop2020.serving.pages.PageContentKeys;
7
import in.shop2020.serving.pages.PageEnum;
8
import in.shop2020.serving.pages.PageManager;
9
 
317 ashish 10
import java.io.IOException;
375 ashish 11
import java.util.HashMap;
12
import java.util.Map;
317 ashish 13
 
14
import javax.servlet.ServletContext;
15
 
16
import org.apache.juli.logging.Log;
17
import org.apache.juli.logging.LogFactory;
18
import org.apache.struts2.convention.annotation.Result;
19
import org.apache.struts2.convention.annotation.Results;
20
import org.apache.struts2.rest.DefaultHttpHeaders;
21
import org.apache.struts2.rest.HttpHeaders;
22
import org.apache.struts2.util.ServletContextAware;
23
 
24
import com.opensymphony.xwork2.ModelDriven;
25
 
26
/**
27
 * 
28
 * @author naveen
29
 *
30
 */
31
@Results({
32
    @Result(name="success", type="redirectAction", params = {"actionName" , 
33
    		"entity"})
34
})
35
public class EntityController extends BaseController 
36
	implements  ModelDriven<Object>, ServletContextAware  {
37
 
375 ashish 38
	private PageManager pageManager = null;
39
 
317 ashish 40
	/**
41
	 * 
42
	 */
43
	private static Log log = LogFactory.getLog(EntityController.class);
44
 
45
	/**
46
	 * 
47
	 */
48
	@SuppressWarnings("unused")
49
	private ServletContext servletContext = null;
50
 
51
	/**
52
	 * 
53
	 */
54
	private String id;
375 ashish 55
 
56
	private String sample;
57
 
58
 
59
	public EntityController(){
60
		super();
61
		pageManager = PageManager.getPageManager();
62
	}
317 ashish 63
    // GET /entity/1000001
64
    public HttpHeaders show() throws SecurityException, IOException {
65
    	log.info("id=" + id);
375 ashish 66
    	Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
67
    	params.put(PageContentKeys.ENTITY_ID, id);
68
    	Map<String,String> contents = pageManager.getPageContents(PageEnum.PRODUCT_PAGE, params);
69
    	sample = contents.get("SLIDE_GUIDE");
70
    	System.out.println(sample);
317 ashish 71
    	/*
72
    	String contextPath = this.servletContext.getContextPath();
73
    	log.info("contextPath=" + contextPath);
74
 
75
    	String realPath = this.servletContext.getRealPath("/");
76
    	log.info("realPath=" + realPath);
77
 
78
    	String path = this.servletContext.getRealPath(
79
    			"/WEB-INF/testdir/test.txt");
80
 
81
    	log.info("path=" + path);
82
 
83
    	FileReader fr = new FileReader(new File(path));
84
    	LineNumberReader lnr = new LineNumberReader(fr);
85
 
86
    	String line = lnr.readLine();
87
    	log.info("line=" + line);
88
    	*/
89
        return new DefaultHttpHeaders("show");
90
    }
91
 
92
    /**
93
     * 
94
     * @param id
95
     */
96
    public void setId(String id) {
97
        this.id = id;
98
    }
99
 
100
	/* (non-Javadoc)
101
	 * @see com.opensymphony.xwork2.ModelDriven#getModel()
102
	 */
103
	@Override
104
	public Object getModel() {
105
		return this.id;
106
	}
107
 
108
	/**
109
	 * 
110
	 */
111
	@Override
112
	public void setServletContext(ServletContext servletContext) {
113
		this.servletContext = servletContext;
114
	}
375 ashish 115
 
116
	public String getSample(){
117
		return sample;
118
	}
317 ashish 119
 
120
}