Subversion Repositories SmartDukaan

Rev

Rev 3052 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3052 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
 
5
 
10
import org.apache.log4j.Logger;
6
import org.apache.log4j.Logger;
11
import org.apache.struts2.convention.annotation.Action;
7
import org.apache.struts2.convention.annotation.Action;
12
import org.apache.struts2.convention.annotation.InterceptorRef;
8
import org.apache.struts2.convention.annotation.InterceptorRef;
13
 
9
 
Line 31... Line 27...
31
    	this.id = id;
27
    	this.id = id;
32
    }
28
    }
33
	
29
	
34
    public String getSnippets(){
30
    public String getSnippets(){
35
    	String itemIds = "";
31
    	String itemIds = "";
36
	    try {
-
 
37
	    	itemIds = FileUtils.read( Utils.EXPORT_ENTITIES_PATH + id + File.separator +"RelatedAccessories.html");
32
    	itemIds = ContentServingService.getSnippet(SnippetType.RELATED_ACCESSORIES_SNIPPET, id, sourceId);
38
	    }
-
 
39
	    catch (FileNotFoundException e) {
-
 
40
	        logger.error("File not found : " + Utils.EXPORT_ENTITIES_PATH + id + File.separator +"RelatedAccessories.html");
-
 
41
	    }
-
 
42
	    catch (IOException e) {
-
 
43
	        logger.error("IO exception : " + Utils.EXPORT_ENTITIES_PATH + id + File.separator +"RelatedAccessories.html");
-
 
44
	    }
-
 
45
	    if(!itemIds.equals("")){
33
	    if(!itemIds.equals("")){
46
	    	String[] items = itemIds.split("\\s|\\n|\\t");
34
	    	String[] items = itemIds.split("\\s|\\n|\\t");
47
	    	for(String item: items){
35
	    	for(String item: items){
48
	    		logger.info("Getting widget snippet for item: " + item);
36
	    		logger.info("Getting widget snippet for item: " + item);
49
	    		try{
-
 
50
	    			long itemId = Long.parseLong(item.trim());
-
 
51
		    		try {
-
 
52
						snippets += FileUtils.read( Utils.EXPORT_ENTITIES_PATH + itemId + File.separator + "WidgetSnippet.html");
37
	    		snippets = snippets + ContentServingService.getSnippet(SnippetType.WIDGET_SNIPPET, item, sourceId);
53
			    	}
-
 
54
		            catch (FileNotFoundException e) {
-
 
55
		                logger.warn("File not found : " + Utils.EXPORT_ENTITIES_PATH + itemId + File.separator +"WidgetSnippet.html");
-
 
56
		            }
-
 
57
		            catch (IOException e) {
-
 
58
		            	logger.warn("IO exception : " + Utils.EXPORT_ENTITIES_PATH + itemId + File.separator +"WidgetSnippet.html");
-
 
59
		            }	
-
 
60
	    		}catch (NumberFormatException nf){
-
 
61
	    			logger.error("Unable to convert string to long");
-
 
62
	    		}
-
 
63
	    	}
38
	    	}
64
	    }
39
	    }
65
	    return snippets;
40
	    return snippets;
66
    }
41
    }
67
}
42
}
68
43