【fix sonar】FreemarkerParseFactory文件

This commit is contained in:
梁琦涛
2023-03-08 12:02:02 +08:00
parent e28a591b2d
commit 2999d4254e
@@ -1,5 +1,6 @@
package com.jero.common.util.dynamic.db;
import com.jero.common.exception.JeroBootException;
import freemarker.cache.StringTemplateLoader;
import freemarker.core.ParseException;
import freemarker.template.Configuration;
@@ -49,7 +50,7 @@ public class FreemarkerParseFactory {
static {
_tplConfig.setClassForTemplateLoading(
new FreemarkerParseFactory().getClass(), "/");
FreemarkerParseFactory.class, "/");
_tplConfig.setNumberFormat("0.#####################");
_sqlConfig.setTemplateLoader(stringTemplateLoader);
_sqlConfig.setNumberFormat("0.#####################");
@@ -62,7 +63,7 @@ public class FreemarkerParseFactory {
*
* @throws Exception
*/
public static boolean isExistTemplate(String tplName) throws Exception {
public static boolean isExistTemplate(String tplName) throws JeroBootException {
try {
Template mytpl = _tplConfig.getTemplate(tplName, "UTF-8");
if (mytpl == null) {
@@ -72,7 +73,7 @@ public class FreemarkerParseFactory {
//update-begin--Author:scott Date:20180320 for:解决问题 - 错误提示sql文件不存在,实际问题是sql freemarker用法错误-----
if (e instanceof ParseException) {
log.error(e.getMessage(), e.fillInStackTrace());
throw new Exception(e);
throw new JeroBootException(e);
}
log.debug("----isExistTemplate----" + e.toString());
//update-end--Author:scott Date:20180320 for:解决问题 - 错误提示sql文件不存在,实际问题是sql freemarker用法错误------
@@ -94,7 +95,7 @@ public class FreemarkerParseFactory {
StringWriter swriter = new StringWriter();
Template mytpl = _tplConfig.getTemplate(tplName, ENCODE);
if (paras.containsKey(MINI_DAO_FORMAT)) {
throw new RuntimeException("DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!");
throw new JeroBootException("DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!");
}
paras.put(MINI_DAO_FORMAT, new SimpleFormat());
mytpl.process(paras, swriter);
@@ -104,7 +105,7 @@ public class FreemarkerParseFactory {
} catch (Exception e) {
log.error(e.getMessage(), e.fillInStackTrace());
log.error("发送一次的模板key:{ " + tplName + " }");
throw new RuntimeException("解析SQL模板异常");
throw new JeroBootException("解析SQL模板异常");
}
}
@@ -124,7 +125,7 @@ public class FreemarkerParseFactory {
}
Template mytpl = _sqlConfig.getTemplate("sql_" + tplContent.hashCode(), ENCODE);
if (paras.containsKey(MINI_DAO_FORMAT)) {
throw new RuntimeException("DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!");
throw new JeroBootException("DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!");
}
paras.put(MINI_DAO_FORMAT, new SimpleFormat());
mytpl.process(paras, swriter);
@@ -134,7 +135,7 @@ public class FreemarkerParseFactory {
} catch (Exception e) {
log.error(e.getMessage(), e.fillInStackTrace());
log.error("发送一次的模板key:{ " + tplContent + " }");
throw new RuntimeException("解析SQL模板异常");
throw new JeroBootException("解析SQL模板异常");
}
}