return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsErrrorReadingTemplateFile", UtilMisc.toMap("filename", fmfilename, "errorString", e.getMessage()), locale));
}
StringWriter outWriter = new StringWriter();
Template template = null;
try {
Configuration conf = org.ofbiz.base.util.template.FreeMarkerWorker.getDefaultOfbizConfig();
template = new Template("FMImportFilter", templateReader, conf);
Map<String, Object> fmcontext = FastMap.newInstance();
InputSource ins = url != null ? new InputSource(url.openStream()) : new InputSource(new StringReader(fulltext));
NodeModel nodeModel;
try {
nodeModel = NodeModel.parse(ins);
} finally {
if (ins.getByteStream() != null) {
ins.getByteStream().close();
}
if (ins.getCharacterStream() != null) {
ins.getCharacterStream().close();
}
}
fmcontext.put("doc", nodeModel);
BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
TemplateHashModel staticModels = wrapper.getStaticModels();
fmcontext.put("Static", staticModels);
template.process(fmcontext, outWriter);
fulltext = outWriter.toString();
} catch (Exception ex) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsErrrorProcessingTemplateFile", UtilMisc.toMap("filename", fmfilename, "errorString", ex.getMessage()), locale));
}
}