From 6a33d2bec02f0d0b0c2ad759d4bf4e2d4bb28a07 Mon Sep 17 00:00:00 2001 From: Jay Chung Date: Thu, 30 Mar 2023 18:57:47 +0800 Subject: [PATCH] fix: Alarm instance port verification (#13827) close: #13532 --- .../alert/dingtalk/DingTalkAlertChannelFactory.java | 5 ++++- .../plugin/alert/email/EmailAlertChannelFactory.java | 9 ++++++--- .../plugin/alert/feishu/FeiShuAlertChannelFactory.java | 10 +++++++--- .../alert/telegram/TelegramAlertChannelFactory.java | 8 ++++++-- .../dolphinscheduler/spi/params/base/FormType.java | 2 +- .../spi/params/input/number/InputNumberParam.java | 10 ++++++++-- 6 files changed, 32 insertions(+), 12 deletions(-) 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 202f435604..95dd2042a2 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 @@ -26,10 +26,12 @@ import org.apache.dolphinscheduler.alert.api.AlertChannel; import org.apache.dolphinscheduler.alert.api.AlertChannelFactory; import org.apache.dolphinscheduler.alert.api.AlertInputTips; import org.apache.dolphinscheduler.spi.params.PasswordParam; +import org.apache.dolphinscheduler.spi.params.base.DataType; import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.Validate; import org.apache.dolphinscheduler.spi.params.input.InputParam; +import org.apache.dolphinscheduler.spi.params.input.number.InputNumberParam; import org.apache.dolphinscheduler.spi.params.radio.RadioParam; import java.util.Arrays; @@ -120,10 +122,11 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory { .build()) .build(); - InputParam portParam = InputParam + InputNumberParam portParam = InputNumberParam .newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PORT, DingTalkParamsConstants.DING_TALK_PORT) .addValidate(Validate.newBuilder() .setRequired(false) + .setType(DataType.NUMBER.getDataType()) .build()) .build(); diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactory.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactory.java index d2b955c6f9..638aff3b6e 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactory.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactory.java @@ -28,10 +28,12 @@ import org.apache.dolphinscheduler.alert.api.AlertConstants; import org.apache.dolphinscheduler.alert.api.AlertInputTips; import org.apache.dolphinscheduler.alert.api.ShowType; import org.apache.dolphinscheduler.spi.params.PasswordParam; +import org.apache.dolphinscheduler.spi.params.base.DataType; import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.Validate; import org.apache.dolphinscheduler.spi.params.input.InputParam; +import org.apache.dolphinscheduler.spi.params.input.number.InputNumberParam; import org.apache.dolphinscheduler.spi.params.radio.RadioParam; import java.util.ArrayList; @@ -69,11 +71,12 @@ public final class EmailAlertChannelFactory implements AlertChannelFactory { .addValidate(Validate.newBuilder().setRequired(true).build()) .build(); - InputParam mailSmtpPort = - InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_PORT, MailParamsConstants.MAIL_SMTP_PORT) - .setValue("25") + InputNumberParam mailSmtpPort = + InputNumberParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_PORT, MailParamsConstants.MAIL_SMTP_PORT) + .setValue(25) .addValidate(Validate.newBuilder() .setRequired(true) + .setType(DataType.NUMBER.getDataType()) .build()) .build(); diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannelFactory.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannelFactory.java index ffa77015c8..d6e888f499 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannelFactory.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannelFactory.java @@ -26,10 +26,12 @@ import org.apache.dolphinscheduler.alert.api.AlertChannel; import org.apache.dolphinscheduler.alert.api.AlertChannelFactory; import org.apache.dolphinscheduler.alert.api.AlertInputTips; import org.apache.dolphinscheduler.spi.params.PasswordParam; +import org.apache.dolphinscheduler.spi.params.base.DataType; import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.Validate; import org.apache.dolphinscheduler.spi.params.input.InputParam; +import org.apache.dolphinscheduler.spi.params.input.number.InputNumberParam; import org.apache.dolphinscheduler.spi.params.radio.RadioParam; import java.util.Arrays; @@ -70,10 +72,12 @@ public final class FeiShuAlertChannelFactory implements AlertChannelFactory { .setRequired(false).build()) .build(); - InputParam portParam = - InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PORT, FeiShuParamsConstants.FEI_SHU_PORT) + InputNumberParam portParam = + InputNumberParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PORT, FeiShuParamsConstants.FEI_SHU_PORT) .addValidate(Validate.newBuilder() - .setRequired(false).build()) + .setRequired(false) + .setType(DataType.NUMBER.getDataType()) + .build()) .build(); InputParam userParam = diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramAlertChannelFactory.java b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramAlertChannelFactory.java index 2bd2b61922..8dcf36dd89 100644 --- a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramAlertChannelFactory.java +++ b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramAlertChannelFactory.java @@ -26,10 +26,12 @@ import org.apache.dolphinscheduler.alert.api.AlertChannel; import org.apache.dolphinscheduler.alert.api.AlertChannelFactory; import org.apache.dolphinscheduler.alert.api.AlertInputTips; import org.apache.dolphinscheduler.spi.params.PasswordParam; +import org.apache.dolphinscheduler.spi.params.base.DataType; import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.Validate; import org.apache.dolphinscheduler.spi.params.input.InputParam; +import org.apache.dolphinscheduler.spi.params.input.number.InputNumberParam; import org.apache.dolphinscheduler.spi.params.radio.RadioParam; import org.apache.dolphinscheduler.spi.params.select.SelectParam; @@ -113,10 +115,12 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory { .build()) .build(); - InputParam portParam = - InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PORT, TelegramParamsConstants.TELEGRAM_PORT) + InputNumberParam portParam = + InputNumberParam + .newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PORT, TelegramParamsConstants.TELEGRAM_PORT) .addValidate(Validate.newBuilder() .setRequired(false) + .setType(DataType.NUMBER.getDataType()) .build()) .build(); diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/base/FormType.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/base/FormType.java index a3bde26264..87296d93f9 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/base/FormType.java +++ b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/base/FormType.java @@ -28,7 +28,7 @@ import com.google.common.base.Functions; public enum FormType { INPUT("input"), - INPUTNUMBER("inputNumber"), + INPUTNUMBER("input-number"), RADIO("radio"), SELECT("select"), SWITCH("switch"), diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/input/number/InputNumberParam.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/input/number/InputNumberParam.java index 7e63432230..c3888ad261 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/input/number/InputNumberParam.java +++ b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/input/number/InputNumberParam.java @@ -30,12 +30,13 @@ import java.util.List; */ public class InputNumberParam extends PluginParams { + private final InputNumberParamProps props; + private InputNumberParam(Builder builder) { super(builder); + this.props = builder.props; } - private InputNumberParamProps props; - public static Builder newBuilder(String name, String title) { return new Builder(name, title); } @@ -95,6 +96,11 @@ public class InputNumberParam extends PluginParams { this.display = display; return this; } + + @Override + public InputNumberParam build() { + return new InputNumberParam(this); + } } @Override