Subversion Repositories SmartDukaan

Rev

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

Rev 2268 Rev 2306
Line 1... Line 1...
1
package in.shop2020.serving.services;
1
package in.shop2020.serving.services;
2
 
2
 
-
 
3
import in.shop2020.logistics.Provider;
-
 
4
import in.shop2020.model.v1.catalog.InventoryService.Client;
-
 
5
import in.shop2020.model.v1.catalog.InventoryServiceException;
-
 
6
import in.shop2020.model.v1.order.Order;
-
 
7
import in.shop2020.model.v1.user.Address;
-
 
8
import in.shop2020.model.v1.user.User;
-
 
9
import in.shop2020.model.v1.user.UserContextException;
-
 
10
import in.shop2020.serving.utils.FileUtils;
-
 
11
import in.shop2020.serving.utils.Utils;
-
 
12
import in.shop2020.thrift.clients.CatalogServiceClient;
-
 
13
import in.shop2020.thrift.clients.LogisticsServiceClient;
-
 
14
import in.shop2020.thrift.clients.TransactionServiceClient;
-
 
15
import in.shop2020.thrift.clients.UserContextServiceClient;
-
 
16
 
3
import java.io.BufferedReader;
17
import java.io.BufferedReader;
4
import java.io.File;
18
import java.io.File;
5
import java.io.FileInputStream;
19
import java.io.FileInputStream;
6
import java.io.FileNotFoundException;
20
import java.io.FileNotFoundException;
7
import java.io.IOException;
21
import java.io.IOException;
Line 22... Line 36...
22
import org.apache.velocity.exception.MethodInvocationException;
36
import org.apache.velocity.exception.MethodInvocationException;
23
import org.apache.velocity.exception.ParseErrorException;
37
import org.apache.velocity.exception.ParseErrorException;
24
import org.apache.velocity.exception.ResourceNotFoundException;
38
import org.apache.velocity.exception.ResourceNotFoundException;
25
 
39
 
26
 
40
 
27
import in.shop2020.logistics.Provider;
-
 
28
import in.shop2020.model.v1.catalog.InventoryServiceException;
-
 
29
import in.shop2020.model.v1.catalog.InventoryService.Client;
-
 
30
import in.shop2020.model.v1.order.Order;
-
 
31
import in.shop2020.model.v1.user.Address;
-
 
32
import in.shop2020.model.v1.user.User;
-
 
33
import in.shop2020.model.v1.user.UserContextException;
-
 
34
import in.shop2020.serving.utils.*;
-
 
35
import in.shop2020.thrift.clients.CatalogServiceClient;
-
 
36
import in.shop2020.thrift.clients.LogisticsServiceClient;
-
 
37
import in.shop2020.thrift.clients.TransactionServiceClient;
-
 
38
import in.shop2020.thrift.clients.UserContextServiceClient;
-
 
39
 
-
 
40
 
-
 
41
public class PageLoaderHandler {
41
public class PageLoaderHandler {
42
 
42
 
43
 
43
 
44
	public String getMainBannerHtml() {
44
	public String getMainBannerHtml() {
45
		String htmlString = "";
45
		String htmlString = "";
Line 244... Line 244...
244
		}
244
		}
245
		
245
		
246
		return htmlString.toString();
246
		return htmlString.toString();
247
	}
247
	}
248
 
248
 
249
	public String getPageTitleHtml(long productId) {
249
	public String getProductPropertiesHtml(long productId) {
250
		StringBuilder htmlString = new StringBuilder();
250
		StringBuilder htmlString = new StringBuilder();
251
		String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "TitleSnippet.html";
251
		String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "ProductPropertiesSnippet.html";
252
		File f = new File(filename);
252
		File f = new File(filename);
253
		
253
		
254
		
254
		
255
		FileInputStream fis = null;
255
		FileInputStream fis = null;
256
		try {
256
		try {
Line 279... Line 279...
279
		}
279
		}
280
		
280
		
281
		return htmlString.toString();
281
		return htmlString.toString();
282
	}
282
	}
283
	
283
	
284
	public String getPageMetaDescriptionHtml(long productId) {
-
 
285
		StringBuilder htmlString = new StringBuilder();
-
 
286
		String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "MetaDescriptionSnippet.html";
-
 
287
		File f = new File(filename);
-
 
288
		
-
 
289
		
-
 
290
		FileInputStream fis = null;
-
 
291
		try {
-
 
292
			fis = new FileInputStream(f);
-
 
293
			BufferedReader br = new BufferedReader(new InputStreamReader(fis));
-
 
294
			String line;
-
 
295
			while((line = br.readLine()) != null){
-
 
296
				htmlString.append(line+"\n");
-
 
297
			}
-
 
298
		} catch (FileNotFoundException e) {
-
 
299
			// TODO Auto-generated catch block
-
 
300
			e.printStackTrace();
-
 
301
		} catch (IOException e) {
-
 
302
			// TODO Auto-generated catch block
-
 
303
			e.printStackTrace();
-
 
304
		}
-
 
305
		finally {
-
 
306
			if(fis != null) {
-
 
307
				try {
-
 
308
					fis.close();
-
 
309
				} catch (IOException e) {
-
 
310
					// TODO Auto-generated catch block
-
 
311
					e.printStackTrace();
-
 
312
				}
-
 
313
			}
-
 
314
		}
-
 
315
		
-
 
316
		return htmlString.toString();
-
 
317
	}
-
 
318
	
-
 
319
	public String getPageMetaKeywordsHtml(long productId) {
-
 
320
		StringBuilder htmlString = new StringBuilder();
-
 
321
		String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "MetaKeywordsSnippet.html";
-
 
322
		File f = new File(filename);
-
 
323
		
-
 
324
		
-
 
325
		FileInputStream fis = null;
-
 
326
		try {
-
 
327
			fis = new FileInputStream(f);
-
 
328
			BufferedReader br = new BufferedReader(new InputStreamReader(fis));
-
 
329
			String line;
-
 
330
			while((line = br.readLine()) != null){
-
 
331
				htmlString.append(line+"\n");
-
 
332
			}
-
 
333
		} catch (FileNotFoundException e) {
-
 
334
			// TODO Auto-generated catch block
-
 
335
			e.printStackTrace();
-
 
336
		} catch (IOException e) {
-
 
337
			// TODO Auto-generated catch block
-
 
338
			e.printStackTrace();
-
 
339
		}
-
 
340
		finally {
-
 
341
			if(fis != null) {
-
 
342
				try {
-
 
343
					fis.close();
-
 
344
				} catch (IOException e) {
-
 
345
					// TODO Auto-generated catch block
-
 
346
					e.printStackTrace();
-
 
347
				}
-
 
348
			}
-
 
349
		}
-
 
350
		
-
 
351
		return htmlString.toString();
-
 
352
	}
-
 
353
 
-
 
354
	public String getMainMenuHtml() {
284
	public String getMainMenuHtml() {
355
		String htmlString = "";
285
		String htmlString = "";
356
		VelocityContext context = new VelocityContext();
286
		VelocityContext context = new VelocityContext();
357
		String templateFile = "templates/mainmenu.vm";
287
		String templateFile = "templates/mainmenu.vm";
358
		htmlString = getHtmlFromVelocity(templateFile, context);
288
		htmlString = getHtmlFromVelocity(templateFile, context);