Browse Source

[Improvement][Style] Fix remaining style errors and wildcard imports (#12412)

* Fix remaining style errors and wildcard imports

* Upgrade spotless to the latest stable version, exclude .github folder from spotless check and fix dead link

* Fix spotless matching scope of markdown files
3.2.0-release
Eric Gao 2 years ago committed by GitHub
parent
commit
d46e4659d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      docs/docs/en/about/hardware.md
  2. 3
      docs/docs/en/contribute/join/become-a-committer.md
  3. 2
      docs/docs/en/guide/datasource/oracle.md
  4. 1
      docs/docs/en/guide/upgrade/incompatible.md
  5. 1
      docs/docs/zh/about/hardware.md
  6. 1
      docs/docs/zh/contribute/join/become-a-committer.md
  7. 1
      docs/docs/zh/guide/datasource/oracle.md
  8. 1
      docs/docs/zh/guide/parameter/built-in.md
  9. 1
      docs/docs/zh/guide/upgrade/incompatible.md
  10. 11
      dolphinscheduler-alert/dolphinscheduler-alert-api/pom.xml
  11. 1
      dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertChannel.java
  12. 3
      dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertChannelFactory.java
  13. 1
      dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertConstants.java
  14. 1
      dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/ShowType.java
  15. 7
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/pom.xml
  16. 19
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannelFactory.java
  17. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkParamsConstants.java
  18. 17
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java
  19. 7
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/pom.xml
  20. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannel.java
  21. 40
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactory.java
  22. 4
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailConstants.java
  23. 16
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java
  24. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailParamsConstants.java
  25. 16
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java
  26. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/exception/AlertEmailException.java
  27. 10
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/template/DefaultHTMLTemplate.java
  28. 7
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/pom.xml
  29. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannel.java
  30. 14
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannelFactory.java
  31. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuParamsConstants.java
  32. 14
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSender.java
  33. 4
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/HttpRequestUtil.java
  34. 7
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/pom.xml
  35. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannel.java
  36. 13
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelFactory.java
  37. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertConstants.java
  38. 7
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/pom.xml
  39. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/src/main/java/org/apache/dolphinscheduler/plugin/alert/pagerduty/PagerDutyAlertChannel.java
  40. 9
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/src/main/java/org/apache/dolphinscheduler/plugin/alert/pagerduty/PagerDutyAlertChannelFactory.java
  41. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/src/main/java/org/apache/dolphinscheduler/plugin/alert/pagerduty/PagerDutyParamsConstants.java
  42. 20
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/src/main/java/org/apache/dolphinscheduler/plugin/alert/pagerduty/PagerDutySender.java
  43. 7
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/pom.xml
  44. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/OSUtils.java
  45. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ProcessUtils.java
  46. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannel.java
  47. 13
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannelFactory.java
  48. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptParamsConstants.java
  49. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptType.java
  50. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/StreamGobbler.java
  51. 7
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/pom.xml
  52. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackAlertChannel.java
  53. 4
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackAlertChannelFactory.java
  54. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackParamsConstants.java
  55. 4
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackSender.java
  56. 7
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/pom.xml
  57. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramAlertChannel.java
  58. 54
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramAlertChannelFactory.java
  59. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramParamsConstants.java
  60. 14
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramSender.java
  61. 7
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/pom.xml
  62. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexMessage.java
  63. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsAlertChannel.java
  64. 34
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsAlertChannelFactory.java
  65. 4
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsDestination.java
  66. 7
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsSender.java
  67. 7
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/pom.xml
  68. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannel.java
  69. 24
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannelFactory.java
  70. 4
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertConstants.java
  71. 1
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertParamsConstants.java
  72. 28
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatSender.java
  73. 2
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatType.java
  74. 4
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WechatAppChatMessage.java
  75. 3
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WechatAppMessage.java
  76. 7
      dolphinscheduler-alert/dolphinscheduler-alert-plugins/pom.xml
  77. 24
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertPluginManager.java
  78. 4
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertRequestProcessor.java
  79. 2
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServerMetrics.java
  80. 10
      dolphinscheduler-alert/pom.xml
  81. 1
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java
  82. 1
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/aspect/AccessLogAnnotation.java
  83. 14
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/aspect/AccessLogAspect.java
  84. 4
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/audit/AuditMessage.java
  85. 1
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/AuditConfiguration.java
  86. 16
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/OpenAPITranslationConfiguration.java
  87. 1
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/PythonGatewayConfiguration.java
  88. 12
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/TaskTypeConfiguration.java
  89. 4
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/TrafficConfiguration.java
  90. 21
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/constants/ApiFuncIdentificationConstant.java
  91. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java
  92. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertGroupController.java
  93. 1
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertPluginInstanceController.java
  94. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ClusterController.java
  95. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataQualityController.java
  96. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
  97. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DsErrorController.java
  98. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/EnvironmentController.java
  99. 26
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ExecutorController.java
  100. 22
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/FavTaskController.java
  101. Some files were not shown because too many files have changed in this diff Show More

1
docs/docs/en/about/hardware.md

@ -49,4 +49,5 @@ DolphinScheduler provides the following network port configurations for normal o
The minimum supported version of Google Chrome is version 85, but version 90 or above is recommended. The minimum supported version of Google Chrome is version 85, but version 90 or above is recommended.
## Synchronize clocks ## Synchronize clocks
To avoid problems with internal cluster communications that can impact your task execution, make sure that the clocks on all of the cluster nodes are synchronized from a common clock source, such as using Chrony and/or NTP. Synchronizing the time ensures that every node in the cluster has the same time. To avoid problems with internal cluster communications that can impact your task execution, make sure that the clocks on all of the cluster nodes are synchronized from a common clock source, such as using Chrony and/or NTP. Synchronizing the time ensures that every node in the cluster has the same time.

3
docs/docs/en/contribute/join/become-a-committer.md

@ -20,7 +20,7 @@ In Dolphinscheduler, **new committer nomination** could only be officially start
The following steps are recommended (to be initiated only by an existing PMC member): The following steps are recommended (to be initiated only by an existing PMC member):
1. Send an email titled `[DISCUSS] Promote xxx as new committer` to `private@dolphinscheduler.apache.org`. List the important contributions of the candidate, 1. Send an email titled `[DISCUSS] Promote xxx as new committer` to `private@dolphinscheduler.apache.org`. List the important contributions of the candidate,
so you could gather support from other PMC members for your proposal. so you could gather support from other PMC members for your proposal.
2. Keep the discussion open for more than 3 days but no more than 1 week, unless there is any express objection or concern. 2. Keep the discussion open for more than 3 days but no more than 1 week, unless there is any express objection or concern.
3. If the PMC generally agrees to the proposal, send an email titled `[VOTE] Promote xxx as new committer` to `private@dolphinscheduler.apache.org`. 3. If the PMC generally agrees to the proposal, send an email titled `[VOTE] Promote xxx as new committer` to `private@dolphinscheduler.apache.org`.
4. Keep the voting process open for more than 3 days, but no more than 1 week. Consider the result as `Consensus Approval` if there are `3 + 1` votes with `NO` vetos. Please note that +1 votes > -1 votes. 4. Keep the voting process open for more than 3 days, but no more than 1 week. Consider the result as `Consensus Approval` if there are `3 + 1` votes with `NO` vetos. Please note that +1 votes > -1 votes.
@ -31,6 +31,7 @@ The following steps are recommended (to be initiated only by an existing PMC mem
The PMC member who starts the promotion is responsible for sending an invitation to the new committer and guiding him/her to set up the ASF env. The PMC member who starts the promotion is responsible for sending an invitation to the new committer and guiding him/her to set up the ASF env.
The PMC member should send an email using the following template to the new committer: The PMC member should send an email using the following template to the new committer:
``` ```
To: <invitee name>@gmail.com To: <invitee name>@gmail.com
Cc: private@dolphinscheduler.apache.org Cc: private@dolphinscheduler.apache.org

2
docs/docs/en/guide/datasource/oracle.md

@ -5,7 +5,7 @@
## Datasource Parameters ## Datasource Parameters
| **Datasource** | **Description** | | **Datasource** | **Description** |
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| |-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| Datasource | Select Oracle. | | Datasource | Select Oracle. |
| Datasource Name | Enter the name of the datasource. | | Datasource Name | Enter the name of the datasource. |
| Description | Enter a description of the datasource. | | Description | Enter a description of the datasource. |

1
docs/docs/en/guide/upgrade/incompatible.md

@ -11,3 +11,4 @@ This document records the incompatible updates between each version. You need to
* Copy and import workflow without 'copy' suffix [#10607](https://github.com/apache/dolphinscheduler/pull/10607) * Copy and import workflow without 'copy' suffix [#10607](https://github.com/apache/dolphinscheduler/pull/10607)
* Use semicolon as default sql segment separator [#10869](https://github.com/apache/dolphinscheduler/pull/10869) * Use semicolon as default sql segment separator [#10869](https://github.com/apache/dolphinscheduler/pull/10869)

1
docs/docs/zh/about/hardware.md

@ -47,4 +47,5 @@ DolphinScheduler正常运行提供如下的网络端口配置:
DolphinScheduler 推荐 Chrome 以及使用 Chromium 内核的较新版本浏览器访问前端可视化操作界面 DolphinScheduler 推荐 Chrome 以及使用 Chromium 内核的较新版本浏览器访问前端可视化操作界面
## 时钟同步 ## 时钟同步
为避免可能影响任务执行的内部集群通信问题,请确保所有集群节点上的时钟与公共时钟源同步,例如使用 Chrony 和/或 NTP。 同步时间确保集群中的每个节点都有相同的时间 为避免可能影响任务执行的内部集群通信问题,请确保所有集群节点上的时钟与公共时钟源同步,例如使用 Chrony 和/或 NTP。 同步时间确保集群中的每个节点都有相同的时间

1
docs/docs/zh/contribute/join/become-a-committer.md

@ -28,6 +28,7 @@ PMC会定期基于活跃贡献者们对Dolphinscheduler的贡献从他们中提
发起提名的PMC成员负责向新的committer发出邀请,并指导他/她建立ASF精神思想。 发起提名的PMC成员负责向新的committer发出邀请,并指导他/她建立ASF精神思想。
PMC成员应使用以下模板向新的committer发送一封电子邮件: PMC成员应使用以下模板向新的committer发送一封电子邮件:
``` ```
To: <invitee name>@gmail.com To: <invitee name>@gmail.com
Cc: private@dolphinscheduler.apache.org Cc: private@dolphinscheduler.apache.org

1
docs/docs/zh/guide/datasource/oracle.md

@ -12,3 +12,4 @@
- 数据库名:输入连接 ORACLE 的 ServiceName 或 SID - 数据库名:输入连接 ORACLE 的 ServiceName 或 SID
- Jdbc 连接参数:用于 ORACLE 连接的参数设置,以 JSON 形式填写 - Jdbc 连接参数:用于 ORACLE 连接的参数设置,以 JSON 形式填写
- 比如 `{"schema": "abc"}` 指定使用 `username` 用户下的 `abc` 数据库 - 比如 `{"schema": "abc"}` 指定使用 `username` 用户下的 `abc` 数据库

1
docs/docs/zh/guide/parameter/built-in.md

@ -59,3 +59,4 @@
* 前(-)/后(+) N 月最后一天:$[month_last_day(yyyy-MM-dd,-N)],如:N=1时 2022-08-28 => 2022-07-31 * 前(-)/后(+) N 月最后一天:$[month_last_day(yyyy-MM-dd,-N)],如:N=1时 2022-08-28 => 2022-07-31
* 前(-)/后(+) N 周的周一:$[week_first_day(yyyy-MM-dd,-N)],如:N=1 2022-08-26 => 2022-08-15 * 前(-)/后(+) N 周的周一:$[week_first_day(yyyy-MM-dd,-N)],如:N=1 2022-08-26 => 2022-08-15
* 前(-)/后(+) N 周的周日:$[week_last_day(yyyy-MM-dd,-N)],如:N=1 2022-08-26 => 2022-08-21 * 前(-)/后(+) N 周的周日:$[week_last_day(yyyy-MM-dd,-N)],如:N=1 2022-08-26 => 2022-08-21

1
docs/docs/zh/guide/upgrade/incompatible.md

@ -11,3 +11,4 @@
* Copy and import workflow without 'copy' suffix [#10607](https://github.com/apache/dolphinscheduler/pull/10607) * Copy and import workflow without 'copy' suffix [#10607](https://github.com/apache/dolphinscheduler/pull/10607)
* Use semicolon as default sql segment separator [#10869](https://github.com/apache/dolphinscheduler/pull/10869) * Use semicolon as default sql segment separator [#10869](https://github.com/apache/dolphinscheduler/pull/10869)

11
dolphinscheduler-alert/dolphinscheduler-alert-api/pom.xml

@ -17,22 +17,21 @@
~ specific language governing permissions and limitations ~ specific language governing permissions and limitations
~ under the License. ~ under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler-alert</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-api</artifactId> <artifactId>dolphinscheduler-alert-api</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-spi</artifactId> <!-- TODO should get rid off this --> <artifactId>dolphinscheduler-spi</artifactId>
<!-- TODO should get rid off this -->
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

1
dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertChannel.java

@ -25,6 +25,7 @@ import lombok.NonNull;
* alert channel for sending alerts * alert channel for sending alerts
*/ */
public interface AlertChannel { public interface AlertChannel {
/** /**
* process and send alert * process and send alert
* *

3
dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertChannelFactory.java

@ -20,8 +20,8 @@
package org.apache.dolphinscheduler.alert.api; package org.apache.dolphinscheduler.alert.api;
import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.plugin.SPIIdentify;
import org.apache.dolphinscheduler.spi.plugin.PrioritySPI; import org.apache.dolphinscheduler.spi.plugin.PrioritySPI;
import org.apache.dolphinscheduler.spi.plugin.SPIIdentify;
import java.util.List; import java.util.List;
@ -29,6 +29,7 @@ import java.util.List;
* alert channel factory * alert channel factory
*/ */
public interface AlertChannelFactory extends PrioritySPI { public interface AlertChannelFactory extends PrioritySPI {
/** /**
* Returns the name of the alert channel * Returns the name of the alert channel
* *

1
dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertConstants.java

@ -20,6 +20,7 @@
package org.apache.dolphinscheduler.alert.api; package org.apache.dolphinscheduler.alert.api;
public final class AlertConstants { public final class AlertConstants {
/** /**
* the field name of alert show type * the field name of alert show type
**/ **/

1
dolphinscheduler-alert/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/ShowType.java

@ -25,6 +25,7 @@ import lombok.Getter;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
public enum ShowType { public enum ShowType {
/** /**
* 0 TABLE; * 0 TABLE;
* 1 TEXT; * 1 TEXT;

7
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/pom.xml

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-dingtalk</artifactId> <artifactId>dolphinscheduler-alert-dingtalk</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>

19
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannelFactory.java

@ -38,6 +38,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class) @AutoService(AlertChannelFactory.class)
public final class DingTalkAlertChannelFactory implements AlertChannelFactory { public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String name() { public String name() {
return "DingTalk"; return "DingTalk";
@ -67,8 +68,10 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
RadioParam msgTypeParam = RadioParam RadioParam msgTypeParam = RadioParam
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_MSG_TYPE, DingTalkParamsConstants.DING_TALK_MSG_TYPE) .newBuilder(DingTalkParamsConstants.NAME_DING_TALK_MSG_TYPE, DingTalkParamsConstants.DING_TALK_MSG_TYPE)
.addParamsOptions(new ParamsOptions(DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT, DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT, false)) .addParamsOptions(new ParamsOptions(DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT,
.addParamsOptions(new ParamsOptions(DingTalkParamsConstants.DING_TALK_MSG_TYPE_MARKDOWN, DingTalkParamsConstants.DING_TALK_MSG_TYPE_MARKDOWN, false)) DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT, false))
.addParamsOptions(new ParamsOptions(DingTalkParamsConstants.DING_TALK_MSG_TYPE_MARKDOWN,
DingTalkParamsConstants.DING_TALK_MSG_TYPE_MARKDOWN, false))
.setValue(DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT) .setValue(DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
@ -76,13 +79,15 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
.build(); .build();
InputParam atMobilesParam = InputParam InputParam atMobilesParam = InputParam
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_AT_MOBILES, DingTalkParamsConstants.DING_TALK_AT_MOBILES) .newBuilder(DingTalkParamsConstants.NAME_DING_TALK_AT_MOBILES,
DingTalkParamsConstants.DING_TALK_AT_MOBILES)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
.build(); .build();
InputParam atUserIdsParam = InputParam InputParam atUserIdsParam = InputParam
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_AT_USERIDS, DingTalkParamsConstants.DING_TALK_AT_USERIDS) .newBuilder(DingTalkParamsConstants.NAME_DING_TALK_AT_USERIDS,
DingTalkParamsConstants.DING_TALK_AT_USERIDS)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
@ -98,7 +103,8 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
.build(); .build();
RadioParam isEnableProxy = RadioParam RadioParam isEnableProxy = RadioParam
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY_ENABLE, DingTalkParamsConstants.DING_TALK_PROXY_ENABLE) .newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY_ENABLE,
DingTalkParamsConstants.DING_TALK_PROXY_ENABLE)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false)) .addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false)) .addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.setValue(STRING_FALSE) .setValue(STRING_FALSE)
@ -131,7 +137,8 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
.setPlaceholder("if enable use authentication, you need input password") .setPlaceholder("if enable use authentication, you need input password")
.build(); .build();
return Arrays.asList(webHookParam, keywordParam, secretParam, msgTypeParam, atMobilesParam, atUserIdsParam, isAtAll, isEnableProxy, proxyParam, portParam, userParam, passwordParam); return Arrays.asList(webHookParam, keywordParam, secretParam, msgTypeParam, atMobilesParam, atUserIdsParam,
isAtAll, isEnableProxy, proxyParam, portParam, userParam, passwordParam);
} }
@Override @Override

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkParamsConstants.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.dingtalk; package org.apache.dolphinscheduler.plugin.alert.dingtalk;
public final class DingTalkParamsConstants { public final class DingTalkParamsConstants {
static final String DING_TALK_PROXY_ENABLE = "$t('isEnableProxy')"; static final String DING_TALK_PROXY_ENABLE = "$t('isEnableProxy')";
static final String NAME_DING_TALK_PROXY_ENABLE = "IsEnableProxy"; static final String NAME_DING_TALK_PROXY_ENABLE = "IsEnableProxy";

17
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java

@ -171,7 +171,8 @@ public final class DingTalkSender {
String msg = generateMsgJson(title, content); String msg = generateMsgJson(title, content);
HttpPost httpPost = constructHttpPost(org.apache.dolphinscheduler.spi.utils.StringUtils.isBlank(secret) ? url : generateSignedUrl(), msg); HttpPost httpPost = constructHttpPost(
org.apache.dolphinscheduler.spi.utils.StringUtils.isBlank(secret) ? url : generateSignedUrl(), msg);
CloseableHttpClient httpClient; CloseableHttpClient httpClient;
if (Boolean.TRUE.equals(enableProxy)) { if (Boolean.TRUE.equals(enableProxy)) {
@ -289,8 +290,12 @@ public final class DingTalkSender {
private void setMsgAt(Map<String, Object> items) { private void setMsgAt(Map<String, Object> items) {
Map<String, Object> at = new HashMap<>(); Map<String, Object> at = new HashMap<>();
String[] atMobileArray = org.apache.dolphinscheduler.spi.utils.StringUtils.isNotBlank(atMobiles) ? atMobiles.split(",") : new String[0]; String[] atMobileArray =
String[] atUserArray = org.apache.dolphinscheduler.spi.utils.StringUtils.isNotBlank(atUserIds) ? atUserIds.split(",") : new String[0]; org.apache.dolphinscheduler.spi.utils.StringUtils.isNotBlank(atMobiles) ? atMobiles.split(",")
: new String[0];
String[] atUserArray =
org.apache.dolphinscheduler.spi.utils.StringUtils.isNotBlank(atUserIds) ? atUserIds.split(",")
: new String[0];
boolean isAtAll = Objects.isNull(atAll) ? false : atAll; boolean isAtAll = Objects.isNull(atAll) ? false : atAll;
at.put("atMobiles", atMobileArray); at.put("atMobiles", atMobileArray);
@ -313,7 +318,7 @@ public final class DingTalkSender {
Mac mac = Mac.getInstance("HmacSHA256"); Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256")); mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256"));
byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8")); byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8"));
sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)),"UTF-8"); sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)), "UTF-8");
} catch (Exception e) { } catch (Exception e) {
logger.error("generate sign error, message:{}", e); logger.error("generate sign error, message:{}", e);
} }
@ -321,6 +326,7 @@ public final class DingTalkSender {
} }
static final class DingTalkSendMsgResponse { static final class DingTalkSendMsgResponse {
private Integer errcode; private Integer errcode;
private String errmsg; private String errmsg;
@ -378,7 +384,8 @@ public final class DingTalkSender {
@Override @Override
public String toString() { public String toString() {
return "DingTalkSender.DingTalkSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg=" + this.getErrmsg() + ")"; return "DingTalkSender.DingTalkSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg="
+ this.getErrmsg() + ")";
} }
} }
} }

7
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/pom.xml

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-email</artifactId> <artifactId>dolphinscheduler-alert-email</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannel.java

@ -28,6 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public final class EmailAlertChannel implements AlertChannel { public final class EmailAlertChannel implements AlertChannel {
private static final Logger logger = LoggerFactory.getLogger(EmailAlertChannel.class); private static final Logger logger = LoggerFactory.getLogger(EmailAlertChannel.class);
@Override @Override

40
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactory.java

@ -40,6 +40,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class) @AutoService(AlertChannelFactory.class)
public final class EmailAlertChannelFactory implements AlertChannelFactory { public final class EmailAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String name() { public String name() {
return "Email"; return "Email";
@ -48,32 +49,40 @@ public final class EmailAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public List<PluginParams> params() { public List<PluginParams> params() {
List<PluginParams> paramsList = new ArrayList<>(); List<PluginParams> paramsList = new ArrayList<>();
InputParam receivesParam = InputParam.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS, MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERS) InputParam receivesParam = InputParam
.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS,
MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERS)
.setPlaceholder("please input receives") .setPlaceholder("please input receives")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.build(); .build();
InputParam receiveCcsParam = InputParam.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERCCS, MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERCCS) InputParam receiveCcsParam = InputParam
.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERCCS,
MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERCCS)
.build(); .build();
InputParam mailSmtpHost = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_HOST, MailParamsConstants.MAIL_SMTP_HOST) InputParam mailSmtpHost =
InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_HOST, MailParamsConstants.MAIL_SMTP_HOST)
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.build(); .build();
InputParam mailSmtpPort = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_PORT, MailParamsConstants.MAIL_SMTP_PORT) InputParam mailSmtpPort =
InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_PORT, MailParamsConstants.MAIL_SMTP_PORT)
.setValue("25") .setValue("25")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.build(); .build();
InputParam mailSender = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SENDER, MailParamsConstants.MAIL_SENDER) InputParam mailSender =
InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SENDER, MailParamsConstants.MAIL_SENDER)
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.build(); .build();
RadioParam enableSmtpAuth = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_AUTH, MailParamsConstants.MAIL_SMTP_AUTH) RadioParam enableSmtpAuth =
RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_AUTH, MailParamsConstants.MAIL_SMTP_AUTH)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false)) .addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false)) .addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.setValue(STRING_TRUE) .setValue(STRING_TRUE)
@ -84,25 +93,30 @@ public final class EmailAlertChannelFactory implements AlertChannelFactory {
.setPlaceholder("if enable use authentication, you need input user") .setPlaceholder("if enable use authentication, you need input user")
.build(); .build();
PasswordParam mailPassword = PasswordParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, MailParamsConstants.MAIL_PASSWD) PasswordParam mailPassword =
PasswordParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, MailParamsConstants.MAIL_PASSWD)
.setPlaceholder("if enable use authentication, you need input password") .setPlaceholder("if enable use authentication, you need input password")
.build(); .build();
RadioParam enableTls = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_STARTTLS_ENABLE, MailParamsConstants.MAIL_SMTP_STARTTLS_ENABLE) RadioParam enableTls = RadioParam
.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_STARTTLS_ENABLE,
MailParamsConstants.MAIL_SMTP_STARTTLS_ENABLE)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false)) .addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false)) .addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.setValue(STRING_FALSE) .setValue(STRING_FALSE)
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.build(); .build();
RadioParam enableSsl = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_ENABLE, MailParamsConstants.MAIL_SMTP_SSL_ENABLE) RadioParam enableSsl = RadioParam
.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_ENABLE, MailParamsConstants.MAIL_SMTP_SSL_ENABLE)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false)) .addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false)) .addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.setValue(STRING_FALSE) .setValue(STRING_FALSE)
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.build(); .build();
InputParam sslTrust = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_TRUST, MailParamsConstants.MAIL_SMTP_SSL_TRUST) InputParam sslTrust = InputParam
.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_TRUST, MailParamsConstants.MAIL_SMTP_SSL_TRUST)
.setValue("*") .setValue("*")
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.build(); .build();
@ -110,8 +124,10 @@ public final class EmailAlertChannelFactory implements AlertChannelFactory {
RadioParam showType = RadioParam.newBuilder(AlertConstants.NAME_SHOW_TYPE, AlertConstants.SHOW_TYPE) RadioParam showType = RadioParam.newBuilder(AlertConstants.NAME_SHOW_TYPE, AlertConstants.SHOW_TYPE)
.addParamsOptions(new ParamsOptions(ShowType.TABLE.getDescp(), ShowType.TABLE.getDescp(), false)) .addParamsOptions(new ParamsOptions(ShowType.TABLE.getDescp(), ShowType.TABLE.getDescp(), false))
.addParamsOptions(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false)) .addParamsOptions(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false))
.addParamsOptions(new ParamsOptions(ShowType.ATTACHMENT.getDescp(), ShowType.ATTACHMENT.getDescp(), false)) .addParamsOptions(
.addParamsOptions(new ParamsOptions(ShowType.TABLE_ATTACHMENT.getDescp(), ShowType.TABLE_ATTACHMENT.getDescp(), false)) new ParamsOptions(ShowType.ATTACHMENT.getDescp(), ShowType.ATTACHMENT.getDescp(), false))
.addParamsOptions(new ParamsOptions(ShowType.TABLE_ATTACHMENT.getDescp(),
ShowType.TABLE_ATTACHMENT.getDescp(), false))
.setValue(ShowType.TABLE.getDescp()) .setValue(ShowType.TABLE.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.build(); .build();

4
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailConstants.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.email; package org.apache.dolphinscheduler.plugin.alert.email;
public final class EmailConstants { public final class EmailConstants {
public static final String XLS_FILE_PATH = "xls.file.path"; public static final String XLS_FILE_PATH = "xls.file.path";
public static final String MAIL_TRANSPORT_PROTOCOL = "mail.transport.protocol"; public static final String MAIL_TRANSPORT_PROTOCOL = "mail.transport.protocol";
@ -38,7 +39,8 @@ public final class EmailConstants {
public static final String TH_END = "</th>"; public static final String TH_END = "</th>";
public static final String HTML_HEADER_PREFIX = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>" public static final String HTML_HEADER_PREFIX =
"<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>"
+ "<html>" + "<html>"
+ "<head>" + "<head>"
+ "<title>dolphinscheduler</title>" + "<title>dolphinscheduler</title>"

16
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java

@ -39,6 +39,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public final class ExcelUtils { public final class ExcelUtils {
private static final int XLSX_WINDOW_ROW = 10000; private static final int XLSX_WINDOW_ROW = 10000;
private static final Logger logger = LoggerFactory.getLogger(ExcelUtils.class); private static final Logger logger = LoggerFactory.getLogger(ExcelUtils.class);
@ -74,32 +75,33 @@ public final class ExcelUtils {
for (Map.Entry<String, Object> en : headerMap.entrySet()) { for (Map.Entry<String, Object> en : headerMap.entrySet()) {
headerList.add(en.getKey()); headerList.add(en.getKey());
} }
try (SXSSFWorkbook wb = new SXSSFWorkbook(XLSX_WINDOW_ROW); try (
SXSSFWorkbook wb = new SXSSFWorkbook(XLSX_WINDOW_ROW);
FileOutputStream fos = new FileOutputStream(String.format("%s/%s.xlsx", xlsFilePath, title))) { FileOutputStream fos = new FileOutputStream(String.format("%s/%s.xlsx", xlsFilePath, title))) {
// declare a workbook // declare a workbook
// generate a table // generate a table
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
Row row = sheet.createRow(0); Row row = sheet.createRow(0);
//set the height of the first line // set the height of the first line
row.setHeight((short) 500); row.setHeight((short) 500);
//set Horizontal right // set Horizontal right
CellStyle cellStyle = wb.createCellStyle(); CellStyle cellStyle = wb.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.RIGHT); cellStyle.setAlignment(HorizontalAlignment.RIGHT);
//setting excel headers // setting excel headers
for (int i = 0; i < headerList.size(); i++) { for (int i = 0; i < headerList.size(); i++) {
Cell cell = row.createCell(i); Cell cell = row.createCell(i);
cell.setCellStyle(cellStyle); cell.setCellStyle(cellStyle);
cell.setCellValue(headerList.get(i)); cell.setCellValue(headerList.get(i));
} }
//setting excel body // setting excel body
int rowIndex = 1; int rowIndex = 1;
for (LinkedHashMap<String, Object> itemsMap : itemsList) { for (LinkedHashMap<String, Object> itemsMap : itemsList) {
Object[] values = itemsMap.values().toArray(); Object[] values = itemsMap.values().toArray();
row = sheet.createRow(rowIndex); row = sheet.createRow(rowIndex);
//setting excel body height // setting excel body height
row.setHeight((short) 500); row.setHeight((short) 500);
rowIndex++; rowIndex++;
for (int j = 0; j < values.length; j++) { for (int j = 0; j < values.length; j++) {
@ -117,7 +119,7 @@ public final class ExcelUtils {
sheet.setColumnWidth(i, headerList.get(i).length() * 800); sheet.setColumnWidth(i, headerList.get(i).length() * 800);
} }
//setting file output // setting file output
wb.write(fos); wb.write(fos);
wb.dispose(); wb.dispose();
} catch (Exception e) { } catch (Exception e) {

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailParamsConstants.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.email; package org.apache.dolphinscheduler.plugin.alert.email;
public final class MailParamsConstants { public final class MailParamsConstants {
public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERS = "$t('receivers')"; public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERS = "$t('receivers')";
public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS = "receivers"; public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS = "receivers";

16
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java

@ -60,6 +60,7 @@ import org.slf4j.LoggerFactory;
import com.sun.mail.smtp.SMTPProvider; import com.sun.mail.smtp.SMTPProvider;
public final class MailSender { public final class MailSender {
private static final Logger logger = LoggerFactory.getLogger(MailSender.class); private static final Logger logger = LoggerFactory.getLogger(MailSender.class);
private final List<String> receivers; private final List<String> receivers;
@ -178,7 +179,7 @@ public final class MailSender {
} }
if (CollectionUtils.isNotEmpty(receiverCcs)) { if (CollectionUtils.isNotEmpty(receiverCcs)) {
//cc // cc
for (String receiverCc : receiverCcs) { for (String receiverCc : receiverCcs) {
email.addCc(receiverCc); email.addCc(receiverCc);
} }
@ -188,7 +189,8 @@ public final class MailSender {
} catch (Exception e) { } catch (Exception e) {
handleException(alertResult, e); handleException(alertResult, e);
} }
} else if (showType.equals(ShowType.ATTACHMENT.getDescp()) || showType.equals(ShowType.TABLE_ATTACHMENT.getDescp())) { } else if (showType.equals(ShowType.ATTACHMENT.getDescp())
|| showType.equals(ShowType.TABLE_ATTACHMENT.getDescp())) {
try { try {
String partContent = (showType.equals(ShowType.ATTACHMENT.getDescp()) String partContent = (showType.equals(ShowType.ATTACHMENT.getDescp())
@ -294,6 +296,7 @@ public final class MailSender {
props.setProperty(MailParamsConstants.MAIL_SMTP_SSL_TRUST, sslTrust); props.setProperty(MailParamsConstants.MAIL_SMTP_SSL_TRUST, sslTrust);
Authenticator auth = new Authenticator() { Authenticator auth = new Authenticator() {
@Override @Override
protected PasswordAuthentication getPasswordAuthentication() { protected PasswordAuthentication getPasswordAuthentication() {
// mail username and password // mail username and password
@ -309,7 +312,8 @@ public final class MailSender {
/** /**
* attach content * attach content
*/ */
private void attachContent(String title, String content, String partContent, MimeMessage msg) throws MessagingException, IOException { private void attachContent(String title, String content, String partContent,
MimeMessage msg) throws MessagingException, IOException {
/* /*
* set receiverCc * set receiverCc
*/ */
@ -329,7 +333,8 @@ public final class MailSender {
MimeBodyPart part2 = new MimeBodyPart(); MimeBodyPart part2 = new MimeBodyPart();
// add random uuid to filename to avoid potential issue // add random uuid to filename to avoid potential issue
String randomFilename = title + UUID.randomUUID(); String randomFilename = title + UUID.randomUUID();
File file = new File(xlsFilePath + EmailConstants.SINGLE_SLASH + randomFilename + EmailConstants.EXCEL_SUFFIX_XLSX); File file =
new File(xlsFilePath + EmailConstants.SINGLE_SLASH + randomFilename + EmailConstants.EXCEL_SUFFIX_XLSX);
if (!file.getParentFile().exists()) { if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
@ -352,7 +357,8 @@ public final class MailSender {
/** /**
* the string object map * the string object map
*/ */
private AlertResult getStringObjectMap(String title, String content, AlertResult alertResult, HtmlEmail email) throws EmailException { private AlertResult getStringObjectMap(String title, String content, AlertResult alertResult,
HtmlEmail email) throws EmailException {
/* /*
* the subject of the message to be sent * the subject of the message to be sent

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/exception/AlertEmailException.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.email.exception; package org.apache.dolphinscheduler.plugin.alert.email.exception;
public class AlertEmailException extends RuntimeException { public class AlertEmailException extends RuntimeException {
public AlertEmailException(String errMsg) { public AlertEmailException(String errMsg) {
super(errMsg); super(errMsg);
} }

10
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/template/DefaultHTMLTemplate.java

@ -33,15 +33,14 @@ import java.util.Set;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.configurationprocessor.json.JSONArray;
import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.boot.configurationprocessor.json.JSONTokener;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import org.springframework.boot.configurationprocessor.json.JSONArray;
import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.boot.configurationprocessor.json.JSONTokener;
public class DefaultHTMLTemplate implements AlertTemplate { public class DefaultHTMLTemplate implements AlertTemplate {
public static final Logger logger = LoggerFactory.getLogger(DefaultHTMLTemplate.class); public static final Logger logger = LoggerFactory.getLogger(DefaultHTMLTemplate.class);
@ -55,7 +54,8 @@ public class DefaultHTMLTemplate implements AlertTemplate {
case TEXT: case TEXT:
return getTextTypeMessage(content); return getTextTypeMessage(content);
default: default:
throw new IllegalArgumentException(String.format("not support showType: %s in DefaultHTMLTemplate", showType)); throw new IllegalArgumentException(
String.format("not support showType: %s in DefaultHTMLTemplate", showType));
} }
} }

7
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/pom.xml

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-feishu</artifactId> <artifactId>dolphinscheduler-alert-feishu</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannel.java

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map; import java.util.Map;
public final class FeiShuAlertChannel implements AlertChannel { public final class FeiShuAlertChannel implements AlertChannel {
@Override @Override
public AlertResult process(AlertInfo alertInfo) { public AlertResult process(AlertInfo alertInfo) {
AlertData alertData = alertInfo.getAlertData(); AlertData alertData = alertInfo.getAlertData();

14
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannelFactory.java

@ -38,6 +38,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class) @AutoService(AlertChannelFactory.class)
public final class FeiShuAlertChannelFactory implements AlertChannelFactory { public final class FeiShuAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String name() { public String name() {
return "Feishu"; return "Feishu";
@ -45,13 +46,16 @@ public final class FeiShuAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public List<PluginParams> params() { public List<PluginParams> params() {
InputParam webHookParam = InputParam.newBuilder(FeiShuParamsConstants.NAME_WEB_HOOK, FeiShuParamsConstants.WEB_HOOK) InputParam webHookParam =
InputParam.newBuilder(FeiShuParamsConstants.NAME_WEB_HOOK, FeiShuParamsConstants.WEB_HOOK)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.build(); .build();
RadioParam isEnableProxy = RadioParam isEnableProxy =
RadioParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PROXY_ENABLE, FeiShuParamsConstants.FEI_SHU_PROXY_ENABLE) RadioParam
.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PROXY_ENABLE,
FeiShuParamsConstants.FEI_SHU_PROXY_ENABLE)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false)) .addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false)) .addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.setValue(STRING_TRUE) .setValue(STRING_TRUE)
@ -65,7 +69,8 @@ public final class FeiShuAlertChannelFactory implements AlertChannelFactory {
.setRequired(false).build()) .setRequired(false).build())
.build(); .build();
InputParam portParam = InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PORT, FeiShuParamsConstants.FEI_SHU_PORT) InputParam portParam =
InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PORT, FeiShuParamsConstants.FEI_SHU_PORT)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false).build()) .setRequired(false).build())
.build(); .build();
@ -75,7 +80,8 @@ public final class FeiShuAlertChannelFactory implements AlertChannelFactory {
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false).build()) .setRequired(false).build())
.build(); .build();
PasswordParam passwordParam = PasswordParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PASSWORD, FeiShuParamsConstants.FEI_SHU_PASSWORD) PasswordParam passwordParam = PasswordParam
.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PASSWORD, FeiShuParamsConstants.FEI_SHU_PASSWORD)
.setPlaceholder("if enable use authentication, you need input password") .setPlaceholder("if enable use authentication, you need input password")
.build(); .build();

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuParamsConstants.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.feishu; package org.apache.dolphinscheduler.plugin.alert.feishu;
public final class FeiShuParamsConstants { public final class FeiShuParamsConstants {
public static final String FEI_SHU_PROXY_ENABLE = "$t('isEnableProxy')"; public static final String FEI_SHU_PROXY_ENABLE = "$t('isEnableProxy')";
static final String WEB_HOOK = "$t('webhook')"; static final String WEB_HOOK = "$t('webhook')";
static final String NAME_WEB_HOOK = "WebHook"; static final String NAME_WEB_HOOK = "WebHook";

14
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSender.java

@ -41,6 +41,7 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
public final class FeiShuSender { public final class FeiShuSender {
private static final Logger logger = LoggerFactory.getLogger(FeiShuSender.class); private static final Logger logger = LoggerFactory.getLogger(FeiShuSender.class);
private final String url; private final String url;
private final Boolean enableProxy; private final Boolean enableProxy;
@ -98,7 +99,8 @@ public final class FeiShuSender {
return alertResult; return alertResult;
} }
alertResult.setMessage(String.format("alert send fei shu msg error : %s", sendMsgResponse.getStatusMessage())); alertResult.setMessage(String.format("alert send fei shu msg error : %s", sendMsgResponse.getStatusMessage()));
logger.info("alert send fei shu msg error : {} ,Extra : {} ", sendMsgResponse.getStatusMessage(), sendMsgResponse.getExtra()); logger.info("alert send fei shu msg error : {} ,Extra : {} ", sendMsgResponse.getStatusMessage(),
sendMsgResponse.getExtra());
return alertResult; return alertResult;
} }
@ -164,7 +166,8 @@ public final class FeiShuSender {
} finally { } finally {
response.close(); response.close();
} }
logger.info("Fei Shu send title :{} ,content :{}, resp: {}", alertData.getTitle(), alertData.getContent(), resp); logger.info("Fei Shu send title :{} ,content :{}, resp: {}", alertData.getTitle(), alertData.getContent(),
resp);
return resp; return resp;
} finally { } finally {
httpClient.close(); httpClient.close();
@ -172,6 +175,7 @@ public final class FeiShuSender {
} }
static final class FeiShuSendMsgResponse { static final class FeiShuSendMsgResponse {
@JsonProperty("Extra") @JsonProperty("Extra")
private String extra; private String extra;
@JsonProperty("StatusCode") @JsonProperty("StatusCode")
@ -229,7 +233,8 @@ public final class FeiShuSender {
} }
final Object this$statusMessage = this.getStatusMessage(); final Object this$statusMessage = this.getStatusMessage();
final Object other$statusMessage = other.getStatusMessage(); final Object other$statusMessage = other.getStatusMessage();
if (this$statusMessage == null ? other$statusMessage != null : !this$statusMessage.equals(other$statusMessage)) { if (this$statusMessage == null ? other$statusMessage != null
: !this$statusMessage.equals(other$statusMessage)) {
return false; return false;
} }
return true; return true;
@ -248,7 +253,8 @@ public final class FeiShuSender {
} }
public String toString() { public String toString() {
return "FeiShuSender.FeiShuSendMsgResponse(extra=" + this.getExtra() + ", statusCode=" + this.getStatusCode() + ", statusMessage=" + this.getStatusMessage() + ")"; return "FeiShuSender.FeiShuSendMsgResponse(extra=" + this.getExtra() + ", statusCode="
+ this.getStatusCode() + ", statusMessage=" + this.getStatusMessage() + ")";
} }
} }
} }

4
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/HttpRequestUtil.java

@ -29,11 +29,13 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
public final class HttpRequestUtil { public final class HttpRequestUtil {
private HttpRequestUtil() { private HttpRequestUtil() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
} }
public static CloseableHttpClient getHttpClient(boolean enableProxy, String proxy, Integer port, String user, String password) { public static CloseableHttpClient getHttpClient(boolean enableProxy, String proxy, Integer port, String user,
String password) {
if (enableProxy) { if (enableProxy) {
HttpHost httpProxy = new HttpHost(proxy, port); HttpHost httpProxy = new HttpHost(proxy, port);
CredentialsProvider provider = new BasicCredentialsProvider(); CredentialsProvider provider = new BasicCredentialsProvider();

7
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/pom.xml

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-http</artifactId> <artifactId>dolphinscheduler-alert-http</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannel.java

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map; import java.util.Map;
public final class HttpAlertChannel implements AlertChannel { public final class HttpAlertChannel implements AlertChannel {
@Override @Override
public AlertResult process(AlertInfo alertInfo) { public AlertResult process(AlertInfo alertInfo) {
AlertData alertData = alertInfo.getAlertData(); AlertData alertData = alertInfo.getAlertData();

13
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelFactory.java

@ -30,6 +30,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class) @AutoService(AlertChannelFactory.class)
public final class HttpAlertChannelFactory implements AlertChannelFactory { public final class HttpAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String name() { public String name() {
return "Http"; return "Http";
@ -45,28 +46,32 @@ public final class HttpAlertChannelFactory implements AlertChannelFactory {
.build()) .build())
.build(); .build();
InputParam headerParams = InputParam.newBuilder(HttpAlertConstants.NAME_HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS) InputParam headerParams =
InputParam.newBuilder(HttpAlertConstants.NAME_HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS)
.setPlaceholder("input request headers as JSON format ") .setPlaceholder("input request headers as JSON format ")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.build(); .build();
InputParam bodyParams = InputParam.newBuilder(HttpAlertConstants.NAME_BODY_PARAMS, HttpAlertConstants.BODY_PARAMS) InputParam bodyParams =
InputParam.newBuilder(HttpAlertConstants.NAME_BODY_PARAMS, HttpAlertConstants.BODY_PARAMS)
.setPlaceholder("input request body as JSON format ") .setPlaceholder("input request body as JSON format ")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
.build(); .build();
InputParam contentField = InputParam.newBuilder(HttpAlertConstants.NAME_CONTENT_FIELD, HttpAlertConstants.CONTENT_FIELD) InputParam contentField =
InputParam.newBuilder(HttpAlertConstants.NAME_CONTENT_FIELD, HttpAlertConstants.CONTENT_FIELD)
.setPlaceholder("input alert msg field name") .setPlaceholder("input alert msg field name")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.build(); .build();
InputParam requestType = InputParam.newBuilder(HttpAlertConstants.NAME_REQUEST_TYPE, HttpAlertConstants.REQUEST_TYPE) InputParam requestType =
InputParam.newBuilder(HttpAlertConstants.NAME_REQUEST_TYPE, HttpAlertConstants.REQUEST_TYPE)
.setPlaceholder("input request type POST or GET") .setPlaceholder("input request type POST or GET")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertConstants.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.http; package org.apache.dolphinscheduler.plugin.alert.http;
public final class HttpAlertConstants { public final class HttpAlertConstants {
public static final String URL = "$t('url')"; public static final String URL = "$t('url')";
public static final String NAME_URL = "url"; public static final String NAME_URL = "url";

7
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/pom.xml

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-pagerduty</artifactId> <artifactId>dolphinscheduler-alert-pagerduty</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/src/main/java/org/apache/dolphinscheduler/plugin/alert/pagerduty/PagerDutyAlertChannel.java

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map; import java.util.Map;
public final class PagerDutyAlertChannel implements AlertChannel { public final class PagerDutyAlertChannel implements AlertChannel {
@Override @Override
public AlertResult process(AlertInfo alertInfo) { public AlertResult process(AlertInfo alertInfo) {
AlertData alertData = alertInfo.getAlertData(); AlertData alertData = alertInfo.getAlertData();

9
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/src/main/java/org/apache/dolphinscheduler/plugin/alert/pagerduty/PagerDutyAlertChannelFactory.java

@ -17,17 +17,20 @@
package org.apache.dolphinscheduler.plugin.alert.pagerduty; package org.apache.dolphinscheduler.plugin.alert.pagerduty;
import com.google.auto.service.AutoService;
import org.apache.dolphinscheduler.alert.api.AlertChannel; import org.apache.dolphinscheduler.alert.api.AlertChannel;
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory; import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.params.base.Validate; import org.apache.dolphinscheduler.spi.params.base.Validate;
import org.apache.dolphinscheduler.spi.params.input.InputParam; import org.apache.dolphinscheduler.spi.params.input.InputParam;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class) @AutoService(AlertChannelFactory.class)
public final class PagerDutyAlertChannelFactory implements AlertChannelFactory { public final class PagerDutyAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String name() { public String name() {
return "PagerDuty"; return "PagerDuty";
@ -35,7 +38,9 @@ public final class PagerDutyAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public List<PluginParams> params() { public List<PluginParams> params() {
InputParam integrationKey = InputParam.newBuilder(PagerDutyParamsConstants.NAME_PAGER_DUTY_INTEGRATION_KEY_NAME, PagerDutyParamsConstants.PAGER_DUTY_INTEGRATION_KEY) InputParam integrationKey = InputParam
.newBuilder(PagerDutyParamsConstants.NAME_PAGER_DUTY_INTEGRATION_KEY_NAME,
PagerDutyParamsConstants.PAGER_DUTY_INTEGRATION_KEY)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/src/main/java/org/apache/dolphinscheduler/plugin/alert/pagerduty/PagerDutyParamsConstants.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.pagerduty; package org.apache.dolphinscheduler.plugin.alert.pagerduty;
public final class PagerDutyParamsConstants { public final class PagerDutyParamsConstants {
public static final String NAME_PAGER_DUTY_INTEGRATION_KEY_NAME = "IntegrationKey"; public static final String NAME_PAGER_DUTY_INTEGRATION_KEY_NAME = "IntegrationKey";
public static final String PAGER_DUTY_INTEGRATION_KEY = "integrationKey"; public static final String PAGER_DUTY_INTEGRATION_KEY = "integrationKey";
public static final String PAGER_DUTY_EVENT_ACTION_TRIGGER = "trigger"; public static final String PAGER_DUTY_EVENT_ACTION_TRIGGER = "trigger";

20
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/src/main/java/org/apache/dolphinscheduler/plugin/alert/pagerduty/PagerDutySender.java

@ -17,21 +17,29 @@
package org.apache.dolphinscheduler.plugin.alert.pagerduty; package org.apache.dolphinscheduler.plugin.alert.pagerduty;
import com.google.common.base.Preconditions;
import org.apache.dolphinscheduler.alert.api.AlertResult; import org.apache.dolphinscheduler.alert.api.AlertResult;
import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.slf4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.slf4j.Logger;
import com.google.common.base.Preconditions;
public final class PagerDutySender { public final class PagerDutySender {
private static final Logger log = org.slf4j.LoggerFactory.getLogger(PagerDutySender.class); private static final Logger log = org.slf4j.LoggerFactory.getLogger(PagerDutySender.class);
private final String integrationKey; private final String integrationKey;
@ -41,7 +49,7 @@ public final class PagerDutySender {
Preconditions.checkArgument(!Objects.isNull(integrationKey), "PagerDuty integration key can not be null"); Preconditions.checkArgument(!Objects.isNull(integrationKey), "PagerDuty integration key can not be null");
} }
public AlertResult sendPagerDutyAlter(String title, String content){ public AlertResult sendPagerDutyAlter(String title, String content) {
AlertResult alertResult = new AlertResult(); AlertResult alertResult = new AlertResult();
alertResult.setStatus("false"); alertResult.setStatus("false");
alertResult.setMessage("send pager duty alert fail."); alertResult.setMessage("send pager duty alert fail.");
@ -72,10 +80,10 @@ public final class PagerDutySender {
if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_ACCEPTED) { if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_ACCEPTED) {
alertResult.setStatus("true"); alertResult.setStatus("true");
alertResult.setMessage("send pager duty alert success"); alertResult.setMessage("send pager duty alert success");
}else { } else {
log.info("send pager duty alert fail, statusCode : {}", statusCode); log.info("send pager duty alert fail, statusCode : {}", statusCode);
} }
}finally { } finally {
response.close(); response.close();
} }
} catch (IOException e) { } catch (IOException e) {

7
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/pom.xml

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-script</artifactId> <artifactId>dolphinscheduler-alert-script</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
</project> </project>

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/OSUtils.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.script; package org.apache.dolphinscheduler.plugin.alert.script;
public final class OSUtils { public final class OSUtils {
private OSUtils() { private OSUtils() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
} }

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ProcessUtils.java

@ -23,6 +23,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public final class ProcessUtils { public final class ProcessUtils {
private static final Logger logger = LoggerFactory.getLogger(ProcessUtils.class); private static final Logger logger = LoggerFactory.getLogger(ProcessUtils.class);
private ProcessUtils() { private ProcessUtils() {

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannel.java

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map; import java.util.Map;
public final class ScriptAlertChannel implements AlertChannel { public final class ScriptAlertChannel implements AlertChannel {
@Override @Override
public AlertResult process(AlertInfo alertinfo) { public AlertResult process(AlertInfo alertinfo) {
AlertData alertData = alertinfo.getAlertData(); AlertData alertData = alertinfo.getAlertData();

13
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannelFactory.java

@ -32,6 +32,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class) @AutoService(AlertChannelFactory.class)
public final class ScriptAlertChannelFactory implements AlertChannelFactory { public final class ScriptAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String name() { public String name() {
return "Script"; return "Script";
@ -40,14 +41,17 @@ public final class ScriptAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public List<PluginParams> params() { public List<PluginParams> params() {
InputParam scriptUserParam = InputParam.newBuilder(ScriptParamsConstants.NAME_SCRIPT_USER_PARAMS, ScriptParamsConstants.SCRIPT_USER_PARAMS) InputParam scriptUserParam = InputParam
.newBuilder(ScriptParamsConstants.NAME_SCRIPT_USER_PARAMS, ScriptParamsConstants.SCRIPT_USER_PARAMS)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
.setPlaceholder("please enter your custom parameters, which will be passed to you when calling your script") .setPlaceholder(
"please enter your custom parameters, which will be passed to you when calling your script")
.build(); .build();
// need check file type and file exist // need check file type and file exist
InputParam scriptPathParam = InputParam.newBuilder(ScriptParamsConstants.NAME_SCRIPT_PATH, ScriptParamsConstants.SCRIPT_PATH) InputParam scriptPathParam =
InputParam.newBuilder(ScriptParamsConstants.NAME_SCRIPT_PATH, ScriptParamsConstants.SCRIPT_PATH)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
@ -55,7 +59,8 @@ public final class ScriptAlertChannelFactory implements AlertChannelFactory {
+ " and ensure that the path is absolute and has the corresponding access rights") + " and ensure that the path is absolute and has the corresponding access rights")
.build(); .build();
RadioParam scriptTypeParams = RadioParam.newBuilder(ScriptParamsConstants.NAME_SCRIPT_TYPE, ScriptParamsConstants.SCRIPT_TYPE) RadioParam scriptTypeParams = RadioParam
.newBuilder(ScriptParamsConstants.NAME_SCRIPT_TYPE, ScriptParamsConstants.SCRIPT_TYPE)
.addParamsOptions(new ParamsOptions(ScriptType.SHELL.getDescp(), ScriptType.SHELL.getDescp(), false)) .addParamsOptions(new ParamsOptions(ScriptType.SHELL.getDescp(), ScriptType.SHELL.getDescp(), false))
.setValue(ScriptType.SHELL.getDescp()) .setValue(ScriptType.SHELL.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptParamsConstants.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.script; package org.apache.dolphinscheduler.plugin.alert.script;
public final class ScriptParamsConstants { public final class ScriptParamsConstants {
static final String SCRIPT_TYPE = "$t('scriptType')"; static final String SCRIPT_TYPE = "$t('scriptType')";
static final String NAME_SCRIPT_TYPE = "type"; static final String NAME_SCRIPT_TYPE = "type";

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptType.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.script; package org.apache.dolphinscheduler.plugin.alert.script;
public enum ScriptType { public enum ScriptType {
SHELL(0, "SHELL"), SHELL(0, "SHELL"),
; ;

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/StreamGobbler.java

@ -26,6 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public final class StreamGobbler extends Thread { public final class StreamGobbler extends Thread {
private static final Logger logger = LoggerFactory.getLogger(StreamGobbler.class); private static final Logger logger = LoggerFactory.getLogger(StreamGobbler.class);
private final InputStream inputStream; private final InputStream inputStream;

7
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/pom.xml

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-slack</artifactId> <artifactId>dolphinscheduler-alert-slack</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackAlertChannel.java

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map; import java.util.Map;
public final class SlackAlertChannel implements AlertChannel { public final class SlackAlertChannel implements AlertChannel {
@Override @Override
public AlertResult process(AlertInfo alertInfo) { public AlertResult process(AlertInfo alertInfo) {
AlertData alertData = alertInfo.getAlertData(); AlertData alertData = alertInfo.getAlertData();

4
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackAlertChannelFactory.java

@ -30,6 +30,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class) @AutoService(AlertChannelFactory.class)
public final class SlackAlertChannelFactory implements AlertChannelFactory { public final class SlackAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String name() { public String name() {
return "Slack"; return "Slack";
@ -39,7 +40,8 @@ public final class SlackAlertChannelFactory implements AlertChannelFactory {
public List<PluginParams> params() { public List<PluginParams> params() {
List<PluginParams> paramsList = new LinkedList<>(); List<PluginParams> paramsList = new LinkedList<>();
InputParam webHookParam = InputParam.newBuilder(SlackParamsConstants.SLACK_WEB_HOOK_URL_NAME, SlackParamsConstants.SLACK_WEB_HOOK_URL) InputParam webHookParam = InputParam
.newBuilder(SlackParamsConstants.SLACK_WEB_HOOK_URL_NAME, SlackParamsConstants.SLACK_WEB_HOOK_URL)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackParamsConstants.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.slack; package org.apache.dolphinscheduler.plugin.alert.slack;
public final class SlackParamsConstants { public final class SlackParamsConstants {
public static final String SLACK_WEB_HOOK_URL = "$t('webhook')"; public static final String SLACK_WEB_HOOK_URL = "$t('webhook')";
public static final String SLACK_WEB_HOOK_URL_NAME = "webHook"; public static final String SLACK_WEB_HOOK_URL_NAME = "webHook";
public static final String SLACK_BOT = "$t('Username')"; public static final String SLACK_BOT = "$t('Username')";

4
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackSender.java

@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
public final class SlackSender { public final class SlackSender {
private static final Logger logger = LoggerFactory.getLogger(SlackSender.class); private static final Logger logger = LoggerFactory.getLogger(SlackSender.class);
private final String webHookUrl; private final String webHookUrl;
@ -53,7 +54,8 @@ public final class SlackSender {
webHookUrl = slackAlertParam.get(SlackParamsConstants.SLACK_WEB_HOOK_URL_NAME); webHookUrl = slackAlertParam.get(SlackParamsConstants.SLACK_WEB_HOOK_URL_NAME);
botName = slackAlertParam.get(SlackParamsConstants.SLACK_BOT_NAME); botName = slackAlertParam.get(SlackParamsConstants.SLACK_BOT_NAME);
Preconditions.checkArgument(!Objects.isNull(webHookUrl), "SlackWebHookURL can not be null"); Preconditions.checkArgument(!Objects.isNull(webHookUrl), "SlackWebHookURL can not be null");
Preconditions.checkArgument(webHookUrl.startsWith("https://hooks.slack.com/services/"), "SlackWebHookURL invalidate"); Preconditions.checkArgument(webHookUrl.startsWith("https://hooks.slack.com/services/"),
"SlackWebHookURL invalidate");
Preconditions.checkArgument(!Objects.isNull(botName), "slack bot name can not be null"); Preconditions.checkArgument(!Objects.isNull(botName), "slack bot name can not be null");
} }

7
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/pom.xml

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-telegram</artifactId> <artifactId>dolphinscheduler-alert-telegram</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramAlertChannel.java

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map; import java.util.Map;
public final class TelegramAlertChannel implements AlertChannel { public final class TelegramAlertChannel implements AlertChannel {
@Override @Override
public AlertResult process(AlertInfo info) { public AlertResult process(AlertInfo info) {
Map<String, String> alertParams = info.getAlertParams(); Map<String, String> alertParams = info.getAlertParams();

54
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramAlertChannelFactory.java

@ -17,7 +17,11 @@
package org.apache.dolphinscheduler.plugin.alert.telegram; package org.apache.dolphinscheduler.plugin.alert.telegram;
import com.google.auto.service.AutoService; import static org.apache.dolphinscheduler.spi.utils.Constants.STRING_FALSE;
import static org.apache.dolphinscheduler.spi.utils.Constants.STRING_NO;
import static org.apache.dolphinscheduler.spi.utils.Constants.STRING_TRUE;
import static org.apache.dolphinscheduler.spi.utils.Constants.STRING_YES;
import org.apache.dolphinscheduler.alert.api.AlertChannel; import org.apache.dolphinscheduler.alert.api.AlertChannel;
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory; import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
import org.apache.dolphinscheduler.spi.params.PasswordParam; import org.apache.dolphinscheduler.spi.params.PasswordParam;
@ -31,7 +35,7 @@ import org.apache.dolphinscheduler.spi.params.select.SelectParam;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import static org.apache.dolphinscheduler.spi.utils.Constants.*; import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class) @AutoService(AlertChannelFactory.class)
public final class TelegramAlertChannelFactory implements AlertChannelFactory { public final class TelegramAlertChannelFactory implements AlertChannelFactory {
@ -49,40 +53,50 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public List<PluginParams> params() { public List<PluginParams> params() {
InputParam webHookParam = InputParam
InputParam webHookParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_WEB_HOOK, TelegramParamsConstants.TELEGRAM_WEB_HOOK) .newBuilder(TelegramParamsConstants.NAME_TELEGRAM_WEB_HOOK, TelegramParamsConstants.TELEGRAM_WEB_HOOK)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.setPlaceholder("telegram web hook") .setPlaceholder("telegram web hook")
.build(); .build();
InputParam botTokenParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_BOT_TOKEN, TelegramParamsConstants.TELEGRAM_BOT_TOKEN) InputParam botTokenParam = InputParam
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_BOT_TOKEN, TelegramParamsConstants.TELEGRAM_BOT_TOKEN)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.setPlaceholder("telegram bot token") .setPlaceholder("telegram bot token")
.build(); .build();
InputParam chatIdParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_CHAT_ID, TelegramParamsConstants.TELEGRAM_CHAT_ID) InputParam chatIdParam = InputParam
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_CHAT_ID, TelegramParamsConstants.TELEGRAM_CHAT_ID)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.setPlaceholder("telegram channel chat id") .setPlaceholder("telegram channel chat id")
.build(); .build();
SelectParam parseMode = SelectParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PARSE_MODE, TelegramParamsConstants.TELEGRAM_PARSE_MODE) SelectParam parseMode = SelectParam
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_TXT, TelegramAlertConstants.PARSE_MODE_TXT, false)) .newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PARSE_MODE,
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_MARKDOWN, TelegramAlertConstants.PARSE_MODE_MARKDOWN, false)) TelegramParamsConstants.TELEGRAM_PARSE_MODE)
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_MARKDOWN_V2, TelegramAlertConstants.PARSE_MODE_MARKDOWN_V2, false)) .addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_TXT,
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_HTML, TelegramAlertConstants.PARSE_MODE_HTML, false)) TelegramAlertConstants.PARSE_MODE_TXT, false))
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_MARKDOWN,
TelegramAlertConstants.PARSE_MODE_MARKDOWN, false))
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_MARKDOWN_V2,
TelegramAlertConstants.PARSE_MODE_MARKDOWN_V2, false))
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_HTML,
TelegramAlertConstants.PARSE_MODE_HTML, false))
.setValue(TelegramAlertConstants.PARSE_MODE_TXT) .setValue(TelegramAlertConstants.PARSE_MODE_TXT)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.build(); .build();
RadioParam isEnableProxy = RadioParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PROXY_ENABLE, TelegramParamsConstants.TELEGRAM_PROXY_ENABLE) RadioParam isEnableProxy = RadioParam
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PROXY_ENABLE,
TelegramParamsConstants.TELEGRAM_PROXY_ENABLE)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false)) .addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false)) .addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.setValue(STRING_FALSE) .setValue(STRING_FALSE)
@ -91,33 +105,37 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory {
.build()) .build())
.build(); .build();
InputParam proxyParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PROXY, TelegramParamsConstants.TELEGRAM_PROXY) InputParam proxyParam = InputParam
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PROXY, TelegramParamsConstants.TELEGRAM_PROXY)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
.build(); .build();
InputParam portParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PORT, TelegramParamsConstants.TELEGRAM_PORT) InputParam portParam =
InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PORT, TelegramParamsConstants.TELEGRAM_PORT)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
.build(); .build();
InputParam userParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_USER, TelegramParamsConstants.TELEGRAM_USER) InputParam userParam =
InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_USER, TelegramParamsConstants.TELEGRAM_USER)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
.build(); .build();
PasswordParam passwordParam = PasswordParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PASSWORD, TelegramParamsConstants.TELEGRAM_PASSWORD) PasswordParam passwordParam = PasswordParam
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PASSWORD, TelegramParamsConstants.TELEGRAM_PASSWORD)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
.setPlaceholder("if enable use authentication, you need input password") .setPlaceholder("if enable use authentication, you need input password")
.build(); .build();
return Arrays.asList(webHookParam, botTokenParam, chatIdParam, parseMode, isEnableProxy, proxyParam, portParam, userParam, passwordParam); return Arrays.asList(webHookParam, botTokenParam, chatIdParam, parseMode, isEnableProxy, proxyParam, portParam,
userParam, passwordParam);
} }
} }

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramParamsConstants.java

@ -17,7 +17,6 @@
package org.apache.dolphinscheduler.plugin.alert.telegram; package org.apache.dolphinscheduler.plugin.alert.telegram;
public final class TelegramParamsConstants { public final class TelegramParamsConstants {
static final String TELEGRAM_WEB_HOOK = "$t('webHook')"; static final String TELEGRAM_WEB_HOOK = "$t('webHook')";

14
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramSender.java

@ -17,11 +17,11 @@
package org.apache.dolphinscheduler.plugin.alert.telegram; package org.apache.dolphinscheduler.plugin.alert.telegram;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.dolphinscheduler.alert.api.AlertData; import org.apache.dolphinscheduler.alert.api.AlertData;
import org.apache.dolphinscheduler.alert.api.AlertResult; import org.apache.dolphinscheduler.alert.api.AlertResult;
import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import org.apache.dolphinscheduler.spi.utils.StringUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders; import org.apache.http.HttpHeaders;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
@ -37,14 +37,17 @@ import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonProperty;
public final class TelegramSender { public final class TelegramSender {
private static final Logger logger = LoggerFactory.getLogger(TelegramSender.class); private static final Logger logger = LoggerFactory.getLogger(TelegramSender.class);
@ -69,7 +72,6 @@ public final class TelegramSender {
private String password; private String password;
TelegramSender(Map<String, String> config) { TelegramSender(Map<String, String> config) {
url = config.get(TelegramParamsConstants.NAME_TELEGRAM_WEB_HOOK); url = config.get(TelegramParamsConstants.NAME_TELEGRAM_WEB_HOOK);
botToken = config.get(TelegramParamsConstants.NAME_TELEGRAM_BOT_TOKEN); botToken = config.get(TelegramParamsConstants.NAME_TELEGRAM_BOT_TOKEN);
@ -132,14 +134,13 @@ public final class TelegramSender {
return result; return result;
} }
private String sendInvoke(String title, String content) throws IOException { private String sendInvoke(String title, String content) throws IOException {
HttpPost httpPost = buildHttpPost(url, buildMsgJsonStr(content)); HttpPost httpPost = buildHttpPost(url, buildMsgJsonStr(content));
CloseableHttpClient httpClient; CloseableHttpClient httpClient;
if (Boolean.TRUE.equals(enableProxy)) { if (Boolean.TRUE.equals(enableProxy)) {
if (StringUtils.isNotEmpty(user) && StringUtils.isNotEmpty(password)) { if (StringUtils.isNotEmpty(user) && StringUtils.isNotEmpty(password)) {
httpClient = getProxyClient(proxy, port, user, password); httpClient = getProxyClient(proxy, port, user, password);
}else { } else {
httpClient = getDefaultClient(); httpClient = getDefaultClient();
} }
RequestConfig rcf = getProxyConfig(proxy, port); RequestConfig rcf = getProxyConfig(proxy, port);
@ -180,6 +181,7 @@ public final class TelegramSender {
} }
static class TelegramSendMsgResponse { static class TelegramSendMsgResponse {
@JsonProperty("ok") @JsonProperty("ok")
private Boolean ok; private Boolean ok;
@JsonProperty("error_code") @JsonProperty("error_code")

7
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/pom.xml

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-webexteams</artifactId> <artifactId>dolphinscheduler-alert-webexteams</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexMessage.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.webexteams; package org.apache.dolphinscheduler.plugin.alert.webexteams;
public class WebexMessage { public class WebexMessage {
private String roomId; private String roomId;
private String toPersonId; private String toPersonId;
private String toPersonEmail; private String toPersonEmail;

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsAlertChannel.java

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map; import java.util.Map;
public final class WebexTeamsAlertChannel implements AlertChannel { public final class WebexTeamsAlertChannel implements AlertChannel {
@Override @Override
public AlertResult process(AlertInfo alertInfo) { public AlertResult process(AlertInfo alertInfo) {
AlertData alertData = alertInfo.getAlertData(); AlertData alertData = alertInfo.getAlertData();

34
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsAlertChannelFactory.java

@ -32,6 +32,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class) @AutoService(AlertChannelFactory.class)
public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory { public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String name() { public String name() {
return "WebexTeams"; return "WebexTeams";
@ -40,45 +41,60 @@ public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory
@Override @Override
public List<PluginParams> params() { public List<PluginParams> params() {
List<PluginParams> paramsList = new ArrayList<>(); List<PluginParams> paramsList = new ArrayList<>();
InputParam botAccessToken = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_BOT_ACCESS_TOKEN, WebexTeamsParamsConstants.WEBEX_TEAMS_BOT_ACCESS_TOKEN) InputParam botAccessToken = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_BOT_ACCESS_TOKEN,
WebexTeamsParamsConstants.WEBEX_TEAMS_BOT_ACCESS_TOKEN)
.setPlaceholder("Please enter the robot's access token you were given") .setPlaceholder("Please enter the robot's access token you were given")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.build(); .build();
InputParam roomId = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_ROOM_ID, WebexTeamsParamsConstants.WEBEX_TEAMS_ROOM_ID) InputParam roomId = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_ROOM_ID,
WebexTeamsParamsConstants.WEBEX_TEAMS_ROOM_ID)
.setPlaceholder("The room ID of the message") .setPlaceholder("The room ID of the message")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
.build(); .build();
InputParam toPersonId = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_ID, WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_ID) InputParam toPersonId = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_ID,
WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_ID)
.setPlaceholder("The person ID of the message recipient") .setPlaceholder("The person ID of the message recipient")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
.build(); .build();
InputParam toPersonEmail = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_EMAIL, WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_EMAIL) InputParam toPersonEmail = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_EMAIL,
WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_EMAIL)
.setPlaceholder("The email address of the message recipient") .setPlaceholder("The email address of the message recipient")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
.build(); .build();
InputParam atSomeoneInRoom = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_AT_SOMEONE_IN_ROOM, WebexTeamsParamsConstants.WEBEX_TEAMS_AT_SOMEONE_IN_ROOM) InputParam atSomeoneInRoom = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_AT_SOMEONE_IN_ROOM,
WebexTeamsParamsConstants.WEBEX_TEAMS_AT_SOMEONE_IN_ROOM)
.setPlaceholder("use ,(eng commas) to separate multiple emails") .setPlaceholder("use ,(eng commas) to separate multiple emails")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
.build(); .build();
RadioParam destination = RadioParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_DESTINATION, WebexTeamsParamsConstants.WEBEX_TEAMS_DESTINATION) RadioParam destination = RadioParam
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.ROOM_ID.getDescp(), WebexTeamsDestination.ROOM_ID.getDescp(), false)) .newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_DESTINATION,
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.PERSON_EMAIL.getDescp(), WebexTeamsDestination.PERSON_EMAIL.getDescp(), false)) WebexTeamsParamsConstants.WEBEX_TEAMS_DESTINATION)
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.PERSON_ID.getDescp(), WebexTeamsDestination.PERSON_ID.getDescp(), false)) .addParamsOptions(new ParamsOptions(WebexTeamsDestination.ROOM_ID.getDescp(),
WebexTeamsDestination.ROOM_ID.getDescp(), false))
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.PERSON_EMAIL.getDescp(),
WebexTeamsDestination.PERSON_EMAIL.getDescp(), false))
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.PERSON_ID.getDescp(),
WebexTeamsDestination.PERSON_ID.getDescp(), false))
.setValue(WebexTeamsDestination.ROOM_ID.getDescp()) .setValue(WebexTeamsDestination.ROOM_ID.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.build(); .build();

4
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsDestination.java

@ -25,6 +25,7 @@ import java.util.Map;
import com.google.common.base.Functions; import com.google.common.base.Functions;
public enum WebexTeamsDestination { public enum WebexTeamsDestination {
/** /**
* 0 ROOM_ID; * 0 ROOM_ID;
* 1 PERSON_EMAIL; * 1 PERSON_EMAIL;
@ -51,7 +52,8 @@ public enum WebexTeamsDestination {
} }
private static final Map<String, WebexTeamsDestination> WEBEX_TEAMS_DESTINATION_MAP = private static final Map<String, WebexTeamsDestination> WEBEX_TEAMS_DESTINATION_MAP =
Arrays.stream(WebexTeamsDestination.values()).collect(toMap(WebexTeamsDestination::getDescp, Functions.identity())); Arrays.stream(WebexTeamsDestination.values())
.collect(toMap(WebexTeamsDestination::getDescp, Functions.identity()));
public static WebexTeamsDestination of(String descp) { public static WebexTeamsDestination of(String descp) {
if (WEBEX_TEAMS_DESTINATION_MAP.containsKey(descp)) { if (WEBEX_TEAMS_DESTINATION_MAP.containsKey(descp)) {

7
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsSender.java

@ -39,6 +39,7 @@ import org.slf4j.Logger;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
public final class WebexTeamsSender { public final class WebexTeamsSender {
private static final Logger log = org.slf4j.LoggerFactory.getLogger(WebexTeamsSender.class); private static final Logger log = org.slf4j.LoggerFactory.getLogger(WebexTeamsSender.class);
private final String botAccessToken; private final String botAccessToken;
@ -57,7 +58,9 @@ public final class WebexTeamsSender {
destination = WebexTeamsDestination.of(config.get(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_DESTINATION)); destination = WebexTeamsDestination.of(config.get(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_DESTINATION));
Preconditions.checkArgument(!Objects.isNull(botAccessToken), "WebexTeams bot access token can not be null"); Preconditions.checkArgument(!Objects.isNull(botAccessToken), "WebexTeams bot access token can not be null");
Preconditions.checkArgument(!Objects.isNull(destination), "WebexTeams message destination can not be null"); Preconditions.checkArgument(!Objects.isNull(destination), "WebexTeams message destination can not be null");
Preconditions.checkArgument((!Objects.isNull(roomId) || !Objects.isNull(toPersonId) || !Objects.isNull(toPersonEmail)),"WebexTeams message destination could not be determined. Provide only one destination in the roomId, toPersonEmail, or toPersonId field"); Preconditions.checkArgument(
(!Objects.isNull(roomId) || !Objects.isNull(toPersonId) || !Objects.isNull(toPersonEmail)),
"WebexTeams message destination could not be determined. Provide only one destination in the roomId, toPersonEmail, or toPersonId field");
} }
public AlertResult sendWebexTeamsAlter(AlertData alertData) { public AlertResult sendWebexTeamsAlter(AlertData alertData) {
@ -137,7 +140,7 @@ public final class WebexTeamsSender {
public static String addAtPersonEmailInRoom(String formatContent, String atPersonEmailInRoom) { public static String addAtPersonEmailInRoom(String formatContent, String atPersonEmailInRoom) {
String[] emailArr = atPersonEmailInRoom.split(","); String[] emailArr = atPersonEmailInRoom.split(",");
StringBuilder formatContentBuilder = new StringBuilder(formatContent); StringBuilder formatContentBuilder = new StringBuilder(formatContent);
for (String email: emailArr) { for (String email : emailArr) {
formatContentBuilder.append(" <@personEmail:").append(email).append(">"); formatContentBuilder.append(" <@personEmail:").append(email).append(">");
} }

7
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/pom.xml

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-wechat</artifactId> <artifactId>dolphinscheduler-alert-wechat</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannel.java

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map; import java.util.Map;
public final class WeChatAlertChannel implements AlertChannel { public final class WeChatAlertChannel implements AlertChannel {
@Override @Override
public AlertResult process(AlertInfo info) { public AlertResult process(AlertInfo info) {
AlertData alertData = info.getAlertData(); AlertData alertData = info.getAlertData();

24
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannelFactory.java

@ -34,6 +34,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class) @AutoService(AlertChannelFactory.class)
public final class WeChatAlertChannelFactory implements AlertChannelFactory { public final class WeChatAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String name() { public String name() {
return "WeChat"; return "WeChat";
@ -41,37 +42,48 @@ public final class WeChatAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public List<PluginParams> params() { public List<PluginParams> params() {
InputParam corpIdParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_CORP_ID, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_CORP_ID) InputParam corpIdParam = InputParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_CORP_ID,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_CORP_ID)
.setPlaceholder("please input corp id ") .setPlaceholder("please input corp id ")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.build(); .build();
InputParam secretParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SECRET) InputParam secretParam = InputParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SECRET)
.setPlaceholder("please input secret ") .setPlaceholder("please input secret ")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.build(); .build();
InputParam usersParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USERS, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_USERS) InputParam usersParam = InputParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USERS,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_USERS)
.setPlaceholder("use `|` to separate userIds and `@all` to everyone ") .setPlaceholder("use `|` to separate userIds and `@all` to everyone ")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(false) .setRequired(false)
.build()) .build())
.build(); .build();
InputParam agentIdParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_AGENT_ID, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_AGENT_ID) InputParam agentIdParam = InputParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_AGENT_ID,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_AGENT_ID)
.setPlaceholder("please input agent id or chat id ") .setPlaceholder("please input agent id or chat id ")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.build()) .build())
.build(); .build();
RadioParam sendType = RadioParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SEND_TYPE, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SEND_TYPE) RadioParam sendType = RadioParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SEND_TYPE,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SEND_TYPE)
.addParamsOptions(new ParamsOptions(WeChatType.APP.getDescp(), WeChatType.APP.getDescp(), false)) .addParamsOptions(new ParamsOptions(WeChatType.APP.getDescp(), WeChatType.APP.getDescp(), false))
.addParamsOptions(new ParamsOptions(WeChatType.APPCHAT.getDescp(), WeChatType.APPCHAT.getDescp(), false)) .addParamsOptions(
new ParamsOptions(WeChatType.APPCHAT.getDescp(), WeChatType.APPCHAT.getDescp(), false))
.setValue(WeChatType.APP.getDescp()) .setValue(WeChatType.APP.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.build(); .build();

4
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertConstants.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.wechat; package org.apache.dolphinscheduler.plugin.alert.wechat;
public final class WeChatAlertConstants { public final class WeChatAlertConstants {
static final String MARKDOWN_QUOTE = ">"; static final String MARKDOWN_QUOTE = ">";
static final String MARKDOWN_ENTER = "\n"; static final String MARKDOWN_ENTER = "\n";
@ -29,7 +30,8 @@ public final class WeChatAlertConstants {
static final String WE_CHAT_APP_CHAT_PUSH_URL = "https://qyapi.weixin.qq.com/cgi-bin/appchat/send?access_token" + static final String WE_CHAT_APP_CHAT_PUSH_URL = "https://qyapi.weixin.qq.com/cgi-bin/appchat/send?access_token" +
"={token}"; "={token}";
static final String WE_CHAT_TOKEN_URL = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpId}&corpsecret={secret}"; static final String WE_CHAT_TOKEN_URL =
"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpId}&corpsecret={secret}";
static final String WE_CHAT_CONTENT_KEY = "content"; static final String WE_CHAT_CONTENT_KEY = "content";

1
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertParamsConstants.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.wechat; package org.apache.dolphinscheduler.plugin.alert.wechat;
public final class WeChatAlertParamsConstants { public final class WeChatAlertParamsConstants {
static final String ENTERPRISE_WE_CHAT_CORP_ID = "$t('corpId')"; static final String ENTERPRISE_WE_CHAT_CORP_ID = "$t('corpId')";
static final String NAME_ENTERPRISE_WE_CHAT_CORP_ID = "corpId"; 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 = "$t('secret')";

28
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatSender.java

@ -17,10 +17,16 @@
package org.apache.dolphinscheduler.plugin.alert.wechat; package org.apache.dolphinscheduler.plugin.alert.wechat;
import static java.util.Objects.requireNonNull;
import static org.apache.dolphinscheduler.plugin.alert.wechat.WeChatAlertConstants.WE_CHAT_DUPLICATE_CHECK_INTERVAL_ZERO;
import static org.apache.dolphinscheduler.plugin.alert.wechat.WeChatAlertConstants.WE_CHAT_ENABLE_ID_TRANS;
import static org.apache.dolphinscheduler.plugin.alert.wechat.WeChatAlertConstants.WE_CHAT_MESSAGE_SAFE_PUBLICITY;
import org.apache.dolphinscheduler.alert.api.AlertConstants; import org.apache.dolphinscheduler.alert.api.AlertConstants;
import org.apache.dolphinscheduler.alert.api.AlertResult; import org.apache.dolphinscheduler.alert.api.AlertResult;
import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import org.apache.dolphinscheduler.spi.utils.StringUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
@ -29,8 +35,6 @@ import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -40,11 +44,11 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.slf4j.Logger;
import static java.util.Objects.requireNonNull; import org.slf4j.LoggerFactory;
import static org.apache.dolphinscheduler.plugin.alert.wechat.WeChatAlertConstants.*;
public final class WeChatSender { public final class WeChatSender {
private static final Logger logger = LoggerFactory.getLogger(WeChatSender.class); private static final Logger logger = LoggerFactory.getLogger(WeChatSender.class);
private static final String MUST_NOT_NULL = " must not null"; private static final String MUST_NOT_NULL = " must not null";
private static final String ALERT_STATUS = "false"; private static final String ALERT_STATUS = "false";
@ -210,11 +214,15 @@ public final class WeChatSender {
String msgJson = ""; String msgJson = "";
if (sendType.equals(WeChatType.APP.getDescp())) { if (sendType.equals(WeChatType.APP.getDescp())) {
enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken); enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken);
WechatAppMessage wechatAppMessage = new WechatAppMessage(weChatUsers, showType, Integer.valueOf(weChatAgentIdChatId), contentMap, WE_CHAT_MESSAGE_SAFE_PUBLICITY, WE_CHAT_ENABLE_ID_TRANS, WE_CHAT_DUPLICATE_CHECK_INTERVAL_ZERO); WechatAppMessage wechatAppMessage = new WechatAppMessage(weChatUsers, showType,
Integer.valueOf(weChatAgentIdChatId), contentMap, WE_CHAT_MESSAGE_SAFE_PUBLICITY,
WE_CHAT_ENABLE_ID_TRANS, WE_CHAT_DUPLICATE_CHECK_INTERVAL_ZERO);
msgJson = JSONUtils.toJsonString(wechatAppMessage); msgJson = JSONUtils.toJsonString(wechatAppMessage);
} else if (sendType.equals(WeChatType.APPCHAT.getDescp())) { } else if (sendType.equals(WeChatType.APPCHAT.getDescp())) {
enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_APP_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken); enterpriseWeChatPushUrlReplace =
WechatAppChatMessage wechatAppChatMessage = new WechatAppChatMessage(weChatAgentIdChatId, showType, contentMap, WE_CHAT_MESSAGE_SAFE_PUBLICITY); WeChatAlertConstants.WE_CHAT_APP_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken);
WechatAppChatMessage wechatAppChatMessage =
new WechatAppChatMessage(weChatAgentIdChatId, showType, contentMap, WE_CHAT_MESSAGE_SAFE_PUBLICITY);
msgJson = JSONUtils.toJsonString(wechatAppChatMessage); msgJson = JSONUtils.toJsonString(wechatAppChatMessage);
} }
@ -248,6 +256,7 @@ public final class WeChatSender {
} }
static final class WeChatSendMsgResponse { static final class WeChatSendMsgResponse {
private Integer errcode; private Integer errcode;
private String errmsg; private String errmsg;
@ -302,7 +311,8 @@ public final class WeChatSender {
} }
public String toString() { public String toString() {
return "WeChatSender.WeChatSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg=" + this.getErrmsg() + ")"; return "WeChatSender.WeChatSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg=" + this.getErrmsg()
+ ")";
} }
} }
} }

2
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatType.java

@ -15,10 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.plugin.alert.wechat; package org.apache.dolphinscheduler.plugin.alert.wechat;
public enum WeChatType { public enum WeChatType {
APP(1, "APP/应用"), APP(1, "APP/应用"),
APPCHAT(2, "GROUP CHAT/群聊"), APPCHAT(2, "GROUP CHAT/群聊"),
; ;

4
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WechatAppChatMessage.java

@ -25,8 +25,8 @@ public class WechatAppChatMessage {
private String chatid; private String chatid;
private String msgtype; private String msgtype;
private Map<String,String> text; private Map<String, String> text;
private Map<String,String> markdown; private Map<String, String> markdown;
private Integer safe; private Integer safe;
public String getChatid() { public String getChatid() {

3
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WechatAppMessage.java

@ -99,7 +99,8 @@ public class WechatAppMessage {
public WechatAppMessage() { public WechatAppMessage() {
} }
public WechatAppMessage(String touser, String msgtype, Integer agentid, Map<String, String> contentMap, Integer safe, Integer enableIdTrans, Integer enableDuplicateCheck) { public WechatAppMessage(String touser, String msgtype, Integer agentid, Map<String, String> contentMap,
Integer safe, Integer enableIdTrans, Integer enableDuplicateCheck) {
this.touser = touser; this.touser = touser;
this.msgtype = msgtype; this.msgtype = msgtype;
this.agentid = agentid; this.agentid = agentid;

7
dolphinscheduler-alert/dolphinscheduler-alert-plugins/pom.xml

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler-alert</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-plugins</artifactId> <artifactId>dolphinscheduler-alert-plugins</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>

24
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertPluginManager.java

@ -30,11 +30,6 @@ import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.params.base.Validate; import org.apache.dolphinscheduler.spi.params.base.Validate;
import org.apache.dolphinscheduler.spi.params.radio.RadioParam; import org.apache.dolphinscheduler.spi.params.radio.RadioParam;
import org.apache.dolphinscheduler.spi.plugin.PrioritySPIFactory; import org.apache.dolphinscheduler.spi.plugin.PrioritySPIFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -42,10 +37,15 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import static java.lang.String.format; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
@Component @Component
public final class AlertPluginManager { public final class AlertPluginManager {
private static final Logger logger = LoggerFactory.getLogger(AlertPluginManager.class); private static final Logger logger = LoggerFactory.getLogger(AlertPluginManager.class);
private final PluginDao pluginDao; private final PluginDao pluginDao;
@ -59,10 +59,11 @@ public final class AlertPluginManager {
private final PluginParams warningTypeParams = getWarningTypeParams(); private final PluginParams warningTypeParams = getWarningTypeParams();
public PluginParams getWarningTypeParams() { public PluginParams getWarningTypeParams() {
return return RadioParam.newBuilder(AlertConstants.NAME_WARNING_TYPE, AlertConstants.WARNING_TYPE)
RadioParam.newBuilder(AlertConstants.NAME_WARNING_TYPE, AlertConstants.WARNING_TYPE) .addParamsOptions(
.addParamsOptions(new ParamsOptions(WarningType.SUCCESS.getDescp(), WarningType.SUCCESS.getDescp(), false)) new ParamsOptions(WarningType.SUCCESS.getDescp(), WarningType.SUCCESS.getDescp(), false))
.addParamsOptions(new ParamsOptions(WarningType.FAILURE.getDescp(), WarningType.FAILURE.getDescp(), false)) .addParamsOptions(
new ParamsOptions(WarningType.FAILURE.getDescp(), WarningType.FAILURE.getDescp(), false))
.addParamsOptions(new ParamsOptions(WarningType.ALL.getDescp(), WarningType.ALL.getDescp(), false)) .addParamsOptions(new ParamsOptions(WarningType.ALL.getDescp(), WarningType.ALL.getDescp(), false))
.setValue(WarningType.ALL.getDescp()) .setValue(WarningType.ALL.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
@ -72,7 +73,8 @@ public final class AlertPluginManager {
@EventListener @EventListener
public void installPlugin(ApplicationReadyEvent readyEvent) { public void installPlugin(ApplicationReadyEvent readyEvent) {
PrioritySPIFactory<AlertChannelFactory> prioritySPIFactory = new PrioritySPIFactory<>(AlertChannelFactory.class); PrioritySPIFactory<AlertChannelFactory> prioritySPIFactory =
new PrioritySPIFactory<>(AlertChannelFactory.class);
for (Map.Entry<String, AlertChannelFactory> entry : prioritySPIFactory.getSPIMap().entrySet()) { for (Map.Entry<String, AlertChannelFactory> entry : prioritySPIFactory.getSPIMap().entrySet()) {
String name = entry.getKey(); String name = entry.getKey();
AlertChannelFactory factory = entry.getValue(); AlertChannelFactory factory = entry.getValue();

4
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertRequestProcessor.java

@ -34,6 +34,7 @@ import io.netty.channel.Channel;
@Component @Component
public final class AlertRequestProcessor implements NettyRequestProcessor { public final class AlertRequestProcessor implements NettyRequestProcessor {
private static final Logger logger = LoggerFactory.getLogger(AlertRequestProcessor.class); private static final Logger logger = LoggerFactory.getLogger(AlertRequestProcessor.class);
private final AlertSenderService alertSenderService; private final AlertSenderService alertSenderService;
@ -44,7 +45,8 @@ public final class AlertRequestProcessor implements NettyRequestProcessor {
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Command command) {
checkArgument(CommandType.ALERT_SEND_REQUEST == command.getType(), "invalid command type: %s", command.getType()); checkArgument(CommandType.ALERT_SEND_REQUEST == command.getType(), "invalid command type: %s",
command.getType());
AlertSendRequestCommand alertSendRequestCommand = JsonSerializer.deserialize( AlertSendRequestCommand alertSendRequestCommand = JsonSerializer.deserialize(
command.getBody(), AlertSendRequestCommand.class); command.getBody(), AlertSendRequestCommand.class);

2
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServerMetrics.java

@ -19,10 +19,10 @@ package org.apache.dolphinscheduler.alert;
import java.util.function.Supplier; import java.util.function.Supplier;
import lombok.experimental.UtilityClass;
import io.micrometer.core.instrument.Counter; import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.Metrics; import io.micrometer.core.instrument.Metrics;
import lombok.experimental.UtilityClass;
@UtilityClass @UtilityClass
public class AlertServerMetrics { public class AlertServerMetrics {

10
dolphinscheduler-alert/pom.xml

@ -17,18 +17,16 @@
~ specific language governing permissions and limitations ~ specific language governing permissions and limitations
~ under the License. ~ under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dolphinscheduler</artifactId>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<artifactId>dolphinscheduler-alert</artifactId> <artifactId>dolphinscheduler-alert</artifactId>
<packaging>pom</packaging>
<modules> <modules>
<module>dolphinscheduler-alert-api</module> <module>dolphinscheduler-alert-api</module>

1
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java

@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.common.enums.PluginType;
import org.apache.dolphinscheduler.dao.PluginDao; import org.apache.dolphinscheduler.dao.PluginDao;
import org.apache.dolphinscheduler.dao.entity.PluginDefine; import org.apache.dolphinscheduler.dao.entity.PluginDefine;
import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory;
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginException;
import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.dolphinscheduler.service.task.TaskPluginManager;
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.PluginParams;

1
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/aspect/AccessLogAnnotation.java

@ -27,6 +27,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
public @interface AccessLogAnnotation { public @interface AccessLogAnnotation {
// ignore request args // ignore request args
String[] ignoreRequestArgs() default {"loginUser"}; String[] ignoreRequestArgs() default {"loginUser"};

14
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/aspect/AccessLogAspect.java

@ -47,6 +47,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
@Aspect @Aspect
@Component @Component
public class AccessLogAspect { public class AccessLogAspect {
private static final Logger logger = LoggerFactory.getLogger(AccessLogAspect.class); private static final Logger logger = LoggerFactory.getLogger(AccessLogAspect.class);
private static final String TRACE_ID = "traceId"; private static final String TRACE_ID = "traceId";
@ -56,7 +57,7 @@ public class AccessLogAspect {
private static final Pattern sensitiveDataPattern = Pattern.compile(sensitiveDataRegEx, Pattern.CASE_INSENSITIVE); private static final Pattern sensitiveDataPattern = Pattern.compile(sensitiveDataRegEx, Pattern.CASE_INSENSITIVE);
@Pointcut("@annotation(org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation)") @Pointcut("@annotation(org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation)")
public void logPointCut(){ public void logPointCut() {
// Do nothing because of it's a pointcut // Do nothing because of it's a pointcut
} }
@ -73,7 +74,8 @@ public class AccessLogAspect {
// log request // log request
if (!annotation.ignoreRequest()) { if (!annotation.ignoreRequest()) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); ServletRequestAttributes attributes =
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (attributes != null) { if (attributes != null) {
HttpServletRequest request = attributes.getRequest(); HttpServletRequest request = attributes.getRequest();
String traceIdFromHeader = request.getHeader(TRACE_ID); String traceIdFromHeader = request.getHeader(TRACE_ID);
@ -92,7 +94,8 @@ public class AccessLogAspect {
userName, userName,
request.getRequestURI(), request.getRequestURI(),
request.getMethod(), request.getMethod(),
proceedingJoinPoint.getSignature().getDeclaringTypeName() + "." + proceedingJoinPoint.getSignature().getName(), proceedingJoinPoint.getSignature().getDeclaringTypeName() + "."
+ proceedingJoinPoint.getSignature().getName(),
argsString); argsString);
} }
@ -102,7 +105,8 @@ public class AccessLogAspect {
// log response // log response
if (!annotation.ignoreResponse()) { if (!annotation.ignoreResponse()) {
logger.info("RESPONSE TRACE_ID:{}, BODY:{}, REQUEST DURATION:{} milliseconds", traceId, ob, (System.currentTimeMillis() - startTime)); logger.info("RESPONSE TRACE_ID:{}, BODY:{}, REQUEST DURATION:{} milliseconds", traceId, ob,
(System.currentTimeMillis() - startTime));
} }
return ob; return ob;
@ -134,7 +138,7 @@ public class AccessLogAspect {
boolean exists = false; boolean exists = false;
while (matcher.find()) { while (matcher.find()) {
if (matcher.groupCount() == 3) { if (matcher.groupCount() == 3) {
stream = IntStream.concat(stream, IntStream.range(matcher.end(1),matcher.end(2))); stream = IntStream.concat(stream, IntStream.range(matcher.end(1), matcher.end(2)));
exists = true; exists = true;
} }
} }

4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/audit/AuditMessage.java

@ -24,6 +24,7 @@ import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Date; import java.util.Date;
public class AuditMessage { public class AuditMessage {
private User user; private User user;
private Date auditDate; private Date auditDate;
@ -34,7 +35,8 @@ public class AuditMessage {
private Integer resourceId; private Integer resourceId;
public AuditMessage(User user, Date auditDate, AuditResourceType resourceType, AuditOperationType operation, Integer resourceId) { public AuditMessage(User user, Date auditDate, AuditResourceType resourceType, AuditOperationType operation,
Integer resourceId) {
this.user = user; this.user = user;
this.auditDate = auditDate; this.auditDate = auditDate;
this.resourceType = resourceType; this.resourceType = resourceType;

1
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/AuditConfiguration.java

@ -25,6 +25,7 @@ import org.springframework.stereotype.Component;
@EnableConfigurationProperties @EnableConfigurationProperties
@ConfigurationProperties(value = "audit", ignoreUnknownFields = false) @ConfigurationProperties(value = "audit", ignoreUnknownFields = false)
public class AuditConfiguration { public class AuditConfiguration {
private boolean enabled; private boolean enabled;
public boolean getEnabled() { public boolean getEnabled() {

16
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/OpenAPITranslationConfiguration.java

@ -18,20 +18,24 @@ package org.apache.dolphinscheduler.api.configuration;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet; import static java.util.stream.Collectors.toSet;
import springfox.documentation.service.Operation;
import springfox.documentation.service.RequestParameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.OperationBuilderPlugin;
import springfox.documentation.spi.service.contexts.OperationContext;
import java.util.Collection; import java.util.Collection;
import java.util.Locale; import java.util.Locale;
import java.util.Set; import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import lombok.RequiredArgsConstructor;
import springfox.documentation.service.Operation;
import springfox.documentation.service.RequestParameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.OperationBuilderPlugin;
import springfox.documentation.spi.service.contexts.OperationContext;
@Component @Component
public class OpenAPITranslationConfiguration { public class OpenAPITranslationConfiguration {

1
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/PythonGatewayConfiguration.java

@ -25,6 +25,7 @@ import org.springframework.stereotype.Component;
@EnableConfigurationProperties @EnableConfigurationProperties
@ConfigurationProperties(value = "python-gateway", ignoreUnknownFields = false) @ConfigurationProperties(value = "python-gateway", ignoreUnknownFields = false)
public class PythonGatewayConfiguration { public class PythonGatewayConfiguration {
private boolean enabled; private boolean enabled;
private String gatewayServerAddress; private String gatewayServerAddress;
private int gatewayServerPort; private int gatewayServerPort;

12
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/TaskTypeConfiguration.java

@ -24,6 +24,9 @@ import org.apache.dolphinscheduler.common.config.YamlPropertySourceFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
@ -31,9 +34,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import lombok.Getter;
import lombok.Setter;
@Component @Component
@EnableConfigurationProperties @EnableConfigurationProperties
@PropertySource(value = {"classpath:task-type-config.yaml"}, factory = YamlPropertySourceFactory.class) @PropertySource(value = {"classpath:task-type-config.yaml"}, factory = YamlPropertySourceFactory.class)
@ -62,9 +62,11 @@ public class TaskTypeConfiguration {
universal.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_UNIVERSAL))); universal.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_UNIVERSAL)));
cloud.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_CLOUD))); cloud.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_CLOUD)));
logic.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_LOGIC))); logic.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_LOGIC)));
dataIntegration.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_DATA_INTEGRATION))); dataIntegration
.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_DATA_INTEGRATION)));
dataQuality.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_DATA_QUALITY))); dataQuality.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_DATA_QUALITY)));
machineLearning.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_MACHINE_LEARNING))); machineLearning
.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_MACHINE_LEARNING)));
other.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_OTHER))); other.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_OTHER)));
return defaultTaskTypes; return defaultTaskTypes;
} }

4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/TrafficConfiguration.java

@ -17,11 +17,11 @@
package org.apache.dolphinscheduler.api.configuration; package org.apache.dolphinscheduler.api.configuration;
import lombok.Data;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;

21
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/constants/ApiFuncIdentificationConstant.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.api.constants; package org.apache.dolphinscheduler.api.constants;
import org.apache.dolphinscheduler.api.enums.ExecuteType; import org.apache.dolphinscheduler.api.enums.ExecuteType;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -156,28 +157,28 @@ public class ApiFuncIdentificationConstant {
public static final String MONITOR_STATISTICS_VIEW = "monitor:statistics:view"; public static final String MONITOR_STATISTICS_VIEW = "monitor:statistics:view";
public final static Map<ExecuteType,String> map = new HashMap<ExecuteType,String>(); public final static Map<ExecuteType, String> map = new HashMap<ExecuteType, String>();
static{ static {
for(ExecuteType type : ExecuteType.values()){ for (ExecuteType type : ExecuteType.values()) {
switch (type){ switch (type) {
case REPEAT_RUNNING: case REPEAT_RUNNING:
map.put(type,RERUN); map.put(type, RERUN);
break; break;
case RECOVER_SUSPENDED_PROCESS: case RECOVER_SUSPENDED_PROCESS:
map.put(type,RECOVERY_SUSPEND); map.put(type, RECOVERY_SUSPEND);
break; break;
case START_FAILURE_TASK_PROCESS: case START_FAILURE_TASK_PROCESS:
map.put(type,FAILED_TO_RETRY); map.put(type, FAILED_TO_RETRY);
break; break;
case STOP: case STOP:
map.put(type,STOP); map.put(type, STOP);
break; break;
case PAUSE: case PAUSE:
map.put(type,PAUSE); map.put(type, PAUSE);
break; break;
case NONE: case NONE:
map.put(type,null); map.put(type, null);
break; break;
default: default:
} }

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java

@ -29,8 +29,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.AccessTokenService; import org.apache.dolphinscheduler.api.service.AccessTokenService;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertGroupController.java

@ -30,8 +30,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.AlertGroupService; import org.apache.dolphinscheduler.api.service.AlertGroupService;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;

1
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertPluginInstanceController.java

@ -32,6 +32,7 @@ import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.util.Map; import java.util.Map;

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ClusterController.java

@ -29,8 +29,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.ClusterService; import org.apache.dolphinscheduler.api.service.ClusterService;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataQualityController.java

@ -28,8 +28,8 @@ import org.apache.dolphinscheduler.api.service.DqExecuteResultService;
import org.apache.dolphinscheduler.api.service.DqRuleService; import org.apache.dolphinscheduler.api.service.DqRuleService;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java

@ -36,10 +36,10 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.DataSourceService; import org.apache.dolphinscheduler.api.service.DataSourceService;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO; import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO;
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import org.apache.dolphinscheduler.service.utils.CommonUtils; import org.apache.dolphinscheduler.service.utils.CommonUtils;
import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; import org.apache.dolphinscheduler.spi.datasource.ConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.dolphinscheduler.spi.enums.DbType;

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DsErrorController.java

@ -21,6 +21,7 @@ package org.apache.dolphinscheduler.api.controller;
import javax.servlet.RequestDispatcher; import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.boot.web.servlet.error.ErrorController; import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -29,6 +30,7 @@ import org.springframework.web.servlet.ModelAndView;
@Controller @Controller
public class DsErrorController implements ErrorController { public class DsErrorController implements ErrorController {
@RequestMapping("/error") @RequestMapping("/error")
public ModelAndView handleError(HttpServletRequest request) { public ModelAndView handleError(HttpServletRequest request) {
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/EnvironmentController.java

@ -29,8 +29,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.EnvironmentService; import org.apache.dolphinscheduler.api.service.EnvironmentService;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;

26
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ExecutorController.java

@ -121,7 +121,7 @@ public class ExecutorController extends BaseController {
@ApiImplicitParam(name = "workerGroup", value = "WORKER_GROUP", dataType = "String", example = "default"), @ApiImplicitParam(name = "workerGroup", value = "WORKER_GROUP", dataType = "String", example = "default"),
@ApiImplicitParam(name = "environmentCode", value = "ENVIRONMENT_CODE", dataType = "Long", example = "-1"), @ApiImplicitParam(name = "environmentCode", value = "ENVIRONMENT_CODE", dataType = "Long", example = "-1"),
@ApiImplicitParam(name = "timeout", value = "TIMEOUT", dataType = "Int", example = "100"), @ApiImplicitParam(name = "timeout", value = "TIMEOUT", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "expectedParallelismNumber", value = "EXPECTED_PARALLELISM_NUMBER", dataType = "Int" , example = "8"), @ApiImplicitParam(name = "expectedParallelismNumber", value = "EXPECTED_PARALLELISM_NUMBER", dataType = "Int", example = "8"),
@ApiImplicitParam(name = "dryRun", value = "DRY_RUN", dataType = "Int", example = "0"), @ApiImplicitParam(name = "dryRun", value = "DRY_RUN", dataType = "Int", example = "0"),
@ApiImplicitParam(name = "testFlag", value = "TEST_FLAG", dataType = "Int", example = "0"), @ApiImplicitParam(name = "testFlag", value = "TEST_FLAG", dataType = "Int", example = "0"),
@ApiImplicitParam(name = "complementDependentMode", value = "COMPLEMENT_DEPENDENT_MODE", dataType = "complementDependentMode") @ApiImplicitParam(name = "complementDependentMode", value = "COMPLEMENT_DEPENDENT_MODE", dataType = "complementDependentMode")
@ -166,7 +166,8 @@ public class ExecutorController extends BaseController {
Map<String, Object> result = execService.execProcessInstance(loginUser, projectCode, processDefinitionCode, Map<String, Object> result = execService.execProcessInstance(loginUser, projectCode, processDefinitionCode,
scheduleTime, execType, failureStrategy, scheduleTime, execType, failureStrategy,
startNodeList, taskDependType, warningType, warningGroupId, runMode, processInstancePriority, startNodeList, taskDependType, warningType, warningGroupId, runMode, processInstancePriority,
workerGroup, environmentCode, timeout, startParamMap, expectedParallelismNumber, dryRun, testFlag, complementDependentMode); workerGroup, environmentCode, timeout, startParamMap, expectedParallelismNumber, dryRun, testFlag,
complementDependentMode);
return returnDataList(result); return returnDataList(result);
} }
@ -268,10 +269,12 @@ public class ExecutorController extends BaseController {
complementDependentMode); complementDependentMode);
if (!Status.SUCCESS.equals(result.get(Constants.STATUS))) { if (!Status.SUCCESS.equals(result.get(Constants.STATUS))) {
logger.error("Process definition start failed, projectCode:{}, processDefinitionCode:{}.", projectCode, processDefinitionCode); logger.error("Process definition start failed, projectCode:{}, processDefinitionCode:{}.", projectCode,
processDefinitionCode);
startFailedProcessDefinitionCodeList.add(String.valueOf(processDefinitionCode)); startFailedProcessDefinitionCodeList.add(String.valueOf(processDefinitionCode));
} else } else
logger.info("Start process definition complete, projectCode:{}, processDefinitionCode:{}.", projectCode, processDefinitionCode); logger.info("Start process definition complete, projectCode:{}, processDefinitionCode:{}.", projectCode,
processDefinitionCode);
} }
if (!startFailedProcessDefinitionCodeList.isEmpty()) { if (!startFailedProcessDefinitionCodeList.isEmpty()) {
@ -303,9 +306,9 @@ public class ExecutorController extends BaseController {
public Result execute(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result execute(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode, @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam("processInstanceId") Integer processInstanceId, @RequestParam("processInstanceId") Integer processInstanceId,
@RequestParam("executeType") ExecuteType executeType @RequestParam("executeType") ExecuteType executeType) {
) { logger.info("Start to execute process instance, projectCode:{}, processInstanceId:{}.", projectCode,
logger.info("Start to execute process instance, projectCode:{}, processInstanceId:{}.", projectCode, processInstanceId); processInstanceId);
Map<String, Object> result = execService.execute(loginUser, projectCode, processInstanceId, executeType); Map<String, Object> result = execService.execute(loginUser, projectCode, processInstanceId, executeType);
return returnDataList(result); return returnDataList(result);
} }
@ -344,10 +347,12 @@ public class ExecutorController extends BaseController {
Map<String, Object> singleResult = Map<String, Object> singleResult =
execService.execute(loginUser, projectCode, processInstanceId, executeType); execService.execute(loginUser, projectCode, processInstanceId, executeType);
if (!Status.SUCCESS.equals(singleResult.get(Constants.STATUS))) { if (!Status.SUCCESS.equals(singleResult.get(Constants.STATUS))) {
logger.error("Start to execute process instance error, projectCode:{}, processInstanceId:{}.", projectCode, processInstanceId); logger.error("Start to execute process instance error, projectCode:{}, processInstanceId:{}.",
projectCode, processInstanceId);
executeFailedIdList.add((String) singleResult.get(Constants.MSG)); executeFailedIdList.add((String) singleResult.get(Constants.MSG));
} else } else
logger.info("Start to execute process instance complete, projectCode:{}, processInstanceId:{}.", projectCode, processInstanceId); logger.info("Start to execute process instance complete, projectCode:{}, processInstanceId:{}.",
projectCode, processInstanceId);
} catch (Exception e) { } catch (Exception e) {
executeFailedIdList executeFailedIdList
.add(MessageFormat.format(Status.PROCESS_INSTANCE_ERROR.getMsg(), strProcessInstanceId)); .add(MessageFormat.format(Status.PROCESS_INSTANCE_ERROR.getMsg(), strProcessInstanceId));
@ -440,7 +445,8 @@ public class ExecutorController extends BaseController {
startParamMap = JSONUtils.toMap(startParams); startParamMap = JSONUtils.toMap(startParams);
} }
logger.info("Start to execute stream task instance, projectCode:{}, taskDefinitionCode:{}, taskVersion:{}.", projectCode, code, version); logger.info("Start to execute stream task instance, projectCode:{}, taskDefinitionCode:{}, taskVersion:{}.",
projectCode, code, version);
Map<String, Object> result = execService.execStreamTaskInstance(loginUser, projectCode, code, version, Map<String, Object> result = execService.execStreamTaskInstance(loginUser, projectCode, code, version,
warningGroupId, workerGroup, environmentCode, startParamMap, dryRun); warningGroupId, workerGroup, environmentCode, startParamMap, dryRun);
return returnDataList(result); return returnDataList(result);

22
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/FavTaskController.java

@ -17,8 +17,10 @@
package org.apache.dolphinscheduler.api.controller; package org.apache.dolphinscheduler.api.controller;
import io.swagger.annotations.Api; import static org.apache.dolphinscheduler.api.enums.Status.ADD_TASK_TYPE_ERROR;
import io.swagger.annotations.ApiOperation; import static org.apache.dolphinscheduler.api.enums.Status.DELETE_TASK_TYPE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.LIST_TASK_TYPE_ERROR;
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation; import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
import org.apache.dolphinscheduler.api.dto.FavTaskDto; import org.apache.dolphinscheduler.api.dto.FavTaskDto;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
@ -27,6 +29,13 @@ import org.apache.dolphinscheduler.api.service.FavTaskService;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -36,14 +45,9 @@ import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.List;
import static org.apache.dolphinscheduler.api.enums.Status.ADD_TASK_TYPE_ERROR; import io.swagger.annotations.Api;
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_TASK_TYPE_ERROR; import io.swagger.annotations.ApiOperation;
import static org.apache.dolphinscheduler.api.enums.Status.LIST_TASK_TYPE_ERROR;
/** /**
* fav controller * fav controller

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save