Subversion Repositories SmartDukaan

Rev

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

Rev 2867 Rev 3599
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
3
import in.shop2020.serving.utils.FileUtils;
3
import in.shop2020.serving.services.ContentServingService;
4
import in.shop2020.serving.utils.Utils;
4
import in.shop2020.serving.utils.SnippetType;
5
 
-
 
6
import java.io.File;
-
 
7
import java.io.FileNotFoundException;
-
 
8
import java.io.IOException;
-
 
9
 
-
 
10
import org.apache.log4j.Logger;
-
 
11
 
5
 
12
@SuppressWarnings("serial")
6
@SuppressWarnings("serial")
13
public class MostComparedProductsController extends BaseController {
7
public class MostComparedProductsController extends BaseController {
14
 
8
 
15
	private static final String relatedProductsFileName = "MostComparedProducts.html";
-
 
16
	private static Logger logger = Logger.getLogger(MostComparedProductsController.class);
-
 
17
	private String id;
9
	private String id;
18
    private String snippets="";
10
    private String snippets="";
19
 
11
 
20
	public MostComparedProductsController(){
12
	public MostComparedProductsController(){
21
		super();
13
		super();
Line 29... Line 21...
29
    	this.id = id;
21
    	this.id = id;
30
    }
22
    }
31
	
23
	
32
    public String getSnippets(){
24
    public String getSnippets(){
33
    	String itemIds = "";
25
    	String itemIds = "";
34
	    try {
-
 
35
	    	itemIds = FileUtils.read(Utils.EXPORT_ENTITIES_PATH + id + File.separator + relatedProductsFileName);
26
	    itemIds = ContentServingService.getSnippet(SnippetType.MOST_COMPARED_SNIPPET, id, sourceId);
36
	    }
-
 
37
	    catch (FileNotFoundException e) {
-
 
38
	        logger.error("File not found : " + Utils.EXPORT_ENTITIES_PATH + id + File.separator + relatedProductsFileName);
-
 
39
	    }
-
 
40
	    catch (IOException e) {
-
 
41
	        logger.error("IO exception : " + Utils.EXPORT_ENTITIES_PATH + id + File.separator + relatedProductsFileName);
-
 
42
	    }
-
 
43
	    if(!itemIds.equals("")){
27
	    if(!itemIds.equals("")){
44
	    	String[] items = itemIds.split("\\s|\\n|\\t");
28
	    	String[] items = itemIds.split("\\s|\\n|\\t");
45
	    	for(String item: items){
29
	    	for(String item: items){
46
	    		try{
-
 
47
	    			long itemId = Long.parseLong(item.trim());
-
 
48
		    		try {
-
 
49
						snippets += FileUtils.read( Utils.EXPORT_ENTITIES_PATH + itemId + File.separator + "WidgetSnippet.html");
30
	    		snippets = snippets + ContentServingService.getSnippet(SnippetType.WIDGET_SNIPPET, item, sourceId);
50
			    	}
-
 
51
		            catch (FileNotFoundException e) {
-
 
52
		                logger.error("File not found : " + Utils.EXPORT_ENTITIES_PATH + itemId + File.separator +"WidgetSnippet.html");
-
 
53
		            }
-
 
54
		            catch (IOException e) {
-
 
55
		                logger.error("IO exception : " + Utils.EXPORT_ENTITIES_PATH + itemId + File.separator +"WidgetSnippet.html");
-
 
56
		            }	
-
 
57
	    		}catch (NumberFormatException nf){
-
 
58
	    			logger.error("Unable to convert string to long");
-
 
59
	    		}
-
 
60
	    	}
31
	    	}
61
	    }	    
32
	    }	    
62
	    return snippets;
33
	    return snippets;
63
    }
34
    }
64
}
35
}
65
36