Commit 989db43a authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '181-404' into 'master'

Bug on rendering 404 error page

Closes #181

See merge request genesys-pgr/genesys-server!90
parents 1bf4f6d6 a0cb3fe2
......@@ -52,7 +52,7 @@ public class UserControllerAdvice extends BaseController {
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(value = { ResourceNotFoundException.class, NoHandlerFoundException.class })
public ModelAndView handleResourceNotFoundException(final ResourceNotFoundException e) {
public ModelAndView handleResourceNotFoundException(final Exception e) {
final ModelAndView mav = new ModelAndView("/errors/error");
mav.addObject("exception", e);
return mav;
......
......@@ -18,7 +18,6 @@ package org.genesys2.spring.config;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
......@@ -48,7 +47,6 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
import org.springframework.validation.Validator;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
......@@ -56,7 +54,6 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
import org.springframework.web.servlet.theme.CookieThemeResolver;
import org.springframework.web.servlet.theme.ThemeChangeInterceptor;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
......@@ -86,16 +83,6 @@ public class WebConfiguration extends WebMvcConfigurerAdapter {
@Resource
private Set<String> supportedLocales;
@Bean
public SimpleMappingExceptionResolver simpleMappingExceptionResolver() {
final Properties properties = new Properties();
properties.setProperty("javax.servlet.UnavailableException", "/404");
final SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver();
resolver.setExceptionMappings(properties);
return resolver;
}
@Scope("singleton")
@Bean
@Override
......@@ -133,11 +120,6 @@ public class WebConfiguration extends WebMvcConfigurerAdapter {
super.addViewControllers(registry);
}
@Override
public void configureDefaultServletHandling(final DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Override
public void configurePathMatch(final PathMatchConfigurer configurer) {
configurer.setUseTrailingSlashMatch(true);
......
......@@ -31,8 +31,10 @@ import org.genesys2.server.servlet.filter.NewGUIFilter;
import org.sitemesh.builder.SiteMeshFilterBuilder;
import org.sitemesh.config.ConfigurableSiteMeshFilter;
import org.sitemesh.webapp.contentfilter.BasicSelector;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.filter.DelegatingFilterProxy;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter;
import org.tuckey.web.filters.urlrewrite.gzip.GzipFilter;
......@@ -62,6 +64,13 @@ public class WebInitializer extends AbstractAnnotationConfigDispatcherServletIni
return null;
}
@Override
protected DispatcherServlet createDispatcherServlet(final WebApplicationContext servletAppContext) {
final DispatcherServlet dispatcherServlet = (DispatcherServlet) super.createDispatcherServlet(servletAppContext);
dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
return dispatcherServlet;
}
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
......
......@@ -170,6 +170,7 @@ public class ApiImagesDocsTest extends AbstractRestTest {
fieldWithPath("path").description("Location (directory) of the image in the Genesys repository"),
fieldWithPath("size").description("Image size in bytes"),
fieldWithPath("filename").description("The new generated filename of the image"),
fieldWithPath("metadataFilename").description("The generated filename for image metadata"),
fieldWithPath("url").description("The relative URL to the image in Genesys repository [path+filename]"),
fieldWithPath("sha1Sum").description("SHA1 hash of the image bytes"), fieldWithPath("md5Sum").description("MD5 hash of the image bytes"),
fieldWithPath("width").description("Image width in pixels (autodetected)"), fieldWithPath("height").description("Image height in pixels (autodetected)"),
......@@ -219,7 +220,9 @@ public class ApiImagesDocsTest extends AbstractRestTest {
// ignored
fieldWithPath("active").ignored(), fieldWithPath("id").ignored(), fieldWithPath("thumbnailPath").ignored(), fieldWithPath("url").ignored(), fieldWithPath("storageFullPath").ignored()),
responseFields(fieldWithPath("uuid").ignored(), fieldWithPath("originalFilename").description("The original filename that you have provided"),
fieldWithPath("extension").ignored(), fieldWithPath("contentType").ignored(), fieldWithPath("path").ignored(), fieldWithPath("filename").ignored(),
fieldWithPath("extension").ignored(), fieldWithPath("contentType").ignored(), fieldWithPath("path").ignored(),
fieldWithPath("filename").ignored(),
fieldWithPath("metadataFilename").ignored(),
fieldWithPath("url").ignored(), fieldWithPath("sha1Sum").ignored(), fieldWithPath("md5Sum").ignored(),
// Ignored stuff
fieldWithPath("id").ignored(),
......@@ -259,6 +262,7 @@ public class ApiImagesDocsTest extends AbstractRestTest {
fieldWithPath("contentType").description("The content type of the image (autodetected when possible)"), fieldWithPath("format").description("Image format"),
fieldWithPath("path").description("Location (directory) of the image in the Genesys repository"),
fieldWithPath("filename").description("The new generated filename of the image"),
fieldWithPath("metadataFilename").description("The generated filename for image metadata"),
fieldWithPath("url").description("The relative URL to the image in Genesys repository [path+filename]"),
fieldWithPath("sha1Sum").description("SHA1 hash of the image bytes"), fieldWithPath("md5Sum").description("MD5 hash of the image bytes"),
fieldWithPath("width").description("Image width in pixels (autodetected)"), fieldWithPath("height").description("Image height in pixels (autodetected)"),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment