WIP
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
package com.wisemapping.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.transaction.TransactionManager;
|
||||
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;
|
||||
@@ -18,11 +19,18 @@ import org.springframework.web.servlet.view.JstlView;
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
@ComponentScan
|
||||
@SpringBootApplication
|
||||
@EnableJpaRepositories("com.wisemapping.model")
|
||||
@ImportResource("classpath:spring/wisemapping-common.xml")
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
HandlerExceptionResolver errorHandler() {
|
||||
final SimpleMappingExceptionResolver result = new SimpleMappingExceptionResolver();
|
||||
final SimpleMappingExceptionResolver result = new SimpleMappingExceptionResolver();
|
||||
|
||||
//mapping status code with view response.
|
||||
result.addStatusCode("reactInclude", 403);
|
||||
@@ -34,7 +42,7 @@ public class Application {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ViewResolver viewResolver(){
|
||||
public ViewResolver viewResolver() {
|
||||
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
|
||||
resolver.setPrefix("/WEB-INF/views/");
|
||||
resolver.setSuffix(".jsp");
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package com.wisemapping.config;
|
||||
|
||||
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;
|
||||
@@ -17,72 +15,72 @@ import java.util.Properties;
|
||||
@EnableTransactionManagement
|
||||
public class HibernateConfig {
|
||||
|
||||
@Value("${database.hibernate.dialect}")
|
||||
private String dbDialect;
|
||||
// @Value("${database.hibernate.dialect}")
|
||||
// private String dbDialect;
|
||||
//
|
||||
// @Value("${database.driver}")
|
||||
// private String dbDriver;
|
||||
//
|
||||
// @Value("${database.url}")
|
||||
// private String dbUrl;
|
||||
//
|
||||
// @Value("${database.username}")
|
||||
// private String dbUsername;
|
||||
// @Value("${database.password}")
|
||||
// private String dbPassword;
|
||||
//
|
||||
// @Value("${database.validation.enabled:true}")
|
||||
// private boolean dbSetOnBorrow;
|
||||
//
|
||||
// @Value("${database.validation.query:SELECT 1}")
|
||||
// private String dbValQuery;
|
||||
|
||||
@Value("${database.driver}")
|
||||
private String dbDriver;
|
||||
|
||||
@Value("${database.url}")
|
||||
private String dbUrl;
|
||||
|
||||
@Value("${database.username}")
|
||||
private String dbUsername;
|
||||
@Value("${database.password}")
|
||||
private String dbPassword;
|
||||
|
||||
@Value("${database.validation.enabled:true}")
|
||||
private boolean dbSetOnBorrow;
|
||||
|
||||
@Value("${database.validation.query:SELECT 1}")
|
||||
private String dbValQuery;
|
||||
|
||||
@Bean
|
||||
public LocalSessionFactoryBean sessionFactory() {
|
||||
final LocalSessionFactoryBean result = new LocalSessionFactoryBean();
|
||||
result.setPackagesToScan("com.wisemapping.model");
|
||||
result.setDataSource(dataSource());
|
||||
result.setHibernateProperties(hibernateProperties());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public HibernateTransactionManager hibernateTransactionManager() {
|
||||
final HibernateTransactionManager result = new HibernateTransactionManager();
|
||||
result.setNestedTransactionAllowed(true);
|
||||
// @Todo: Am I creatting two instances ???
|
||||
result.setSessionFactory(sessionFactory().getObject());
|
||||
return result;
|
||||
}
|
||||
|
||||
private Properties hibernateProperties() {
|
||||
final Properties result = new Properties();
|
||||
result.setProperty("hibernate.dialect", dbDialect);
|
||||
result.setProperty("hibernate.default_batch_fetch_size", "200");
|
||||
result.setProperty("hibernate.nestedTransactionAllowed", "true");
|
||||
result.setProperty("hibernate.auto_quote_keyword", "true");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
final BasicDataSource result = new BasicDataSource();
|
||||
result.setDriverClassName(dbDriver);
|
||||
result.setUrl(dbUrl);
|
||||
result.setUsername(dbUsername);
|
||||
result.setPassword(dbPassword);
|
||||
result.setTestOnBorrow(dbSetOnBorrow);
|
||||
|
||||
result.setDefaultQueryTimeout(15);
|
||||
result.setMaxTotal(100);
|
||||
result.setMaxIdle(30);
|
||||
result.setInitialSize(5);
|
||||
result.setMaxWaitMillis(10000);
|
||||
result.setValidationQuery(dbValQuery);
|
||||
|
||||
return result;
|
||||
}
|
||||
// @Bean
|
||||
// public LocalSessionFactoryBean sessionFactory() {
|
||||
// final LocalSessionFactoryBean result = new LocalSessionFactoryBean();
|
||||
// result.setPackagesToScan("com.wisemapping.model");
|
||||
// result.setDataSource(dataSource());
|
||||
// result.setHibernateProperties(hibernateProperties());
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Bean
|
||||
// public HibernateTransactionManager hibernateTransactionManager() {
|
||||
// final HibernateTransactionManager result = new HibernateTransactionManager();
|
||||
// result.setNestedTransactionAllowed(true);
|
||||
// // @Todo: Am I creatting two instances ???
|
||||
// result.setSessionFactory(sessionFactory().getObject());
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// private Properties hibernateProperties() {
|
||||
// final Properties result = new Properties();
|
||||
// result.setProperty("hibernate.dialect", dbDialect);
|
||||
// result.setProperty("hibernate.default_batch_fetch_size", "200");
|
||||
// result.setProperty("hibernate.nestedTransactionAllowed", "true");
|
||||
// result.setProperty("hibernate.auto_quote_keyword", "true");
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public DataSource dataSource() {
|
||||
// final BasicDataSource result = new BasicDataSource();
|
||||
// result.setDriverClassName(dbDriver);
|
||||
// result.setUrl(dbUrl);
|
||||
// result.setUsername(dbUsername);
|
||||
// result.setPassword(dbPassword);
|
||||
// result.setTestOnBorrow(dbSetOnBorrow);
|
||||
//
|
||||
// result.setDefaultQueryTimeout(15);
|
||||
// result.setMaxTotal(100);
|
||||
// result.setMaxIdle(30);
|
||||
// result.setInitialSize(5);
|
||||
// result.setMaxWaitMillis(10000);
|
||||
// result.setValidationQuery(dbValQuery);
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
@Repository
|
||||
public class UserManagerImpl
|
||||
implements UserManager {
|
||||
@Autowired
|
||||
// @Autowired
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
@Autowired
|
||||
|
@@ -48,7 +48,7 @@ public class RequestPropertiesInterceptor implements HandlerInterceptor {
|
||||
@Value("${site.homepage}")
|
||||
private String siteHomepage;
|
||||
|
||||
@Value("${site.baseurl}")
|
||||
@Value("${site.baseurl:}")
|
||||
private String siteUrl;
|
||||
|
||||
@Value("${security.type}")
|
||||
@@ -75,7 +75,7 @@ public class RequestPropertiesInterceptor implements HandlerInterceptor {
|
||||
request.setAttribute("security.type", securityType);
|
||||
|
||||
// If the property could not be resolved, try to infer one from the request...
|
||||
if ("${site.baseurl}".equals(siteUrl)) {
|
||||
if (siteUrl.isBlank()) {
|
||||
siteUrl = request.getRequestURL().toString().replace(request.getRequestURI(), request.getContextPath());
|
||||
}
|
||||
request.setAttribute("site.baseurl", siteUrl);
|
||||
|
@@ -50,7 +50,7 @@ public final class MailerService {
|
||||
@Value("${mail.supportEmail}")
|
||||
private String supportEmail;
|
||||
|
||||
@Value("${mail.errorReporterEmail}")
|
||||
@Value("${mail.errorReporterEmail:}")
|
||||
private String errorReporterEmail;
|
||||
|
||||
//~ Methods ..............................................................................................
|
||||
|
@@ -34,15 +34,15 @@ import com.wisemapping.service.google.http.HttpInvokerException;
|
||||
public class GoogleService {
|
||||
@Autowired
|
||||
private HttpInvoker httpInvoker;
|
||||
@Value("${security.oauth2.google.confirmUrl}")
|
||||
@Value("${security.oauth2.google.confirmUrl:}")
|
||||
private String optinConfirmUrl;
|
||||
@Value("${security.oauth2.google.userinfoUrl}")
|
||||
@Value("${security.oauth2.google.userinfoUrl:}")
|
||||
private String accountBasicDataUrl;
|
||||
@Value("${security.oauth2.google.clientId}")
|
||||
@Value("${security.oauth2.google.clientId:}")
|
||||
private String clientId;
|
||||
@Value("${security.oauth2.google.clientSecret}")
|
||||
@Value("${security.oauth2.google.clientSecret:}")
|
||||
private String clientSecret;
|
||||
@Value("${security.oauth2.google.callbackUrl}")
|
||||
@Value("${security.oauth2.google.callbackUrl:}")
|
||||
private String callbackUrl;
|
||||
|
||||
public void setHttpInvoker(HttpInvoker httpInvoker) {
|
||||
|
@@ -31,7 +31,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
@PreAuthorize("permitAll()")
|
||||
public class MvcLoginController {
|
||||
|
||||
@Value("${database.driver}")
|
||||
// @Value("${database.driver}")
|
||||
private String driver;
|
||||
|
||||
@RequestMapping(value = "login", method = RequestMethod.GET)
|
||||
|
@@ -22,15 +22,16 @@
|
||||
#database.validation.enabled=false
|
||||
|
||||
|
||||
# HSQL Configuration properties
|
||||
database.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping
|
||||
database.driver=org.hsqldb.jdbc.JDBCDriver
|
||||
database.hibernate.dialect=org.hibernate.dialect.HSQLDialect
|
||||
|
||||
database.username=sa
|
||||
database.password=
|
||||
database.validation.enabled=false
|
||||
database.validation.query=
|
||||
##database.base.url=/Users/veigap/repos/wisemapping-open-source/wise-webapp
|
||||
### HSQL Configuration properties
|
||||
##database.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping
|
||||
##database.driver=org.hsqldb.jdbc.JDBCDriver
|
||||
##database.hibernate.dialect=org.hibernate.dialect.HSQLDialect
|
||||
#
|
||||
#database.username=sa
|
||||
#database.password=
|
||||
#database.validation.enabled=false
|
||||
#database.validation.query=
|
||||
|
||||
##################################################################################
|
||||
# Mail configuration. Must be configured to enable user registration confirmation.
|
||||
@@ -149,7 +150,9 @@ security.oauth2.google.confirmUrl=https://oauth2.googleapis.com/token
|
||||
# Google service for get user data (name, email, etc)
|
||||
security.oauth2.google.userinfoUrl=https://www.googleapis.com/oauth2/v3/userinfo
|
||||
# Url for starting auth process with google
|
||||
security.oauth2.google.url=https://accounts.google.com/o/oauth2/v2/auth?redirect_uri=${security.oauth2.google.callbackUrl}&prompt=consent&response_type=code&client_id=${security.oauth2.google.clientId}&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&access_type=offline&state=wisemapping&include_granted_scopes=true
|
||||
|
||||
@Todo
|
||||
security.oauth2.google.url=https//review
|
||||
|
||||
|
||||
|
||||
@@ -161,3 +164,21 @@ security.oauth2.google.url=https://accounts.google.com/o/oauth2/v2/auth?redirect
|
||||
# Coma separated list of domains and emails ban
|
||||
#accounts.exclusion.domain=
|
||||
|
||||
|
||||
#######################################################################################
|
||||
# Spring related configurations
|
||||
#######################################################################################
|
||||
spring.main.allow-circular-references=true
|
||||
|
||||
database.base.url=/Users/veigap/repos/wisemapping-open-source/wise-webapp
|
||||
spring.datasource.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=
|
||||
spring.datasource.driver-class-name = org.hsqldb.jdbc.JDBCDriver
|
||||
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
|
||||
|
||||
|
||||
|
@@ -1,13 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<context:property-placeholder location="/WEB-INF/app.properties" ignore-unresolvable="true"/>
|
||||
<!-- <context:property-placeholder location="/WEB-INF/app.properties" ignore-unresolvable="true"/>-->
|
||||
|
||||
<import resource="wisemapping-service.xml"/>
|
||||
<import resource="wisemapping-servlet.xml"/>
|
||||
|
@@ -50,12 +50,12 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
||||
<property name="defaultEncoding" value="UTF-8"/>
|
||||
<property name="basenames">
|
||||
<list>
|
||||
<value>messages</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
<!-- <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">-->
|
||||
<!-- <property name="defaultEncoding" value="UTF-8"/>-->
|
||||
<!-- <property name="basenames">-->
|
||||
<!-- <list>-->
|
||||
<!-- <value>messages</value>-->
|
||||
<!-- </list>-->
|
||||
<!-- </property>-->
|
||||
<!-- </bean>-->
|
||||
</beans>
|
@@ -19,16 +19,16 @@
|
||||
<bean id="requestInterceptor" class="com.wisemapping.filter.RequestPropertiesInterceptor"/>
|
||||
</mvc:interceptors>
|
||||
|
||||
<bean id="localeResolver"
|
||||
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
|
||||
</bean>
|
||||
<!-- <bean id="localeResolver"-->
|
||||
<!-- class="org.springframework.web.servlet.i18n.SessionLocaleResolver">-->
|
||||
<!-- </bean>-->
|
||||
|
||||
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
||||
<property name="defaultEncoding" value="UTF-8"/>
|
||||
<property name="basenames">
|
||||
<list>
|
||||
<value>messages</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
<!-- <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">-->
|
||||
<!-- <property name="defaultEncoding" value="UTF-8"/>-->
|
||||
<!-- <property name="basenames">-->
|
||||
<!-- <list>-->
|
||||
<!-- <value>messages</value>-->
|
||||
<!-- </list>-->
|
||||
<!-- </property>-->
|
||||
<!-- </bean>-->
|
||||
</beans>
|
||||
|
Reference in New Issue
Block a user