ServletContext servletContext = null;
if(context.getServlet() != null) {
servletContext = context.getServlet().getServletContext();
}
XmlFileCacher xmlCache = cacheMap.get(preferedLanguage);
File xmlFile = new File(xmlFilePath);
if (xmlCache == null){
xmlCache = new XmlFileCacher(xmlFile,servletContext,appPath);
cacheMap.put(preferedLanguage, xmlCache);
}
Element result;
try {
result = (Element)xmlCache.get().clone();
} catch (Exception e) {
Log.error(Log.RESOURCES, "Error cloning the cached data. Attempted to get: "+xmlFilePath+"but failed so falling back to default language");
Log.debug(Log.RESOURCES, "Error cloning the cached data. Attempted to get: "+xmlFilePath+"but failed so falling back to default language", e);
String xmlDefaultLangFilePath = rootPath + File.separator + defaultLang + File.separator + file;
xmlCache = new XmlFileCacher(new File(xmlDefaultLangFilePath),servletContext, appPath);
cacheMap.put(preferedLanguage, xmlCache);
result = (Element)xmlCache.get().clone();
}
String name = xmlFile.getName();
int lastIndexOfDot = name.lastIndexOf('.');
if (lastIndexOfDot > 0) {
name = name.substring(0,lastIndexOfDot);