Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
20424 kshitij.so 1
package com.hotspotstore.controllers;
2
 
3
 
4
import org.apache.struts2.convention.annotation.Action;
5
import org.apache.struts2.convention.annotation.Actions;
6
import org.apache.struts2.convention.annotation.Result;
7
import org.apache.struts2.convention.annotation.Results;
8
import org.json.JSONObject;
9
 
10
import com.google.gson.Gson;
11
import com.hotspotstore.model.ContentPojo;
12
import com.hotspotstore.model.Snippet;
13
import com.hotspotstore.storage.Mongo;
14
 
15
@Results({
16
    @Result(name = "show", location = "entity-show.vm"),
17
    @Result(name = "redirect", location = "${redirectUrl}", type = "redirect", params={"statusCode", "301"})
18
})
19
public class EntityController extends BaseController{
20
 
21
	/**
22
	 * 
23
	 */
24
	private static final long serialVersionUID = 1L;
25
	private String id;
26
	private long productId;
27
	private ContentPojo cp;
28
 
29
	@Actions({
30
		@Action("/mobile-phones"),
31
		@Action("/cameras"),
32
		@Action("/mobile-accessories"),
33
		@Action("/tablets"),
34
		@Action("/laptops"),
35
		@Action("/laptop-accessories"),
36
		@Action("/entity"),
37
		@Action("/music-players"),
38
		@Action("/smart-watches"),
39
		@Action("/projectors"),
40
		@Action("/smart-watch-accessories")
41
	})
42
	public String show() throws Exception{
43
		Gson gson = new Gson();
44
		cp = gson.fromJson(Mongo.getEntityById(productId).toString(), ContentPojo.class);
45
		return "show";
46
	}
47
 
48
	public String getId() {
49
		return id;
50
	}
51
 
52
	public ContentPojo getCp() {
53
		return cp;
54
	}
55
 
56
	public void setCp(ContentPojo cp) {
57
		this.cp = cp;
58
	}
59
 
60
	public void setId(String id) {
61
		String[] tokens = id.split("-");
62
    	this.id = tokens[tokens.length - 1];
63
    	this.productId = Long.parseLong(this.id);
64
	}
65
 
66
}