From 70e67dfc670059d08f9db399d8ec962f0312ba5a Mon Sep 17 00:00:00 2001 From: CalvinKirs Date: Sat, 4 Dec 2021 22:44:49 +0800 Subject: [PATCH] [2.0.1-prepare]revert alert plugin novalid change --- .../alert/api/AlertChannelFactory.java | 2 +- .../alert/api/AlertConstants.java | 2 +- .../dingtalk/DingTalkAlertChannelFactory.java | 67 ++++----- .../dingtalk/DingTalkParamsConstants.java | 22 ++- .../plugin/alert/dingtalk/DingTalkSender.java | 3 + .../alert/email/MailParamsConstants.java | 24 ++-- .../alert/email/EmailAlertChannelTest.java | 134 +++++++++--------- .../alert/feishu/FeiShuParamsConstants.java | 27 ++-- .../alert/http/HttpAlertChannelFactory.java | 10 +- .../plugin/alert/http/HttpAlertConstants.java | 20 +-- .../plugin/alert/http/HttpSender.java | 10 +- .../plugin/alert/http/HttpSenderTest.java | 10 +- .../alert/script/ScriptParamsConstants.java | 7 +- .../alert/slack/SlackParamsConstants.java | 7 +- .../wechat/WeChatAlertParamsConstants.java | 29 +++- 15 files changed, 194 insertions(+), 180 deletions(-) diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertChannelFactory.java b/dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertChannelFactory.java index a55c7ffa4d..c889d62f32 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertChannelFactory.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertChannelFactory.java @@ -27,9 +27,9 @@ public interface AlertChannelFactory { String name(); AlertChannel create(); - /** * Returns the configurable parameters that this plugin needs to display on the web ui */ List params(); + } diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertConstants.java b/dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertConstants.java index 9d85fd24bf..3fae801f4f 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertConstants.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertConstants.java @@ -23,7 +23,7 @@ public final class AlertConstants { /** * the field name of alert show type **/ - public static final String SHOW_TYPE = "$t('showType')"; + public static final String SHOW_TYPE = "show_type"; public static final String NAME_SHOW_TYPE = "showType"; diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannelFactory.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannelFactory.java index 27d95e7c67..2050eaae40 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannelFactory.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannelFactory.java @@ -43,52 +43,53 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory { return "DingTalk"; } + @Override + public AlertChannel create() { + return new DingTalkAlertChannel(); + } + @Override public List params() { InputParam webHookParam = InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_WEB_HOOK, DingTalkParamsConstants.DING_TALK_WEB_HOOK) - .addValidate(Validate.newBuilder() - .setRequired(true) - .build()) - .build(); + .addValidate(Validate.newBuilder() + .setRequired(true) + .build()) + .build(); InputParam keywordParam = InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_KEYWORD, DingTalkParamsConstants.DING_TALK_KEYWORD) - .addValidate(Validate.newBuilder() - .setRequired(true) - .build()) - .build(); + .addValidate(Validate.newBuilder() + .setRequired(true) + .build()) + .build(); RadioParam isEnableProxy = - RadioParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY_ENABLE, DingTalkParamsConstants.DING_TALK_PROXY_ENABLE) - .addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false)) - .addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false)) - .setValue(STRING_TRUE) - .addValidate(Validate.newBuilder() - .setRequired(false) - .build()) - .build(); + RadioParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY_ENABLE, DingTalkParamsConstants.NAME_DING_TALK_PROXY_ENABLE) + .addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false)) + .addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false)) + .setValue(STRING_TRUE) + .addValidate(Validate.newBuilder() + .setRequired(false) + .build()) + .build(); InputParam proxyParam = - InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY, DingTalkParamsConstants.DING_TALK_PROXY) - .addValidate(Validate.newBuilder() - .setRequired(false).build()) - .build(); + InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY, DingTalkParamsConstants.DING_TALK_PROXY) + .addValidate(Validate.newBuilder() + .setRequired(false).build()) + .build(); InputParam portParam = InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PORT, DingTalkParamsConstants.DING_TALK_PORT) - .addValidate(Validate.newBuilder() - .setRequired(false).build()) - .build(); + .addValidate(Validate.newBuilder() + .setRequired(false).build()) + .build(); InputParam userParam = - InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_USER, DingTalkParamsConstants.DING_TALK_USER) - .addValidate(Validate.newBuilder() - .setRequired(false).build()) - .build(); + InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_USER, DingTalkParamsConstants.DING_TALK_USER) + .addValidate(Validate.newBuilder() + .setRequired(false).build()) + .build(); PasswordParam passwordParam = PasswordParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PASSWORD, DingTalkParamsConstants.DING_TALK_PASSWORD) - .setPlaceholder("if enable use authentication, you need input password") - .build(); + .setPlaceholder("if enable use authentication, you need input password") + .build(); return Arrays.asList(webHookParam, keywordParam, isEnableProxy, proxyParam, portParam, userParam, passwordParam); } - @Override - public AlertChannel create() { - return new DingTalkAlertChannel(); - } } diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkParamsConstants.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkParamsConstants.java index ec0003a94f..3042db6286 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkParamsConstants.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkParamsConstants.java @@ -18,25 +18,19 @@ package org.apache.dolphinscheduler.plugin.alert.dingtalk; public final class DingTalkParamsConstants { - static final String DING_TALK_PROXY_ENABLE = "$t('isEnableProxy')"; - static final String NAME_DING_TALK_PROXY_ENABLE = "IsEnableProxy"; - - static final String DING_TALK_WEB_HOOK = "$t('webhook')"; + static final String DING_TALK_PROXY_ENABLE = "isEnableProxy"; + static final String DING_TALK_WEB_HOOK = "webhook"; static final String NAME_DING_TALK_WEB_HOOK = "WebHook"; - - static final String DING_TALK_KEYWORD = "$t('keyword')"; + static final String DING_TALK_KEYWORD = "keyword"; static final String NAME_DING_TALK_KEYWORD = "Keyword"; - - static final String DING_TALK_PROXY = "$t('proxy')"; + static final String NAME_DING_TALK_PROXY_ENABLE = "IsEnableProxy"; + static final String DING_TALK_PROXY = "proxy"; static final String NAME_DING_TALK_PROXY = "Proxy"; - - static final String DING_TALK_PORT = "$t('port')"; + static final String DING_TALK_PORT = "port"; static final String NAME_DING_TALK_PORT = "Port"; - - static final String DING_TALK_USER = "$t('user')"; + static final String DING_TALK_USER = "user"; static final String NAME_DING_TALK_USER = "User"; - - static final String DING_TALK_PASSWORD = "$t('password')"; + static final String DING_TALK_PASSWORD = "password"; static final String NAME_DING_TALK_PASSWORD = "Password"; private DingTalkParamsConstants() { diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java index a97fb006eb..f5d5f1428d 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java @@ -196,6 +196,7 @@ public final class DingTalkSender { this.errmsg = errmsg; } + @Override public boolean equals(final Object o) { if (o == this) { return true; @@ -217,6 +218,7 @@ public final class DingTalkSender { return true; } + @Override public int hashCode() { final int PRIME = 59; int result = 1; @@ -227,6 +229,7 @@ public final class DingTalkSender { return result; } + @Override public String toString() { return "DingTalkSender.DingTalkSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg=" + this.getErrmsg() + ")"; } diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailParamsConstants.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailParamsConstants.java index 7bd75b841e..e7b5143288 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailParamsConstants.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailParamsConstants.java @@ -18,39 +18,41 @@ package org.apache.dolphinscheduler.plugin.alert.email; public final class MailParamsConstants { + public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERS = "$t('receivers')"; public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS = "receivers"; public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERCCS = "$t('receiverCcs')"; public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERCCS = "receiverCcs"; + public static final String MAIL_PROTOCOL = "transport.protocol"; public static final String NAME_MAIL_PROTOCOL = "mail.protocol"; - public static final String MAIL_SMTP_HOST = "$t('mailSmtpHost')"; + public static final String MAIL_SMTP_HOST = "mail.smtp.host"; public static final String NAME_MAIL_SMTP_HOST = "serverHost"; - public static final String MAIL_SMTP_PORT = "$t('mailSmtpPort')"; + public static final String MAIL_SMTP_PORT = "mail.smtp.port"; public static final String NAME_MAIL_SMTP_PORT = "serverPort"; - public static final String MAIL_SENDER = "$t('mailSender')"; + public static final String MAIL_SENDER = "mail.sender"; public static final String NAME_MAIL_SENDER = "sender"; - public static final String MAIL_SMTP_AUTH = "$t('mailSmtpAuth')"; + public static final String MAIL_SMTP_AUTH = "mail.smtp.auth"; public static final String NAME_MAIL_SMTP_AUTH = "enableSmtpAuth"; - public static final String MAIL_USER = "$t('mailUser')"; - public static final String NAME_MAIL_USER = "User"; + public static final String MAIL_USER = "mail.user"; + public static final String NAME_MAIL_USER = "user"; - public static final String MAIL_PASSWD = "$t('mailPasswd')"; - public static final String NAME_MAIL_PASSWD = "Password"; + public static final String MAIL_PASSWD = "mail.passwd"; + public static final String NAME_MAIL_PASSWD = "passwd"; - public static final String MAIL_SMTP_STARTTLS_ENABLE = "$t('mailSmtpStarttlsEnable')"; + public static final String MAIL_SMTP_STARTTLS_ENABLE = "mail.smtp.starttls.enable"; public static final String NAME_MAIL_SMTP_STARTTLS_ENABLE = "starttlsEnable"; - public static final String MAIL_SMTP_SSL_ENABLE = "$t('mailSmtpSslEnable')"; + public static final String MAIL_SMTP_SSL_ENABLE = "mail.smtp.ssl.enable"; public static final String NAME_MAIL_SMTP_SSL_ENABLE = "sslEnable"; - public static final String MAIL_SMTP_SSL_TRUST = "$t('mailSmtpSslTrust')"; + public static final String MAIL_SMTP_SSL_TRUST = "mail.smtp.ssl.trust"; public static final String NAME_MAIL_SMTP_SSL_TRUST = "smtpSslTrust"; private MailParamsConstants() { diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelTest.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelTest.java index 49f67b2ffa..a0237af50a 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelTest.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelTest.java @@ -40,6 +40,10 @@ import org.junit.Assert; import org.junit.Test; public class EmailAlertChannelTest { + + /** + * Method: process(AlertInfo info) + */ @Test public void testProcess() { EmailAlertChannel emailAlertChannel = new EmailAlertChannel(); @@ -55,9 +59,9 @@ public class EmailAlertChannelTest { String mapjson = JSONUtils.toJsonString(maps); alertData.setId(10) - .setContent(mapjson) - .setLog("10") - .setTitle("test"); + .setContent(mapjson) + .setLog("10") + .setTitle("test"); AlertInfo alertInfo = new AlertInfo(); alertInfo.setAlertData(alertData); Map paramsMap = PluginParamsTransfer.getPluginParamsMap(getEmailAlertParams()); @@ -70,74 +74,74 @@ public class EmailAlertChannelTest { public String getEmailAlertParams() { List paramsList = new ArrayList<>(); - InputParam receivesParam = InputParam.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS, "receivers") - .setValue("540957506@qq.com") - .addValidate(Validate.newBuilder().setRequired(true).build()) - .build(); - - InputParam mailSmtpHost = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_HOST, "smtp.host") - .addValidate(Validate.newBuilder().setRequired(true).build()) - .setValue("smtp.126.com") - .build(); - - InputParam mailSmtpPort = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_PORT, "smtp.port") - .addValidate(Validate.newBuilder() - .setRequired(true) - .build()) - .setValue("25") - .build(); - - InputParam mailSender = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SENDER, "sender") - .addValidate(Validate.newBuilder().setRequired(true).build()) - .setValue("dolphinscheduler@126.com") - .build(); - - RadioParam enableSmtpAuth = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_AUTH, "smtp.auth") - .addParamsOptions(new ParamsOptions("YES", "true", false)) - .addParamsOptions(new ParamsOptions("NO", "false", false)) - .addValidate(Validate.newBuilder().setRequired(true).build()) - .setValue("false") - .build(); - - InputParam mailUser = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_USER, "user") - .setPlaceholder("if enable use authentication, you need input user") - .setValue("dolphinscheduler@126.com") - .build(); - - PasswordParam mailPassword = PasswordParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, "passwd") - .setPlaceholder("if enable use authentication, you need input password") - .setValue("escheduler123") - .build(); - - RadioParam enableTls = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_STARTTLS_ENABLE, "starttls.enable") - .addParamsOptions(new ParamsOptions("YES", "true", false)) - .addParamsOptions(new ParamsOptions("NO", "false", false)) - .addValidate(Validate.newBuilder().setRequired(true).build()) - .setValue("true") - .build(); - - RadioParam enableSsl = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_ENABLE, "smtp.ssl.enable") - .addParamsOptions(new ParamsOptions("YES", "true", false)) - .addParamsOptions(new ParamsOptions("NO", "false", false)) - .addValidate(Validate.newBuilder().setRequired(true).build()) - .setValue("true") - .build(); - - InputParam sslTrust = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_TRUST, "smtp.ssl.trust") - .addValidate(Validate.newBuilder().setRequired(true).build()) - .setValue("smtp.126.com") - .build(); + InputParam receivesParam = InputParam.newBuilder("receivers", "receivers") + .setValue("540957506@qq.com") + .addValidate(Validate.newBuilder().setRequired(true).build()) + .build(); + + InputParam mailSmtpHost = InputParam.newBuilder("serverHost", "smtp.host") + .addValidate(Validate.newBuilder().setRequired(true).build()) + .setValue("smtp.126.com") + .build(); + + InputParam mailSmtpPort = InputParam.newBuilder("serverPort", "smtp.port") + .addValidate(Validate.newBuilder() + .setRequired(true) + .build()) + .setValue("25") + .build(); + + InputParam mailSender = InputParam.newBuilder("sender", "sender") + .addValidate(Validate.newBuilder().setRequired(true).build()) + .setValue("dolphinscheduler@126.com") + .build(); + + RadioParam enableSmtpAuth = RadioParam.newBuilder("enableSmtpAuth", "smtp.auth") + .addParamsOptions(new ParamsOptions("YES", "true", false)) + .addParamsOptions(new ParamsOptions("NO", "false", false)) + .addValidate(Validate.newBuilder().setRequired(true).build()) + .setValue("false") + .build(); + + InputParam mailUser = InputParam.newBuilder("user", "user") + .setPlaceholder("if enable use authentication, you need input user") + .setValue("dolphinscheduler@126.com") + .build(); + + PasswordParam mailPassword = PasswordParam.newBuilder("passwd", "passwd") + .setPlaceholder("if enable use authentication, you need input password") + .setValue("escheduler123") + .build(); + + RadioParam enableTls = RadioParam.newBuilder("starttlsEnable", "starttls.enable") + .addParamsOptions(new ParamsOptions("YES", "true", false)) + .addParamsOptions(new ParamsOptions("NO", "false", false)) + .addValidate(Validate.newBuilder().setRequired(true).build()) + .setValue("true") + .build(); + + RadioParam enableSsl = RadioParam.newBuilder("sslEnable", "smtp.ssl.enable") + .addParamsOptions(new ParamsOptions("YES", "true", false)) + .addParamsOptions(new ParamsOptions("NO", "false", false)) + .addValidate(Validate.newBuilder().setRequired(true).build()) + .setValue("true") + .build(); + + InputParam sslTrust = InputParam.newBuilder("smtpSslTrust", "smtp.ssl.trust") + .addValidate(Validate.newBuilder().setRequired(true).build()) + .setValue("smtp.126.com") + .build(); List emailShowTypeList = new ArrayList<>(); emailShowTypeList.add(new ParamsOptions(ShowType.TABLE.getDescp(), ShowType.TABLE.getDescp(), false)); emailShowTypeList.add(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false)); emailShowTypeList.add(new ParamsOptions(ShowType.ATTACHMENT.getDescp(), ShowType.ATTACHMENT.getDescp(), false)); emailShowTypeList.add(new ParamsOptions(ShowType.TABLEATTACHMENT.getDescp(), ShowType.TABLEATTACHMENT.getDescp(), false)); - RadioParam showType = RadioParam.newBuilder(AlertConstants.NAME_SHOW_TYPE, "showType") - .setOptions(emailShowTypeList) - .setValue(ShowType.TABLE.getDescp()) - .addValidate(Validate.newBuilder().setRequired(true).build()) - .build(); + RadioParam showType = RadioParam.newBuilder(AlertConstants.SHOW_TYPE, "showType") + .setOptions(emailShowTypeList) + .setValue(ShowType.TABLE.getDescp()) + .addValidate(Validate.newBuilder().setRequired(true).build()) + .build(); paramsList.add(receivesParam); paramsList.add(mailSmtpHost); diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuParamsConstants.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuParamsConstants.java index aa743903e9..bcbad17860 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuParamsConstants.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuParamsConstants.java @@ -18,26 +18,29 @@ package org.apache.dolphinscheduler.plugin.alert.feishu; public final class FeiShuParamsConstants { - public static final String FEI_SHU_PROXY_ENABLE = "$t('isEnableProxy')"; - static final String WEB_HOOK = "$t('webhook')"; - static final String NAME_WEB_HOOK = "WebHook"; - static final String NAME_FEI_SHU_PROXY_ENABLE = "IsEnableProxy"; + static final String WEB_HOOK = "webhook"; - static final String FEI_SHU_PROXY = "$t('proxy')"; + static final String NAME_WEB_HOOK = "webHook"; - static final String NAME_FEI_SHU_PROXY = "Proxy"; + public static final String FEI_SHU_PROXY_ENABLE = "isEnableProxy"; - static final String FEI_SHU_PORT = "$t('port')"; + static final String NAME_FEI_SHU_PROXY_ENABLE = "isEnableProxy"; - static final String NAME_FEI_SHU_PORT = "Port"; + static final String FEI_SHU_PROXY = "proxy"; - static final String FEI_SHU_USER = "$t('user')"; + static final String NAME_FEI_SHU_PROXY = "proxy"; - static final String NAME_FEI_SHU_USER = "User"; + static final String FEI_SHU_PORT = "port"; - static final String FEI_SHU_PASSWORD = "$t('password')"; + static final String NAME_FEI_SHU_PORT = "port"; - static final String NAME_FEI_SHU_PASSWORD = "Password"; + static final String FEI_SHU_USER = "user"; + + static final String NAME_FEI_SHU_USER = "user"; + + static final String FEI_SHU_PASSWORD = "password"; + + static final String NAME_FEI_SHU_PASSWORD = "password"; private FeiShuParamsConstants() { throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelFactory.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelFactory.java index d5c628c90c..28b4c16e72 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelFactory.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelFactory.java @@ -38,31 +38,31 @@ public final class HttpAlertChannelFactory implements AlertChannelFactory { @Override public List params() { - InputParam url = InputParam.newBuilder(HttpAlertConstants.NAME_URL, HttpAlertConstants.URL) + InputParam url = InputParam.newBuilder(HttpAlertConstants.URL, HttpAlertConstants.URL) .addValidate(Validate.newBuilder() .setRequired(true) .build()) .build(); - InputParam headerParams = InputParam.newBuilder(HttpAlertConstants.NAME_HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS) + InputParam headerParams = InputParam.newBuilder(HttpAlertConstants.HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS) .addValidate(Validate.newBuilder() .setRequired(true) .build()) .build(); - InputParam bodyParams = InputParam.newBuilder(HttpAlertConstants.NAME_BODY_PARAMS, HttpAlertConstants.BODY_PARAMS) + InputParam bodyParams = InputParam.newBuilder(HttpAlertConstants.BODY_PARAMS, HttpAlertConstants.BODY_PARAMS) .addValidate(Validate.newBuilder() .setRequired(true) .build()) .build(); - InputParam contentField = InputParam.newBuilder(HttpAlertConstants.NAME_CONTENT_FIELD, HttpAlertConstants.CONTENT_FIELD) + InputParam contentField = InputParam.newBuilder(HttpAlertConstants.CONTENT_FIELD, HttpAlertConstants.CONTENT_FIELD) .addValidate(Validate.newBuilder() .setRequired(true) .build()) .build(); - InputParam requestType = InputParam.newBuilder(HttpAlertConstants.NAME_REQUEST_TYPE, HttpAlertConstants.REQUEST_TYPE) + InputParam requestType = InputParam.newBuilder(HttpAlertConstants.REQUEST_TYPE, HttpAlertConstants.REQUEST_TYPE) .addValidate(Validate.newBuilder() .setRequired(true) .build()) diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertConstants.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertConstants.java index 6bbf0bfbe0..58cac57c3a 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertConstants.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertConstants.java @@ -18,25 +18,15 @@ package org.apache.dolphinscheduler.plugin.alert.http; public final class HttpAlertConstants { - public static final String URL = "$t('url')"; + public static final String URL = "url"; - public static final String NAME_URL = "url"; + public static final String HEADER_PARAMS = "headerParams"; - public static final String HEADER_PARAMS = "$t('headerParams')"; + public static final String BODY_PARAMS = "bodyParams"; - public static final String NAME_HEADER_PARAMS = "headerParams"; + public static final String CONTENT_FIELD = "contentField"; - public static final String BODY_PARAMS = "$t('bodyParams')"; - - public static final String NAME_BODY_PARAMS = "bodyParams"; - - public static final String CONTENT_FIELD = "$t('contentField')"; - - public static final String NAME_CONTENT_FIELD = "contentField"; - - public static final String REQUEST_TYPE = "$t('requestType')"; - - public static final String NAME_REQUEST_TYPE = "requestType"; + public static final String REQUEST_TYPE = "requestType"; private HttpAlertConstants() { throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java index bc789edc5f..a1b0923013 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java @@ -56,11 +56,11 @@ public final class HttpSender { public HttpSender(Map paramsMap) { - url = paramsMap.get(HttpAlertConstants.NAME_URL); - headerParams = paramsMap.get(HttpAlertConstants.NAME_HEADER_PARAMS); - bodyParams = paramsMap.get(HttpAlertConstants.NAME_BODY_PARAMS); - contentField = paramsMap.get(HttpAlertConstants.NAME_CONTENT_FIELD); - requestType = paramsMap.get(HttpAlertConstants.NAME_REQUEST_TYPE); + url = paramsMap.get(HttpAlertConstants.URL); + headerParams = paramsMap.get(HttpAlertConstants.HEADER_PARAMS); + bodyParams = paramsMap.get(HttpAlertConstants.BODY_PARAMS); + contentField = paramsMap.get(HttpAlertConstants.CONTENT_FIELD); + requestType = paramsMap.get(HttpAlertConstants.REQUEST_TYPE); } public AlertResult send(String msg) { diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSenderTest.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSenderTest.java index 637c615dd1..8628f0c55d 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSenderTest.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSenderTest.java @@ -29,11 +29,11 @@ public class HttpSenderTest { @Test public void sendTest() { Map paramsMap = new HashMap<>(); - paramsMap.put(HttpAlertConstants.NAME_URL, "http://www.baidu.com"); - paramsMap.put(HttpAlertConstants.NAME_REQUEST_TYPE, "POST"); - paramsMap.put(HttpAlertConstants.NAME_HEADER_PARAMS, "{\"Content-Type\":\"application/json\"}"); - paramsMap.put(HttpAlertConstants.NAME_BODY_PARAMS, "{\"number\":\"13457654323\"}"); - paramsMap.put(HttpAlertConstants.NAME_CONTENT_FIELD, "content"); + paramsMap.put(HttpAlertConstants.URL, "http://www.baidu.com"); + paramsMap.put(HttpAlertConstants.REQUEST_TYPE, "POST"); + paramsMap.put(HttpAlertConstants.HEADER_PARAMS, "{\"Content-Type\":\"application/json\"}"); + paramsMap.put(HttpAlertConstants.BODY_PARAMS, "{\"number\":\"13457654323\"}"); + paramsMap.put(HttpAlertConstants.CONTENT_FIELD, "content"); HttpSender httpSender = new HttpSender(paramsMap); AlertResult alertResult = httpSender.send("Fault tolerance warning"); Assert.assertEquals("true", alertResult.getStatus()); diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptParamsConstants.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptParamsConstants.java index e680903fb2..1f1da4a368 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptParamsConstants.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptParamsConstants.java @@ -18,15 +18,16 @@ package org.apache.dolphinscheduler.plugin.alert.script; public final class ScriptParamsConstants { - static final String SCRIPT_TYPE = "$t('scriptType')"; + + static final String SCRIPT_TYPE = "type"; static final String NAME_SCRIPT_TYPE = "type"; - static final String SCRIPT_PATH = "$t('scriptPath')"; + static final String SCRIPT_PATH = "path"; static final String NAME_SCRIPT_PATH = "path"; - static final String SCRIPT_USER_PARAMS = "$t('userParams')"; + static final String SCRIPT_USER_PARAMS = "user.params"; static final String NAME_SCRIPT_USER_PARAMS = "userParams"; diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackParamsConstants.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackParamsConstants.java index 928eba6719..e43856ba36 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackParamsConstants.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackParamsConstants.java @@ -18,13 +18,12 @@ package org.apache.dolphinscheduler.plugin.alert.slack; public final class SlackParamsConstants { - public static final String SLACK_WEB_HOOK_URL = "$t('webhook')"; - public static final String SLACK_WEN_HOOK_URL_NAME = "webHook"; - public static final String SLACK_BOT = "$t('Username')"; + public static final String SLACK_WEB_HOOK_URL = "webhook"; + public static final String SLACK_WEN_HOOK_URL_NAME = "WebHook"; + public static final String SLACK_BOT = "username"; public static final String SLACK_BOT_NAME = "username"; public static final String TEXT = "text"; public static final String ATTACHMENT = "attachments"; - public static final Integer MAX_SHOW_NUMBER = 100; private SlackParamsConstants() { diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertParamsConstants.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertParamsConstants.java index e4c63813ae..bfc7fedb61 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertParamsConstants.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertParamsConstants.java @@ -18,19 +18,36 @@ package org.apache.dolphinscheduler.plugin.alert.wechat; public final class WeChatAlertParamsConstants { - static final String ENTERPRISE_WE_CHAT_CORP_ID = "$t('corpId')"; + static final String ENTERPRISE_WE_CHAT_CORP_ID = "corp.id"; + static final String NAME_ENTERPRISE_WE_CHAT_CORP_ID = "corpId"; - static final String ENTERPRISE_WE_CHAT_SECRET = "$t('secret')"; + + + static final String ENTERPRISE_WE_CHAT_SECRET = "secret"; + static final String NAME_ENTERPRISE_WE_CHAT_SECRET = "secret"; - static final String ENTERPRISE_WE_CHAT_TEAM_SEND_MSG = "$t('teamSendMsg')"; + + static final String ENTERPRISE_WE_CHAT_TEAM_SEND_MSG = "team.send.msg"; + static final String NAME_ENTERPRISE_WE_CHAT_TEAM_SEND_MSG = "teamSendMsg"; - static final String ENTERPRISE_WE_CHAT_USER_SEND_MSG = "$t('userSendMsg')"; + + + static final String ENTERPRISE_WE_CHAT_USER_SEND_MSG = "user.send.msg"; + static final String NAME_ENTERPRISE_WE_CHAT_USER_SEND_MSG = "userSendMsg"; - static final String ENTERPRISE_WE_CHAT_AGENT_ID = "$t('agentId')"; + + + static final String ENTERPRISE_WE_CHAT_AGENT_ID = "agent.id"; + static final String NAME_ENTERPRISE_WE_CHAT_AGENT_ID = "agentId"; - static final String ENTERPRISE_WE_CHAT_USERS = "$t('users')"; + + + static final String ENTERPRISE_WE_CHAT_USERS = "users"; + + static final String NAME_ENTERPRISE_WE_CHAT_USERS = "users"; + private WeChatAlertParamsConstants() { throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); }