Rev 5190 | Rev 5497 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*** @author Varun Gupta*/package in.shop2020.serving.controllers;import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.HashMap;import java.util.Map;import in.shop2020.serving.utils.Utils;import org.apache.commons.lang.WordUtils;import org.apache.log4j.Logger;public class GeneratedController extends BaseController {private static Logger logger = Logger.getLogger(GeneratedController.class);private static String BASE_PATH = Utils.EXPORT_ENTITIES_PATH + "../../partners/";private static Map<String, String> snippetFileNames = new HashMap<String, String>();private static Map<String, String> snippets = new HashMap<String, String>();private String id;static {try {snippetFileNames.put("product-index", BASE_PATH + "productindex.html");snippetFileNames.put("accessories-compatibility-index", BASE_PATH + "compatible-accessories-index.html");snippetFileNames.put("most-compared-phones", BASE_PATH + "most-compared-index.html");for (String index: snippetFileNames.keySet()) {FileReader fr = new FileReader(snippetFileNames.get(index));BufferedReader br = new BufferedReader(fr);StringBuilder sb = new StringBuilder();String str = null;while ((str = br.readLine()) != null) {sb.append(str);}snippets.put(index, sb.toString());}} catch (IOException e) {logger.error("", e);}}public GeneratedController() {super();}public String show() {return "show";}public String getHTML() {return snippets.get(id);}public String getTitle() {String[] urlChunks = request.getServletPath().split("/");String title = urlChunks[urlChunks.length - 1].replaceAll("-", " ");return WordUtils.capitalize(title);}public void setId(String id) {this.id = id;}}