Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package in.shop2020.serving.services;

import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;

import in.shop2020.serving.utils.Utils;
import in.shop2020.serving.utils.SnippetType;

public class ContentServingService {
        private static Logger log = Logger.getLogger(ContentServingService.class);
        
        public static String getSnippet(SnippetType type, String entityId, long sourceId){
                String filename;
                if(sourceId == -1){
                        filename = Utils.EXPORT_ENTITIES_PATH + entityId + File.separator + type.getFilename();
                }else{
                        filename = Utils.EXPORT_ENTITIES_PATH + entityId + File.separator + sourceId + File.separator + type.getFilename();
                }
                String htmlString = "";
                File file = new File(filename);
                try {
                        htmlString =  FileUtils.readFileToString(file);
                } catch (IOException e) {
                        log.warn("Snippet of type " + type + " for entity " + entityId + " not found. ",e);
                }
                return htmlString;
        }
}