diff --git a/.gitignore b/.gitignore index 7cf1d4d7db..6717162b37 100644 --- a/.gitignore +++ b/.gitignore @@ -4,15 +4,9 @@ .zip .gz .DS_Store -.idea -.idea/ -.idea/* .target -.target/ -**/**/target/** -target/* -*/target -*/target/* +.idea/ +target/ .settings .nbproject .classpath @@ -28,123 +22,23 @@ node_modules npm-debug.log .vscode logs/* +.mvn/ .www t.* +.factorypath +Chart.lock yarn.lock package-lock.json config.gypi test/coverage /docs/zh_CN/介绍 /docs/zh_CN/贡献代码.md -/dolphinscheduler-common/src/main/resources/zookeeper.properties +dolphinscheduler-common/src/main/resources/zookeeper.properties +dolphinscheduler-dao/src/main/resources/dao/data_source.properties dolphinscheduler-alert/logs/ dolphinscheduler-alert/src/main/resources/alert.properties_bak dolphinscheduler-alert/src/main/resources/logback.xml dolphinscheduler-server/src/main/resources/logback.xml dolphinscheduler-ui/dist dolphinscheduler-ui/node -dolphinscheduler-ui/dist/css/common.16ac5d9.css -dolphinscheduler-ui/dist/css/home/index.b444b91.css -dolphinscheduler-ui/dist/css/login/index.5866c64.css -dolphinscheduler-ui/dist/js/0.ac94e5d.js -dolphinscheduler-ui/dist/js/0.ac94e5d.js.map -dolphinscheduler-ui/dist/js/1.0b043a3.js -dolphinscheduler-ui/dist/js/1.0b043a3.js.map -dolphinscheduler-ui/dist/js/10.1bce3dc.js -dolphinscheduler-ui/dist/js/10.1bce3dc.js.map -dolphinscheduler-ui/dist/js/11.79f04d8.js -dolphinscheduler-ui/dist/js/11.79f04d8.js.map -dolphinscheduler-ui/dist/js/12.420daa5.js -dolphinscheduler-ui/dist/js/12.420daa5.js.map -dolphinscheduler-ui/dist/js/13.e5bae1c.js -dolphinscheduler-ui/dist/js/13.e5bae1c.js.map -dolphinscheduler-ui/dist/js/14.f2a0dca.js -dolphinscheduler-ui/dist/js/14.f2a0dca.js.map -dolphinscheduler-ui/dist/js/15.45373e8.js -dolphinscheduler-ui/dist/js/15.45373e8.js.map -dolphinscheduler-ui/dist/js/16.fecb0fc.js -dolphinscheduler-ui/dist/js/16.fecb0fc.js.map -dolphinscheduler-ui/dist/js/17.84be279.js -dolphinscheduler-ui/dist/js/17.84be279.js.map -dolphinscheduler-ui/dist/js/18.307ea70.js -dolphinscheduler-ui/dist/js/18.307ea70.js.map -dolphinscheduler-ui/dist/js/19.144db9c.js -dolphinscheduler-ui/dist/js/19.144db9c.js.map -dolphinscheduler-ui/dist/js/2.8b4ef29.js -dolphinscheduler-ui/dist/js/2.8b4ef29.js.map -dolphinscheduler-ui/dist/js/20.4c527e9.js -dolphinscheduler-ui/dist/js/20.4c527e9.js.map -dolphinscheduler-ui/dist/js/21.831b2a2.js -dolphinscheduler-ui/dist/js/21.831b2a2.js.map -dolphinscheduler-ui/dist/js/22.2b4bb2a.js -dolphinscheduler-ui/dist/js/22.2b4bb2a.js.map -dolphinscheduler-ui/dist/js/23.81467ef.js -dolphinscheduler-ui/dist/js/23.81467ef.js.map -dolphinscheduler-ui/dist/js/24.54a00e4.js -dolphinscheduler-ui/dist/js/24.54a00e4.js.map -dolphinscheduler-ui/dist/js/25.8d7bd36.js -dolphinscheduler-ui/dist/js/25.8d7bd36.js.map -dolphinscheduler-ui/dist/js/26.2ec5e78.js -dolphinscheduler-ui/dist/js/26.2ec5e78.js.map -dolphinscheduler-ui/dist/js/27.3ab48c2.js -dolphinscheduler-ui/dist/js/27.3ab48c2.js.map -dolphinscheduler-ui/dist/js/28.363088a.js -dolphinscheduler-ui/dist/js/28.363088a.js.map -dolphinscheduler-ui/dist/js/29.6c5853a.js -dolphinscheduler-ui/dist/js/29.6c5853a.js.map -dolphinscheduler-ui/dist/js/3.a0edb5b.js -dolphinscheduler-ui/dist/js/3.a0edb5b.js.map -dolphinscheduler-ui/dist/js/30.940fdd3.js -dolphinscheduler-ui/dist/js/30.940fdd3.js.map -dolphinscheduler-ui/dist/js/31.168a460.js -dolphinscheduler-ui/dist/js/31.168a460.js.map -dolphinscheduler-ui/dist/js/32.8df6594.js -dolphinscheduler-ui/dist/js/32.8df6594.js.map -dolphinscheduler-ui/dist/js/33.4480bbe.js -dolphinscheduler-ui/dist/js/33.4480bbe.js.map -dolphinscheduler-ui/dist/js/34.b407fe1.js -dolphinscheduler-ui/dist/js/34.b407fe1.js.map -dolphinscheduler-ui/dist/js/35.f340b0a.js -dolphinscheduler-ui/dist/js/35.f340b0a.js.map -dolphinscheduler-ui/dist/js/36.8880c2d.js -dolphinscheduler-ui/dist/js/36.8880c2d.js.map -dolphinscheduler-ui/dist/js/37.ea2a25d.js -dolphinscheduler-ui/dist/js/37.ea2a25d.js.map -dolphinscheduler-ui/dist/js/38.98a59ee.js -dolphinscheduler-ui/dist/js/38.98a59ee.js.map -dolphinscheduler-ui/dist/js/39.a5e958a.js -dolphinscheduler-ui/dist/js/39.a5e958a.js.map -dolphinscheduler-ui/dist/js/4.4ca44db.js -dolphinscheduler-ui/dist/js/4.4ca44db.js.map -dolphinscheduler-ui/dist/js/40.e187b1e.js -dolphinscheduler-ui/dist/js/40.e187b1e.js.map -dolphinscheduler-ui/dist/js/41.0e89182.js -dolphinscheduler-ui/dist/js/41.0e89182.js.map -dolphinscheduler-ui/dist/js/42.341047c.js -dolphinscheduler-ui/dist/js/42.341047c.js.map -dolphinscheduler-ui/dist/js/43.27b8228.js -dolphinscheduler-ui/dist/js/43.27b8228.js.map -dolphinscheduler-ui/dist/js/44.e8869bc.js -dolphinscheduler-ui/dist/js/44.e8869bc.js.map -dolphinscheduler-ui/dist/js/45.8d54901.js -dolphinscheduler-ui/dist/js/45.8d54901.js.map -dolphinscheduler-ui/dist/js/5.e1ed7f3.js -dolphinscheduler-ui/dist/js/5.e1ed7f3.js.map -dolphinscheduler-ui/dist/js/6.241ba07.js -dolphinscheduler-ui/dist/js/6.241ba07.js.map -dolphinscheduler-ui/dist/js/7.ab2e297.js -dolphinscheduler-ui/dist/js/7.ab2e297.js.map -dolphinscheduler-ui/dist/js/8.83ff814.js -dolphinscheduler-ui/dist/js/8.83ff814.js.map -dolphinscheduler-ui/dist/js/9.39cb29f.js -dolphinscheduler-ui/dist/js/9.39cb29f.js.map -dolphinscheduler-ui/dist/js/common.733e342.js -dolphinscheduler-ui/dist/js/common.733e342.js.map -dolphinscheduler-ui/dist/js/home/index.78a5d12.js -dolphinscheduler-ui/dist/js/home/index.78a5d12.js.map -dolphinscheduler-ui/dist/js/login/index.291b8e3.js -dolphinscheduler-ui/dist/js/login/index.291b8e3.js.map -dolphinscheduler-ui/dist/lib/external/ -dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskInstance/index.vue -/dolphinscheduler-dao/src/main/resources/dao/data_source.properties - +docker/build/apache-dolphinscheduler* diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkParamsConstants.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkParamsConstants.java index fb9f5f9f5d..c00d13076e 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkParamsConstants.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkParamsConstants.java @@ -22,7 +22,7 @@ package org.apache.dolphinscheduler.plugin.alert.dingtalk; */ public class DingTalkParamsConstants { - public DingTalkParamsConstants() { + private DingTalkParamsConstants() { throw new IllegalStateException("Utility class"); } diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java index 4500f3e28e..d152bc89cb 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java @@ -113,7 +113,7 @@ public class DingTalkSender { } finally { response.close(); } - logger.info("Ding Talk send [ %s ], resp:{%s}", msg, resp); + logger.info("Ding Talk send {}, resp: {}", msg, resp); return resp; } finally { httpClient.close(); diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailConstants.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailConstants.java index d0e85ffb03..091bf28f24 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailConstants.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailConstants.java @@ -19,6 +19,10 @@ package org.apache.dolphinscheduler.plugin.alert.email; public class EmailConstants { + private EmailConstants() { + throw new IllegalStateException(EmailConstants.class.getName()); + } + public static final String XLS_FILE_PATH = "xls.file.path"; diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java index 1579f9548e..5802394d3b 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java @@ -17,6 +17,7 @@ package org.apache.dolphinscheduler.plugin.alert.email; +import org.apache.dolphinscheduler.plugin.alert.email.exception.AlertEmailException; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.commons.collections4.CollectionUtils; @@ -31,7 +32,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory; */ public class ExcelUtils { - public ExcelUtils() { + private ExcelUtils() { throw new IllegalStateException("Utility class"); } @@ -65,16 +65,14 @@ public class ExcelUtils { if (CollectionUtils.isEmpty(itemsList)) { logger.error("itemsList is null"); - throw new RuntimeException("itemsList is null"); + throw new AlertEmailException("itemsList is null"); } LinkedHashMap headerMap = itemsList.get(0); List headerList = new ArrayList<>(); - Iterator> iter = headerMap.entrySet().iterator(); - while (iter.hasNext()) { - Map.Entry en = iter.next(); + for (Map.Entry en : headerMap.entrySet()) { headerList.add(en.getKey()); } @@ -130,8 +128,7 @@ public class ExcelUtils { wb.write(fos); } catch (Exception e) { - logger.error("generate excel error", e); - throw new RuntimeException("generate excel error", e); + throw new AlertEmailException("generate excel error", e); } finally { if (wb != null) { try { @@ -150,4 +147,4 @@ public class ExcelUtils { } } -} \ No newline at end of file +} diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailParamsConstants.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailParamsConstants.java index 3eaa420301..0bbbe103f0 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailParamsConstants.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailParamsConstants.java @@ -22,7 +22,7 @@ package org.apache.dolphinscheduler.plugin.alert.email; */ public class MailParamsConstants { - public MailParamsConstants() { + private MailParamsConstants() { throw new IllegalStateException("Utility class"); } diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java index 03765b248d..192578f861 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java @@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.plugin.alert.email; import static java.util.Objects.requireNonNull; +import org.apache.dolphinscheduler.plugin.alert.email.exception.AlertEmailException; import org.apache.dolphinscheduler.plugin.alert.email.template.AlertTemplate; import org.apache.dolphinscheduler.plugin.alert.email.template.DefaultHTMLTemplate; import org.apache.dolphinscheduler.spi.alert.AlertConstants; @@ -67,7 +68,7 @@ public class MailSender { private String mailProtocol = "SMTP"; private String mailSmtpHost; private String mailSmtpPort; - private String mailSender; + private String mailSenderEmail; private String enableSmtpAuth; private String mailUser; private String mailPasswd; @@ -77,12 +78,13 @@ public class MailSender { private String sslTrust; private String showType; private AlertTemplate alertTemplate; + private String mustNotNull = "must not be null"; public MailSender(Map config) { String receiversConfig = config.get(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS); if (receiversConfig == null || "".equals(receiversConfig)) { - throw new RuntimeException(MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERS + "must not be null"); + throw new AlertEmailException(MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERS + mustNotNull); } receivers = Arrays.asList(receiversConfig.split(",")); @@ -95,33 +97,33 @@ public class MailSender { } mailSmtpHost = config.get(MailParamsConstants.NAME_MAIL_SMTP_HOST); - requireNonNull(mailSmtpHost, MailParamsConstants.MAIL_SMTP_HOST + " must not null"); + requireNonNull(mailSmtpHost, MailParamsConstants.MAIL_SMTP_HOST + mustNotNull); mailSmtpPort = config.get(MailParamsConstants.NAME_MAIL_SMTP_PORT); - requireNonNull(mailSmtpPort, MailParamsConstants.MAIL_SMTP_PORT + " must not null"); + requireNonNull(mailSmtpPort, MailParamsConstants.MAIL_SMTP_PORT + mustNotNull); - mailSender = config.get(MailParamsConstants.NAME_MAIL_SENDER); - requireNonNull(mailSender, MailParamsConstants.MAIL_SENDER + " must not null"); + mailSenderEmail = config.get(MailParamsConstants.NAME_MAIL_SENDER); + requireNonNull(mailSenderEmail, MailParamsConstants.MAIL_SENDER + mustNotNull); enableSmtpAuth = config.get(MailParamsConstants.NAME_MAIL_SMTP_AUTH); mailUser = config.get(MailParamsConstants.NAME_MAIL_USER); - requireNonNull(mailUser, MailParamsConstants.MAIL_USER + " must not null"); + requireNonNull(mailUser, MailParamsConstants.MAIL_USER + mustNotNull); mailPasswd = config.get(MailParamsConstants.NAME_MAIL_PASSWD); - requireNonNull(mailPasswd, MailParamsConstants.MAIL_PASSWD + " must not null"); + requireNonNull(mailPasswd, MailParamsConstants.MAIL_PASSWD + mustNotNull); mailUseStartTLS = config.get(MailParamsConstants.NAME_MAIL_SMTP_STARTTLS_ENABLE); - requireNonNull(mailUseStartTLS, MailParamsConstants.MAIL_SMTP_STARTTLS_ENABLE + " must not null"); + requireNonNull(mailUseStartTLS, MailParamsConstants.MAIL_SMTP_STARTTLS_ENABLE + mustNotNull); mailUseSSL = config.get(MailParamsConstants.NAME_MAIL_SMTP_SSL_ENABLE); - requireNonNull(mailUseSSL, MailParamsConstants.MAIL_SMTP_SSL_ENABLE + " must not null"); + requireNonNull(mailUseSSL, MailParamsConstants.MAIL_SMTP_SSL_ENABLE + mustNotNull); sslTrust = config.get(MailParamsConstants.NAME_MAIL_SMTP_SSL_TRUST); - requireNonNull(sslTrust, MailParamsConstants.MAIL_SMTP_SSL_TRUST + " must not null"); + requireNonNull(sslTrust, MailParamsConstants.MAIL_SMTP_SSL_TRUST + mustNotNull); showType = config.get(AlertConstants.SHOW_TYPE); - requireNonNull(showType, AlertConstants.SHOW_TYPE + " must not null"); + requireNonNull(showType, AlertConstants.SHOW_TYPE + mustNotNull); xlsFilePath = config.get(EmailConstants.XLS_FILE_PATH); if (StringUtils.isBlank(xlsFilePath)) { @@ -134,9 +136,8 @@ public class MailSender { /** * send mail to receivers * - * @param title title + * @param title title * @param content content - * @return */ public AlertResult sendMails(String title, String content) { return sendMails(this.receivers, this.receiverCcs, title, content); @@ -145,9 +146,8 @@ public class MailSender { /** * send mail to receivers * - * @param title email title + * @param title email title * @param content email content - * @return */ public AlertResult sendMailsToReceiverOnly(String title, String content) { return sendMails(this.receivers, null, title, content); @@ -156,11 +156,10 @@ public class MailSender { /** * send mail * - * @param receivers receivers + * @param receivers receivers * @param receiverCcs receiverCcs - * @param title title - * @param content content - * @return + * @param title title + * @param content content */ public AlertResult sendMails(List receivers, List receiverCcs, String title, String content) { AlertResult alertResult = new AlertResult(); @@ -180,7 +179,7 @@ public class MailSender { try { Session session = getSession(); email.setMailSession(session); - email.setFrom(mailSender); + email.setFrom(mailSenderEmail); email.setCharset(EmailConstants.UTF_8); if (CollectionUtils.isNotEmpty(receivers)) { // receivers mail @@ -251,11 +250,6 @@ public class MailSender { /** * send mail as Excel attachment - * - * @param title - * @param content - * @param partContent - * @throws Exception */ private void attachment(String title, String content, String partContent) throws Exception { MimeMessage msg = getMimeMessage(); @@ -265,9 +259,6 @@ public class MailSender { /** * get MimeMessage - * - * @return - * @throws MessagingException */ private MimeMessage getMimeMessage() throws MessagingException { @@ -279,7 +270,7 @@ public class MailSender { // 2. creating mail: Creating a MimeMessage MimeMessage msg = new MimeMessage(session); // 3. set sender - msg.setFrom(new InternetAddress(mailSender)); + msg.setFrom(new InternetAddress(mailSenderEmail)); // 4. set receivers for (String receiver : receivers) { msg.addRecipients(Message.RecipientType.TO, InternetAddress.parse(receiver)); @@ -317,16 +308,9 @@ public class MailSender { /** * attach content - * - * @param title - * @param content - * @param partContent - * @param msg - * @throws MessagingException - * @throws IOException */ private void attachContent(String title, String content, String partContent, MimeMessage msg) throws MessagingException, IOException { - /** + /* * set receiverCc */ if (CollectionUtils.isNotEmpty(receiverCcs)) { @@ -365,21 +349,14 @@ public class MailSender { /** * the string object map - * - * @param title - * @param content - * @param alertResult - * @param email - * @return - * @throws EmailException */ private AlertResult getStringObjectMap(String title, String content, AlertResult alertResult, HtmlEmail email) throws EmailException { - /** + /* * the subject of the message to be sent */ email.setSubject(title); - /** + /* * to send information, you can use HTML tags in mail content because of the use of HtmlEmail */ if (showType.equals(ShowType.TABLE.getDescp())) { @@ -417,9 +394,6 @@ public class MailSender { /** * handle exception - * - * @param alertResult - * @param e */ private void handleException(AlertResult alertResult, Exception e) { logger.error("Send email to {} failed", receivers, e); diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/exception/AlertEmailException.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/exception/AlertEmailException.java new file mode 100644 index 0000000000..466ccc06de --- /dev/null +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/exception/AlertEmailException.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.alert.email.exception; + +public class AlertEmailException extends RuntimeException { + + /** + * Create Runtime exception + * + * @param errMsg - Error message + */ + public AlertEmailException(String errMsg) { + super(errMsg); + } + + /** + * Create Runtime exception + * + * @param errMsg - Error message + * @param cause - cause + */ + public AlertEmailException(String errMsg, Throwable cause) { + super(errMsg, cause); + } +} diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/template/DefaultHTMLTemplate.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/template/DefaultHTMLTemplate.java index 06decd6ffc..57187aa70c 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/template/DefaultHTMLTemplate.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/template/DefaultHTMLTemplate.java @@ -50,7 +50,7 @@ public class DefaultHTMLTemplate implements AlertTemplate { case TABLE: return getTableTypeMessage(content, showAll); case TEXT: - return getTextTypeMessage(content, showAll); + return getTextTypeMessage(content); default: throw new IllegalArgumentException(String.format("not support showType: %s in DefaultHTMLTemplate", showType)); } @@ -77,7 +77,7 @@ public class DefaultHTMLTemplate implements AlertTemplate { boolean flag = true; String title = ""; - for (LinkedHashMap mapItems : mapItemsList) { + for (LinkedHashMap mapItems : mapItemsList) { Set> entries = mapItems.entrySet(); @@ -111,10 +111,9 @@ public class DefaultHTMLTemplate implements AlertTemplate { * get alert message which type is TEXT * * @param content message content - * @param showAll weather to show all * @return alert message */ - private String getTextTypeMessage(String content, boolean showAll) { + private String getTextTypeMessage(String content) { if (StringUtils.isNotEmpty(content)) { ArrayNode list = JSONUtils.parseArray(content); @@ -135,14 +134,14 @@ public class DefaultHTMLTemplate implements AlertTemplate { /** * get alert message from a html template * - * @param title message title + * @param title message title * @param content message content * @return alert message which use html template */ private String getMessageFromHtmlTemplate(String title, String content) { requireNonNull(content, "content must not null"); - String htmlTableThead = StringUtils.isEmpty(title) ? "" : String.format("%s\n", title); + String htmlTableThead = StringUtils.isEmpty(title) ? "" : String.format("%s%n", title); return EmailConstants.HTML_HEADER_PREFIX + htmlTableThead + content + EmailConstants.TABLE_BODY_HTML_TAIL; } diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/OSUtils.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/OSUtils.java index acf3e310cc..b8816724c7 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/OSUtils.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/OSUtils.java @@ -22,7 +22,7 @@ package org.apache.dolphinscheduler.plugin.alert.script; */ public class OSUtils { - public OSUtils() { + private OSUtils() { throw new UnsupportedOperationException("Construct OSUtils"); } diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptParamsConstants.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptParamsConstants.java index 98e4eee788..5b096d54ad 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptParamsConstants.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptParamsConstants.java @@ -22,7 +22,7 @@ package org.apache.dolphinscheduler.plugin.alert.script; */ public class ScriptParamsConstants { - public ScriptParamsConstants() { + private ScriptParamsConstants() { throw new IllegalStateException("Utility class"); } diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/StreamGobbler.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/StreamGobbler.java index 2ec25280b4..813e91a729 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/StreamGobbler.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/StreamGobbler.java @@ -51,11 +51,11 @@ public class StreamGobbler extends Thread { output.append(System.getProperty("line.separator")); } if (output.length() > 0) { - logger.info("out put msg is{}",output.toString()); + logger.info("out put msg is{}", output); } } catch (IOException e) { logger.error("I/O error occurs {}", e.getMessage()); } } -} \ No newline at end of file +} diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertConstants.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertConstants.java index 904060c3e0..9aec21b9d9 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertConstants.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertConstants.java @@ -22,6 +22,10 @@ package org.apache.dolphinscheduler.plugin.alert.wechat; */ public class WeChatAlertConstants { + private WeChatAlertConstants() { + throw new IllegalStateException(WeChatAlertConstants.class.getName()); + } + static final String MARKDOWN_QUOTE = ">"; static final String MARKDOWN_ENTER = "\n"; diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertParamsConstants.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertParamsConstants.java index 138bd83b3a..c254b27ebf 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertParamsConstants.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertParamsConstants.java @@ -22,6 +22,9 @@ package org.apache.dolphinscheduler.plugin.alert.wechat; */ public class WeChatAlertParamsConstants { + private WeChatAlertParamsConstants() { + throw new IllegalStateException(WeChatAlertParamsConstants.class.getName()); + } static final String ENTERPRISE_WE_CHAT_CORP_ID = "corp.id"; diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatSender.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatSender.java index f4fd090744..6944da66bb 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatSender.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatSender.java @@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.plugin.alert.wechat; import static java.util.Objects.requireNonNull; +import org.apache.dolphinscheduler.plugin.alert.wechat.exception.WeChatAlertException; import org.apache.dolphinscheduler.spi.alert.AlertConstants; import org.apache.dolphinscheduler.spi.alert.AlertResult; import org.apache.dolphinscheduler.spi.alert.ShowType; @@ -59,8 +60,6 @@ public class WeChatSender { private String weChatUsers; - private String weChatTeamSendMsg; - private String weChatUserSendMsg; private String weChatTokenUrlReplace; @@ -70,14 +69,14 @@ public class WeChatSender { private String showType; - private static final String agentIdRegExp = "{agentId}"; - private static final String msgRegExp = "{msg}"; - private static final String userRegExp = "{toUser}"; - private static final String corpIdRegex = "{corpId}"; - private static final String secretRegex = "{secret}"; - private static final String toPartyRegex = "{toParty}"; - private static final String toUserRegex = "{toUser}"; - private static final String tokenRegex = "{token}"; + private static final String MUST_NOT_NULL = " must not null"; + private static final String ALERT_STATUS = "false"; + private static final String AGENT_ID_REG_EXP = "{agentId}"; + private static final String MSG_REG_EXP = "{msg}"; + private static final String USER_REG_EXP = "{toUser}"; + private static final String CORP_ID_REGEX = "{corpId}"; + private static final String SECRET_REGEX = "{secret}"; + private static final String TOKEN_REGEX = "{token}"; WeChatSender(Map config) { weChatAgentId = config.get(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_AGENT_ID); @@ -85,13 +84,12 @@ public class WeChatSender { String weChatCorpId = config.get(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_CORP_ID); String weChatSecret = config.get(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET); String weChatTokenUrl = WeChatAlertConstants.WE_CHAT_TOKEN_URL; - weChatTeamSendMsg = config.get(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_TEAM_SEND_MSG); weChatUserSendMsg = config.get(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USER_SEND_MSG); showType = config.get(AlertConstants.SHOW_TYPE); - requireNonNull(showType, AlertConstants.SHOW_TYPE + " must not null"); + requireNonNull(showType, AlertConstants.SHOW_TYPE + MUST_NOT_NULL); weChatTokenUrlReplace = weChatTokenUrl - .replace(corpIdRegex, weChatCorpId) - .replace(secretRegex, weChatSecret); + .replace(CORP_ID_REGEX, weChatCorpId) + .replace(SECRET_REGEX, weChatSecret); weChatToken = getToken(); } @@ -105,16 +103,15 @@ public class WeChatSender { */ private String makeUserSendMsg(Collection toUser, String agentId, String msg) { String listUser = mkString(toUser); - return weChatUserSendMsg.replace(userRegExp, listUser) - .replace(agentIdRegExp, agentId) - .replace(msgRegExp, msg); + return weChatUserSendMsg.replace(USER_REG_EXP, listUser) + .replace(AGENT_ID_REG_EXP, agentId) + .replace(MSG_REG_EXP, msg); } /** * send Enterprise WeChat * * @return Enterprise WeChat resp, demo: {"errcode":0,"errmsg":"ok","invaliduser":""} - * @throws Exception the Exception */ public AlertResult sendEnterpriseWeChat(String title, String content) { AlertResult alertResult; @@ -124,10 +121,10 @@ public class WeChatSender { if (null == weChatToken) { alertResult = new AlertResult(); alertResult.setMessage("send we chat alert fail,get weChat token error"); - alertResult.setStatus("false"); + alertResult.setStatus(ALERT_STATUS); return alertResult; } - String enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_PUSH_URL.replace(tokenRegex, weChatToken); + String enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken); try { return checkWeChatSendMsgResult(post(enterpriseWeChatPushUrlReplace, msg)); @@ -135,7 +132,7 @@ public class WeChatSender { logger.info("send we chat alert msg exception : {}", e.getMessage()); alertResult = new AlertResult(); alertResult.setMessage("send we chat alert fail"); - alertResult.setStatus("false"); + alertResult.setStatus(ALERT_STATUS); } return alertResult; } @@ -170,7 +167,7 @@ public class WeChatSender { List mapItemsList = JSONUtils.toList(content, LinkedHashMap.class); if (null == mapItemsList || mapItemsList.isEmpty()) { logger.error("itemsList is null"); - throw new RuntimeException("itemsList is null"); + throw new WeChatAlertException("itemsList is null"); } StringBuilder contents = new StringBuilder(200); for (LinkedHashMap mapItems : mapItemsList) { @@ -259,7 +256,7 @@ public class WeChatSender { EntityUtils.consume(entity); } - HashMap map = JSONUtils.parseObject(resp, HashMap.class); + HashMap map = JSONUtils.parseObject(resp, HashMap.class); if (map != null && null != map.get("access_token")) { return map.get("access_token").toString(); } else { @@ -310,7 +307,7 @@ public class WeChatSender { private static AlertResult checkWeChatSendMsgResult(String result) { AlertResult alertResult = new AlertResult(); - alertResult.setStatus("false"); + alertResult.setStatus(ALERT_STATUS); if (null == result) { alertResult.setMessage("we chat send fail"); @@ -328,7 +325,7 @@ public class WeChatSender { alertResult.setMessage("we chat alert send success"); return alertResult; } - alertResult.setStatus("false"); + alertResult.setStatus(ALERT_STATUS); alertResult.setMessage(sendMsgResponse.getErrmsg()); return alertResult; } diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/exception/WeChatAlertException.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/exception/WeChatAlertException.java new file mode 100644 index 0000000000..f36bc2ff8a --- /dev/null +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/exception/WeChatAlertException.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.alert.wechat.exception; + +public class WeChatAlertException extends RuntimeException { + + /** + * Create Runtime Exception + * + * @param errMsg - Error message + */ + public WeChatAlertException(String errMsg) { + super(errMsg); + } +} diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/AppConfiguration.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/AppConfiguration.java index 28a42929ca..badc0a905f 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/AppConfiguration.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/AppConfiguration.java @@ -17,17 +17,20 @@ package org.apache.dolphinscheduler.api.configuration; +import org.apache.dolphinscheduler.api.interceptor.LocaleChangeInterceptor; import org.apache.dolphinscheduler.api.interceptor.LoginHandlerInterceptor; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; import org.springframework.web.servlet.LocaleResolver; import org.springframework.web.servlet.config.annotation.*; import org.springframework.web.servlet.i18n.CookieLocaleResolver; -import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; import java.util.Locale; - /** * application configuration */ @@ -39,7 +42,17 @@ public class AppConfiguration implements WebMvcConfigurer { public static final String REGISTER_PATH_PATTERN = "/users/register"; public static final String PATH_PATTERN = "/**"; public static final String LOCALE_LANGUAGE_COOKIE = "language"; - public static final int COOKIE_MAX_AGE = 3600; + + @Bean + public CorsFilter corsFilter() { + CorsConfiguration config = new CorsConfiguration(); + config.addAllowedOrigin("*"); + config.addAllowedMethod("*"); + config.addAllowedHeader("*"); + UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource(); + configSource.registerCorsConfiguration(PATH_PATTERN, config); + return new CorsFilter(configSource); + } @Bean public LoginHandlerInterceptor loginInterceptor() { @@ -56,16 +69,14 @@ public class AppConfiguration implements WebMvcConfigurer { localeResolver.setCookieName(LOCALE_LANGUAGE_COOKIE); // set default locale localeResolver.setDefaultLocale(Locale.US); - // set cookie max age - localeResolver.setCookieMaxAge(COOKIE_MAX_AGE); + // set language tag compliant + localeResolver.setLanguageTagCompliant(false); return localeResolver; } @Bean public LocaleChangeInterceptor localeChangeInterceptor() { - LocaleChangeInterceptor lci = new LocaleChangeInterceptor(); - lci.setParamName("language"); - return lci; + return new LocaleChangeInterceptor(); } @Override @@ -94,11 +105,6 @@ public class AppConfiguration implements WebMvcConfigurer { registry.addViewController("/").setViewName("forward:/ui/index.html"); } - @Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping(PATH_PATTERN).allowedOrigins("*").allowedMethods("*"); - } - /** * Turn off suffix-based content negotiation * diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java index 458f0bf356..de80740d4e 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java @@ -40,6 +40,7 @@ import org.apache.dolphinscheduler.api.service.ProcessDefinitionService; import org.apache.dolphinscheduler.api.service.ProcessDefinitionVersionService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; +import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.utils.ParameterUtils; import org.apache.dolphinscheduler.common.utils.StringUtils; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; @@ -239,7 +240,7 @@ public class ProcessDefinitionController extends BaseController { @ApiImplicitParam(name = "locations", value = "PROCESS_DEFINITION_LOCATIONS", required = true, type = "String"), @ApiImplicitParam(name = "connects", value = "PROCESS_DEFINITION_CONNECTS", required = true, type = "String"), @ApiImplicitParam(name = "description", value = "PROCESS_DEFINITION_DESC", required = false, type = "String"), - @ApiImplicitParam(name = "releaseState", value = "RELEASE_PROCESS_DEFINITION_NOTES", required = false, dataType = "Int", example = "0") + @ApiImplicitParam(name = "releaseState", value = "RELEASE_PROCESS_DEFINITION_NOTES", required = false, dataType = "ReleaseState") }) @PostMapping(value = "/update") @ResponseStatus(HttpStatus.OK) @@ -252,7 +253,7 @@ public class ProcessDefinitionController extends BaseController { @RequestParam(value = "locations", required = false) String locations, @RequestParam(value = "connects", required = false) String connects, @RequestParam(value = "description", required = false) String description, - @RequestParam(value = "releaseState", required = false, defaultValue = "0") int releaseState) { + @RequestParam(value = "releaseState", required = false, defaultValue = "OFFLINE") ReleaseState releaseState) { logger.info("login user {}, update process define, project name: {}, process define name: {}, " + "process_definition_json: {}, desc: {}, locations:{}, connects:{}", @@ -260,12 +261,12 @@ public class ProcessDefinitionController extends BaseController { Map result = processDefinitionService.updateProcessDefinition(loginUser, projectName, id, name, processDefinitionJson, description, locations, connects); // If the update fails, the result will be returned directly - Status status = (Status) result.get("status"); - if (status.getCode() != 0) { + if (result.get(Constants.STATUS) != Status.SUCCESS) { return returnDataList(result); } + // Judge whether to go online after editing,0 means offline, 1 means online - if (releaseState == 1) { + if (releaseState == ReleaseState.ONLINE) { result = processDefinitionService.releaseProcessDefinition(loginUser, projectName, id, releaseState); } return returnDataList(result); @@ -367,7 +368,7 @@ public class ProcessDefinitionController extends BaseController { @ApiImplicitParams({ @ApiImplicitParam(name = "name", value = "PROCESS_DEFINITION_NAME", required = true, type = "String"), @ApiImplicitParam(name = "processId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"), - @ApiImplicitParam(name = "releaseState", value = "PROCESS_DEFINITION_CONNECTS", required = true, dataType = "Int", example = "100"), + @ApiImplicitParam(name = "releaseState", value = "PROCESS_DEFINITION_CONNECTS", required = true, dataType = "ReleaseState"), }) @PostMapping(value = "/release") @ResponseStatus(HttpStatus.OK) @@ -375,7 +376,7 @@ public class ProcessDefinitionController extends BaseController { public Result releaseProcessDefinition(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, @RequestParam(value = "processId", required = true) int processId, - @RequestParam(value = "releaseState", required = true) int releaseState) { + @RequestParam(value = "releaseState", required = true) ReleaseState releaseState) { logger.info("login user {}, release process definition, project name: {}, release state: {}", loginUser.getUserName(), projectName, releaseState); diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LocaleChangeInterceptor.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LocaleChangeInterceptor.java new file mode 100644 index 0000000000..3fe236e065 --- /dev/null +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LocaleChangeInterceptor.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.api.interceptor; + +import org.apache.dolphinscheduler.api.service.BaseService; +import org.apache.dolphinscheduler.common.Constants; + +import java.util.Locale; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.lang.Nullable; +import org.springframework.util.StringUtils; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +public class LocaleChangeInterceptor extends HandlerInterceptorAdapter { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { + Cookie cookie = BaseService.getCookie(request, Constants.LOCALE_LANGUAGE); + if (cookie != null) { + // Proceed in cookie + return true; + } + // Proceed in header + String newLocale = request.getHeader(Constants.LOCALE_LANGUAGE); + if (newLocale != null) { + LocaleContextHolder.setLocale(parseLocaleValue(newLocale)); + } + return true; + } + + @Nullable + protected Locale parseLocaleValue(String localeValue) { + return StringUtils.parseLocale(localeValue); + } + +} diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java index 37d856059c..82651dde74 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java @@ -17,6 +17,7 @@ package org.apache.dolphinscheduler.api.service; +import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.dao.entity.ProcessData; import org.apache.dolphinscheduler.dao.entity.User; @@ -190,7 +191,7 @@ public interface ProcessDefinitionService { Map releaseProcessDefinition(User loginUser, String projectName, int id, - int releaseState); + ReleaseState releaseState); /** * batch export process definition by ids diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java index 92aa1f5f69..9810674863 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java @@ -583,7 +583,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements */ @Override @Transactional(rollbackFor = RuntimeException.class) - public Map releaseProcessDefinition(User loginUser, String projectName, int id, int releaseState) { + public Map releaseProcessDefinition(User loginUser, String projectName, int id, ReleaseState releaseState) { HashMap result = new HashMap<>(); Project project = projectMapper.queryByName(projectName); @@ -593,17 +593,15 @@ public class ProcessDefinitionServiceImpl extends BaseService implements return checkResult; } - ReleaseState state = ReleaseState.getEnum(releaseState); - // check state - if (null == state) { + if (null == releaseState) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE); return result; } ProcessDefinition processDefinition = processDefineMapper.selectById(id); - switch (state) { + switch (releaseState) { case ONLINE: // To check resources whether they are already cancel authorized or deleted String resourceIds = processDefinition.getResourceIds(); @@ -619,11 +617,11 @@ public class ProcessDefinitionServiceImpl extends BaseService implements } } - processDefinition.setReleaseState(state); + processDefinition.setReleaseState(releaseState); processDefineMapper.updateById(processDefinition); break; case OFFLINE: - processDefinition.setReleaseState(state); + processDefinition.setReleaseState(releaseState); processDefineMapper.updateById(processDefinition); List scheduleList = scheduleMapper.selectAllByProcessDefineArray( new int[]{processDefinition.getId()} diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java index 06b8eacf1b..9241df6d71 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java @@ -24,6 +24,7 @@ import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.UserType; +import org.apache.dolphinscheduler.common.utils.CollectionUtils; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.ProjectUser; @@ -442,21 +443,13 @@ public class ProjectServiceImpl extends BaseService implements ProjectService { */ public Map queryAllProjectList() { Map result = new HashMap<>(); - List projects = projectMapper.selectList(null); - List processDefinitions = processDefinitionMapper.selectList(null); - if (projects != null) { - Set set = new HashSet<>(); - for (ProcessDefinition processDefinition : processDefinitions) { - set.add(processDefinition.getProjectId()); - } - List tempDeletelist = new ArrayList<>(); - for (Project project : projects) { - if (!set.contains(project.getId())) { - tempDeletelist.add(project); - } - } - projects.removeAll(tempDeletelist); + List projects = new ArrayList<>(); + + List projectIds = processDefinitionMapper.listProjectIds(); + if (CollectionUtils.isNotEmpty(projectIds)) { + projects = projectMapper.selectBatchIds(projectIds); } + result.put(Constants.DATA_LIST, projects); putMsg(result, Status.SUCCESS); return result; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionControllerTest.java index 662c45d7ac..9719448ad8 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionControllerTest.java @@ -142,7 +142,6 @@ public class ProcessDefinitionControllerTest { String description = "desc test"; String connects = "[]"; int id = 1; - int releaseState = 0; Map result = new HashMap<>(); putMsg(result, Status.SUCCESS); result.put("processDefinitionId", 1); @@ -151,7 +150,7 @@ public class ProcessDefinitionControllerTest { description, locations, connects)).thenReturn(result); Result response = processDefinitionController.updateProcessDefinition(user, projectName, name, id, json, - locations, connects, description,releaseState); + locations, connects, description,ReleaseState.OFFLINE); Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue()); } @@ -162,8 +161,8 @@ public class ProcessDefinitionControllerTest { Map result = new HashMap<>(); putMsg(result, Status.SUCCESS); - Mockito.when(processDefinitionService.releaseProcessDefinition(user, projectName, id, ReleaseState.OFFLINE.ordinal())).thenReturn(result); - Result response = processDefinitionController.releaseProcessDefinition(user, projectName, id, ReleaseState.OFFLINE.ordinal()); + Mockito.when(processDefinitionService.releaseProcessDefinition(user, projectName, id, ReleaseState.OFFLINE)).thenReturn(result); + Result response = processDefinitionController.releaseProcessDefinition(user, projectName, id, ReleaseState.OFFLINE); Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue()); } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/interceptor/LocaleChangeInterceptorTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/interceptor/LocaleChangeInterceptorTest.java new file mode 100644 index 0000000000..7a7506fda5 --- /dev/null +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/interceptor/LocaleChangeInterceptorTest.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.api.interceptor; + +import org.apache.dolphinscheduler.api.ApiApplicationServer; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ApiApplicationServer.class) +public class LocaleChangeInterceptorTest { + + @Autowired + LocaleChangeInterceptor interceptor; + + @Test + public void testPreHandle() { + HttpServletRequest request = Mockito.mock(HttpServletRequest.class); + HttpServletResponse response = Mockito.mock(HttpServletResponse.class); + // test no language + Assert.assertTrue(interceptor.preHandle(request, response, null)); + } + +} diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java index 89d8b86841..4db533838c 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java @@ -592,14 +592,14 @@ public class ProcessDefinitionServiceTest { putMsg(result, Status.PROJECT_NOT_FOUNT, projectName); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); Map map = processDefinitionService.releaseProcessDefinition(loginUser, "project_test1", - 6, ReleaseState.OFFLINE.getCode()); + 6, ReleaseState.OFFLINE); Assert.assertEquals(Status.PROJECT_NOT_FOUNT, map.get(Constants.STATUS)); // project check auth success, processs definition online putMsg(result, Status.SUCCESS, projectName); Mockito.when(processDefineMapper.selectById(46)).thenReturn(getProcessDefinition()); Map onlineRes = processDefinitionService.releaseProcessDefinition( - loginUser, "project_test1", 46, ReleaseState.ONLINE.getCode()); + loginUser, "project_test1", 46, ReleaseState.ONLINE); Assert.assertEquals(Status.SUCCESS, onlineRes.get(Constants.STATUS)); // project check auth success, processs definition online @@ -608,12 +608,12 @@ public class ProcessDefinitionServiceTest { Mockito.when(processDefineMapper.selectById(46)).thenReturn(processDefinition1); Mockito.when(processService.getUserById(1)).thenReturn(loginUser); Map onlineWithResourceRes = processDefinitionService.releaseProcessDefinition( - loginUser, "project_test1", 46, ReleaseState.ONLINE.getCode()); + loginUser, "project_test1", 46, ReleaseState.ONLINE); Assert.assertEquals(Status.SUCCESS, onlineWithResourceRes.get(Constants.STATUS)); // release error code Map failRes = processDefinitionService.releaseProcessDefinition( - loginUser, "project_test1", 46, 2); + loginUser, "project_test1", 46, ReleaseState.getEnum(2)); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, failRes.get(Constants.STATUS)); //FIXME has function exit code 1 when exception diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java index cc39925aa5..076eb59b27 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java @@ -32,6 +32,7 @@ import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -319,9 +320,8 @@ public class ProjectServiceTest { @Test public void testQueryAllProjectList() { - - Mockito.when(projectMapper.selectList(null)).thenReturn(getList()); - Mockito.when(processDefinitionMapper.selectList(null)).thenReturn(getProcessDefinitions()); + Mockito.when(processDefinitionMapper.listProjectIds()).thenReturn(getProjectIds()); + Mockito.when(projectMapper.selectBatchIds(getProjectIds())).thenReturn(getList()); Map result = projectService.queryAllProjectList(); logger.info(result.toString()); @@ -387,6 +387,11 @@ public class ProjectServiceTest { return list; } + private List getProjectIds() { + return Collections.singletonList(1); + } + + private String getDesc() { return "projectUserMapper.deleteProjectRelation(projectId,userId)projectUserMappe" + ".deleteProjectRelation(projectId,userId)projectUserMappe" diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java index 02580e6749..f0c7c40c49 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java @@ -906,6 +906,11 @@ public final class Constants { public static final String PASSWORD_DEFAULT = "******"; + /** + * locale + */ + public static final String LOCALE_LANGUAGE = "language"; + /** * driver */ diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java index bc7c93af3d..ba55a37f81 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java @@ -263,13 +263,13 @@ public class CollectionUtils { } Map instanceMap; for (T instance : originList) { - Map dataMap = new BeanMap(instance); + BeanMap beanMap = new BeanMap(instance); instanceMap = new LinkedHashMap<>(16, 0.75f, true); - for (Map.Entry entry : dataMap.entrySet()) { + for (Map.Entry entry : beanMap.entrySet()) { if (exclusionSet.contains(entry.getKey())) { continue; } - instanceMap.put(entry.getKey(), entry.getValue()); + instanceMap.put((String) entry.getKey(), entry.getValue()); } instanceList.add(instanceMap); } diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java index 08e092d20d..b48f2d30cc 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java @@ -22,6 +22,7 @@ import org.apache.dolphinscheduler.common.shell.ShellExecutor; import org.apache.commons.configuration.Configuration; +import java.lang.management.OperatingSystemMXBean; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; @@ -130,11 +131,17 @@ public class OSUtils { * @return load average */ public static double loadAverage() { - double loadAverage = hal.getProcessor().getSystemLoadAverage(); - if (Double.isNaN(loadAverage)) { - return NEGATIVE_ONE; + double loadAverage; + try { + OperatingSystemMXBean osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class); + loadAverage = osBean.getSystemLoadAverage(); + } catch (Exception e) { + logger.error("get operation system load average exception, try another method ", e); + loadAverage = hal.getProcessor().getSystemLoadAverage(); + if (Double.isNaN(loadAverage)) { + return NEGATIVE_ONE; + } } - DecimalFormat df = new DecimalFormat(TWO_DECIMAL); df.setRoundingMode(RoundingMode.HALF_UP); return Double.parseDouble(df.format(loadAverage)); diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.java index 621ec43c27..36c988776f 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.java @@ -138,4 +138,10 @@ public interface ProcessDefinitionMapper extends BaseMapper { * @param version version */ void updateVersionByProcessDefinitionId(@Param("processDefinitionId") int processDefinitionId, @Param("version") long version); + + /** + * list all project ids + * @return project ids list + */ + List listProjectIds(); } diff --git a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml index 6a9165f076..a24fd294a7 100644 --- a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml +++ b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml @@ -128,6 +128,12 @@ WHERE user_id = #{userId} and release_state = 1 and resource_ids is not null and resource_ids != '' + + + update t_ds_process_definition set version = #{version} diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java index 2046735221..02b5f12321 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java @@ -366,4 +366,12 @@ public class ProcessDefinitionMapperTest { ProcessDefinition processDefinition1 = processDefinitionMapper.selectById(processDefinition.getId()); Assert.assertEquals(expectedVersion, processDefinition1.getVersion()); } + + @Test + public void listProjectIds() { + ProcessDefinition processDefinition = insertOne(); + List projectIds = processDefinitionMapper.listProjectIds(); + Assert.assertNotNull(projectIds); + } + } diff --git a/dolphinscheduler-dist/release-docs/LICENSE b/dolphinscheduler-dist/release-docs/LICENSE index 44892a242e..416c7969a3 100644 --- a/dolphinscheduler-dist/release-docs/LICENSE +++ b/dolphinscheduler-dist/release-docs/LICENSE @@ -227,7 +227,7 @@ The text of each license is also included at licenses/LICENSE-[project].txt. byte-buddy 1.9.10: https://mvnrepository.com/artifact/net.bytebuddy/byte-buddy/1.9.10, Apache 2.0 classmate 1.4.0: https://mvnrepository.com/artifact/com.fasterxml/classmate/1.4.0, Apache 2.0 clickhouse-jdbc 0.1.52: https://mvnrepository.com/artifact/ru.yandex.clickhouse/clickhouse-jdbc/0.1.52, Apache 2.0 - commons-beanutils 1.7.0 https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils/1.7.0, Apache 2.0 + commons-beanutils 1.9.4 https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils/1.9.4, Apache 2.0 commons-cli 1.2: https://mvnrepository.com/artifact/commons-cli/commons-cli/1.2, Apache 2.0 commons-codec 1.11: https://mvnrepository.com/artifact/commons-codec/commons-codec/1.11, Apache 2.0 commons-collections 3.2.2: https://mvnrepository.com/artifact/commons-collections/commons-collections/3.2.2, Apache 2.0 diff --git a/dolphinscheduler-dist/release-docs/licenses/ui-licenses/LICENSE-@form-create-element-ui b/dolphinscheduler-dist/release-docs/licenses/ui-licenses/LICENSE-@form-create-element-ui new file mode 100644 index 0000000000..468a05fc1d --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/ui-licenses/LICENSE-@form-create-element-ui @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 xaboy + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/JSONUtils.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/JSONUtils.java index 6542ef86a4..89d6e50ea5 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/JSONUtils.java +++ b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/JSONUtils.java @@ -58,7 +58,7 @@ public class JSONUtils { /** * json representation of object * - * @param object object + * @param object object * @param feature feature * @return object to json string */ @@ -81,9 +81,9 @@ public class JSONUtils { * the fields of the specified object are generics, just the object itself should not be a * generic type. * - * @param json the string from which the object is to be deserialized + * @param json the string from which the object is to be deserialized * @param clazz the class of T - * @param T + * @param T * @return an object of type T from the string * classOfT */ @@ -103,9 +103,9 @@ public class JSONUtils { /** * json to list * - * @param json json string + * @param json json string * @param clazz class - * @param T + * @param T * @return list */ public static List toList(String json, Class clazz) { @@ -153,4 +153,4 @@ public class JSONUtils { throw new RuntimeException("Json deserialization exception.", e); } } -} \ No newline at end of file +} diff --git a/dolphinscheduler-ui/package.json b/dolphinscheduler-ui/package.json index acc40b6f52..b325561aad 100644 --- a/dolphinscheduler-ui/package.json +++ b/dolphinscheduler-ui/package.json @@ -3,6 +3,8 @@ "version": "1.0.0", "description": "A vue.js project", "author": "DolphinScheduler", + "repository": "https://github.com/apache/incubator-dolphinscheduler", + "license": "Apache-2.0", "scripts": { "build": "npm run clean && cross-env NODE_ENV=production webpack --config ./build/webpack.config.prod.js", "dev": "cross-env NODE_ENV=development webpack-dev-server --config ./build/webpack.config.dev.js", @@ -13,6 +15,7 @@ "build:release": "npm run clean && cross-env NODE_ENV=production PUBLIC_PATH=/dolphinscheduler/ui webpack --config ./build/webpack.config.release.js" }, "dependencies": { + "@form-create/element-ui": "^1.0.18", "@riophae/vue-treeselect": "^0.4.0", "axios": "^0.16.2", "bootstrap": "3.3.7", @@ -38,6 +41,7 @@ "vuex-router-sync": "^5.0.0" }, "devDependencies": { + "acorn": "^7.4.1", "autoprefixer": "^9.1.0", "babel-core": "^6.25.0", "babel-helper-vue-jsx-merge-props": "^2.0.2", diff --git a/dolphinscheduler-ui/src/js/conf/home/index.js b/dolphinscheduler-ui/src/js/conf/home/index.js index 42295b24a2..c1bcdff63d 100644 --- a/dolphinscheduler-ui/src/js/conf/home/index.js +++ b/dolphinscheduler-ui/src/js/conf/home/index.js @@ -38,6 +38,7 @@ import 'bootstrap/dist/css/bootstrap.min.css' import 'bootstrap/dist/js/bootstrap.min.js' import 'canvg/dist/browser/canvg.min.js' import 'remixicon/fonts/remixicon.css' +import formCreate from '@form-create/element-ui' // Component internationalization const useOpt = i18n.globalScope.LOCALE === 'en_US' ? { locale: locale } : {} @@ -46,6 +47,7 @@ i18n.globalScope.LOCALE === 'en_US' ? Vue.use(ElementUI, { locale }) : Vue.use(E // Vue.use(ans) Vue.use(useOpt) +Vue.use(formCreate) sync(store, router) diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/sql.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/sql.vue index 7e3ae465c8..706edcda6a 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/sql.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/sql.vue @@ -55,18 +55,6 @@ - -
*{{$t('Recipient')}}
-
- -
-
- -
{{$t('Cc')}}
-
- -
-
{{$t('SQL Parameter')}}
@@ -155,7 +143,6 @@ import mLocalParams from './_source/localParams' import mStatementList from './_source/statementList' import disabledState from '@/module/mixin/disabledState' - import mEmail from '@/conf/home/pages/projects/pages/definition/pages/list/_source/email' import codemirror from '@/conf/home/pages/resource/pages/file/pages/_source/codemirror' let editor @@ -188,10 +175,6 @@ preStatements: [], // Post statements postStatements: [], - // recipients - receivers: [], - // copy to - receiversCc: [], item: '', scriptBoxDialog: false } @@ -274,14 +257,6 @@ this.$message.warning(`${i18n.$t('Recipient required')}`) return false } - // receivers Subcomponent verification - if (this.sqlType === 0 && !this.$refs.refEmail._manualEmail()) { - return false - } - // receiversCc Subcomponent verification - if (this.sqlType === 0 && !this.$refs.refCc._manualEmail()) { - return false - } // udfs Subcomponent verification Verification only if the data type is HIVE if (this.type === 'HIVE') { if (!this.$refs.refUdfs._verifUdfs()) { @@ -312,8 +287,6 @@ udfs: this.udfs, sqlType: this.sqlType, title: this.title, - receivers: this.receivers.join(','), - receiversCc: this.receiversCc.join(','), showType: (() => { /** * Special processing return order TABLE,ATTACHMENT @@ -366,19 +339,6 @@ return editor }, - _getReceiver () { - let param = {} - let current = this.router.history.current - if (current.name === 'projects-definition-details') { - param.processDefinitionId = current.params.id - } else { - param.processInstanceId = current.params.id - } - this.store.dispatch('dag/getReceiver', param).then(res => { - this.receivers = res.receivers && res.receivers.split(',') || [] - this.receiversCc = res.receiversCc && res.receiversCc.split(',') || [] - }) - }, _cacheParams () { this.$emit('on-cache-params', { type: this.type, @@ -387,8 +347,6 @@ udfs: this.udfs, sqlType: this.sqlType, title: this.title, - receivers: this.receivers.join(','), - receiversCc: this.receiversCc.join(','), showType: (() => { let showType = this.showType if (showType.length === 2 && showType[0] === 'ATTACHMENT') { @@ -419,8 +377,6 @@ } if (val !== 0) { this.title = '' - this.receivers = [] - this.receiversCc = [] } }, // Listening data source @@ -455,13 +411,6 @@ this.preStatements = o.params.preStatements || [] this.postStatements = o.params.postStatements || [] this.title = o.params.title || '' - this.receivers = o.params.receivers && o.params.receivers.split(',') || [] - this.receiversCc = o.params.receiversCc && o.params.receiversCc.split(',') || [] - } - // read tasks from cache - if (!_.some(this.store.state.dag.cacheTasks, { id: this.createNodeId }) && - this.router.history.current.name !== 'definition-create') { - this._getReceiver() } }, mounted () { @@ -487,8 +436,6 @@ udfs: this.udfs, sqlType: this.sqlType, title: this.title, - receivers: this.receivers.join(','), - receiversCc: this.receiversCc.join(','), showType: (() => { let showType = this.showType if (showType.length === 2 && showType[0] === 'ATTACHMENT') { @@ -504,6 +451,6 @@ } } }, - components: { mListBox, mDatasource, mLocalParams, mUdfs, mSqlType, mStatementList, mEmail, mScriptBox } + components: { mListBox, mDatasource, mLocalParams, mUdfs, mSqlType, mStatementList, mScriptBox } } diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/sqoop.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/sqoop.vue index 25133934c5..7819b23fc1 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/sqoop.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/sqoop.vue @@ -1175,7 +1175,6 @@ } if (val !== 0) { this.title = '' - this.receivers = [] } }, // Listening data source diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/udp/udp.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/udp/udp.vue index a57f472977..a040b4be43 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/udp/udp.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/udp/udp.vue @@ -76,7 +76,7 @@
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/list.vue b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/list.vue index 1a119d1028..69798e85ee 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/list.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/list.vue @@ -81,24 +81,28 @@
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/index.vue b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/index.vue index ca0117e96f..46e91ad7ce 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/index.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/index.vue @@ -21,6 +21,8 @@ diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningGroups/_source/list.vue b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningGroups/_source/list.vue index a4fd982a26..c3c0a9e343 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningGroups/_source/list.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningGroups/_source/list.vue @@ -20,11 +20,6 @@ - - - diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningGroups/index.vue b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningGroups/index.vue index 8368a04773..cfe9bac55a 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningGroups/index.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningGroups/index.vue @@ -21,9 +21,11 @@ @@ -83,13 +85,14 @@ isLeft: true, isADMIN: store.state.user.userInfo.userType === 'ADMIN_USER', createWarningDialog: false, - item: {} + item: {}, + allAlertPluginInstance: [] } }, mixins: [listUrlParamHandle], props: {}, methods: { - ...mapActions('security', ['getAlertgroupP']), + ...mapActions('security', ['queryAlertGroupListPaging', 'queryAllAlertPluginInstance']), /** * Inquire */ @@ -110,6 +113,11 @@ this._create(item) }, _create (item) { + this.queryAllAlertPluginInstance().then(res => { + this.allAlertPluginInstance = res + }).catch(e => { + this.$message.error(e.msg) + }) this.item = item this.createWarningDialog = true }, @@ -130,7 +138,7 @@ this.isLeft = true } this.isLoading = !flag - this.getAlertgroupP(this.searchParams).then(res => { + this.queryAlertGroupListPaging(this.searchParams).then(res => { if (this.searchParams.pageNo > 1 && res.totalList.length === 0) { this.searchParams.pageNo = this.searchParams.pageNo - 1 } else { diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningInstance/_source/createWarningInstance.vue b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningInstance/_source/createWarningInstance.vue new file mode 100644 index 0000000000..c41af3db42 --- /dev/null +++ b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningInstance/_source/createWarningInstance.vue @@ -0,0 +1,197 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningInstance/_source/list.vue b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningInstance/_source/list.vue new file mode 100644 index 0000000000..5a8cf2ad1b --- /dev/null +++ b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningInstance/_source/list.vue @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningInstance/index.vue b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningInstance/index.vue new file mode 100644 index 0000000000..a0623ab2e0 --- /dev/null +++ b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/warningInstance/index.vue @@ -0,0 +1,171 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/user/pages/account/_source/info.vue b/dolphinscheduler-ui/src/js/conf/home/pages/user/pages/account/_source/info.vue index 0c7467b294..ce9e1fb9a7 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/user/pages/account/_source/info.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/user/pages/account/_source/info.vue @@ -69,6 +69,8 @@