Commit 7410fb2f authored by zhu-mingye's avatar zhu-mingye

Fix Email Alert Type

parent e3de2731
package com.dlink.alert.email; package com.dlink.alert.email;
import com.dlink.alert.email.exception.AlertEmailException; import com.dlink.alert.AlertException;
import com.dlink.utils.JSONUtil; import com.dlink.utils.JSONUtil;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
...@@ -39,14 +39,14 @@ public final class ExcelUtils { ...@@ -39,14 +39,14 @@ public final class ExcelUtils {
File file = new File(xlsFilePath); File file = new File(xlsFilePath);
if (!file.exists() && !file.mkdirs()) { if (!file.exists() && !file.mkdirs()) {
logger.error("Create xlsx directory error, path:{}", xlsFilePath); logger.error("Create xlsx directory error, path:{}", xlsFilePath);
throw new AlertEmailException("Create xlsx directory error"); throw new AlertException("Create xlsx directory error");
} }
List<LinkedHashMap> itemsList = JSONUtil.toList(content, LinkedHashMap.class); List<LinkedHashMap> itemsList = JSONUtil.toList(content, LinkedHashMap.class);
if (CollectionUtils.isEmpty(itemsList)) { if (CollectionUtils.isEmpty(itemsList)) {
logger.error("itemsList is null"); logger.error("itemsList is null");
throw new AlertEmailException("itemsList is null"); throw new AlertException("itemsList is null");
} }
LinkedHashMap<String, Object> headerMap = itemsList.get(0); LinkedHashMap<String, Object> headerMap = itemsList.get(0);
...@@ -103,7 +103,7 @@ public final class ExcelUtils { ...@@ -103,7 +103,7 @@ public final class ExcelUtils {
wb.write(fos); wb.write(fos);
wb.dispose(); wb.dispose();
} catch (Exception e) { } catch (Exception e) {
throw new AlertEmailException("generate excel error", e); throw new AlertException("generate excel error", e);
} }
} }
......
package com.dlink.alert.email; package com.dlink.alert.email;
import com.dlink.alert.AlertException;
import com.dlink.alert.AlertResult; import com.dlink.alert.AlertResult;
import com.dlink.alert.ShowType; import com.dlink.alert.ShowType;
import com.dlink.alert.email.exception.AlertEmailException;
import com.dlink.alert.email.template.AlertTemplate; import com.dlink.alert.email.template.AlertTemplate;
import com.dlink.alert.email.template.DefaultHTMLTemplate; import com.dlink.alert.email.template.DefaultHTMLTemplate;
import com.sun.mail.smtp.SMTPProvider; import com.sun.mail.smtp.SMTPProvider;
...@@ -52,7 +52,7 @@ public final class MailSender { ...@@ -52,7 +52,7 @@ public final class MailSender {
public MailSender(Map<String, String> config) { public MailSender(Map<String, String> config) {
String receiversConfig = config.get(EmailConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS); String receiversConfig = config.get(EmailConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS);
if (receiversConfig == null || "".equals(receiversConfig)) { if (receiversConfig == null || "".equals(receiversConfig)) {
throw new AlertEmailException(EmailConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS + mustNotNull); throw new AlertException(EmailConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS + mustNotNull);
} }
receivers = Arrays.asList(receiversConfig.split(",")); receivers = Arrays.asList(receiversConfig.split(","));
......
package com.dlink.alert.email.exception;
/**
* @Author: zhumingye
* @date: 2022/4/3
* @Description: 告警邮件异常类
*/
public class AlertEmailException extends RuntimeException {
public AlertEmailException(String errMsg) {
super(errMsg);
}
public AlertEmailException(String errMsg, Throwable cause) {
super(errMsg, cause);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment