Move error page to react.

main
Paulo Gustavo Veiga 2023-07-30 22:31:24 -07:00
parent 68aa7c20eb
commit 1340fff68a
8 changed files with 60 additions and 40 deletions

View File

@ -9,7 +9,7 @@ WiseMapping is based on the same code product supporting [http://www.wisemapping
The following products must be installed: The following products must be installed:
* OpenJDK 11 or higher * OpenJDK 17 or higher
* Maven 3.x or higher ([http://maven.apache.org/]) * Maven 3.x or higher ([http://maven.apache.org/])
* npm 6 or higher ([https://www.npmjs.com/package/npm?activeTab=versions]) * npm 6 or higher ([https://www.npmjs.com/package/npm?activeTab=versions])

View File

@ -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;
}
}

View File

@ -20,11 +20,11 @@ package com.wisemapping.exceptions;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class MapNonPublicException public class MapNotPublicSecurityException
extends ClientException { extends ClientException {
public static final String MSG_KEY = "ACCESS_HAS_BEEN_REVOKED"; public static final String MSG_KEY = "ACCESS_HAS_BEEN_REVOKED";
public MapNonPublicException(@NotNull String msg) { public MapNotPublicSecurityException(@NotNull String msg) {
super(msg, Severity.FATAL); super(msg, Severity.FATAL);
} }

View File

@ -21,7 +21,7 @@ package com.wisemapping.webmvc;
import com.wisemapping.exceptions.AccessDeniedSecurityException; import com.wisemapping.exceptions.AccessDeniedSecurityException;
import com.wisemapping.exceptions.MapCouldNotFoundException; import com.wisemapping.exceptions.MapCouldNotFoundException;
import com.wisemapping.exceptions.MapNonPublicException; import com.wisemapping.exceptions.MapNotPublicSecurityException;
import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.CollaborationRole; import com.wisemapping.model.CollaborationRole;
import com.wisemapping.model.Mindmap; import com.wisemapping.model.Mindmap;
@ -121,9 +121,9 @@ public class MvcMindmapController {
@RequestMapping(value = "maps/{id}/embed") @RequestMapping(value = "maps/{id}/embed")
@PreAuthorize("permitAll()") @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)) { 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); final MindMapBean mindmap = findMindmapBean(id);
@ -138,7 +138,7 @@ public class MvcMindmapController {
@PreAuthorize("permitAll()") @PreAuthorize("permitAll()")
public String showPublicViewPage(@PathVariable int id, @NotNull Model model) throws WiseMappingException { public String showPublicViewPage(@PathVariable int id, @NotNull Model model) throws WiseMappingException {
if (!mindmapService.isMindmapPublic(id)) { 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); return this.showPrintPage(id, model);
} }

View File

@ -8,7 +8,6 @@ INVALID_EMAIL_ADDRESS=Invalid email address. Please, verify that your entered v
CREATOR=Creator CREATOR=Creator
WELCOME=Welcome WELCOME=Welcome
SHARE=Share SHARE=Share
UNEXPECTED_ERROR=An unexpected error has occurred.
MAP_TITLE_ALREADY_EXISTS=You have already a map with the same name MAP_TITLE_ALREADY_EXISTS=You have already a map with the same name
LABEL_TITLE_ALREADY_EXISTS=You have already a label with the same name LABEL_TITLE_ALREADY_EXISTS=You have already a label with the same name
TUTORIAL.MULTIPLE_TEXT_STYLES=Multiple Text Styles TUTORIAL.MULTIPLE_TEXT_STYLES=Multiple Text Styles
@ -47,9 +46,7 @@ MINDMAP_IS_LOCKED=Min map is locked for edition.
# Confirmed # Confirmed
RESET_PASSWORD_INVALID_EMAIL=The email provided is not a valid user account. Please, try again with a valid email. RESET_PASSWORD_INVALID_EMAIL=The email provided is not a valid user account. Please, try again with a valid email.
TRY_WELCOME=This edition space showcases some of the mind map editor capabilities \!. TRY_WELCOME=This edition space showcases some of the mind map editor capabilities \!.
UNEXPECTED_ERROR_DETAILS=Unexpected error processing request.
NO_ENOUGH_PERMISSIONS=This mind map cannot be opened. NO_ENOUGH_PERMISSIONS=This mind map cannot be opened.
NO_ENOUGH_PERMISSIONS_DETAILS=You do not have enough right access to see this map. This map has been changed to private or deleted.
CAPTCHA_TIMEOUT_OUT_DUPLICATE=Please, refresh the page and try again. CAPTCHA_TIMEOUT_OUT_DUPLICATE=Please, refresh the page and try again.
CAPTCHA_INVALID_INPUT_RESPONSE=Invalid input response, refresh the page and try again. CAPTCHA_INVALID_INPUT_RESPONSE=Invalid input response, refresh the page and try again.
MINDMAP_EMPTY_ERROR=Mind map can not be empty. MINDMAP_EMPTY_ERROR=Mind map can not be empty.

View File

@ -14,7 +14,7 @@
<Logger name="com.wisemapping" level="warn"> <Logger name="com.wisemapping" level="warn">
<AppenderRef ref="LogToConsole"/> <AppenderRef ref="LogToConsole"/>
</Logger> </Logger>
<Logger name="org.springframework" level="warn"> <Logger name="org.springframework" level="trace">
<AppenderRef ref="LogToConsole"/> <AppenderRef ref="LogToConsole"/>
</Logger> </Logger>
<Root level="warn"> <Root level="warn">

View File

@ -11,8 +11,6 @@
<link rel="preload" href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400;600&display=swap" as="style" onload="this.onload=null;this.rel='stylesheet'" crossorigin> <link rel="preload" href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400;600&display=swap" as="style" onload="this.onload=null;this.rel='stylesheet'" crossorigin>
<%@ include file="pageHeaders.jsf" %> <%@ include file="pageHeaders.jsf" %>
<title>WiseMapping</title>
<script> <script>
window.serverconfig = { window.serverconfig = {
apiBaseUrl: '${requestScope['site.baseurl']}', apiBaseUrl: '${requestScope['site.baseurl']}',
@ -23,7 +21,10 @@
googleOauth2Url: '${requestScope['security.oauth2.google.url']}' googleOauth2Url: '${requestScope['security.oauth2.google.url']}'
}; };
<!-- Hack to force view selection on react to move all the UI to react-->
window.errorMvcView = '${requestScope['exception']!=null?(fn:indexOf(requestScope['exception'],'SecurityException') gt 1?'securityError':'unexpectedError'):''}';
</script> </script>
<c:if test="${requestScope['google.analytics.enabled']}"> <c:if test="${requestScope['google.analytics.enabled']}">
<!-- Google Ads Sense Config. Lazy loading optimization --> <!-- Google Ads Sense Config. Lazy loading optimization -->
<script type="text/javascript"> <script type="text/javascript">

View File

@ -22,33 +22,6 @@
<bean id="requestInterceptor" class="com.wisemapping.filter.RequestPropertiesInterceptor"/> <bean id="requestInterceptor" class="com.wisemapping.filter.RequestPropertiesInterceptor"/>
</mvc:interceptors> </mvc:interceptors>
<bean id="simpleMappingExceptionResolver"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="defaultStatusCode" value="500"/>
<property name="defaultErrorView" value="errorTemplate"/>
<property name="warnLogCategory" value="com.wisemapping.mvc.Exceptions"/>
<property name="exceptionMappings">
<props>
<!-- Security access exceptions must not handle as unexpected errors -->
<prop key="com.wisemapping.exceptions.MapNonPublicException">securityError</prop>
<prop key="com.wisemapping.exceptions.AccessDeniedSecurityException">securityError</prop>
</props>
</property>
<property name="statusCodes">
<props>
<prop key="securityError">403</prop>
</props>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean id="localeResolver" <bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver"> class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
</bean> </bean>