diff --git a/wise-webapp/src/main/java/com/wisemapping/config/AppConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/Application.java similarity index 87% rename from wise-webapp/src/main/java/com/wisemapping/config/AppConfig.java rename to wise-webapp/src/main/java/com/wisemapping/config/Application.java index a31c0be8..b406ca6e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/AppConfig.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/Application.java @@ -2,11 +2,11 @@ package com.wisemapping.config; import org.springframework.beans.factory.annotation.Autowired; 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.transaction.TransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; -import org.springframework.transaction.interceptor.TransactionAttributeSource; -import org.springframework.transaction.interceptor.TransactionInterceptor; import org.springframework.web.servlet.HandlerExceptionResolver; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; @@ -17,7 +17,9 @@ import org.springframework.web.servlet.view.JstlView; @EnableWebMvc @Configuration @EnableTransactionManagement -public class AppConfig { +@ComponentScan +@ImportResource("classpath:spring/wisemapping-common.xml") +public class Application { @Autowired TransactionManager txManager; diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/DebugMappingJacksonHttpMessageConverter.java b/wise-webapp/src/main/java/com/wisemapping/rest/DebugMappingJacksonHttpMessageConverter.java deleted file mode 100644 index ddcff5fe..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/rest/DebugMappingJacksonHttpMessageConverter.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright [2022] [wisemapping] - * - * Licensed under WiseMapping Public License, Version 1.0 (the "License"). - * It is basically the Apache License, Version 2.0 (the "License") plus the - * "powered by wisemapping" text requirement on every single page; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the license at - * - * http://www.wisemapping.org/license - * - * 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 com.wisemapping.rest; - -import org.apache.commons.io.IOUtils; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpInputMessage; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; - - -public class DebugMappingJacksonHttpMessageConverter extends MappingJackson2HttpMessageConverter { - - @Override - protected Object readInternal(Class clazz, HttpInputMessage inputMessage) throws JsonHttpMessageNotReadableException { - try { - final byte[] bytes = IOUtils.toByteArray(inputMessage.getBody()); - final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); - final WrapHttpInputMessage wrap = new WrapHttpInputMessage(bais, inputMessage.getHeaders()); - - return super.readInternal(clazz, wrap); - - } catch (HttpMessageNotReadableException | IOException e) { - throw new JsonHttpMessageNotReadableException("Request Body could not be read", e); - } - } -} - - -class WrapHttpInputMessage implements HttpInputMessage { - private final InputStream body; - private final HttpHeaders headers; - - WrapHttpInputMessage(InputStream is, HttpHeaders headers) { - this.body = is; - this.headers = headers; - } - - @Override - public InputStream getBody() { - return body; - } - - @Override - public HttpHeaders getHeaders() { - return headers; - } -} diff --git a/wise-webapp/src/main/java/com/wisemapping/security/UserDetailsService.java b/wise-webapp/src/main/java/com/wisemapping/security/UserDetailsService.java index f74a582d..42725a89 100644 --- a/wise-webapp/src/main/java/com/wisemapping/security/UserDetailsService.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/UserDetailsService.java @@ -23,13 +23,16 @@ import com.wisemapping.model.User; import com.wisemapping.service.UserService; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.springframework.context.annotation.Bean; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataAccessException; import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; +@Service public class UserDetailsService implements org.springframework.security.core.userdetails.UserDetailsService { + @Autowired private UserService userService; private String adminUser; diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/log4j2-stdout.xml b/wise-webapp/src/main/resources/log4j2-stdout.xml similarity index 100% rename from wise-webapp/src/main/webapp/WEB-INF/classes/log4j2-stdout.xml rename to wise-webapp/src/main/resources/log4j2-stdout.xml diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/log4j2.xml b/wise-webapp/src/main/resources/log4j2.xml similarity index 100% rename from wise-webapp/src/main/webapp/WEB-INF/classes/log4j2.xml rename to wise-webapp/src/main/resources/log4j2.xml diff --git a/wise-webapp/src/main/webapp/WEB-INF/spring.tld b/wise-webapp/src/main/resources/spring/spring.tld similarity index 100% rename from wise-webapp/src/main/webapp/WEB-INF/spring.tld rename to wise-webapp/src/main/resources/spring/spring.tld diff --git a/wise-webapp/src/main/resources/spring/wisemapping-common.xml b/wise-webapp/src/main/resources/spring/wisemapping-common.xml new file mode 100644 index 00000000..6697c0cd --- /dev/null +++ b/wise-webapp/src/main/resources/spring/wisemapping-common.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-dao.xml b/wise-webapp/src/main/resources/spring/wisemapping-dao.xml similarity index 100% rename from wise-webapp/src/main/webapp/WEB-INF/wisemapping-dao.xml rename to wise-webapp/src/main/resources/spring/wisemapping-dao.xml diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-datasource.xml b/wise-webapp/src/main/resources/spring/wisemapping-datasource.xml similarity index 100% rename from wise-webapp/src/main/webapp/WEB-INF/wisemapping-datasource.xml rename to wise-webapp/src/main/resources/spring/wisemapping-datasource.xml diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-rest.xml b/wise-webapp/src/main/resources/spring/wisemapping-rest.xml similarity index 95% rename from wise-webapp/src/main/webapp/WEB-INF/wisemapping-rest.xml rename to wise-webapp/src/main/resources/spring/wisemapping-rest.xml index f6d279e1..6fbcb6a1 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-rest.xml +++ b/wise-webapp/src/main/resources/spring/wisemapping-rest.xml @@ -13,11 +13,10 @@ http://www.springframework.org/schema/mvc/spring-mvc.xsd"> - - + diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security-db.xml b/wise-webapp/src/main/resources/spring/wisemapping-security-db.xml similarity index 100% rename from wise-webapp/src/main/webapp/WEB-INF/wisemapping-security-db.xml rename to wise-webapp/src/main/resources/spring/wisemapping-security-db.xml diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security-ldap.xml b/wise-webapp/src/main/resources/spring/wisemapping-security-ldap.xml similarity index 100% rename from wise-webapp/src/main/webapp/WEB-INF/wisemapping-security-ldap.xml rename to wise-webapp/src/main/resources/spring/wisemapping-security-ldap.xml diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-service.xml b/wise-webapp/src/main/resources/spring/wisemapping-service.xml similarity index 95% rename from wise-webapp/src/main/webapp/WEB-INF/wisemapping-service.xml rename to wise-webapp/src/main/resources/spring/wisemapping-service.xml index 581baba5..075d2ceb 100755 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-service.xml +++ b/wise-webapp/src/main/resources/spring/wisemapping-service.xml @@ -33,5 +33,5 @@ - + diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml b/wise-webapp/src/main/resources/spring/wisemapping-servlet.xml similarity index 96% rename from wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml rename to wise-webapp/src/main/resources/spring/wisemapping-servlet.xml index 847e46b6..6c0adfb2 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml +++ b/wise-webapp/src/main/resources/spring/wisemapping-servlet.xml @@ -12,8 +12,6 @@ http://www.springframework.org/schema/mvc/spring-mvc.xsd"> - - diff --git a/wise-webapp/src/main/webapp/WEB-INF/web.xml b/wise-webapp/src/main/webapp/WEB-INF/web.xml index 4b04bc68..80132f68 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/web.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/web.xml @@ -24,10 +24,7 @@ contextConfigLocation - /WEB-INF/wisemapping-datasource.xml - /WEB-INF/wisemapping-dao.xml - /WEB-INF/wisemapping-service.xml - /WEB-INF/wisemapping-servlet.xml + classpath:spring/wisemapping-common.xml @@ -35,8 +32,7 @@ contextInitializerClasses com.wisemapping.webmvc.ApplicationContextInitializer - - +