Subversion Repositories SmartDukaan

Rev

Rev 2652 | Rev 3052 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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