Subversion Repositories SmartDukaan

Rev

Rev 2419 | Rev 2434 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2419 Rev 2426
Line 10... Line 10...
10
import in.shop2020.serving.utils.DataLogger;
10
import in.shop2020.serving.utils.DataLogger;
11
import in.shop2020.thrift.clients.CatalogServiceClient;
11
import in.shop2020.thrift.clients.CatalogServiceClient;
12
import in.shop2020.thrift.clients.UserContextServiceClient;
12
import in.shop2020.thrift.clients.UserContextServiceClient;
13
 
13
 
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.net.URLEncoder;
-
 
16
import java.util.Map;
15
import java.util.Map;
17
import java.util.StringTokenizer;
16
import java.util.StringTokenizer;
18
 
17
 
19
import org.apache.log4j.Logger;
18
import org.apache.log4j.Logger;
20
import org.apache.struts2.convention.annotation.Action;
19
import org.apache.struts2.convention.annotation.Action;
21
import org.apache.struts2.convention.annotation.Actions;
20
import org.apache.struts2.convention.annotation.Actions;
22
import org.apache.struts2.convention.annotation.Result;
21
import org.apache.struts2.convention.annotation.Result;
23
import org.apache.struts2.convention.annotation.Results;
22
import org.apache.struts2.convention.annotation.Results;
24
import org.apache.velocity.VelocityContext;
-
 
25
import org.json.JSONException;
23
import org.json.JSONException;
26
import org.json.JSONObject;
24
import org.json.JSONObject;
27
 
25
 
28
/**
26
/**
29
 * 
27
 * 
Line 96... Line 94...
96
    	//Extracting Product name from Page Title
94
    	//Extracting Product name from Page Title
97
        String[] items = pageTitle.split("\\|");
95
        String[] items = pageTitle.split("\\|");
98
    	String productName = items[0] != null ? items[0].trim() : null;
96
    	String productName = items[0] != null ? items[0].trim() : null;
99
    	String rootUrl = currentUrl.split("/")[2];
97
    	String rootUrl = currentUrl.split("/")[2];
100
    	
98
    	
101
    	String productUrlEncoded = URLEncoder.encode(currentUrl, "UTF-8");
-
 
102
    	
99
    	
103
    	htmlSnippets.put("PRODUCT_SUMMARY", pageLoader.getProductSummaryHtml(productId));
100
    	htmlSnippets.put("PRODUCT_SUMMARY", pageLoader.getProductSummaryHtml(productId));
104
    	htmlSnippets.put("PRODUCT_ID", productId + "");
101
    	htmlSnippets.put("PRODUCT_ID", productId + "");
105
    	htmlSnippets.put("PRODUCT_NAME", productName);
102
    	htmlSnippets.put("PRODUCT_NAME", productName);
106
    	htmlSnippets.put("PRODUCT_URL", currentUrl);
103
    	htmlSnippets.put("PRODUCT_URL", currentUrl);
107
    	htmlSnippets.put("PRODUCT_URL_ENCODED", productUrlEncoded);
-
 
108
    	htmlSnippets.put("ROOT_URL", "http://" + rootUrl);
104
    	htmlSnippets.put("ROOT_URL", "http://" + rootUrl);
109
		htmlSnippets.put("SOCIAL_UTILS", getSocialUtilsHtml(productId, productName, productUrlEncoded));
-
 
110
		htmlSnippets.put("SLIDE_GUIDE", pageLoader.getSlideGuideHtml(productId));
105
		htmlSnippets.put("SLIDE_GUIDE", pageLoader.getSlideGuideHtml(productId));
111
		htmlSnippets.put("PAGE_TITLE", pageTitle.trim());
106
		htmlSnippets.put("PAGE_TITLE", pageTitle.trim());
112
		htmlSnippets.put("PAGE_METADESC", metaDescription);
107
		htmlSnippets.put("PAGE_METADESC", metaDescription);
113
		htmlSnippets.put("PAGE_METAKEYWORDS", metaKeywords);
108
		htmlSnippets.put("PAGE_METAKEYWORDS", metaKeywords);
114
	
109
	
Line 170... Line 165...
170
	
165
	
171
	public String getPageMetaKeywordsSnippet(){
166
	public String getPageMetaKeywordsSnippet(){
172
		return htmlSnippets.get("PAGE_METAKEYWORDS");
167
		return htmlSnippets.get("PAGE_METAKEYWORDS");
173
	}
168
	}
174
	
169
	
175
	public String getSocialUtilsSnippet(){
-
 
176
		return htmlSnippets.get("SOCIAL_UTILS"); 
-
 
177
	}
-
 
178
	
-
 
179
	public String getLocatorSnippet(){
-
 
180
		return htmlSnippets.get("LOCATOR");
-
 
181
	}
-
 
182
	
-
 
183
	public String getRecommendationsSnippet(){
-
 
184
		return htmlSnippets.get("RECOMMENDATIONS");
-
 
185
	}
-
 
186
	
-
 
187
	public String getSimilarProductsSnippet(){
-
 
188
		return htmlSnippets.get("SIMILAR_PRODUCTS");
-
 
189
	}
-
 
190
	
-
 
191
	public String getAccessoriesSnippet(){
-
 
192
		return htmlSnippets.get("ACCESSORIES");
-
 
193
	}
-
 
194
	
-
 
195
	public String getReviewsSnippet(){
-
 
196
		return htmlSnippets.get("REVIEWS");
-
 
197
	}
-
 
198
	
-
 
199
	public String getProductName()	{
170
	public String getProductName()	{
200
		return htmlSnippets.get("PRODUCT_NAME");
171
		return htmlSnippets.get("PRODUCT_NAME");
201
	}
172
	}
202
 
173
 
203
	public String getProductId()	{
174
	public String getProductId()	{
Line 209... Line 180...
209
	}
180
	}
210
	
181
	
211
	public String getRootUrl()	{
182
	public String getRootUrl()	{
212
		return htmlSnippets.get("ROOT_URL");
183
		return htmlSnippets.get("ROOT_URL");
213
	}
184
	}
214
 
-
 
215
	private String getSocialUtilsHtml(long productId, String productName, String productEncodedUrl) {
-
 
216
		String htmlString = "";
-
 
217
		VelocityContext context = new VelocityContext();
-
 
218
		
-
 
219
		String templateFile = "templates/socialutils.vm";
-
 
220
		
-
 
221
		context.put("PRODUCT_ID", productId + "");
-
 
222
		context.put("PRODUCT_NAME", productName);
-
 
223
		context.put("PRODUCT_URL_ENCODED", productEncodedUrl);
-
 
224
		
-
 
225
		htmlString = pageLoader.getHtmlFromVelocity(templateFile, context);
-
 
226
		return htmlString;
-
 
227
	}
-
 
228
}
185
}
229
186