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