Subversion Repositories SmartDukaan

Rev

Rev 590 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 590 Rev 620
Line 4... Line 4...
4
package in.shop2020.serving.controllers;
4
package in.shop2020.serving.controllers;
5
 
5
 
6
import in.shop2020.serving.pages.PageContentKeys;
6
import in.shop2020.serving.pages.PageContentKeys;
7
import in.shop2020.serving.pages.PageEnum;
7
import in.shop2020.serving.pages.PageEnum;
8
import in.shop2020.serving.pages.PageManager;
8
import in.shop2020.serving.pages.PageManager;
-
 
9
import in.shop2020.serving.services.PageLoaderHandler;
9
import in.shop2020.thrift.clients.UserContextServiceClient;
10
import in.shop2020.thrift.clients.UserContextServiceClient;
10
import in.shop2020.model.v1.user.UserContextService.Client;
11
import in.shop2020.model.v1.user.UserContextService.Client;
11
 
12
 
12
import java.io.IOException;
13
import java.io.IOException;
13
import java.util.HashMap;
14
import java.util.HashMap;
Line 55... Line 56...
55
	/**
56
	/**
56
	 * 
57
	 * 
57
	 */
58
	 */
58
	private String id;
59
	private String id;
59
	
60
	
-
 
61
	private long productId;
-
 
62
	
60
	private Map<String,String> htmlSnippets;
63
	private Map<String,String> htmlSnippets = new HashMap<String, String>();;
61
	
64
	
62
	
65
	
63
	public EntityController(){
66
	public EntityController(){
64
		super();
67
		super();
65
		pageManager = PageManager.getPageManager();
68
		pageManager = PageManager.getPageManager();
Line 72... Line 75...
72
		@Action("/mobile"),
75
		@Action("/mobile"),
73
		@Action("/entity")
76
		@Action("/entity")
74
	})
77
	})
