Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
5121 varun.gupt 1
/**
2
 * @author Varun Gupta
3
 */
4
 
5
package in.shop2020.serving.controllers;
6
 
7
import java.io.BufferedReader;
8
import java.io.FileReader;
9
import java.io.IOException;
10
import java.util.HashMap;
11
import java.util.Map;
12
 
13
import in.shop2020.serving.utils.Utils;
14
 
15
import org.apache.log4j.Logger;
16
 
17
public class GeneratedController extends BaseController {
18
 
19
	private static Logger logger = Logger.getLogger(GeneratedController.class);
20
	private static String BASE_PATH = Utils.EXPORT_ENTITIES_PATH + "../../partners/";
21
	private static Map<String, String> snippetFileNames = new HashMap<String, String>();
22
	private static Map<String, String> snippets = new HashMap<String, String>();
23
 
24
	private String id;
25
 
26
	static	{
27
		try {
28
			snippetFileNames.put("product-index", BASE_PATH + "productindex.html");
29
			snippetFileNames.put("accessories-compatibility-index", BASE_PATH + "compatible-accessories-index.html");
30
 
31
			for (String index: snippetFileNames.keySet())	{
32
 
33
				FileReader fr = new FileReader(snippetFileNames.get(index));
34
				BufferedReader br = new BufferedReader(fr);
35
		        StringBuilder sb = new StringBuilder();
36
		        String str = null;
37
 
38
				while ((str = br.readLine()) != null) {
39
					sb.append(str);
40
				}
41
				snippets.put(index, sb.toString());
42
			}
43
		} catch (IOException e) {
44
			logger.error("", e);
45
		}
46
	}
47
 
48
	public GeneratedController()	{
49
		super();
50
	}
51
 
52
	public String show()	{
53
		return "show";
54
	}
55
 
56
	public String getHTML()	{
57
		return snippets.get(id);
58
	}
59
 
60
	public String getHeading()	{
61
		return null;
62
	}
63
 
64
	public void setId(String id) {
65
		this.id = id;
66
	}
67
}