Move error page to react.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package com.wisemapping.config;
|
||||
|
||||
import com.wisemapping.exceptions.AccessDeniedSecurityException;
|
||||
import com.wisemapping.exceptions.MapNotPublicSecurityException;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
|
||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||
import org.springframework.web.servlet.view.JstlView;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@EnableWebMvc
|
||||
@Configuration
|
||||
public class AppConfig {
|
||||
|
||||
@Bean
|
||||
HandlerExceptionResolver errorHandler() {
|
||||
final SimpleMappingExceptionResolver result =
|
||||
new SimpleMappingExceptionResolver();
|
||||
|
||||
//exception to view name mapping
|
||||
final Properties p = new Properties();
|
||||
p.setProperty(MapNotPublicSecurityException.class.getName(), "reactInclude");
|
||||
p.setProperty(AccessDeniedSecurityException.class.getName(), "reactInclude");
|
||||
result.setExceptionMappings(p);
|
||||
|
||||
//mapping status code with view response.
|
||||
result.addStatusCode("reactInclude", 403);
|
||||
|
||||
//setting default error view
|
||||
result.setDefaultErrorView("errorTemplate");
|
||||
result.setDefaultStatusCode(500);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ViewResolver viewResolver(){
|
||||
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
|
||||
resolver.setPrefix("/WEB-INF/views/");
|
||||
resolver.setSuffix(".jsp");
|
||||
resolver.setViewClass(JstlView.class);
|
||||
return resolver;
|
||||
}
|
||||
}
|
@@ -20,11 +20,11 @@ package com.wisemapping.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MapNonPublicException
|
||||
public class MapNotPublicSecurityException
|
||||
extends ClientException {
|
||||
public static final String MSG_KEY = "ACCESS_HAS_BEEN_REVOKED";
|
||||
|
||||
public MapNonPublicException(@NotNull String msg) {
|
||||
public MapNotPublicSecurityException(@NotNull String msg) {
|
||||
super(msg, Severity.FATAL);
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ package com.wisemapping.webmvc;
|
||||
|
||||
import com.wisemapping.exceptions.AccessDeniedSecurityException;
|
||||
import com.wisemapping.exceptions.MapCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.MapNonPublicException;
|
||||
import com.wisemapping.exceptions.MapNotPublicSecurityException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
@@ -121,9 +121,9 @@ public class MvcMindmapController {
|
||||
|
||||
@RequestMapping(value = "maps/{id}/embed")
|
||||
@PreAuthorize("permitAll()")
|
||||
public ModelAndView showEmbeddedPage(@PathVariable int id, @RequestParam(required = false) Float zoom) throws MapCouldNotFoundException, MapNonPublicException, AccessDeniedSecurityException {
|
||||
public ModelAndView showEmbeddedPage(@PathVariable int id, @RequestParam(required = false) Float zoom) throws MapCouldNotFoundException, MapNotPublicSecurityException, AccessDeniedSecurityException {
|
||||
if (!mindmapService.isMindmapPublic(id)) {
|
||||
throw new MapNonPublicException("Map " + id + " is not public.");
|
||||
throw new MapNotPublicSecurityException("Map " + id + " is not public.");
|
||||
}
|
||||
|
||||
final MindMapBean mindmap = findMindmapBean(id);
|
||||
@@ -138,7 +138,7 @@ public class MvcMindmapController {
|
||||
@PreAuthorize("permitAll()")
|
||||
public String showPublicViewPage(@PathVariable int id, @NotNull Model model) throws WiseMappingException {
|
||||
if (!mindmapService.isMindmapPublic(id)) {
|
||||
throw new MapNonPublicException("Map " + id + " is not public.");
|
||||
throw new MapNotPublicSecurityException("Map " + id + " is not public.");
|
||||
}
|
||||
return this.showPrintPage(id, model);
|
||||
}
|
||||
|
Reference in New Issue
Block a user