Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dlink
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaowei
dlink
Commits
7410fb2f
Commit
7410fb2f
authored
Apr 03, 2022
by
zhu-mingye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Email Alert Type
parent
e3de2731
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
23 deletions
+6
-23
ExcelUtils.java
...email/src/main/java/com/dlink/alert/email/ExcelUtils.java
+4
-4
MailSender.java
...email/src/main/java/com/dlink/alert/email/MailSender.java
+2
-2
AlertEmailException.java
.../com/dlink/alert/email/exception/AlertEmailException.java
+0
-17
No files found.
dlink-alert/dlink-alert-email/src/main/java/com/dlink/alert/email/ExcelUtils.java
View file @
7410fb2f
package
com
.
dlink
.
alert
.
email
;
import
com.dlink.alert.
email.exception.AlertEmail
Exception
;
import
com.dlink.alert.
Alert
Exception
;
import
com.dlink.utils.JSONUtil
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.poi.ss.usermodel.*
;
...
...
@@ -39,14 +39,14 @@ public final class ExcelUtils {
File
file
=
new
File
(
xlsFilePath
);
if
(!
file
.
exists
()
&&
!
file
.
mkdirs
())
{
logger
.
error
(
"Create xlsx directory error, path:{}"
,
xlsFilePath
);
throw
new
AlertE
mailE
xception
(
"Create xlsx directory error"
);
throw
new
AlertException
(
"Create xlsx directory error"
);
}
List
<
LinkedHashMap
>
itemsList
=
JSONUtil
.
toList
(
content
,
LinkedHashMap
.
class
);
if
(
CollectionUtils
.
isEmpty
(
itemsList
))
{
logger
.
error
(
"itemsList is null"
);
throw
new
AlertE
mailE
xception
(
"itemsList is null"
);
throw
new
AlertException
(
"itemsList is null"
);
}
LinkedHashMap
<
String
,
Object
>
headerMap
=
itemsList
.
get
(
0
);
...
...
@@ -103,7 +103,7 @@ public final class ExcelUtils {
wb
.
write
(
fos
);
wb
.
dispose
();
}
catch
(
Exception
e
)
{
throw
new
AlertE
mailE
xception
(
"generate excel error"
,
e
);
throw
new
AlertException
(
"generate excel error"
,
e
);
}
}
...
...
dlink-alert/dlink-alert-email/src/main/java/com/dlink/alert/email/MailSender.java
View file @
7410fb2f
package
com
.
dlink
.
alert
.
email
;
import
com.dlink.alert.AlertException
;
import
com.dlink.alert.AlertResult
;
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.DefaultHTMLTemplate
;
import
com.sun.mail.smtp.SMTPProvider
;
...
...
@@ -52,7 +52,7 @@ public final class MailSender {
public
MailSender
(
Map
<
String
,
String
>
config
)
{
String
receiversConfig
=
config
.
get
(
EmailConstants
.
NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS
);
if
(
receiversConfig
==
null
||
""
.
equals
(
receiversConfig
))
{
throw
new
AlertE
mailE
xception
(
EmailConstants
.
NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS
+
mustNotNull
);
throw
new
AlertException
(
EmailConstants
.
NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS
+
mustNotNull
);
}
receivers
=
Arrays
.
asList
(
receiversConfig
.
split
(
","
));
...
...
dlink-alert/dlink-alert-email/src/main/java/com/dlink/alert/email/exception/AlertEmailException.java
deleted
100644 → 0
View file @
e3de2731
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
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment