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 020ee027b1..59e9c7e632 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 java.util.TimeZone; 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 fb961169f0..215e8f537d 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 class AppConfiguration implements WebMvcConfigurer { .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 0000000000..f42df4f4e1 --- /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 efa658fa7e..2013348ed8 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 9120521f46..35a9cd3551 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 java.util.TimeZone; 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;