Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

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