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)
|
||||
|
Reference in New Issue
Block a user