| 7268 |
anupam.sin |
1 |
package in.shop2020.serving.service;
|
| 7263 |
anupam.sin |
2 |
|
|
|
3 |
import java.io.File;
|
|
|
4 |
import java.io.IOException;
|
|
|
5 |
import org.apache.commons.io.FileUtils;
|
|
|
6 |
import org.apache.log4j.Logger;
|
|
|
7 |
|
|
|
8 |
import in.shop2020.serving.utils.Utils;
|
|
|
9 |
import in.shop2020.serving.utils.SnippetType;
|
|
|
10 |
|
|
|
11 |
public class ContentServingService {
|
|
|
12 |
private static Logger log = Logger.getLogger(ContentServingService.class);
|
|
|
13 |
|
|
|
14 |
public static String getSnippet(SnippetType type, String entityId, long sourceId){
|
|
|
15 |
String filename;
|
|
|
16 |
if(sourceId == -1){
|
|
|
17 |
filename = Utils.EXPORT_ENTITIES_PATH + entityId + File.separator + type.getFilename();
|
|
|
18 |
}else{
|
|
|
19 |
filename = Utils.EXPORT_ENTITIES_PATH + entityId + File.separator + sourceId + File.separator + type.getFilename();
|
|
|
20 |
}
|
|
|
21 |
String htmlString = "";
|
|
|
22 |
File file = new File(filename);
|
|
|
23 |
try {
|
|
|
24 |
htmlString = FileUtils.readFileToString(file);
|
|
|
25 |
} catch (IOException e) {
|
|
|
26 |
log.warn("Snippet of type " + type + " for entity " + entityId + " not found. ",e);
|
|
|
27 |
}
|
|
|
28 |
return htmlString;
|
|
|
29 |
}
|
|
|
30 |
}
|