75
    public HttpHeaders show() throws SecurityException, IOException {
78
    public HttpHeaders show() throws SecurityException, IOException {
76
    	log.info("id=" + id);
79
    	log.info("id=" + id);
77
    	Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
-
 
78
    	
-
 
79
    	params.put(PageContentKeys.ENTITY_ID, id);
-
 
80
    	params.put(PageContentKeys.USER_ID, new Long(userinfo.getUserId()).toString());
-
 
81
    	params.put(PageContentKeys.CART_ID, new Long(userinfo.getCartId()).toString());
-
 
82
    	params.put(PageContentKeys.USER_NAME, userinfo.getNameOfUser());
-
 
83
    	params.put(PageContentKeys.ITEM_COUNT, new Long(userinfo.getTotalItems()).toString());
-
 
84
    	
-
 
85
    	htmlSnippets = pageManager.getPageContents(PageEnum.PRODUCT_PAGE, params);
-
 
86
    	
80
    	
-
 
81
    	PageLoaderHandler pageLoader = new PageLoaderHandler();
87
    	
82
		
-
 
83
		htmlSnippets.put("HEADER", pageLoader.getHeaderHtml(this.userinfo.isLoggedIn(), this.userinfo.getNameOfUser()));
-
 
84
		htmlSnippets.put("MAIN_MENU", pageLoader.getMainMenuHtml());
-
 
85
		htmlSnippets.put("SEARCH_BAR", pageLoader.getSearchBarHtml(userinfo.getTotalItems(), 0));
-
 
86
		
-
 
87
		
-
 
88
		htmlSnippets.put("PRODUCT_SUMMARY", pageLoader.getProductSummaryHtml(productId));
-
 
89
		htmlSnippets.put("SOCIAL_UTILS", pageLoader.getSocialUtilsHtml(productId));
-
 
90
		htmlSnippets.put("SLIDE_GUIDE", pageLoader.getSlideGuideHtml(productId));
-
 
91
		htmlSnippets.put("LOCATOR", pageLoader.getLocatorHtml());
-
 
92
		htmlSnippets.put("REVIEWS", pageLoader.getReviewsHtml(productId));
-
 
93
		
-
 
94
		htmlSnippets.put("CUSTOMER_SERVICE", pageLoader.getCustomerServiceHtml());
-
 
95
		htmlSnippets.put("MY_RESEARCH", pageLoader.getMyResearchHtml(userinfo.getUserId(), true));
-
 
96
		htmlSnippets.put("RECOMMENDATIONS", pageLoader.getRecommendationsHtml());
-
 
97
		htmlSnippets.put("SIMILAR_PRODUCTS", pageLoader.getSimilarProductsHtml(productId));
-
 
98
		htmlSnippets.put("ACCESSORIES", pageLoader.getAccessoriesHtml(productId));
-
 
99
		htmlSnippets.put("FOOTER", pageLoader.getFooterHtml());
88
    	System.out.println(htmlSnippets);
100
		htmlSnippets.put("JS_FILES", "");
89
    	// To update the browse history of the user
101
		htmlSnippets.put("CSS_FILES", "");
-
 
102
	
90
    	try {
103
    	try {
91
			UserContextServiceClient userServiceClient = new UserContextServiceClient();
104
			UserContextServiceClient userServiceClient = new UserContextServiceClient();
92
			Client client = userServiceClient.getClient();
105
			Client client = userServiceClient.getClient();
93
			long item_id = Long.parseLong(id);
106
			long item_id = Long.parseLong(id);
94
			boolean isSessionId = userinfo.isSessionId();
107
			boolean isSessionId = userinfo.isSessionId();
Line 98... Line 111...
98
		} catch (Exception e) {
111
		} catch (Exception e) {
99
			// TODO Auto-generated catch block
112
			// TODO Auto-generated catch block
100
			e.printStackTrace();
113
			e.printStackTrace();
101
		}
114
		}
102
    	
115
    	
103
    	/*
-
 
104
    	String contextPath = this.servletContext.getContextPath();
-
 
105
    	log.info("contextPath=" + contextPath);
-
 
106
    	
-
 
107
    	String realPath = this.servletContext.getRealPath("/");
-
 
108
    	log.info("realPath=" + realPath);
-
 
109
    	
-
 
110
    	String path = this.servletContext.getRealPath(
-
 
111
    			"/WEB-INF/testdir/test.txt");
-
 
112
    	
-
 
113
    	log.info("path=" + path);
-
 
114
    	
-
 
115
    	FileReader fr = new FileReader(new File(path));
-
 
116
    	LineNumberReader lnr = new LineNumberReader(fr);
-
 
117
    	
-
 
118
    	String line = lnr.readLine();
-
 
119
    	log.info("line=" + line);
-
 
120
    	*/
-
 
121
        return new DefaultHttpHeaders("show");
116
    	return new DefaultHttpHeaders("show");
122
    }
117
    }
123
    
118
    
124
    /**
119
    /**
125
     * 
120
     * 
126
     * @param id
121
     * @param id
Line 128... Line 123...
128
    public void setId(String id) {
123
    public void setId(String id) {
129
    	StringTokenizer tokenizer = new StringTokenizer(id,"-");
124
    	StringTokenizer tokenizer = new StringTokenizer(id,"-");
130
    	while(tokenizer.hasMoreTokens()){
125
    	while(tokenizer.hasMoreTokens()){
131
    		this.id = tokenizer.nextToken();
126
    		this.id = tokenizer.nextToken();
132
    	}
127
    	}
-
 
128
    	this.productId = Long.parseLong(id);
133
    }
129
    }
134
 
130
 
135
	/* (non-Javadoc)
131
	/* (non-Javadoc)
136
	 * @see com.opensymphony.xwork2.ModelDriven#getModel()
132
	 * @see com.opensymphony.xwork2.ModelDriven#getModel()
137
	 */
133
	 */