From ea6b2ad1063e52f7d87c5cbfcd36efd186d9352f Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 26 Nov 2023 16:13:45 -0800 Subject: [PATCH] Fix public resource sharing. --- .../com/wisemapping/config/Application.java | 32 ------------- .../wisemapping/config/HibernateConfig.java | 11 ----- .../com/wisemapping/config/MvcConfig.java | 45 ++++++++++++++++++ .../src/main/resources/application.properties | 4 -- .../main/{webapp => resources/public}/ads.txt | 0 .../public}/css/viewonly.css | 0 .../{webapp => resources/public}/favicon.ico | Bin .../{webapp => resources/public}/favicon.png | Bin .../public}/images/add.svg | 0 .../public}/images/center_focus.svg | 0 .../public}/images/logo-icon.png | Bin .../public}/images/logo-icon.svg | 0 .../public}/images/logo-small.png | Bin .../public}/images/logo-text-black.svg | 0 .../public}/images/minus.svg | 0 .../{webapp => resources/public}/index.html | 0 .../{webapp => resources/public}/robots.txt | 0 .../WEB-INF => resources}/views/init.jsp | 0 .../views/mindmapEditor.jsp | 0 .../views/mindmapViewonly.jsp | 0 .../views/pageHeaders.jsf | 0 .../views/reactInclude.jsp | 0 .../src/main/webapp/META-INF/Context.xml | 16 ------- wise-webapp/src/main/webapp/index.jsp | 3 -- 24 files changed, 45 insertions(+), 66 deletions(-) create mode 100644 wise-webapp/src/main/java/com/wisemapping/config/MvcConfig.java rename wise-webapp/src/main/{webapp => resources/public}/ads.txt (100%) rename wise-webapp/src/main/{webapp => resources/public}/css/viewonly.css (100%) rename wise-webapp/src/main/{webapp => resources/public}/favicon.ico (100%) rename wise-webapp/src/main/{webapp => resources/public}/favicon.png (100%) rename wise-webapp/src/main/{webapp => resources/public}/images/add.svg (100%) rename wise-webapp/src/main/{webapp => resources/public}/images/center_focus.svg (100%) rename wise-webapp/src/main/{webapp => resources/public}/images/logo-icon.png (100%) rename wise-webapp/src/main/{webapp => resources/public}/images/logo-icon.svg (100%) rename wise-webapp/src/main/{webapp => resources/public}/images/logo-small.png (100%) rename wise-webapp/src/main/{webapp => resources/public}/images/logo-text-black.svg (100%) rename wise-webapp/src/main/{webapp => resources/public}/images/minus.svg (100%) rename wise-webapp/src/main/{webapp => resources/public}/index.html (100%) rename wise-webapp/src/main/{webapp => resources/public}/robots.txt (100%) rename wise-webapp/src/main/{webapp/WEB-INF => resources}/views/init.jsp (100%) rename wise-webapp/src/main/{webapp/WEB-INF => resources}/views/mindmapEditor.jsp (100%) rename wise-webapp/src/main/{webapp/WEB-INF => resources}/views/mindmapViewonly.jsp (100%) rename wise-webapp/src/main/{webapp/WEB-INF => resources}/views/pageHeaders.jsf (100%) rename wise-webapp/src/main/{webapp/WEB-INF => resources}/views/reactInclude.jsp (100%) delete mode 100755 wise-webapp/src/main/webapp/META-INF/Context.xml delete mode 100644 wise-webapp/src/main/webapp/index.jsp diff --git a/wise-webapp/src/main/java/com/wisemapping/config/Application.java b/wise-webapp/src/main/java/com/wisemapping/config/Application.java index c694c89a..e22ae7ed 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/Application.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/Application.java @@ -2,20 +2,10 @@ package com.wisemapping.config; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.transaction.annotation.EnableTransactionManagement; -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; -@EnableWebMvc @EnableTransactionManagement @SpringBootApplication @EnableJpaRepositories("com.wisemapping.model") @@ -25,26 +15,4 @@ public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } - - @Bean - HandlerExceptionResolver errorHandler() { - final SimpleMappingExceptionResolver result = new SimpleMappingExceptionResolver(); - - //mapping status code with view response. - result.addStatusCode("reactInclude", 403); - - //setting default error view - result.setDefaultErrorView("reactInclude"); - 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; - } } diff --git a/wise-webapp/src/main/java/com/wisemapping/config/HibernateConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/HibernateConfig.java index a4e19549..8e25e9ce 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/HibernateConfig.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/HibernateConfig.java @@ -1,19 +1,8 @@ package com.wisemapping.config; -import jakarta.persistence.EntityManagerFactory; -import org.apache.commons.dbcp2.BasicDataSource; -import org.hibernate.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.orm.hibernate5.HibernateTransactionManager; -import org.springframework.orm.hibernate5.LocalSessionFactoryBean; import org.springframework.transaction.annotation.EnableTransactionManagement; -import javax.sql.DataSource; -import java.util.Properties; - @Configuration @EnableTransactionManagement public class HibernateConfig { diff --git a/wise-webapp/src/main/java/com/wisemapping/config/MvcConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/MvcConfig.java new file mode 100644 index 00000000..7c86002c --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/config/MvcConfig.java @@ -0,0 +1,45 @@ +package com.wisemapping.config; + +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.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@Configuration +@EnableWebMvc +public class MvcConfig implements WebMvcConfigurer { + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry + .addResourceHandler("/**") + .addResourceLocations("classpath:/public/"); + } + + @Bean + public ViewResolver viewResolver() { + InternalResourceViewResolver resolver = new InternalResourceViewResolver(); + resolver.setPrefix("/views/"); + resolver.setSuffix(".jsp"); + resolver.setViewClass(JstlView.class); + return resolver; + } + + @Bean + HandlerExceptionResolver errorHandler() { + final SimpleMappingExceptionResolver result = new SimpleMappingExceptionResolver(); + + //mapping status code with view response. + result.addStatusCode("reactInclude", 403); + + //setting default error view + result.setDefaultErrorView("reactInclude"); + result.setDefaultStatusCode(500); + return result; + } +} \ No newline at end of file diff --git a/wise-webapp/src/main/resources/application.properties b/wise-webapp/src/main/resources/application.properties index 04a919e7..fbd8c1f9 100755 --- a/wise-webapp/src/main/resources/application.properties +++ b/wise-webapp/src/main/resources/application.properties @@ -179,7 +179,3 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect spring.jpa.open-in-view=true spring.h2.console.enabled=true spring.h2.console.path=/h2-ui - -spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext - - diff --git a/wise-webapp/src/main/webapp/ads.txt b/wise-webapp/src/main/resources/public/ads.txt similarity index 100% rename from wise-webapp/src/main/webapp/ads.txt rename to wise-webapp/src/main/resources/public/ads.txt diff --git a/wise-webapp/src/main/webapp/css/viewonly.css b/wise-webapp/src/main/resources/public/css/viewonly.css similarity index 100% rename from wise-webapp/src/main/webapp/css/viewonly.css rename to wise-webapp/src/main/resources/public/css/viewonly.css diff --git a/wise-webapp/src/main/webapp/favicon.ico b/wise-webapp/src/main/resources/public/favicon.ico similarity index 100% rename from wise-webapp/src/main/webapp/favicon.ico rename to wise-webapp/src/main/resources/public/favicon.ico diff --git a/wise-webapp/src/main/webapp/favicon.png b/wise-webapp/src/main/resources/public/favicon.png similarity index 100% rename from wise-webapp/src/main/webapp/favicon.png rename to wise-webapp/src/main/resources/public/favicon.png diff --git a/wise-webapp/src/main/webapp/images/add.svg b/wise-webapp/src/main/resources/public/images/add.svg similarity index 100% rename from wise-webapp/src/main/webapp/images/add.svg rename to wise-webapp/src/main/resources/public/images/add.svg diff --git a/wise-webapp/src/main/webapp/images/center_focus.svg b/wise-webapp/src/main/resources/public/images/center_focus.svg similarity index 100% rename from wise-webapp/src/main/webapp/images/center_focus.svg rename to wise-webapp/src/main/resources/public/images/center_focus.svg diff --git a/wise-webapp/src/main/webapp/images/logo-icon.png b/wise-webapp/src/main/resources/public/images/logo-icon.png similarity index 100% rename from wise-webapp/src/main/webapp/images/logo-icon.png rename to wise-webapp/src/main/resources/public/images/logo-icon.png diff --git a/wise-webapp/src/main/webapp/images/logo-icon.svg b/wise-webapp/src/main/resources/public/images/logo-icon.svg similarity index 100% rename from wise-webapp/src/main/webapp/images/logo-icon.svg rename to wise-webapp/src/main/resources/public/images/logo-icon.svg diff --git a/wise-webapp/src/main/webapp/images/logo-small.png b/wise-webapp/src/main/resources/public/images/logo-small.png similarity index 100% rename from wise-webapp/src/main/webapp/images/logo-small.png rename to wise-webapp/src/main/resources/public/images/logo-small.png diff --git a/wise-webapp/src/main/webapp/images/logo-text-black.svg b/wise-webapp/src/main/resources/public/images/logo-text-black.svg similarity index 100% rename from wise-webapp/src/main/webapp/images/logo-text-black.svg rename to wise-webapp/src/main/resources/public/images/logo-text-black.svg diff --git a/wise-webapp/src/main/webapp/images/minus.svg b/wise-webapp/src/main/resources/public/images/minus.svg similarity index 100% rename from wise-webapp/src/main/webapp/images/minus.svg rename to wise-webapp/src/main/resources/public/images/minus.svg diff --git a/wise-webapp/src/main/webapp/index.html b/wise-webapp/src/main/resources/public/index.html similarity index 100% rename from wise-webapp/src/main/webapp/index.html rename to wise-webapp/src/main/resources/public/index.html diff --git a/wise-webapp/src/main/webapp/robots.txt b/wise-webapp/src/main/resources/public/robots.txt similarity index 100% rename from wise-webapp/src/main/webapp/robots.txt rename to wise-webapp/src/main/resources/public/robots.txt diff --git a/wise-webapp/src/main/webapp/WEB-INF/views/init.jsp b/wise-webapp/src/main/resources/views/init.jsp similarity index 100% rename from wise-webapp/src/main/webapp/WEB-INF/views/init.jsp rename to wise-webapp/src/main/resources/views/init.jsp diff --git a/wise-webapp/src/main/webapp/WEB-INF/views/mindmapEditor.jsp b/wise-webapp/src/main/resources/views/mindmapEditor.jsp similarity index 100% rename from wise-webapp/src/main/webapp/WEB-INF/views/mindmapEditor.jsp rename to wise-webapp/src/main/resources/views/mindmapEditor.jsp diff --git a/wise-webapp/src/main/webapp/WEB-INF/views/mindmapViewonly.jsp b/wise-webapp/src/main/resources/views/mindmapViewonly.jsp similarity index 100% rename from wise-webapp/src/main/webapp/WEB-INF/views/mindmapViewonly.jsp rename to wise-webapp/src/main/resources/views/mindmapViewonly.jsp diff --git a/wise-webapp/src/main/webapp/WEB-INF/views/pageHeaders.jsf b/wise-webapp/src/main/resources/views/pageHeaders.jsf similarity index 100% rename from wise-webapp/src/main/webapp/WEB-INF/views/pageHeaders.jsf rename to wise-webapp/src/main/resources/views/pageHeaders.jsf diff --git a/wise-webapp/src/main/webapp/WEB-INF/views/reactInclude.jsp b/wise-webapp/src/main/resources/views/reactInclude.jsp similarity index 100% rename from wise-webapp/src/main/webapp/WEB-INF/views/reactInclude.jsp rename to wise-webapp/src/main/resources/views/reactInclude.jsp diff --git a/wise-webapp/src/main/webapp/META-INF/Context.xml b/wise-webapp/src/main/webapp/META-INF/Context.xml deleted file mode 100755 index 0af54be5..00000000 --- a/wise-webapp/src/main/webapp/META-INF/Context.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - diff --git a/wise-webapp/src/main/webapp/index.jsp b/wise-webapp/src/main/webapp/index.jsp deleted file mode 100644 index a444398c..00000000 --- a/wise-webapp/src/main/webapp/index.jsp +++ /dev/null @@ -1,3 +0,0 @@ -<% - response.sendRedirect("c/maps/"); -%> \ No newline at end of file