00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 package org.openmobileis.embedded.webserver.templates;
00029
00030 import java.io.File;
00031
00032 import org.openmobileis.common.intl.IntlResourceManager;
00033 import org.openmobileis.common.util.PropertiesManager;
00034
00035 import freemarker.template.FileTemplateCache;
00036 import freemarker.template.Template;
00037
00042 public final class FileTemplateRetrieverService implements TemplateRetrieverService {
00043 private String rootTemplatePath;
00044
00045 private FileTemplateCache fileTemplateCache = null;
00046
00050 public FileTemplateRetrieverService() {
00051 rootTemplatePath = PropertiesManager.getManager().getProperty("org.openmobileis.services.templatesDir");
00052 fileTemplateCache = new FileTemplateCache(rootTemplatePath);
00053 fileTemplateCache.setFilenameSuffix("htm");
00054 }
00055
00056
00057
00058
00059 public String getModuleName() {
00060 return null;
00061 }
00062
00063
00064
00065
00066 public Template getServiceTemplate(String relatifPath) {
00067
00068 IntlResourceManager resourceManager = IntlResourceManager.getManager();
00069 String newrelatifPath = resourceManager.getLocalizedFileName(relatifPath, false);
00070
00071 File file = new File(rootTemplatePath+newrelatifPath);
00072 if (!file.exists()) newrelatifPath = relatifPath;
00073
00074
00075
00076
00077
00078 return (Template)fileTemplateCache.getItem(newrelatifPath);
00079 }
00080
00081
00082
00083
00084 public boolean isTemplateExist(String relatifPath) {
00085 IntlResourceManager resourceManager = IntlResourceManager.getManager();
00086 String newrelatifPath = resourceManager.getLocalizedFileName(relatifPath, false);
00087
00088 File file = new File(rootTemplatePath+File.separator+newrelatifPath);
00089 if (!file.exists()) newrelatifPath = relatifPath;
00090 file = new File(rootTemplatePath+File.separator+newrelatifPath);
00091 return file.exists();
00092 }
00093
00094 }