Subversion Repositories SmartDukaan

Rev

Rev 2662 | Go to most recent revision | Details | 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
	    logger.info(itemIds);
43
	    if(!itemIds.equals("")){
44
	    	String[] items = itemIds.split("\\s|\\n|\\t");
45
	    	for(String item: items){
46
	    		logger.info(item);
47
	    		try{
48
	    			long itemId = Long.parseLong(item.trim());
49
		    		try {
50
						snippets += FileUtils.read( Utils.EXPORT_ENTITIES_PATH + itemId + File.separator + "WidgetSnippet.html");
51
			    	}
52
		            catch (FileNotFoundException e) {
53
		                logger.error("File not found : " + Utils.EXPORT_ENTITIES_PATH + itemId + File.separator +"WidgetSnippet.html");
54
		            }
55
		            catch (IOException e) {
56
		                logger.error("IO exception : " + Utils.EXPORT_ENTITIES_PATH + itemId + File.separator +"WidgetSnippet.html");
57
		            }	
58
	    		}catch (NumberFormatException nf){
59
	    			logger.error("Unable to convert string to long");
60
	    		}
61
	    	}
62
	    }
63
	    logger.info(snippets);
64
	    return snippets;
65
    }
66
}