Subversion Repositories SmartDukaan

Rev

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

Rev 1325 Rev 1364
Line 14... Line 14...
14
 
14
 
15
import org.apache.log4j.Logger;
15
import org.apache.log4j.Logger;
16
import org.apache.struts2.convention.annotation.Action;
16
import org.apache.struts2.convention.annotation.Action;
17
import org.apache.struts2.convention.annotation.Actions;
17
import org.apache.struts2.convention.annotation.Actions;
18
import org.apache.struts2.convention.annotation.Result;
18
import org.apache.struts2.convention.annotation.Result;
-
 
19
import org.apache.velocity.VelocityContext;
19
 
20
 
20
/**
21
/**
21
 * 
22
 * 
22
 * @author rajveer
23
 * @author rajveer
23
 *
24
 *
Line 52... Line 53...
52
    	
53
    	
53
    	//Extracting Product name from Page Title
54
    	//Extracting Product name from Page Title
54
    	
55
    	
55
    	String[] items = pageTitle.split("\\|");
56
    	String[] items = pageTitle.split("\\|");
56
    	String productName = items[0] != null ? items[0].trim() : null;
57
    	String productName = items[0] != null ? items[0].trim() : null;
57
    	String productUrl = "";
58
    	String rootUrl = request.getRequestURL().toString().split("/")[2];
58
    	String baseUrl = "";
59
    	
-
 
60
    	String productUrlEncoded = URLEncoder.encode(request.getRequestURL().toString(), "UTF-8");
59
    	
61
    	
60
    	productUrl = URLEncoder.encode(request.getRequestURL().toString(), "UTF-8");
-
 
61
    	baseUrl = URLEncoder.encode("http://saholic.com", "UTF-8");
-
 
62
		System.out.println(request.getRequestURL());
-
 
63
		
-
 
64
    	htmlSnippets.put("PRODUCT_SUMMARY", pageLoader.getProductSummaryHtml(productId));
62
    	htmlSnippets.put("PRODUCT_SUMMARY", pageLoader.getProductSummaryHtml(productId));
65
    	htmlSnippets.put("PRODUCT_ID", productId + "");
63
    	htmlSnippets.put("PRODUCT_ID", productId + "");
66
    	htmlSnippets.put("PRODUCT_NAME", productName);
64
    	htmlSnippets.put("PRODUCT_NAME", productName);
-
 
65
    	htmlSnippets.put("PRODUCT_URL", request.getRequestURL().toString());
67
    	htmlSnippets.put("PRODUCT_URL", productUrl);
66
    	htmlSnippets.put("PRODUCT_URL_ENCODED", productUrlEncoded);
-
 
67
    	htmlSnippets.put("ROOT_URL", "http://" + rootUrl);
68
		htmlSnippets.put("SOCIAL_UTILS", pageLoader.getSocialUtilsHtml(productId, productName, productUrl));
68
		htmlSnippets.put("SOCIAL_UTILS", getSocialUtilsHtml(productId, productName, productUrlEncoded));
69
		htmlSnippets.put("SLIDE_GUIDE", pageLoader.getSlideGuideHtml(productId));
69
		htmlSnippets.put("SLIDE_GUIDE", pageLoader.getSlideGuideHtml(productId));
70
		htmlSnippets.put("PAGE_TITLE", pageTitle.trim());
70
		htmlSnippets.put("PAGE_TITLE", pageTitle.trim());
71
		htmlSnippets.put("PAGE_METADESC", pageLoader.getPageMetaDescriptionHtml(productId).trim());
71
		htmlSnippets.put("PAGE_METADESC", pageLoader.getPageMetaDescriptionHtml(productId).trim());
72
		htmlSnippets.put("PAGE_METAKEYWORDS", pageLoader.getPageMetaKeywordsHtml(productId).trim());
72
		htmlSnippets.put("PAGE_METAKEYWORDS", pageLoader.getPageMetaKeywordsHtml(productId).trim());
73
	
73
	
-
 
74
		System.out.println(htmlSnippets.get("ROOT_URL"));
74
		try {
75
		try {
75
			UserContextServiceClient userServiceClient = new UserContextServiceClient();
76
			UserContextServiceClient userServiceClient = new UserContextServiceClient();
76
			Client client = userServiceClient.getClient();
77
			Client client = userServiceClient.getClient();
77
			long itemId = Long.parseLong(id);
78
			long itemId = Long.parseLong(id);
78
			long userId = userinfo.getUserId();
79
			long userId = userinfo.getUserId();
Line 156... Line 157...
156
	}
157
	}
157
	
158
	
158
	public String getProductUrl()	{
159
	public String getProductUrl()	{
159
		return htmlSnippets.get("PRODUCT_URL");
160
		return htmlSnippets.get("PRODUCT_URL");
160
	}
161
	}
-
 
162
	
-
 
163
	public String getRootUrl()	{
-
 
164
		return htmlSnippets.get("ROOT_URL");
-
 
165
	}
-
 
166
 
-
 
167
	private String getSocialUtilsHtml(long productId, String productName, String productEncodedUrl) {
-
 
168
		String htmlString = "";
-
 
169
		VelocityContext context = new VelocityContext();
-
 
170
		
-
 
171
		String templateFile = "templates/socialutils.vm";
-
 
172
		
-
 
173
		context.put("PRODUCT_ID", productId + "");
-
 
174
		context.put("PRODUCT_NAME", productName);
-
 
175
		context.put("PRODUCT_URL_ENCODED", productEncodedUrl);
-
 
176
		
-
 
177
		htmlString = pageLoader.getHtmlFromVelocity(templateFile, context);
-
 
178
		return htmlString;
-
 
179
	}
161
}
180
}
162
181