From b5c8e50a27a98330380b3b47fbd552ff90f50a96 Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Tue, 1 Mar 2022 21:58:56 +0800 Subject: [PATCH 1/2] Adapt web configurations for UI next --- .../api/ApiApplicationServer.java | 1 - .../api/configuration/AppConfiguration.java | 6 +-- .../api/controller/DsErrorController.java | 50 +++++++++++++++++++ .../interceptor/LoginHandlerInterceptor.java | 1 - .../dolphinscheduler/StandaloneServer.java | 1 - 5 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DsErrorController.java diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java index 020ee027b16c..59e9c7e632f4 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java @@ -21,7 +21,6 @@ import javax.annotation.PostConstruct; -import org.quartz.SchedulerException; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; 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 fb961169f009..215e8f537d89 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,12 +17,10 @@ package org.apache.dolphinscheduler.api.configuration; +import java.util.Locale; import org.apache.dolphinscheduler.api.interceptor.LocaleChangeInterceptor; import org.apache.dolphinscheduler.api.interceptor.LoginHandlerInterceptor; import org.apache.dolphinscheduler.api.interceptor.RateLimitInterceptor; - -import java.util.Locale; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -104,7 +102,7 @@ public void addInterceptors(InterceptorRegistry registry) { .addPathPatterns(LOGIN_INTERCEPTOR_PATH_PATTERN) .excludePathPatterns(LOGIN_PATH_PATTERN, REGISTER_PATH_PATTERN, "/swagger-resources/**", "/webjars/**", "/v2/**", - "/doc.html", "/swagger-ui.html", "*.html", "/ui/**"); + "/doc.html", "/swagger-ui.html", "*.html", "/ui/**", "/error"); } @Override diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DsErrorController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DsErrorController.java new file mode 100644 index 000000000000..f42df4f4e162 --- /dev/null +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DsErrorController.java @@ -0,0 +1,50 @@ +/* + * 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.controller; + +import javax.servlet.RequestDispatcher; +import javax.servlet.http.HttpServletRequest; +import org.springframework.boot.web.servlet.error.ErrorController; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class DsErrorController implements ErrorController { + @RequestMapping("/error") + public ModelAndView handleError(HttpServletRequest request) { + Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); + ModelAndView modelAndView = new ModelAndView(); + + if (status != null) { + Integer statusCode = Integer.valueOf(status.toString()); + + if (statusCode == HttpStatus.NOT_FOUND.value()) { + modelAndView.setStatus(HttpStatus.OK); + modelAndView.setViewName("forward:/ui/index.html"); + return modelAndView; + } + + modelAndView.setStatus(HttpStatus.valueOf(statusCode)); + } + return modelAndView; + } +} diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java index efa658fa7e0c..2013348ed8ef 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java @@ -59,7 +59,6 @@ public class LoginHandlerInterceptor implements HandlerInterceptor { */ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { - // get token String token = request.getHeader("token"); User user; diff --git a/dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/StandaloneServer.java b/dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/StandaloneServer.java index 9120521f46c7..35a9cd35514d 100644 --- a/dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/StandaloneServer.java +++ b/dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/StandaloneServer.java @@ -23,7 +23,6 @@ import javax.annotation.PostConstruct; -import org.quartz.SchedulerException; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; From f17faef9d1a19ddbed81352f20e5c67189b12d23 Mon Sep 17 00:00:00 2001 From: SbloodyS <460888207@qq.com> Date: Wed, 2 Mar 2022 14:27:22 +0800 Subject: [PATCH 2/2] remove VITE_APP_PROD_WEB_URL --- dolphinscheduler-ui-next/.env.production | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dolphinscheduler-ui-next/.env.production b/dolphinscheduler-ui-next/.env.production index 683b8c3aab16..74bc29d2e35b 100644 --- a/dolphinscheduler-ui-next/.env.production +++ b/dolphinscheduler-ui-next/.env.production @@ -15,4 +15,4 @@ NODE_ENV=production -VITE_APP_PROD_WEB_URL='http://127.0.0.1:12345' +VITE_APP_PROD_WEB_URL=''