|
|
@ -196,7 +196,7 @@ public class SqlTask extends AbstractTask { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// special characters need to be escaped, ${} needs to be escaped
|
|
|
|
// special characters need to be escaped, ${} needs to be escaped
|
|
|
|
String rgex = "'?\\$\\{(.*?)\\}'?"; |
|
|
|
String rgex = "['\"]*\\$\\{(.*?)\\}['\"]*"; |
|
|
|
setSqlParamsMap(sql,rgex,sqlParamsMap,paramsMap); |
|
|
|
setSqlParamsMap(sql,rgex,sqlParamsMap,paramsMap); |
|
|
|
|
|
|
|
|
|
|
|
// replace the ${} of the SQL statement with the Placeholder
|
|
|
|
// replace the ${} of the SQL statement with the Placeholder
|
|
|
@ -310,6 +310,7 @@ public class SqlTask extends AbstractTask { |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage(),e); |
|
|
|
logger.error(e.getMessage(),e); |
|
|
|
|
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
return connection; |
|
|
|
return connection; |
|
|
|
} |
|
|
|
} |
|
|
@ -326,6 +327,7 @@ public class SqlTask extends AbstractTask { |
|
|
|
ParameterUtils.setInParameter(key,stmt,prop.getType(),prop.getValue()); |
|
|
|
ParameterUtils.setInParameter(key,stmt,prop.getType(),prop.getValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("prepare statement replace sql:{}",stmt.toString()); |
|
|
|
return stmt; |
|
|
|
return stmt; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -371,9 +373,13 @@ public class SqlTask extends AbstractTask { |
|
|
|
|
|
|
|
|
|
|
|
String showTypeName = sqlParameters.getShowType().replace(Constants.COMMA,"").trim(); |
|
|
|
String showTypeName = sqlParameters.getShowType().replace(Constants.COMMA,"").trim(); |
|
|
|
if(EnumUtils.isValidEnum(ShowType.class,showTypeName)){ |
|
|
|
if(EnumUtils.isValidEnum(ShowType.class,showTypeName)){ |
|
|
|
MailUtils.sendMails(receviersList,receviersCcList,title, content, ShowType.valueOf(showTypeName)); |
|
|
|
Map<String, Object> mailResult = MailUtils.sendMails(receviersList, receviersCcList, title, content, ShowType.valueOf(showTypeName)); |
|
|
|
|
|
|
|
if(!(Boolean) mailResult.get(cn.escheduler.api.utils.Constants.STATUS)){ |
|
|
|
|
|
|
|
throw new RuntimeException("send mail failed!"); |
|
|
|
|
|
|
|
} |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
logger.error("showType: {} is not valid " ,showTypeName); |
|
|
|
logger.error("showType: {} is not valid " ,showTypeName); |
|
|
|
|
|
|
|
throw new RuntimeException(String.format("showType: %s is not valid ",showTypeName)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -411,19 +417,5 @@ public class SqlTask extends AbstractTask { |
|
|
|
logPrint.append(sqlParamsMap.get(i).getValue()+"("+sqlParamsMap.get(i).getType()+")"); |
|
|
|
logPrint.append(sqlParamsMap.get(i).getValue()+"("+sqlParamsMap.get(i).getType()+")"); |
|
|
|
} |
|
|
|
} |
|
|
|
logger.info(logPrint.toString()); |
|
|
|
logger.info(logPrint.toString()); |
|
|
|
|
|
|
|
|
|
|
|
//direct print style
|
|
|
|
|
|
|
|
Pattern pattern = Pattern.compile(rgex); |
|
|
|
|
|
|
|
Matcher m = pattern.matcher(content); |
|
|
|
|
|
|
|
int index = 1; |
|
|
|
|
|
|
|
StringBuffer sb = new StringBuffer("replaced sql , direct:"); |
|
|
|
|
|
|
|
while (m.find()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m.appendReplacement(sb, sqlParamsMap.get(index).getValue()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index ++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
m.appendTail(sb); |
|
|
|
|
|
|
|
logger.info(sb.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|