From 66bd3edc9d361dcc90af24ae185967e1d1956b27 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 15:37:48 +0200 Subject: [PATCH 01/17] migrate spring-boot --- pom.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pom.xml b/pom.xml index 4e9d7592..465fe9be 100644 --- a/pom.xml +++ b/pom.xml @@ -84,6 +84,11 @@ + + org.springframework.boot + spring-boot-properties-migrator + runtime + @@ -49,7 +49,7 @@ 1.8 - 2.1.3 + 2.2.1 5.11.1.Final 1.11.2 2.5.3 @@ -58,7 +58,7 @@ 3.0.0 3.0.0 3.11.0 - 2.22.1 + 3.0.0-M4 2.7 2.8.2 org.woehlke.simpleworklist.SimpleworklistApplication @@ -399,12 +399,13 @@ maven-source-plugin ${maven-source-plugin.version} + org.apache.maven.plugins maven-war-plugin @@ -1049,7 +1050,6 @@ org.apache.maven.plugins maven-surefire-report-plugin - ${maven-surefire-report-plugin.version} diff --git a/src/test/java/org/woehlke/simpleworklist/model/services/impl/UserAccountServiceImplTest.java b/src/test/java/org/woehlke/simpleworklist/model/services/impl/UserAccountServiceImplTest.java index c6189e35..897d8fb7 100644 --- a/src/test/java/org/woehlke/simpleworklist/model/services/impl/UserAccountServiceImplTest.java +++ b/src/test/java/org/woehlke/simpleworklist/model/services/impl/UserAccountServiceImplTest.java @@ -1,187 +1,187 @@ -package org.woehlke.simpleworklist.model.services.impl; - -import org.springframework.beans.factory.annotation.Autowired; - -import org.junit.Assert; - -import org.junit.Test; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.woehlke.simpleworklist.AbstractTest; -import org.woehlke.simpleworklist.oodm.services.UserPasswordRecoveryService; -import org.woehlke.simpleworklist.oodm.services.UserRegistrationService; -import org.woehlke.simpleworklist.model.beans.LoginForm; -import org.woehlke.simpleworklist.model.beans.UserAccountForm; -import org.woehlke.simpleworklist.oodm.entities.UserAccount; - - -public class UserAccountServiceImplTest extends AbstractTest { - - @Autowired - private UserRegistrationService registrationService; - - @Autowired - private UserPasswordRecoveryService userPasswordRecoveryService; - - @Test - public void testStartSecondOptIn() throws Exception { - int zeroNumberOfAllRegistrations = 0; - deleteAll(); - String email = applicationProperties.getRegistration().getMailFrom(); - Assert.assertEquals(zeroNumberOfAllRegistrations, testHelperService.getNumberOfAllRegistrations()); - Assert.assertNotNull(email); - Assert.assertTrue(userAccountService.isEmailAvailable(email)); - registrationService.registrationSendEmailTo(email); - Assert.assertFalse(registrationService.registrationIsRetryAndMaximumNumberOfRetries(email)); - Assert.assertTrue(userAccountService.isEmailAvailable(email)); - registrationService.registrationSendEmailTo(email); - Assert.assertFalse(registrationService.registrationIsRetryAndMaximumNumberOfRetries(email)); - registrationService.registrationSendEmailTo(email); - Assert.assertFalse(registrationService.registrationIsRetryAndMaximumNumberOfRetries(email)); - registrationService.registrationSendEmailTo(email); - Assert.assertFalse(registrationService.registrationIsRetryAndMaximumNumberOfRetries(email)); - registrationService.registrationSendEmailTo(email); - Assert.assertFalse(registrationService.registrationIsRetryAndMaximumNumberOfRetries(email)); - registrationService.registrationSendEmailTo(email); - Assert.assertTrue(registrationService.registrationIsRetryAndMaximumNumberOfRetries(email)); - int sixSeconds = 6000; - Thread.sleep(sixSeconds); - deleteAll(); - Assert.assertEquals(zeroNumberOfAllRegistrations, testHelperService.getNumberOfAllRegistrations()); - } - - @Test - public void testPasswordResetSendEmail() throws Exception { - deleteAll(); - for(UserAccount userAccount:testUser){ - userAccountService.saveAndFlush(userAccount); - } - int zeroNumberOfAllRegistrations = 0; - Assert.assertEquals(zeroNumberOfAllRegistrations, testHelperService.getNumberOfAllRegistrations()); - Assert.assertNotNull(emails[0]); - Assert.assertFalse(userAccountService.isEmailAvailable(emails[0])); - userPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]); - Assert.assertFalse(userPasswordRecoveryService.passwordRecoveryIsRetryAndMaximumNumberOfRetries(emails[0])); - Assert.assertFalse(userAccountService.isEmailAvailable(emails[0])); - userPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]); - Assert.assertFalse(userPasswordRecoveryService.passwordRecoveryIsRetryAndMaximumNumberOfRetries(emails[0])); - userPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]); - Assert.assertFalse(userPasswordRecoveryService.passwordRecoveryIsRetryAndMaximumNumberOfRetries(emails[0])); - userPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]); - Assert.assertFalse(userPasswordRecoveryService.passwordRecoveryIsRetryAndMaximumNumberOfRetries(emails[0])); - userPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]); - Assert.assertFalse(userPasswordRecoveryService.passwordRecoveryIsRetryAndMaximumNumberOfRetries(emails[0])); - userPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]); - Assert.assertTrue(userPasswordRecoveryService.passwordRecoveryIsRetryAndMaximumNumberOfRetries(emails[0])); - int sixSeconds = 6000; - Thread.sleep(sixSeconds); - deleteAll(); - Assert.assertEquals(zeroNumberOfAllRegistrations, testHelperService.getNumberOfAllRegistrations()); - } - - @Test - public void testSaveAndFlush(){ - deleteAll(); - for(UserAccount userAccount:testUser){ - userAccountService.saveAndFlush(userAccount); - } - for(String email:emails){ - UserAccount user = userAccountService.findByUserEmail(email); - Assert.assertTrue(user.getUserEmail().compareTo(email) == 0); - } - Pageable request = new PageRequest(0,10); - for(UserAccount user: userAccountService.findAll(request)){ - Assert.assertNotNull(user.getId()); - Assert.assertNotNull(user.getUserEmail()); - Assert.assertNotNull(user.getUserPassword()); - Assert.assertNotNull(user.getUserFullname()); - Assert.assertNotNull(user.getRowCreatedAt()); - } - } - - @Test - public void testLoadUserByUsername(){ - for(String email:emails){ - UserDetails userDetails = userAccountSecurityService.loadUserByUsername(email); - Assert.assertTrue(userDetails.getUsername().compareTo(email) == 0); - } - try { - UserDetails userDetails = userAccountSecurityService.loadUserByUsername(username_email); - } catch (UsernameNotFoundException e){ - Assert.assertNotNull(e.getMessage()); - Assert.assertTrue(username_email.compareTo(e.getMessage())==0); - } - } - - @Test - public void testAuthorize(){ - LoginForm loginForm = new LoginForm(); - loginForm.setUserEmail(emails[0]); - loginForm.setUserPassword(passwords[0]); - Assert.assertTrue(userAccountAccessService.authorize(loginForm)); - loginForm = new LoginForm(); - loginForm.setUserEmail(username_email); - loginForm.setUserPassword(password); - Assert.assertFalse(userAccountAccessService.authorize(loginForm)); - } - - @Test - public void testIsEmailAvailable() { - Assert.assertFalse(userAccountService.isEmailAvailable(emails[0])); - Assert.assertTrue(userAccountService.isEmailAvailable(username_email)); - } - - @Test - public void testCreateUser() { - UserAccountForm userAccount = new UserAccountForm(); - userAccount.setUserEmail(username_email); - userAccount.setUserPassword(password); - userAccount.setUserPasswordConfirmation(password); - userAccount.setUserFullname(full_name); - userAccountService.createUser(userAccount); - Assert.assertFalse(userAccountService.isEmailAvailable(username_email)); - } - - @Test - public void testChangeUsersPassword(){ - UserAccountForm userAccount = new UserAccountForm(); - userAccount.setUserEmail(emails[0]); - userAccount.setUserPassword(password + "_NEU"); - userAccount.setUserPasswordConfirmation(password + "_NEU"); - userAccount.setUserFullname(fullnames[0]); - userAccountService.changeUsersPassword(userAccount); - } - - @Test - public void testRetrieveUsernameLoggedOut(){ - String userName = userAccountLoginSuccessService.retrieveUsername(); - Assert.assertTrue(userName.compareTo(" ")==0); - } - - @Test - public void testRetrieveUsernameLoggedIn(){ - makeActiveUser(emails[0]); - String userName = userAccountLoginSuccessService.retrieveUsername(); - Assert.assertNotNull(userName); - Assert.assertTrue(emails[0].compareTo(userName) == 0); - SecurityContextHolder.clearContext(); - } - - @Test(expected = UsernameNotFoundException.class) - public void testRetrieveCurrentUserLoggedOut(){ - userAccountLoginSuccessService.retrieveCurrentUser(); - } - - @Test - public void testRetrieveCurrentUserLoggedIn(){ - makeActiveUser(emails[0]); - UserAccount userAccount = userAccountLoginSuccessService.retrieveCurrentUser(); - Assert.assertNotNull(userAccount); - Assert.assertTrue(emails[0].compareTo(userAccount.getUserEmail()) == 0); - SecurityContextHolder.clearContext(); - deleteAll(); - } -} +package org.woehlke.simpleworklist.model.services.impl; + +import org.springframework.beans.factory.annotation.Autowired; + +import org.junit.Assert; + +import org.junit.Test; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.woehlke.simpleworklist.AbstractTest; +import org.woehlke.simpleworklist.oodm.services.UserPasswordRecoveryService; +import org.woehlke.simpleworklist.oodm.services.UserRegistrationService; +import org.woehlke.simpleworklist.model.beans.LoginForm; +import org.woehlke.simpleworklist.model.beans.UserAccountForm; +import org.woehlke.simpleworklist.oodm.entities.UserAccount; + + +public class UserAccountServiceImplTest extends AbstractTest { + + @Autowired + private UserRegistrationService registrationService; + + @Autowired + private UserPasswordRecoveryService userPasswordRecoveryService; + + @Test + public void testStartSecondOptIn() throws Exception { + int zeroNumberOfAllRegistrations = 0; + deleteAll(); + String email = applicationProperties.getRegistration().getMailFrom(); + Assert.assertEquals(zeroNumberOfAllRegistrations, testHelperService.getNumberOfAllRegistrations()); + Assert.assertNotNull(email); + Assert.assertTrue(userAccountService.isEmailAvailable(email)); + registrationService.registrationSendEmailTo(email); + Assert.assertFalse(registrationService.registrationIsRetryAndMaximumNumberOfRetries(email)); + Assert.assertTrue(userAccountService.isEmailAvailable(email)); + registrationService.registrationSendEmailTo(email); + Assert.assertFalse(registrationService.registrationIsRetryAndMaximumNumberOfRetries(email)); + registrationService.registrationSendEmailTo(email); + Assert.assertFalse(registrationService.registrationIsRetryAndMaximumNumberOfRetries(email)); + registrationService.registrationSendEmailTo(email); + Assert.assertFalse(registrationService.registrationIsRetryAndMaximumNumberOfRetries(email)); + registrationService.registrationSendEmailTo(email); + Assert.assertFalse(registrationService.registrationIsRetryAndMaximumNumberOfRetries(email)); + registrationService.registrationSendEmailTo(email); + Assert.assertTrue(registrationService.registrationIsRetryAndMaximumNumberOfRetries(email)); + int sixSeconds = 6000; + Thread.sleep(sixSeconds); + deleteAll(); + Assert.assertEquals(zeroNumberOfAllRegistrations, testHelperService.getNumberOfAllRegistrations()); + } + + @Test + public void testPasswordResetSendEmail() throws Exception { + deleteAll(); + for(UserAccount userAccount:testUser){ + userAccountService.saveAndFlush(userAccount); + } + int zeroNumberOfAllRegistrations = 0; + Assert.assertEquals(zeroNumberOfAllRegistrations, testHelperService.getNumberOfAllRegistrations()); + Assert.assertNotNull(emails[0]); + Assert.assertFalse(userAccountService.isEmailAvailable(emails[0])); + userPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]); + Assert.assertFalse(userPasswordRecoveryService.passwordRecoveryIsRetryAndMaximumNumberOfRetries(emails[0])); + Assert.assertFalse(userAccountService.isEmailAvailable(emails[0])); + userPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]); + Assert.assertFalse(userPasswordRecoveryService.passwordRecoveryIsRetryAndMaximumNumberOfRetries(emails[0])); + userPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]); + Assert.assertFalse(userPasswordRecoveryService.passwordRecoveryIsRetryAndMaximumNumberOfRetries(emails[0])); + userPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]); + Assert.assertFalse(userPasswordRecoveryService.passwordRecoveryIsRetryAndMaximumNumberOfRetries(emails[0])); + userPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]); + Assert.assertFalse(userPasswordRecoveryService.passwordRecoveryIsRetryAndMaximumNumberOfRetries(emails[0])); + userPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]); + Assert.assertTrue(userPasswordRecoveryService.passwordRecoveryIsRetryAndMaximumNumberOfRetries(emails[0])); + int sixSeconds = 6000; + Thread.sleep(sixSeconds); + deleteAll(); + Assert.assertEquals(zeroNumberOfAllRegistrations, testHelperService.getNumberOfAllRegistrations()); + } + + @Test + public void testSaveAndFlush(){ + deleteAll(); + for(UserAccount userAccount:testUser){ + userAccountService.saveAndFlush(userAccount); + } + for(String email:emails){ + UserAccount user = userAccountService.findByUserEmail(email); + Assert.assertTrue(user.getUserEmail().compareTo(email) == 0); + } + Pageable request = PageRequest.of(0,10); + for(UserAccount user: userAccountService.findAll(request)){ + Assert.assertNotNull(user.getId()); + Assert.assertNotNull(user.getUserEmail()); + Assert.assertNotNull(user.getUserPassword()); + Assert.assertNotNull(user.getUserFullname()); + Assert.assertNotNull(user.getRowCreatedAt()); + } + } + + @Test + public void testLoadUserByUsername(){ + for(String email:emails){ + UserDetails userDetails = userAccountSecurityService.loadUserByUsername(email); + Assert.assertTrue(userDetails.getUsername().compareTo(email) == 0); + } + try { + UserDetails userDetails = userAccountSecurityService.loadUserByUsername(username_email); + } catch (UsernameNotFoundException e){ + Assert.assertNotNull(e.getMessage()); + Assert.assertTrue(username_email.compareTo(e.getMessage())==0); + } + } + + @Test + public void testAuthorize(){ + LoginForm loginForm = new LoginForm(); + loginForm.setUserEmail(emails[0]); + loginForm.setUserPassword(passwords[0]); + Assert.assertTrue(userAccountAccessService.authorize(loginForm)); + loginForm = new LoginForm(); + loginForm.setUserEmail(username_email); + loginForm.setUserPassword(password); + Assert.assertFalse(userAccountAccessService.authorize(loginForm)); + } + + @Test + public void testIsEmailAvailable() { + Assert.assertFalse(userAccountService.isEmailAvailable(emails[0])); + Assert.assertTrue(userAccountService.isEmailAvailable(username_email)); + } + + @Test + public void testCreateUser() { + UserAccountForm userAccount = new UserAccountForm(); + userAccount.setUserEmail(username_email); + userAccount.setUserPassword(password); + userAccount.setUserPasswordConfirmation(password); + userAccount.setUserFullname(full_name); + userAccountService.createUser(userAccount); + Assert.assertFalse(userAccountService.isEmailAvailable(username_email)); + } + + @Test + public void testChangeUsersPassword(){ + UserAccountForm userAccount = new UserAccountForm(); + userAccount.setUserEmail(emails[0]); + userAccount.setUserPassword(password + "_NEU"); + userAccount.setUserPasswordConfirmation(password + "_NEU"); + userAccount.setUserFullname(fullnames[0]); + userAccountService.changeUsersPassword(userAccount); + } + + @Test + public void testRetrieveUsernameLoggedOut(){ + String userName = userAccountLoginSuccessService.retrieveUsername(); + Assert.assertTrue(userName.compareTo(" ")==0); + } + + @Test + public void testRetrieveUsernameLoggedIn(){ + makeActiveUser(emails[0]); + String userName = userAccountLoginSuccessService.retrieveUsername(); + Assert.assertNotNull(userName); + Assert.assertTrue(emails[0].compareTo(userName) == 0); + SecurityContextHolder.clearContext(); + } + + @Test(expected = UsernameNotFoundException.class) + public void testRetrieveCurrentUserLoggedOut(){ + userAccountLoginSuccessService.retrieveCurrentUser(); + } + + @Test + public void testRetrieveCurrentUserLoggedIn(){ + makeActiveUser(emails[0]); + UserAccount userAccount = userAccountLoginSuccessService.retrieveCurrentUser(); + Assert.assertNotNull(userAccount); + Assert.assertTrue(emails[0].compareTo(userAccount.getUserEmail()) == 0); + SecurityContextHolder.clearContext(); + deleteAll(); + } +} diff --git a/src/test/java/org/woehlke/simpleworklist/oodm/Matchers.java b/src/test/java/org/woehlke/simpleworklist/oodm/Matchers.java index e836daf8..a5e549f0 100644 --- a/src/test/java/org/woehlke/simpleworklist/oodm/Matchers.java +++ b/src/test/java/org/woehlke/simpleworklist/oodm/Matchers.java @@ -1,39 +1,39 @@ -package org.woehlke.simpleworklist.oodm; - -import org.hamcrest.Factory; -import org.hamcrest.Matcher; -import org.woehlke.simpleworklist.oodm.entities.Project; -import org.woehlke.simpleworklist.oodm.entities.Task; - -public class Matchers { - - @Factory - public static Matcher categoryNotNullObject() { - return new IsNotNullObjectOfCategory(); - } - - @Factory - public static Matcher categoryNullObject() { - return new IsNullObjectOfCategory(); - } - - @Factory - public static Matcher categorySameIdObject(long id) { - return new IsSameObjectOfCategory(id); - } - - @Factory - public static Matcher actionItemNullObject() { - return new IsNullObjectOfActionItem(); - } - - @Factory - public static Matcher actionItemNotNullObject() { - return new IsNotNullObjectOfActionItem(); - } - - @Factory - public static Matcher actionItemSameIdObject(long id) { - return new IsSameObjectOfActionItem(id); - } -} +package org.woehlke.simpleworklist.oodm; + +//import org.hamcrest.Factory; +import org.hamcrest.Matcher; +import org.woehlke.simpleworklist.oodm.entities.Project; +import org.woehlke.simpleworklist.oodm.entities.Task; + +public class Matchers { + + //@Factory + public static Matcher categoryNotNullObject() { + return new IsNotNullObjectOfCategory(); + } + + //@Factory + public static Matcher categoryNullObject() { + return new IsNullObjectOfCategory(); + } + + //@Factory + public static Matcher categorySameIdObject(long id) { + return new IsSameObjectOfCategory(id); + } + + //@Factory + public static Matcher actionItemNullObject() { + return new IsNullObjectOfActionItem(); + } + + //@Factory + public static Matcher actionItemNotNullObject() { + return new IsNotNullObjectOfActionItem(); + } + + //@Factory + public static Matcher actionItemSameIdObject(long id) { + return new IsSameObjectOfActionItem(id); + } +} From 2765a294a3f284c803c4fe4cb35be0745298fd90 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 16:35:24 +0200 Subject: [PATCH 03/17] migrate spring-boot --- pom.xml | 24 - .../model/dao/impl/SearchDaoImpl.java | 170 +--- .../simpleworklist/oodm/entities/Context.java | 329 ++++--- .../simpleworklist/oodm/entities/Project.java | 457 +++++----- .../simpleworklist/oodm/entities/Task.java | 849 +++++++++--------- .../oodm/entities/UserAccount.java | 482 +++++----- 6 files changed, 1087 insertions(+), 1224 deletions(-) diff --git a/pom.xml b/pom.xml index 51fb73c1..4276de90 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,6 @@ 1.8 2.2.1 - 5.11.1.Final 1.11.2 2.5.3 3.0.0 @@ -186,29 +185,6 @@ spring-security-test test - - org.hibernate - hibernate-search-orm - ${hibernate-search.version} - - - org.hibernate - hibernate-search-engine - ${hibernate-search.version} - - - - org.apache.lucene - lucene-core - 5.5.5 - org.webjars diff --git a/src/main/java/org/woehlke/simpleworklist/model/dao/impl/SearchDaoImpl.java b/src/main/java/org/woehlke/simpleworklist/model/dao/impl/SearchDaoImpl.java index 38d85514..77faf70f 100644 --- a/src/main/java/org/woehlke/simpleworklist/model/dao/impl/SearchDaoImpl.java +++ b/src/main/java/org/woehlke/simpleworklist/model/dao/impl/SearchDaoImpl.java @@ -1,134 +1,36 @@ -package org.woehlke.simpleworklist.model.dao.impl; - -import org.hibernate.search.jpa.FullTextEntityManager; -import org.hibernate.search.query.dsl.QueryBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Repository; -import org.woehlke.simpleworklist.oodm.entities.Project; -import org.woehlke.simpleworklist.oodm.entities.Task; -import org.woehlke.simpleworklist.oodm.entities.UserAccount; -import org.woehlke.simpleworklist.model.beans.SearchResult; -import org.woehlke.simpleworklist.model.dao.SearchDao; - -import javax.persistence.*; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by tw on 14.02.16. - */ -@Repository -public class SearchDaoImpl implements SearchDao { - - private static final Logger LOGGER = LoggerFactory.getLogger(SearchDaoImpl.class); - - @PersistenceContext - private EntityManager em; - - @Override - public SearchResult search(String searchterm, UserAccount userAccount) { - try { - SearchResult searchResult = new SearchResult(); - searchResult.setSearchterm(searchterm); - List taskList = new ArrayList<>(); - List projectList = new ArrayList<>(); - FullTextEntityManager fullTextEntityManager = - org.hibernate.search.jpa.Search.getFullTextEntityManager(em); - // create native Lucene query unsing the query DSL - // alternatively you can write the Lucene query using the Lucene query parser - // or the Lucene programmatic API. The Hibernate Search DSL is recommended though - QueryBuilder qb = fullTextEntityManager.getSearchFactory() - .buildQueryBuilder().forEntity(Task.class).get(); - org.apache.lucene.search.Query luceneQuery1 = qb - .keyword() - .onFields("title", "text") - .matching(searchterm) - .createQuery(); - org.apache.lucene.search.Query luceneQuery2 = qb - .keyword() - .onFields("userAccount.id") - .matching(userAccount.getId().toString()) - .createQuery(); - org.apache.lucene.search.Query luceneQuery = qb - .bool() - .must(luceneQuery1) - .must(luceneQuery2) - .createQuery(); - LOGGER.info(luceneQuery.toString()); - // wrap Lucene query in a javax.persistence.Query - javax.persistence.Query jpaQuery = - fullTextEntityManager.createFullTextQuery(luceneQuery, Task.class); - // execute search - List result = jpaQuery.getResultList(); - for (Object foundItem : result) { - if (foundItem instanceof Task) { - Task item = (Task) foundItem; - LOGGER.info("found: " + item.toString()); - taskList.add(item); - } else { - LOGGER.info("found: " + foundItem.toString()); - } - } - searchResult.setTaskList(taskList); - qb = fullTextEntityManager.getSearchFactory() - .buildQueryBuilder().forEntity(Project.class).get(); - luceneQuery1 = qb - .keyword() - .onFields("name", "description") - .matching(searchterm) - .createQuery(); - luceneQuery2 = qb - .keyword() - .onFields("userAccount.id") - .matching(userAccount.getId().toString()) - .createQuery(); - luceneQuery = qb - .bool() - .must(luceneQuery1) - .must(luceneQuery2) - .createQuery(); - LOGGER.info(luceneQuery.toString()); - // wrap Lucene query in a javax.persistence.Query - jpaQuery = - fullTextEntityManager.createFullTextQuery(luceneQuery, Project.class); - // execute search - result = jpaQuery.getResultList(); - for (Object foundItem : result) { - if (foundItem instanceof Project) { - Project item = (Project) foundItem; - LOGGER.info("found: " + item.toString()); - projectList.add(item); - } else { - LOGGER.info("found: " + foundItem.toString()); - } - } - searchResult.setProjectList(projectList); - return searchResult; - } catch (RuntimeException e){ - LOGGER.info(e.getMessage()); - Throwable t = e.getCause(); - while(t != null){ - LOGGER.info(t.getMessage()); - t = t.getCause(); - } - return null; - } - } - - @Override - public void resetSearchIndex() { - FullTextEntityManager fullTextEntityManager = - org.hibernate.search.jpa.Search.getFullTextEntityManager(em); - TypedQuery findAllActionItems = fullTextEntityManager.createQuery ("select a from Task a",Task.class); - TypedQuery findAllCategories = fullTextEntityManager.createQuery("select c from Project c",Project.class); - for(Project project :findAllCategories.getResultList()){ - fullTextEntityManager.index(project); - } - for(Task task :findAllActionItems.getResultList()){ - fullTextEntityManager.index(task); - } - //fullTextEntityManager.flushToIndexes(); - //fullTextEntityManager.clear(); - } -} +package org.woehlke.simpleworklist.model.dao.impl; + + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Repository; +import org.woehlke.simpleworklist.oodm.entities.Project; +import org.woehlke.simpleworklist.oodm.entities.Task; +import org.woehlke.simpleworklist.oodm.entities.UserAccount; +import org.woehlke.simpleworklist.model.beans.SearchResult; +import org.woehlke.simpleworklist.model.dao.SearchDao; + +import javax.persistence.*; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by tw on 14.02.16. + */ +@Repository +public class SearchDaoImpl implements SearchDao { + + private static final Logger LOGGER = LoggerFactory.getLogger(SearchDaoImpl.class); + + @PersistenceContext + private EntityManager em; + + @Override + public SearchResult search(String searchterm, UserAccount userAccount) { + return new SearchResult(); + } + + @Override + public void resetSearchIndex() { + } +} diff --git a/src/main/java/org/woehlke/simpleworklist/oodm/entities/Context.java b/src/main/java/org/woehlke/simpleworklist/oodm/entities/Context.java index 9c5edc1f..47c8d3b2 100644 --- a/src/main/java/org/woehlke/simpleworklist/oodm/entities/Context.java +++ b/src/main/java/org/woehlke/simpleworklist/oodm/entities/Context.java @@ -1,166 +1,163 @@ -package org.woehlke.simpleworklist.oodm.entities; - -import org.hibernate.search.annotations.*; -import org.hibernate.validator.constraints.Length; -import javax.validation.constraints.NotBlank; -import org.hibernate.validator.constraints.SafeHtml; -import org.woehlke.simpleworklist.oodm.entities.impl.AuditModel; -import org.woehlke.simpleworklist.oodm.entities.impl.ComparableById; - -import javax.persistence.*; -import javax.persistence.Index; -import java.io.Serializable; -import java.util.Objects; - -/** - * Created by tw on 13.03.16. - */ -@Entity -@Table( - name="context", - uniqueConstraints = { - @UniqueConstraint( - name="ux_context", - columnNames = {"uuid", "user_account_id", "name_de", "name_en" } - ) - }, - indexes={ - @Index(name = "ix_context_uuid", columnList = "uuid"), - @Index(name = "ix_context_row_created_at", columnList = "row_created_at") - } -) -public class Context extends AuditModel implements Serializable, ComparableById { - - private static final long serialVersionUID = -5035732370606951871L; - - @Id - @GeneratedValue(generator = "context_generator") - @SequenceGenerator( - name = "context_generator", - sequenceName = "context_sequence", - initialValue = 1000 - ) - @DocumentId(name = "id") - private Long id; - - @ManyToOne( - fetch = FetchType.LAZY, - optional = false, - cascade = { - CascadeType.MERGE, - CascadeType.REFRESH - }) - @JoinColumn(name = "user_account_id") - @IndexedEmbedded(includeEmbeddedObjectId = true) - private UserAccount userAccount; - - @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) - @NotBlank - @Length(min = 1, max = 255) - @Column(name = "name_de", nullable = false) - private String nameDe; - - @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) - @NotBlank - @Length(min = 1, max = 255) - @Column(name = "name_en", nullable = false) - private String nameEn; - - public Context() { - } - - public Context(String nameDe, String nameEn) { - this.nameDe = nameDe; - this.nameEn = nameEn; - } - - @Transient - public boolean hasThisUser(UserAccount userAccount){ - return (this.getUserAccount().getId().longValue()==userAccount.getId().longValue()); - } - - @Transient - @Override - public boolean equalsById(Context otherObject) { - return (this.getId().longValue() == otherObject.getId().longValue()); - } - - @Transient - @Override - public boolean equalsByUniqueConstraint(Context otherObject) { - boolean okUuid = super.equalsByMyUuid(otherObject); - boolean okUser = (this.getUserAccount().equalsByUniqueConstraint(otherObject.getUserAccount())); - boolean okNameDe = (this.getNameDe().compareTo(otherObject.getNameDe())==0); - boolean okNameEn = (this.getNameEn().compareTo(otherObject.getNameEn())==0); - return okUuid && okUser && okNameDe && okNameEn; - } - - @Transient - @Override - public boolean equalsByUuid(Context otherObject) { - return super.equalsByMyUuid(otherObject); - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public UserAccount getUserAccount() { - return userAccount; - } - - public void setUserAccount(UserAccount userAccount) { - this.userAccount = userAccount; - } - - public String getNameDe() { - return nameDe; - } - - public void setNameDe(String name) { - this.nameDe = name; - } - - public String getNameEn() { - return nameEn; - } - - public void setNameEn(String nameEn) { - this.nameEn = nameEn; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof Context)) return false; - if (!super.equals(o)) return false; - Context context = (Context) o; - return Objects.equals(getId(), context.getId()) && - getUserAccount().equals(context.getUserAccount()) && - getNameDe().equals(context.getNameDe()) && - getNameEn().equals(context.getNameEn()); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), getId(), getUserAccount(), getNameDe(), getNameEn()); - } - - @Override - public String toString() { - return "Context{" + - "id=" + id + - ", userAccount=" + userAccount + - ", nameDe='" + nameDe + '\'' + - ", nameEn='" + nameEn + '\'' + - ", uuid='" + uuid + '\'' + - ", rowCreatedAt=" + rowCreatedAt + - ", rowUpdatedAt=" + rowUpdatedAt + - '}'; - } - -} +package org.woehlke.simpleworklist.oodm.entities; + +import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.NotBlank; +import org.hibernate.validator.constraints.SafeHtml; +import org.woehlke.simpleworklist.oodm.entities.impl.AuditModel; +import org.woehlke.simpleworklist.oodm.entities.impl.ComparableById; + +import javax.persistence.*; +import javax.persistence.Index; +import java.io.Serializable; +import java.util.Objects; + +/** + * Created by tw on 13.03.16. + */ +@Entity +@Table( + name="context", + uniqueConstraints = { + @UniqueConstraint( + name="ux_context", + columnNames = {"uuid", "user_account_id", "name_de", "name_en" } + ) + }, + indexes={ + @Index(name = "ix_context_uuid", columnList = "uuid"), + @Index(name = "ix_context_row_created_at", columnList = "row_created_at") + } +) +public class Context extends AuditModel implements Serializable, ComparableById { + + private static final long serialVersionUID = -5035732370606951871L; + + @Id + @GeneratedValue(generator = "context_generator") + @SequenceGenerator( + name = "context_generator", + sequenceName = "context_sequence", + initialValue = 1000 + ) + private Long id; + + @ManyToOne( + fetch = FetchType.LAZY, + optional = false, + cascade = { + CascadeType.MERGE, + CascadeType.REFRESH + }) + @JoinColumn(name = "user_account_id") + private UserAccount userAccount; + + @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) + @NotBlank + @Length(min = 1, max = 255) + @Column(name = "name_de", nullable = false) + private String nameDe; + + @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) + @NotBlank + @Length(min = 1, max = 255) + @Column(name = "name_en", nullable = false) + private String nameEn; + + public Context() { + } + + public Context(String nameDe, String nameEn) { + this.nameDe = nameDe; + this.nameEn = nameEn; + } + + @Transient + public boolean hasThisUser(UserAccount userAccount){ + return (this.getUserAccount().getId().longValue()==userAccount.getId().longValue()); + } + + @Transient + @Override + public boolean equalsById(Context otherObject) { + return (this.getId().longValue() == otherObject.getId().longValue()); + } + + @Transient + @Override + public boolean equalsByUniqueConstraint(Context otherObject) { + boolean okUuid = super.equalsByMyUuid(otherObject); + boolean okUser = (this.getUserAccount().equalsByUniqueConstraint(otherObject.getUserAccount())); + boolean okNameDe = (this.getNameDe().compareTo(otherObject.getNameDe())==0); + boolean okNameEn = (this.getNameEn().compareTo(otherObject.getNameEn())==0); + return okUuid && okUser && okNameDe && okNameEn; + } + + @Transient + @Override + public boolean equalsByUuid(Context otherObject) { + return super.equalsByMyUuid(otherObject); + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public UserAccount getUserAccount() { + return userAccount; + } + + public void setUserAccount(UserAccount userAccount) { + this.userAccount = userAccount; + } + + public String getNameDe() { + return nameDe; + } + + public void setNameDe(String name) { + this.nameDe = name; + } + + public String getNameEn() { + return nameEn; + } + + public void setNameEn(String nameEn) { + this.nameEn = nameEn; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Context)) return false; + if (!super.equals(o)) return false; + Context context = (Context) o; + return Objects.equals(getId(), context.getId()) && + getUserAccount().equals(context.getUserAccount()) && + getNameDe().equals(context.getNameDe()) && + getNameEn().equals(context.getNameEn()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getId(), getUserAccount(), getNameDe(), getNameEn()); + } + + @Override + public String toString() { + return "Context{" + + "id=" + id + + ", userAccount=" + userAccount + + ", nameDe='" + nameDe + '\'' + + ", nameEn='" + nameEn + '\'' + + ", uuid='" + uuid + '\'' + + ", rowCreatedAt=" + rowCreatedAt + + ", rowUpdatedAt=" + rowUpdatedAt + + '}'; + } + +} diff --git a/src/main/java/org/woehlke/simpleworklist/oodm/entities/Project.java b/src/main/java/org/woehlke/simpleworklist/oodm/entities/Project.java index 4cd152a8..2460fa86 100644 --- a/src/main/java/org/woehlke/simpleworklist/oodm/entities/Project.java +++ b/src/main/java/org/woehlke/simpleworklist/oodm/entities/Project.java @@ -1,231 +1,226 @@ -package org.woehlke.simpleworklist.oodm.entities; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import javax.persistence.*; -import javax.persistence.Index; - -import org.hibernate.annotations.OnDelete; -import org.hibernate.annotations.OnDeleteAction; -import org.hibernate.search.annotations.*; -import org.hibernate.validator.constraints.Length; -import javax.validation.constraints.NotBlank; -import org.hibernate.validator.constraints.SafeHtml; -import org.woehlke.simpleworklist.oodm.entities.impl.AuditModel; -import org.woehlke.simpleworklist.oodm.entities.impl.ComparableById; - -@Entity -@Table( - name="project", - uniqueConstraints = { - @UniqueConstraint( - name = "ux_project", - columnNames = {"uuid", "parent_id", "context_id"} - ) - }, indexes = { - @Index(name = "ix_project_uuid", columnList = "uuid"), - @Index(name = "ix_project_row_created_at", columnList = "row_created_at") - } -) -@Indexed -public class Project extends AuditModel implements Serializable, ComparableById { - - private static final long serialVersionUID = 4566653175832872422L; - - @Id - @GeneratedValue(generator = "project_generator") - @SequenceGenerator( - name = "project_generator", - sequenceName = "project_sequence", - initialValue = 1000 - ) - @DocumentId(name="id") - private Long id; - - @ManyToOne( - fetch = FetchType.LAZY, - optional = true, - cascade = { - CascadeType.MERGE, - CascadeType.REFRESH - } - ) - @JoinColumn(name = "parent_id") - @OnDelete(action = OnDeleteAction.NO_ACTION) - private Project parent; - - @ManyToOne( - fetch = FetchType.LAZY, - optional = false, - cascade = { - CascadeType.MERGE, - CascadeType.REFRESH - } - ) - @JoinColumn(name = "context_id") - @OnDelete(action = OnDeleteAction.NO_ACTION) - private Context context; - - @SafeHtml(whitelistType=SafeHtml.WhiteListType.NONE) - @NotBlank - @Length(min=1,max=255) - @Column(name="name",nullable = false) - @Field(index= org.hibernate.search.annotations.Index.YES, analyze= Analyze.YES, store= Store.NO) - private String name; - - //@SafeHtml(whitelistType= SafeHtml.WhiteListType.RELAXED) - @NotBlank - @Length(min=0,max=65535) - @Column(name="description", nullable = true, length = 65535, columnDefinition="text") - @Field(index= org.hibernate.search.annotations.Index.YES, analyze= Analyze.YES, store= Store.NO) - private String description; - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent", cascade = { CascadeType.ALL }) - private List children = new ArrayList<>(); - - @Transient - public boolean hasNoChildren() { - return this.children.size() == 0; - } - - @Transient - public boolean isRootProject() { - return this.parent == null; - } - - @Transient - public boolean hasUser(UserAccount thisUser) { - return (this.getContext().hasThisUser(thisUser)); - } - - @Transient - @Override - public boolean equalsById(Project otherObject) { - return (this.getId().longValue() == otherObject.getId().longValue()); - } - - @Transient - @Override - public boolean equalsByUniqueConstraint(Project otherObject) { - boolean okParent; - if(this.isRootProject()){ - okParent = (otherObject.isRootProject()); - } else { - okParent = this.getParent().equalsByUniqueConstraint(otherObject.getParent()); - } - boolean okContext = this.getContext().equalsByUniqueConstraint(otherObject.getContext()); - boolean okUuid = this.equalsByUuid(otherObject); - return okParent && okContext && okUuid; - } - - @Transient - @Override - public boolean equalsByUuid(Project otherObject) { - return super.equalsByMyUuid(otherObject); - } - - public static Project newProjectFactory(Project parent) { - Project n = new Project(); - n.setParent(parent); - n.setContext(parent.getContext()); - return n; - } - - public static Project newRootProjectFactory(UserAccount userAccount) { - Project n = new Project(); - n.setParent(null); - return n; - } - - public static Project newRootProjectFactory(UserAccount userAccount,Context context) { - Project n = new Project(); - n.setParent(null); - n.setContext(context); - return n; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Project getParent() { - return parent; - } - - public void setParent(Project parent) { - this.parent = parent; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public List getChildren() { - return children; - } - - public void setChildren(List children) { - this.children = children; - } - - public Context getContext() { - return context; - } - - public void setContext(Context context) { - this.context = context; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof Project)) return false; - if (!super.equals(o)) return false; - Project project = (Project) o; - return Objects.equals(getId(), project.getId()) && - Objects.equals(getParent(), project.getParent()) && - getContext().equals(project.getContext()) && - getName().equals(project.getName()) && - getDescription().equals(project.getDescription()) && - getChildren().equals(project.getChildren()); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), getId(), getParent(), getContext(), getName(), getDescription(), getChildren()); - } - - @Override - public String toString() { - return "Project{" + - "id=" + id + - ", parent=" + parent + - ", context=" + context + - ", name='" + name + '\'' + - ", description='" + description + '\'' + - ", uuid='" + uuid + '\'' + - ", rowCreatedAt=" + rowCreatedAt + - ", rowUpdatedAt=" + rowUpdatedAt + - '}'; - } - -} +package org.woehlke.simpleworklist.oodm.entities; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import javax.persistence.*; +import javax.persistence.Index; + +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; +import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.NotBlank; +import org.hibernate.validator.constraints.SafeHtml; +import org.woehlke.simpleworklist.oodm.entities.impl.AuditModel; +import org.woehlke.simpleworklist.oodm.entities.impl.ComparableById; + +@Entity +@Table( + name="project", + uniqueConstraints = { + @UniqueConstraint( + name = "ux_project", + columnNames = {"uuid", "parent_id", "context_id"} + ) + }, indexes = { + @Index(name = "ix_project_uuid", columnList = "uuid"), + @Index(name = "ix_project_row_created_at", columnList = "row_created_at") + } +) +public class Project extends AuditModel implements Serializable, ComparableById { + + private static final long serialVersionUID = 4566653175832872422L; + + @Id + @GeneratedValue(generator = "project_generator") + @SequenceGenerator( + name = "project_generator", + sequenceName = "project_sequence", + initialValue = 1000 + ) + private Long id; + + @ManyToOne( + fetch = FetchType.LAZY, + optional = true, + cascade = { + CascadeType.MERGE, + CascadeType.REFRESH + } + ) + @JoinColumn(name = "parent_id") + @OnDelete(action = OnDeleteAction.NO_ACTION) + private Project parent; + + @ManyToOne( + fetch = FetchType.LAZY, + optional = false, + cascade = { + CascadeType.MERGE, + CascadeType.REFRESH + } + ) + @JoinColumn(name = "context_id") + @OnDelete(action = OnDeleteAction.NO_ACTION) + private Context context; + + @SafeHtml(whitelistType=SafeHtml.WhiteListType.NONE) + @NotBlank + @Length(min=1,max=255) + @Column(name="name",nullable = false) + private String name; + + //@SafeHtml(whitelistType= SafeHtml.WhiteListType.RELAXED) + @NotBlank + @Length(min=0,max=65535) + @Column(name="description", nullable = true, length = 65535, columnDefinition="text") + private String description; + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent", cascade = { CascadeType.ALL }) + private List children = new ArrayList<>(); + + @Transient + public boolean hasNoChildren() { + return this.children.size() == 0; + } + + @Transient + public boolean isRootProject() { + return this.parent == null; + } + + @Transient + public boolean hasUser(UserAccount thisUser) { + return (this.getContext().hasThisUser(thisUser)); + } + + @Transient + @Override + public boolean equalsById(Project otherObject) { + return (this.getId().longValue() == otherObject.getId().longValue()); + } + + @Transient + @Override + public boolean equalsByUniqueConstraint(Project otherObject) { + boolean okParent; + if(this.isRootProject()){ + okParent = (otherObject.isRootProject()); + } else { + okParent = this.getParent().equalsByUniqueConstraint(otherObject.getParent()); + } + boolean okContext = this.getContext().equalsByUniqueConstraint(otherObject.getContext()); + boolean okUuid = this.equalsByUuid(otherObject); + return okParent && okContext && okUuid; + } + + @Transient + @Override + public boolean equalsByUuid(Project otherObject) { + return super.equalsByMyUuid(otherObject); + } + + public static Project newProjectFactory(Project parent) { + Project n = new Project(); + n.setParent(parent); + n.setContext(parent.getContext()); + return n; + } + + public static Project newRootProjectFactory(UserAccount userAccount) { + Project n = new Project(); + n.setParent(null); + return n; + } + + public static Project newRootProjectFactory(UserAccount userAccount,Context context) { + Project n = new Project(); + n.setParent(null); + n.setContext(context); + return n; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Project getParent() { + return parent; + } + + public void setParent(Project parent) { + this.parent = parent; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public Context getContext() { + return context; + } + + public void setContext(Context context) { + this.context = context; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Project)) return false; + if (!super.equals(o)) return false; + Project project = (Project) o; + return Objects.equals(getId(), project.getId()) && + Objects.equals(getParent(), project.getParent()) && + getContext().equals(project.getContext()) && + getName().equals(project.getName()) && + getDescription().equals(project.getDescription()) && + getChildren().equals(project.getChildren()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getId(), getParent(), getContext(), getName(), getDescription(), getChildren()); + } + + @Override + public String toString() { + return "Project{" + + "id=" + id + + ", parent=" + parent + + ", context=" + context + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", uuid='" + uuid + '\'' + + ", rowCreatedAt=" + rowCreatedAt + + ", rowUpdatedAt=" + rowUpdatedAt + + '}'; + } + +} diff --git a/src/main/java/org/woehlke/simpleworklist/oodm/entities/Task.java b/src/main/java/org/woehlke/simpleworklist/oodm/entities/Task.java index 82e4d9aa..33a7c3a3 100644 --- a/src/main/java/org/woehlke/simpleworklist/oodm/entities/Task.java +++ b/src/main/java/org/woehlke/simpleworklist/oodm/entities/Task.java @@ -1,427 +1,422 @@ -package org.woehlke.simpleworklist.oodm.entities; - -import java.io.Serializable; -import java.util.Date; -import java.util.Objects; - -import javax.persistence.*; -import javax.persistence.Index; - - -import org.hibernate.annotations.OnDelete; -import org.hibernate.annotations.OnDeleteAction; -import org.hibernate.search.annotations.*; -import org.hibernate.validator.constraints.Length; -import javax.validation.constraints.NotBlank; -import org.hibernate.validator.constraints.SafeHtml; -import org.springframework.format.annotation.DateTimeFormat; -import org.woehlke.simpleworklist.oodm.entities.impl.AuditModel; -import org.woehlke.simpleworklist.oodm.entities.impl.ComparableById; -import org.woehlke.simpleworklist.oodm.enumerations.TaskEnergy; -import org.woehlke.simpleworklist.oodm.enumerations.TaskState; -import org.woehlke.simpleworklist.oodm.enumerations.TaskTime; - - -@Entity -@Table( - name="task", - uniqueConstraints = { - @UniqueConstraint( - name="ux_task", - columnNames = {"uuid", "context_id" } - )/*, - @UniqueConstraint( - name="ux_task_order_id_project", - columnNames = {"order_id_project", "project_id", "context_id", "user_account_id"} - ), - @UniqueConstraint( - name="ux_task_order_id_task_state", - columnNames = {"order_id_task_state", "task_state", "project_id", "context_id", "user_account_id"} - )*/ - }, - indexes = { - @Index(name = "ix_task_uuid", columnList = "uuid"), - @Index(name = "ix_task_row_created_at", columnList = "row_created_at"), - @Index(name = "ix_task_title", columnList = "title") - } -) -@Indexed -public class Task extends AuditModel implements Serializable, ComparableById { - - private static final long serialVersionUID = 5247710652586269801L; - - @Id - @GeneratedValue(generator = "task_generator") - @SequenceGenerator( - name = "task_generator", - sequenceName = "task_sequence", - initialValue = 1000 - ) - @DocumentId(name="id") - private Long id; - - @ManyToOne( - fetch = FetchType.LAZY, - optional = true, - cascade = { - CascadeType.MERGE, - CascadeType.REFRESH - } - ) - @JoinColumn(name = "project_id") - @OnDelete(action = OnDeleteAction.NO_ACTION) - private Project project; - - @ManyToOne( - fetch = FetchType.LAZY, - optional = false, - cascade = { - CascadeType.MERGE, - CascadeType.REFRESH - } - ) - @JoinColumn(name = "context_id") - @OnDelete(action = OnDeleteAction.NO_ACTION) - private Context context; - - @Deprecated - - @SafeHtml(whitelistType= SafeHtml.WhiteListType.NONE) - @NotBlank - @Length(min=1,max=255) - @Column(name = "title", nullable = false) - @Field(index= org.hibernate.search.annotations.Index.YES, analyze= Analyze.YES, store= Store.NO) - private String title; - - //@SafeHtml(whitelistType= SafeHtml.WhiteListType.RELAXED) - @NotBlank - @Length(min=0,max=65535) - @Column(name = "description", nullable = false, length = 65535, columnDefinition="text") - @Field(index= org.hibernate.search.annotations.Index.YES, analyze= Analyze.YES, store= Store.NO) - private String text; - - @Column(name = "focus", nullable = false) - private Boolean focus; - - /** - * The current TaskState; - */ - @Column(name = "task_state", nullable = false) - @Enumerated(EnumType.STRING) - private TaskState taskState; - - /** - * The TaskState before the current TaskState; - */ - @Column(name = "last_task_state", nullable = true) - @Enumerated(EnumType.STRING) - private TaskState lastTaskState; - - @Column(name = "task_energy", nullable = false) - @Enumerated(EnumType.STRING) - private TaskEnergy taskEnergy; - - @Column(name = "task_time", nullable = false) - @Enumerated(EnumType.STRING) - private TaskTime taskTime; - - @Temporal(value = TemporalType.DATE) - @Column(name = "due_date", nullable = true) - @DateTimeFormat(pattern="MM/dd/yyyy") - private Date dueDate; - - @Column(name = "order_id_project",nullable = false) - private long orderIdProject; - - @Column(name = "order_id_task_state",nullable = false) - private long orderIdTaskState; - - @Transient - public String getTextShortened(){ - StringBuilder sb = new StringBuilder(this.getText()); - if(sb.length() > 50){ - sb.setLength(50); - sb.trimToSize(); - sb.append("..."); - } - return sb.toString(); - } - - /** - * performs 'history back' for taskState - */ - @Transient - public void switchToLastFocusType() { - TaskState old = this.taskState; - this.taskState = this.lastTaskState; - this.lastTaskState = old; - } - - @Transient - public boolean hasSameContextAs(Task otherTask){ - return (this.getContext().equalsById( otherTask.getContext())); - } - - @Transient - public boolean hasSameTaskTypetAs(Task otherTask){ - return (this.getTaskState().ordinal() == otherTask.getTaskState().ordinal()); - } - - @Transient - public boolean isBelowByTaskState(Task otherTask){ - return (this.getOrderIdTaskState() < otherTask.getOrderIdTaskState()); - } - - @Transient - public void moveUpByTaskState(){ - this.orderIdTaskState++; - } - - @Transient - public void moveDownByTaskState(){ - this.orderIdTaskState--; - } - - @Transient - public boolean isBelowByProject(Task otherTask){ - return ( this.getOrderIdProject() < otherTask.getOrderIdProject() ); - } - - @Transient - public boolean hasSameProjectAs(Task destinationTask) { - if(this.isInRootProject() && destinationTask.isInRootProject()){ - return true; - } else { - return ( this.getProject().equalsById(destinationTask.getProject())); - } - } - - @Transient - public boolean hasProject(Project project) { - return this.getProject().equalsById(project); - } - - @Transient - public void moveUpByProject(){ - this.orderIdProject++; - } - - @Transient - public void moveDownByProject(){ - this.orderIdProject--; - } - - @Transient - public boolean isInRootProject(){ - return (this.getProject() == null); - } - - @Transient - public boolean hasUser(UserAccount thisUser) { - boolean viaContextOk = (this.getContext().hasThisUser(thisUser)); - boolean viaProjectOk = true; - if(!this.isInRootProject()){ - viaProjectOk = (this.getProject().getContext().hasThisUser(thisUser)); - } - return viaContextOk && viaProjectOk; - } - - @Transient - public void setRootProject() { - this.setProject(null); - } - - @Transient - public boolean hasSameContextAs(Project project) { - return (this.getContext().getId().longValue() == project.getContext().getId().longValue()); - } - - @Transient - @Override - public boolean equalsById(Task otherObject) { - return (this.getId().longValue() == otherObject.getId().longValue()); - } - - @Transient - @Override - public boolean equalsByUniqueConstraint(Task otherObject) { - boolean okUuid = this.equalsByUuid(otherObject); - boolean contextId = this.getContext().equalsByUniqueConstraint(otherObject.getContext()); - return okUuid && contextId; - } - - @Transient - @Override - public boolean equalsByUuid(Task otherObject) { - return super.equalsByMyUuid(otherObject); - } - - public boolean hasContext(Context context) { - return (this.getContext().getId().longValue() == context.getId().longValue()); - } - - public void setOrderIdTaskState(Task destinationTask) { - this.orderIdTaskState = destinationTask.getOrderIdTaskState(); - } - - public void setOrderIdProject(Task otherTask) { - this.orderIdProject = otherTask.getOrderIdProject(); - } - - /** - * Sets also 'history back' for taskState - */ - public void setTaskState(TaskState taskState) { - this.lastTaskState = this.taskState; - this.taskState = taskState; - } - - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Project getProject() { - return project; - } - - public void setProject(Project project) { - this.project = project; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public TaskState getTaskState() { - return taskState; - } - - public Boolean getFocus() { - return focus; - } - - public void setFocus(Boolean focus) { - this.focus = focus; - } - - public Date getDueDate() { - return dueDate; - } - - public void setDueDate(Date dueDate) { - this.dueDate = dueDate; - } - - public TaskState getLastTaskState() { - return lastTaskState; - } - - public void setLastTaskState(TaskState lastTaskState) { - this.lastTaskState = lastTaskState; - } - - public TaskEnergy getTaskEnergy() { - return taskEnergy; - } - - public void setTaskEnergy(TaskEnergy taskEnergy) { - this.taskEnergy = taskEnergy; - } - - public TaskTime getTaskTime() { - return taskTime; - } - - public void setTaskTime(TaskTime taskTime) { - this.taskTime = taskTime; - } - - public Context getContext() { - return context; - } - - public void setContext(Context context) { - this.context = context; - } - - public long getOrderIdProject() { - return orderIdProject; - } - - public void setOrderIdProject(long orderIdProject) { - this.orderIdProject = orderIdProject; - } - - public long getOrderIdTaskState() { - return orderIdTaskState; - } - - public void setOrderIdTaskState(long orderIdTaskState) { - this.orderIdTaskState = orderIdTaskState; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof Task)) return false; - if (!super.equals(o)) return false; - Task task = (Task) o; - return getOrderIdProject() == task.getOrderIdProject() && - getOrderIdTaskState() == task.getOrderIdTaskState() && - Objects.equals(getId(), task.getId()) && - getProject().equals(task.getProject()) && - getContext().equals(task.getContext()) && - getTitle().equals(task.getTitle()) && - getText().equals(task.getText()) && - getFocus().equals(task.getFocus()) && - getTaskState() == task.getTaskState() && - getLastTaskState() == task.getLastTaskState() && - getTaskEnergy() == task.getTaskEnergy() && - getTaskTime() == task.getTaskTime() && - Objects.equals(getDueDate(), task.getDueDate()); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), getId(), getProject(), getContext(), getTitle(), getText(), getFocus(), getTaskState(), getLastTaskState(), getTaskEnergy(), getTaskTime(), getDueDate(), getOrderIdProject(), getOrderIdTaskState()); - } - - @Override - public String toString() { - return "Task{" + - "id=" + id + - ", project=" + project + - ", context=" + context + - ", title='" + title + '\'' + - ", text='" + text + '\'' + - ", focus=" + focus + - ", taskState=" + taskState + - ", lastTaskState=" + lastTaskState + - ", taskEnergy=" + taskEnergy + - ", taskTime=" + taskTime + - ", dueDate=" + dueDate + - ", orderIdProject=" + orderIdProject + - ", orderIdTaskState=" + orderIdTaskState + - ", uuid='" + uuid + '\'' + - ", rowCreatedAt=" + rowCreatedAt + - ", rowUpdatedAt=" + rowUpdatedAt + - '}'; - } -} +package org.woehlke.simpleworklist.oodm.entities; + +import java.io.Serializable; +import java.util.Date; +import java.util.Objects; + +import javax.persistence.*; +import javax.persistence.Index; + + +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; +import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.NotBlank; +import org.hibernate.validator.constraints.SafeHtml; +import org.springframework.format.annotation.DateTimeFormat; +import org.woehlke.simpleworklist.oodm.entities.impl.AuditModel; +import org.woehlke.simpleworklist.oodm.entities.impl.ComparableById; +import org.woehlke.simpleworklist.oodm.enumerations.TaskEnergy; +import org.woehlke.simpleworklist.oodm.enumerations.TaskState; +import org.woehlke.simpleworklist.oodm.enumerations.TaskTime; + + +@Entity +@Table( + name="task", + uniqueConstraints = { + @UniqueConstraint( + name="ux_task", + columnNames = {"uuid", "context_id" } + )/*, + @UniqueConstraint( + name="ux_task_order_id_project", + columnNames = {"order_id_project", "project_id", "context_id", "user_account_id"} + ), + @UniqueConstraint( + name="ux_task_order_id_task_state", + columnNames = {"order_id_task_state", "task_state", "project_id", "context_id", "user_account_id"} + )*/ + }, + indexes = { + @Index(name = "ix_task_uuid", columnList = "uuid"), + @Index(name = "ix_task_row_created_at", columnList = "row_created_at"), + @Index(name = "ix_task_title", columnList = "title") + } +) +public class Task extends AuditModel implements Serializable, ComparableById { + + private static final long serialVersionUID = 5247710652586269801L; + + @Id + @GeneratedValue(generator = "task_generator") + @SequenceGenerator( + name = "task_generator", + sequenceName = "task_sequence", + initialValue = 1000 + ) + private Long id; + + @ManyToOne( + fetch = FetchType.LAZY, + optional = true, + cascade = { + CascadeType.MERGE, + CascadeType.REFRESH + } + ) + @JoinColumn(name = "project_id") + @OnDelete(action = OnDeleteAction.NO_ACTION) + private Project project; + + @ManyToOne( + fetch = FetchType.LAZY, + optional = false, + cascade = { + CascadeType.MERGE, + CascadeType.REFRESH + } + ) + @JoinColumn(name = "context_id") + @OnDelete(action = OnDeleteAction.NO_ACTION) + private Context context; + + @Deprecated + + @SafeHtml(whitelistType= SafeHtml.WhiteListType.NONE) + @NotBlank + @Length(min=1,max=255) + @Column(name = "title", nullable = false) + private String title; + + //@SafeHtml(whitelistType= SafeHtml.WhiteListType.RELAXED) + @NotBlank + @Length(min=0,max=65535) + @Column(name = "description", nullable = false, length = 65535, columnDefinition="text") + private String text; + + @Column(name = "focus", nullable = false) + private Boolean focus; + + /** + * The current TaskState; + */ + @Column(name = "task_state", nullable = false) + @Enumerated(EnumType.STRING) + private TaskState taskState; + + /** + * The TaskState before the current TaskState; + */ + @Column(name = "last_task_state", nullable = true) + @Enumerated(EnumType.STRING) + private TaskState lastTaskState; + + @Column(name = "task_energy", nullable = false) + @Enumerated(EnumType.STRING) + private TaskEnergy taskEnergy; + + @Column(name = "task_time", nullable = false) + @Enumerated(EnumType.STRING) + private TaskTime taskTime; + + @Temporal(value = TemporalType.DATE) + @Column(name = "due_date", nullable = true) + @DateTimeFormat(pattern="MM/dd/yyyy") + private Date dueDate; + + @Column(name = "order_id_project",nullable = false) + private long orderIdProject; + + @Column(name = "order_id_task_state",nullable = false) + private long orderIdTaskState; + + @Transient + public String getTextShortened(){ + StringBuilder sb = new StringBuilder(this.getText()); + if(sb.length() > 50){ + sb.setLength(50); + sb.trimToSize(); + sb.append("..."); + } + return sb.toString(); + } + + /** + * performs 'history back' for taskState + */ + @Transient + public void switchToLastFocusType() { + TaskState old = this.taskState; + this.taskState = this.lastTaskState; + this.lastTaskState = old; + } + + @Transient + public boolean hasSameContextAs(Task otherTask){ + return (this.getContext().equalsById( otherTask.getContext())); + } + + @Transient + public boolean hasSameTaskTypetAs(Task otherTask){ + return (this.getTaskState().ordinal() == otherTask.getTaskState().ordinal()); + } + + @Transient + public boolean isBelowByTaskState(Task otherTask){ + return (this.getOrderIdTaskState() < otherTask.getOrderIdTaskState()); + } + + @Transient + public void moveUpByTaskState(){ + this.orderIdTaskState++; + } + + @Transient + public void moveDownByTaskState(){ + this.orderIdTaskState--; + } + + @Transient + public boolean isBelowByProject(Task otherTask){ + return ( this.getOrderIdProject() < otherTask.getOrderIdProject() ); + } + + @Transient + public boolean hasSameProjectAs(Task destinationTask) { + if(this.isInRootProject() && destinationTask.isInRootProject()){ + return true; + } else { + return ( this.getProject().equalsById(destinationTask.getProject())); + } + } + + @Transient + public boolean hasProject(Project project) { + return this.getProject().equalsById(project); + } + + @Transient + public void moveUpByProject(){ + this.orderIdProject++; + } + + @Transient + public void moveDownByProject(){ + this.orderIdProject--; + } + + @Transient + public boolean isInRootProject(){ + return (this.getProject() == null); + } + + @Transient + public boolean hasUser(UserAccount thisUser) { + boolean viaContextOk = (this.getContext().hasThisUser(thisUser)); + boolean viaProjectOk = true; + if(!this.isInRootProject()){ + viaProjectOk = (this.getProject().getContext().hasThisUser(thisUser)); + } + return viaContextOk && viaProjectOk; + } + + @Transient + public void setRootProject() { + this.setProject(null); + } + + @Transient + public boolean hasSameContextAs(Project project) { + return (this.getContext().getId().longValue() == project.getContext().getId().longValue()); + } + + @Transient + @Override + public boolean equalsById(Task otherObject) { + return (this.getId().longValue() == otherObject.getId().longValue()); + } + + @Transient + @Override + public boolean equalsByUniqueConstraint(Task otherObject) { + boolean okUuid = this.equalsByUuid(otherObject); + boolean contextId = this.getContext().equalsByUniqueConstraint(otherObject.getContext()); + return okUuid && contextId; + } + + @Transient + @Override + public boolean equalsByUuid(Task otherObject) { + return super.equalsByMyUuid(otherObject); + } + + public boolean hasContext(Context context) { + return (this.getContext().getId().longValue() == context.getId().longValue()); + } + + public void setOrderIdTaskState(Task destinationTask) { + this.orderIdTaskState = destinationTask.getOrderIdTaskState(); + } + + public void setOrderIdProject(Task otherTask) { + this.orderIdProject = otherTask.getOrderIdProject(); + } + + /** + * Sets also 'history back' for taskState + */ + public void setTaskState(TaskState taskState) { + this.lastTaskState = this.taskState; + this.taskState = taskState; + } + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Project getProject() { + return project; + } + + public void setProject(Project project) { + this.project = project; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public TaskState getTaskState() { + return taskState; + } + + public Boolean getFocus() { + return focus; + } + + public void setFocus(Boolean focus) { + this.focus = focus; + } + + public Date getDueDate() { + return dueDate; + } + + public void setDueDate(Date dueDate) { + this.dueDate = dueDate; + } + + public TaskState getLastTaskState() { + return lastTaskState; + } + + public void setLastTaskState(TaskState lastTaskState) { + this.lastTaskState = lastTaskState; + } + + public TaskEnergy getTaskEnergy() { + return taskEnergy; + } + + public void setTaskEnergy(TaskEnergy taskEnergy) { + this.taskEnergy = taskEnergy; + } + + public TaskTime getTaskTime() { + return taskTime; + } + + public void setTaskTime(TaskTime taskTime) { + this.taskTime = taskTime; + } + + public Context getContext() { + return context; + } + + public void setContext(Context context) { + this.context = context; + } + + public long getOrderIdProject() { + return orderIdProject; + } + + public void setOrderIdProject(long orderIdProject) { + this.orderIdProject = orderIdProject; + } + + public long getOrderIdTaskState() { + return orderIdTaskState; + } + + public void setOrderIdTaskState(long orderIdTaskState) { + this.orderIdTaskState = orderIdTaskState; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Task)) return false; + if (!super.equals(o)) return false; + Task task = (Task) o; + return getOrderIdProject() == task.getOrderIdProject() && + getOrderIdTaskState() == task.getOrderIdTaskState() && + Objects.equals(getId(), task.getId()) && + getProject().equals(task.getProject()) && + getContext().equals(task.getContext()) && + getTitle().equals(task.getTitle()) && + getText().equals(task.getText()) && + getFocus().equals(task.getFocus()) && + getTaskState() == task.getTaskState() && + getLastTaskState() == task.getLastTaskState() && + getTaskEnergy() == task.getTaskEnergy() && + getTaskTime() == task.getTaskTime() && + Objects.equals(getDueDate(), task.getDueDate()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getId(), getProject(), getContext(), getTitle(), getText(), getFocus(), getTaskState(), getLastTaskState(), getTaskEnergy(), getTaskTime(), getDueDate(), getOrderIdProject(), getOrderIdTaskState()); + } + + @Override + public String toString() { + return "Task{" + + "id=" + id + + ", project=" + project + + ", context=" + context + + ", title='" + title + '\'' + + ", text='" + text + '\'' + + ", focus=" + focus + + ", taskState=" + taskState + + ", lastTaskState=" + lastTaskState + + ", taskEnergy=" + taskEnergy + + ", taskTime=" + taskTime + + ", dueDate=" + dueDate + + ", orderIdProject=" + orderIdProject + + ", orderIdTaskState=" + orderIdTaskState + + ", uuid='" + uuid + '\'' + + ", rowCreatedAt=" + rowCreatedAt + + ", rowUpdatedAt=" + rowUpdatedAt + + '}'; + } +} diff --git a/src/main/java/org/woehlke/simpleworklist/oodm/entities/UserAccount.java b/src/main/java/org/woehlke/simpleworklist/oodm/entities/UserAccount.java index b7698963..63ee528c 100644 --- a/src/main/java/org/woehlke/simpleworklist/oodm/entities/UserAccount.java +++ b/src/main/java/org/woehlke/simpleworklist/oodm/entities/UserAccount.java @@ -1,242 +1,240 @@ -package org.woehlke.simpleworklist.oodm.entities; - -import org.hibernate.search.annotations.*; -import javax.validation.constraints.Email; -import org.hibernate.validator.constraints.SafeHtml; -import org.woehlke.simpleworklist.oodm.entities.impl.AuditModel; -import org.woehlke.simpleworklist.oodm.entities.impl.ComparableById; -import org.woehlke.simpleworklist.oodm.enumerations.Language; - -import java.io.Serializable; -import java.util.Date; -import java.util.Objects; - -import javax.persistence.*; -import javax.persistence.Index; -import javax.validation.constraints.NotNull; - -@Entity -@Table( - name="user_account", - uniqueConstraints = { - @UniqueConstraint(name="ux_user_account", columnNames = {"user_email"}) - }, - indexes = { - @Index(name="ix_user_account_uuid", columnList = "uuid"), - @Index(name="ix_user_account_row_created_at", columnList = "row_created_at"), - @Index(name="ix_user_account_user_fullname", columnList = "user_fullname"), - @Index(name="ix_user_account_last_login_timestamp", columnList = "last_login_timestamp") - } -) -public class UserAccount extends AuditModel implements Serializable, ComparableById { - - private static final long serialVersionUID = 7860692526488291439L; - - @Id - @GeneratedValue(generator = "user_account_generator") - @SequenceGenerator( - name = "user_account_generator", - sequenceName = "user_account_sequence", - initialValue = 1000 - ) - private Long id; - - @Email - @Column(name="user_email", nullable = false) - @Field - private String userEmail; - - @SafeHtml(whitelistType= SafeHtml.WhiteListType.NONE) - @Column(name="user_password", nullable = false) - private String userPassword; - - @SafeHtml(whitelistType= SafeHtml.WhiteListType.NONE) - @Column(name="user_fullname", nullable = false) - private String userFullname; - - @Column(name="default_language", nullable = false) - @Enumerated(EnumType.STRING) - private Language defaultLanguage; - - @OneToOne( - fetch = FetchType.LAZY, - optional = true, - cascade = { - CascadeType.MERGE, - CascadeType.REFRESH - } - ) - @JoinColumn(name = "default_context_id",nullable=true) - private Context defaultContext; - - @NotNull - @Temporal(value = TemporalType.TIMESTAMP) - @Column(name="last_login_timestamp", nullable = false) - private Date lastLoginTimestamp; - - @NotNull - @Column(name="account_non_expired", nullable = false) - private Boolean accountNonExpired=true; - - @NotNull - @Column(name="account_non_locked", nullable = false) - private Boolean accountNonLocked=true; - - @NotNull - @Column(name="credentials_non_expired", nullable = false) - private Boolean credentialsNonExpired=true; - - @NotNull - @Column(name="enabled", nullable = false) - private Boolean enabled=true; - - @Transient - @Override - public boolean equalsById(UserAccount otherObject) { - return (this.getId().longValue() == otherObject.getId().longValue()); - } - - @Transient - @Override - public boolean equalsByUniqueConstraint(UserAccount otherObject) { - return (this.getUserEmail().compareTo(otherObject.getUserEmail())==0); - } - - @Transient - @Override - public boolean equalsByUuid(UserAccount otherObject) { - return super.equalsByMyUuid(otherObject); - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getUserEmail() { - return userEmail; - } - - public void setUserEmail(String userEmail) { - this.userEmail = userEmail; - } - - public String getUserPassword() { - return userPassword; - } - - public void setUserPassword(String userPassword) { - this.userPassword = userPassword; - } - - public String getUserFullname() { - return userFullname; - } - - public void setUserFullname(String userFullname) { - this.userFullname = userFullname; - } - - public Date getLastLoginTimestamp() { - return lastLoginTimestamp; - } - - public void setLastLoginTimestamp(Date lastLoginTimestamp) { - this.lastLoginTimestamp = lastLoginTimestamp; - } - - public Context getDefaultContext() { - return defaultContext; - } - - public void setDefaultContext(Context defaultContext) { - this.defaultContext = defaultContext; - } - - public Language getDefaultLanguage() { - return defaultLanguage; - } - - public void setDefaultLanguage(Language defaultLanguage) { - this.defaultLanguage = defaultLanguage; - } - - public Boolean getAccountNonExpired() { - return accountNonExpired; - } - - public void setAccountNonExpired(Boolean accountNonExpired) { - this.accountNonExpired = accountNonExpired; - } - - public Boolean getAccountNonLocked() { - return accountNonLocked; - } - - public void setAccountNonLocked(Boolean accountNonLocked) { - this.accountNonLocked = accountNonLocked; - } - - public Boolean getCredentialsNonExpired() { - return credentialsNonExpired; - } - - public void setCredentialsNonExpired(Boolean credentialsNonExpired) { - this.credentialsNonExpired = credentialsNonExpired; - } - - public Boolean getEnabled() { - return enabled; - } - - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof UserAccount)) return false; - if (!super.equals(o)) return false; - UserAccount that = (UserAccount) o; - return Objects.equals(getId(), that.getId()) && - getUserEmail().equals(that.getUserEmail()) && - getUserPassword().equals(that.getUserPassword()) && - getUserFullname().equals(that.getUserFullname()) && - getDefaultLanguage() == that.getDefaultLanguage() && - getDefaultContext().equals(that.getDefaultContext()) && - Objects.equals(getLastLoginTimestamp(), that.getLastLoginTimestamp()) && - getAccountNonExpired().equals(that.getAccountNonExpired()) && - getAccountNonLocked().equals(that.getAccountNonLocked()) && - getCredentialsNonExpired().equals(that.getCredentialsNonExpired()) && - getEnabled().equals(that.getEnabled()); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), getId(), getUserEmail(), getUserPassword(), getUserFullname(), getDefaultLanguage(), getDefaultContext(), getLastLoginTimestamp(), getAccountNonExpired(), getAccountNonLocked(), getCredentialsNonExpired(), getEnabled()); - } - - @Override - public String toString() { - return "UserAccount{" + - "id=" + id + - ", userEmail='" + userEmail + '\'' + - ", userPassword='" + userPassword + '\'' + - ", userFullname='" + userFullname + '\'' + - ", defaultLanguage=" + defaultLanguage + - ", lastLoginTimestamp=" + lastLoginTimestamp + - ", accountNonExpired=" + accountNonExpired + - ", accountNonLocked=" + accountNonLocked + - ", credentialsNonExpired=" + credentialsNonExpired + - ", enabled=" + enabled + - ", uuid='" + uuid + '\'' + - ", rowCreatedAt=" + rowCreatedAt + - ", rowUpdatedAt=" + rowUpdatedAt + - '}'; - } - -} +package org.woehlke.simpleworklist.oodm.entities; + +import javax.validation.constraints.Email; +import org.hibernate.validator.constraints.SafeHtml; +import org.woehlke.simpleworklist.oodm.entities.impl.AuditModel; +import org.woehlke.simpleworklist.oodm.entities.impl.ComparableById; +import org.woehlke.simpleworklist.oodm.enumerations.Language; + +import java.io.Serializable; +import java.util.Date; +import java.util.Objects; + +import javax.persistence.*; +import javax.persistence.Index; +import javax.validation.constraints.NotNull; + +@Entity +@Table( + name="user_account", + uniqueConstraints = { + @UniqueConstraint(name="ux_user_account", columnNames = {"user_email"}) + }, + indexes = { + @Index(name="ix_user_account_uuid", columnList = "uuid"), + @Index(name="ix_user_account_row_created_at", columnList = "row_created_at"), + @Index(name="ix_user_account_user_fullname", columnList = "user_fullname"), + @Index(name="ix_user_account_last_login_timestamp", columnList = "last_login_timestamp") + } +) +public class UserAccount extends AuditModel implements Serializable, ComparableById { + + private static final long serialVersionUID = 7860692526488291439L; + + @Id + @GeneratedValue(generator = "user_account_generator") + @SequenceGenerator( + name = "user_account_generator", + sequenceName = "user_account_sequence", + initialValue = 1000 + ) + private Long id; + + @Email + @Column(name="user_email", nullable = false) + private String userEmail; + + @SafeHtml(whitelistType= SafeHtml.WhiteListType.NONE) + @Column(name="user_password", nullable = false) + private String userPassword; + + @SafeHtml(whitelistType= SafeHtml.WhiteListType.NONE) + @Column(name="user_fullname", nullable = false) + private String userFullname; + + @Column(name="default_language", nullable = false) + @Enumerated(EnumType.STRING) + private Language defaultLanguage; + + @OneToOne( + fetch = FetchType.LAZY, + optional = true, + cascade = { + CascadeType.MERGE, + CascadeType.REFRESH + } + ) + @JoinColumn(name = "default_context_id",nullable=true) + private Context defaultContext; + + @NotNull + @Temporal(value = TemporalType.TIMESTAMP) + @Column(name="last_login_timestamp", nullable = false) + private Date lastLoginTimestamp; + + @NotNull + @Column(name="account_non_expired", nullable = false) + private Boolean accountNonExpired=true; + + @NotNull + @Column(name="account_non_locked", nullable = false) + private Boolean accountNonLocked=true; + + @NotNull + @Column(name="credentials_non_expired", nullable = false) + private Boolean credentialsNonExpired=true; + + @NotNull + @Column(name="enabled", nullable = false) + private Boolean enabled=true; + + @Transient + @Override + public boolean equalsById(UserAccount otherObject) { + return (this.getId().longValue() == otherObject.getId().longValue()); + } + + @Transient + @Override + public boolean equalsByUniqueConstraint(UserAccount otherObject) { + return (this.getUserEmail().compareTo(otherObject.getUserEmail())==0); + } + + @Transient + @Override + public boolean equalsByUuid(UserAccount otherObject) { + return super.equalsByMyUuid(otherObject); + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUserEmail() { + return userEmail; + } + + public void setUserEmail(String userEmail) { + this.userEmail = userEmail; + } + + public String getUserPassword() { + return userPassword; + } + + public void setUserPassword(String userPassword) { + this.userPassword = userPassword; + } + + public String getUserFullname() { + return userFullname; + } + + public void setUserFullname(String userFullname) { + this.userFullname = userFullname; + } + + public Date getLastLoginTimestamp() { + return lastLoginTimestamp; + } + + public void setLastLoginTimestamp(Date lastLoginTimestamp) { + this.lastLoginTimestamp = lastLoginTimestamp; + } + + public Context getDefaultContext() { + return defaultContext; + } + + public void setDefaultContext(Context defaultContext) { + this.defaultContext = defaultContext; + } + + public Language getDefaultLanguage() { + return defaultLanguage; + } + + public void setDefaultLanguage(Language defaultLanguage) { + this.defaultLanguage = defaultLanguage; + } + + public Boolean getAccountNonExpired() { + return accountNonExpired; + } + + public void setAccountNonExpired(Boolean accountNonExpired) { + this.accountNonExpired = accountNonExpired; + } + + public Boolean getAccountNonLocked() { + return accountNonLocked; + } + + public void setAccountNonLocked(Boolean accountNonLocked) { + this.accountNonLocked = accountNonLocked; + } + + public Boolean getCredentialsNonExpired() { + return credentialsNonExpired; + } + + public void setCredentialsNonExpired(Boolean credentialsNonExpired) { + this.credentialsNonExpired = credentialsNonExpired; + } + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof UserAccount)) return false; + if (!super.equals(o)) return false; + UserAccount that = (UserAccount) o; + return Objects.equals(getId(), that.getId()) && + getUserEmail().equals(that.getUserEmail()) && + getUserPassword().equals(that.getUserPassword()) && + getUserFullname().equals(that.getUserFullname()) && + getDefaultLanguage() == that.getDefaultLanguage() && + getDefaultContext().equals(that.getDefaultContext()) && + Objects.equals(getLastLoginTimestamp(), that.getLastLoginTimestamp()) && + getAccountNonExpired().equals(that.getAccountNonExpired()) && + getAccountNonLocked().equals(that.getAccountNonLocked()) && + getCredentialsNonExpired().equals(that.getCredentialsNonExpired()) && + getEnabled().equals(that.getEnabled()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getId(), getUserEmail(), getUserPassword(), getUserFullname(), getDefaultLanguage(), getDefaultContext(), getLastLoginTimestamp(), getAccountNonExpired(), getAccountNonLocked(), getCredentialsNonExpired(), getEnabled()); + } + + @Override + public String toString() { + return "UserAccount{" + + "id=" + id + + ", userEmail='" + userEmail + '\'' + + ", userPassword='" + userPassword + '\'' + + ", userFullname='" + userFullname + '\'' + + ", defaultLanguage=" + defaultLanguage + + ", lastLoginTimestamp=" + lastLoginTimestamp + + ", accountNonExpired=" + accountNonExpired + + ", accountNonLocked=" + accountNonLocked + + ", credentialsNonExpired=" + credentialsNonExpired + + ", enabled=" + enabled + + ", uuid='" + uuid + '\'' + + ", rowCreatedAt=" + rowCreatedAt + + ", rowUpdatedAt=" + rowUpdatedAt + + '}'; + } + +} From 6e3478b9075606c0d8186a34767a527b22ebc8ac Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 16:47:25 +0200 Subject: [PATCH 04/17] migrate spring-boot --- pom.xml | 366 +++++++++--------- .../SimpleworklistApplication.java | 47 ++- 2 files changed, 216 insertions(+), 197 deletions(-) diff --git a/pom.xml b/pom.xml index 4276de90..5772a8fe 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.woehlke simpleworklist 2.3.6-SNAPSHOT - war + jar org.springframework.boot spring-boot-starter-parent @@ -148,18 +148,19 @@ spring-boot-admin-starter-server --> - - org.springframework.boot - spring-boot-devtools - runtime - - + org.postgresql postgresql @@ -381,12 +382,13 @@ maven-surefire-plugin ${maven-surefire-plugin.version} ---> + org.apache.maven.plugins maven-war-plugin ${maven-war-plugin.version} + --> org.apache.maven.plugins maven-project-info-reports-plugin @@ -565,170 +567,172 @@ org.apache.maven.plugins:maven-surefire-plugin - - - com.github.jsimone - webapp-runner - 9.0.19.0 - webapp-runner.jar - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - - + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + - - testing - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - true - ${start-class} - - testing - - - - - pre-integration-test - - start - - - - post-integration-test - - stop - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - - testing - - false - - - - - + + testing + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + ${start-class} + + testing + + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + testing + + false + + + + + - - qa - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - true - ${start-class} - - qa - - - - - pre-integration-test - - start - - - - post-integration-test - - stop - - - - - build-info - - - - ${project.build.sourceEncoding} - ${project.reporting.outputEncoding} - ${maven.compiler.source} - ${maven.compiler.target} - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - - qa - - false - - - - - + + qa + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + ${start-class} + + qa + + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + build-info + + + + ${project.build.sourceEncoding} + ${project.reporting.outputEncoding} + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + qa + + false + + + + + - - developing - - - - org.springframework.boot - spring-boot-maven-plugin - - true - ${start-class} - - developing - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - unpack-dependencies - package - - analyze-only - analyze-report - + + developing + + + + org.springframework.boot + spring-boot-maven-plugin + + true + ${start-class} + + developing + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack-dependencies + package + + analyze-only + analyze-report + build-classpath @@ -750,6 +754,7 @@ org.apache.maven.plugins:maven-surefire-plugin + @@ -844,8 +850,10 @@ org.springframework.boot spring-boot-maven-plugin - WAR + jar + heroku @@ -874,6 +882,7 @@ package copy + unpack-dependencies @@ -926,6 +936,7 @@ true + @@ -946,7 +958,7 @@ spring-boot-maven-plugin ${start-class} - WAR + jar testing diff --git a/src/main/java/org/woehlke/simpleworklist/SimpleworklistApplication.java b/src/main/java/org/woehlke/simpleworklist/SimpleworklistApplication.java index 171d908c..134b5f05 100644 --- a/src/main/java/org/woehlke/simpleworklist/SimpleworklistApplication.java +++ b/src/main/java/org/woehlke/simpleworklist/SimpleworklistApplication.java @@ -1,20 +1,27 @@ -package org.woehlke.simpleworklist; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; -import org.springframework.web.WebApplicationInitializer; -import org.springframework.boot.builder.SpringApplicationBuilder; - -@SpringBootApplication -public class SimpleworklistApplication extends SpringBootServletInitializer implements WebApplicationInitializer { - - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(SimpleworklistApplication.class); - } - - public static void main(String[] args) { - SpringApplication.run(SimpleworklistApplication.class, args); - } -} +package org.woehlke.simpleworklist; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.woehlke.simpleworklist.config.ApplicationConfig; +import org.woehlke.simpleworklist.config.ApplicationProperties; +import org.woehlke.simpleworklist.config.WebMvcConfig; +import org.woehlke.simpleworklist.config.WebSecurityConfig; + + +@ImportAutoConfiguration({ + ApplicationConfig.class, + WebMvcConfig.class, + WebSecurityConfig.class +}) +@EnableConfigurationProperties({ + ApplicationProperties.class +}) +@SpringBootApplication +public class SimpleworklistApplication { + + public static void main(String[] args) { + SpringApplication.run(SimpleworklistApplication.class, args); + } +} From a0ee71178e143af7765e86ffbda03a4f43108537 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 16:51:08 +0200 Subject: [PATCH 05/17] migrate spring-boot --- pom.xml | 82 --------------------------------------------------------- 1 file changed, 82 deletions(-) diff --git a/pom.xml b/pom.xml index 5772a8fe..68dfd503 100644 --- a/pom.xml +++ b/pom.xml @@ -65,13 +65,6 @@ - - de.codecentric - spring-boot-admin-dependencies - ${spring-boot-admin.version} - pom - import - org.springframework.session spring-session-bom @@ -88,30 +81,10 @@ spring-boot-properties-migrator runtime - org.springframework.boot spring-boot-starter-data-jpa - org.springframework.boot spring-boot-starter-mail @@ -132,35 +105,6 @@ org.springframework.boot spring-boot-starter-web - - - org.postgresql postgresql @@ -318,20 +262,7 @@ org.springframework.security spring-security-core - 5.1.5.RELEASE - - org.springframework.boot - spring-boot-starter-tomcat - provided - - @@ -376,19 +307,6 @@ maven-source-plugin ${maven-source-plugin.version} - org.apache.maven.plugins maven-project-info-reports-plugin From 5ceeece50cbfc6b5c39506ca84f7fbc5580a9074 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 16:53:40 +0200 Subject: [PATCH 06/17] migrate spring-boot --- pom.xml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 68dfd503..b87e4d76 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,6 @@ 3.0.0-M4 2.7 2.8.2 - org.woehlke.simpleworklist.SimpleworklistApplication @@ -118,17 +117,15 @@ org.projectlombok lombok - true + false org.springframework.boot spring-boot-starter-test - test org.springframework.security spring-security-test - test @@ -259,10 +256,6 @@ jsoup 1.8.3 - - org.springframework.security - spring-security-core - @@ -432,7 +425,6 @@ spring-boot-maven-plugin true - ${start-class} default @@ -522,7 +514,6 @@ spring-boot-maven-plugin true - ${start-class} testing @@ -572,7 +563,6 @@ spring-boot-maven-plugin true - ${start-class} qa @@ -632,7 +622,6 @@ spring-boot-maven-plugin true - ${start-class} developing @@ -712,7 +701,6 @@ org.springframework.boot spring-boot-maven-plugin - ${start-class} travis @@ -875,7 +863,6 @@ org.springframework.boot spring-boot-maven-plugin - ${start-class} jar testing From a5acd35f58eb7ead7fd1a898d5a6a5699e646092 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 17:19:24 +0200 Subject: [PATCH 07/17] migrate spring-boot --- pom.xml | 99 ++++++++------------------------------------------------- 1 file changed, 14 insertions(+), 85 deletions(-) diff --git a/pom.xml b/pom.xml index b87e4d76..8a4cadbe 100644 --- a/pom.xml +++ b/pom.xml @@ -3,13 +3,12 @@ 4.0.0 org.woehlke simpleworklist - 2.3.6-SNAPSHOT + 2.3.7-SNAPSHOT jar org.springframework.boot spring-boot-starter-parent 2.2.6.RELEASE - simpleworklist @@ -119,15 +118,18 @@ lombok false + org.springframework.boot spring-boot-starter-test + + org.webjars font-awesome @@ -153,7 +155,7 @@ ckeditor 4.11.3 - + org.springframework.session spring-session-jdbc @@ -258,13 +260,11 @@ - - - ${project.artifactId} + @@ -357,10 +360,7 @@ true - - org.apache.maven.plugins - maven-source-plugin - + @@ -416,9 +402,6 @@ simpleworklist clean spring-boot:run - - - org.springframework.boot @@ -477,16 +460,6 @@ org.apache.maven.plugins:maven-surefire-plugin - @@ -661,16 +634,6 @@ org.apache.maven.plugins:maven-surefire-plugin - @@ -757,9 +720,6 @@ spring-boot-maven-plugin jar - heroku @@ -788,18 +748,6 @@ package copy - unpack-dependencies @@ -842,16 +790,6 @@ true - @@ -863,16 +801,14 @@ org.springframework.boot spring-boot-maven-plugin - jar - testing + default org.apache.maven.plugins maven-project-info-reports-plugin - ${maven-project-info-reports-plugin.version} true @@ -880,18 +816,15 @@ org.apache.maven.plugins maven-dependency-plugin - ${maven-dependency-plugin.version} true org.apache.maven.plugins maven-source-plugin - ${maven-source-plugin.version} org.apache.maven.plugins maven-javadoc-plugin - ${maven-javadoc-plugin.version} true 1024m @@ -902,7 +835,6 @@ org.apache.maven.plugins maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} ${project.build.sourceEncoding} @@ -910,12 +842,10 @@ org.apache.maven.plugins maven-jxr-plugin - ${maven-jxr-plugin.version} org.apache.maven.plugins maven-pmd-plugin - ${maven-pmd-plugin.version} ${project.build.sourceEncoding} 100 @@ -928,7 +858,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} false From 5246464f1ab584095e7bd89d608b3f7522c11908 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 17:34:48 +0200 Subject: [PATCH 08/17] migrate spring-boot --- .../config/WebSecurityConfig.java | 164 +++++++++--------- 1 file changed, 83 insertions(+), 81 deletions(-) diff --git a/src/main/java/org/woehlke/simpleworklist/config/WebSecurityConfig.java b/src/main/java/org/woehlke/simpleworklist/config/WebSecurityConfig.java index 14f96c4a..f4639f14 100644 --- a/src/main/java/org/woehlke/simpleworklist/config/WebSecurityConfig.java +++ b/src/main/java/org/woehlke/simpleworklist/config/WebSecurityConfig.java @@ -1,81 +1,83 @@ -package org.woehlke.simpleworklist.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.web.config.EnableSpringDataWebSupport; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.authentication.AuthenticationSuccessHandler; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; -import org.woehlke.simpleworklist.model.services.UserAccountSecurityService; - -@Configuration -@EnableWebSecurity -@EnableSpringDataWebSupport -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - - @Autowired - public WebSecurityConfig(AuthenticationManagerBuilder auth, LoginSuccessHandler loginSuccessHandler, UserAccountSecurityService userAccountSecurityService) { - this.auth = auth; - this.loginSuccessHandler = loginSuccessHandler; - this.userAccountSecurityService = userAccountSecurityService; - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - http - .headers().disable() - .authorizeRequests() - .antMatchers( - "/webjars/**", "/css/**", "/img/**", "/js/**", "/favicon.ico", - "/test*/**", "/login*", "/register*", "/confirm*/**", - "/resetPassword*", "/passwordResetConfirm*/**", "/error*" - ) - .permitAll() - .anyRequest().authenticated().antMatchers("/**").fullyAuthenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("j_username").passwordParameter("j_password") - .loginProcessingUrl("/j_spring_security_check") - .failureForwardUrl("/login?login_error=1") - .defaultSuccessUrl("/") - .successHandler(loginSuccessHandler) - .permitAll() - .and() - .logout() - .logoutUrl("/logout") - .deleteCookies("JSESSIONID") - .invalidateHttpSession(true) - .permitAll(); - } - - @Bean - public AuthenticationManager authenticationManager() throws Exception { - int strength = 10; - PasswordEncoder encoder = new BCryptPasswordEncoder(strength); - return auth.userDetailsService(userAccountSecurityService).passwordEncoder(encoder).and().build(); - } - - @Bean - public UsernamePasswordAuthenticationFilter authenticationFilter() throws Exception { - UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter(); - filter.setAuthenticationManager(authenticationManager()); - filter.setFilterProcessesUrl("/j_spring_security_check"); - return filter; - } - - private final AuthenticationManagerBuilder auth; - - private final AuthenticationSuccessHandler loginSuccessHandler; - - private final UserDetailsService userAccountSecurityService; - -} +package org.woehlke.simpleworklist.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.web.config.EnableSpringDataWebSupport; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.woehlke.simpleworklist.model.services.UserAccountSecurityService; + +@Configuration +@EnableWebSecurity +@EnableSpringDataWebSupport +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + + @Autowired + public WebSecurityConfig(AuthenticationManagerBuilder auth, LoginSuccessHandler loginSuccessHandler, UserAccountSecurityService userAccountSecurityService) { + this.auth = auth; + this.loginSuccessHandler = loginSuccessHandler; + this.userAccountSecurityService = userAccountSecurityService; + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .headers().disable() + .authorizeRequests() + .antMatchers( + "/webjars/**", "/css/**", "/img/**", "/js/**", "/favicon.ico", + "/test*/**", "/login*", "/register*", "/confirm*/**", + "/resetPassword*", "/passwordResetConfirm*/**", "/error*" + ) + .permitAll() + //.and() + //.authorizeRequests() + .anyRequest().fullyAuthenticated().and() + //.authenticated().antMatcher("/**").fullyAuthenticated() + .formLogin() + .loginPage("/login") + .usernameParameter("j_username").passwordParameter("j_password") + .loginProcessingUrl("/j_spring_security_check") + .failureForwardUrl("/login?login_error=1") + .defaultSuccessUrl("/") + .successHandler(loginSuccessHandler) + .permitAll() + .and() + .logout() + .logoutUrl("/logout") + .deleteCookies("JSESSIONID") + .invalidateHttpSession(true) + .permitAll(); + } + + @Bean + public AuthenticationManager authenticationManager() throws Exception { + int strength = 10; + PasswordEncoder encoder = new BCryptPasswordEncoder(strength); + return auth.userDetailsService(userAccountSecurityService).passwordEncoder(encoder).and().build(); + } + + @Bean + public UsernamePasswordAuthenticationFilter authenticationFilter() throws Exception { + UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter(); + filter.setAuthenticationManager(authenticationManager()); + filter.setFilterProcessesUrl("/j_spring_security_check"); + return filter; + } + + private final AuthenticationManagerBuilder auth; + + private final AuthenticationSuccessHandler loginSuccessHandler; + + private final UserDetailsService userAccountSecurityService; + +} From 06cd4ea86ccc880f5da904aec6e0abc1535bc9a4 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 17:43:41 +0200 Subject: [PATCH 09/17] migrate spring-boot --- .../config/ApplicationConfig.java | 122 +++++++++--------- 1 file changed, 62 insertions(+), 60 deletions(-) diff --git a/src/main/java/org/woehlke/simpleworklist/config/ApplicationConfig.java b/src/main/java/org/woehlke/simpleworklist/config/ApplicationConfig.java index 12c519c5..dd63f454 100644 --- a/src/main/java/org/woehlke/simpleworklist/config/ApplicationConfig.java +++ b/src/main/java/org/woehlke/simpleworklist/config/ApplicationConfig.java @@ -1,60 +1,62 @@ -package org.woehlke.simpleworklist.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.mail.javamail.JavaMailSender; -import org.springframework.mail.javamail.JavaMailSenderImpl; -import org.springframework.scheduling.annotation.EnableAsync; - -import java.util.Properties; - -@Configuration -@EnableAsync -@EnableJpaAuditing -@EnableJpaRepositories({ - "org.woehlke.simpleworklist.oodm.repository" -}) -@EnableConfigurationProperties({ - ApplicationProperties.class -}) -public class ApplicationConfig { - - @Autowired - public ApplicationConfig(ApplicationProperties applicationProperties) { - this.applicationProperties = applicationProperties; - } - - @Bean - public JavaMailSender mailSender(){ - Properties javaMailProperties = new Properties(); - javaMailProperties.setProperty( - "mail.smtp.auth", - applicationProperties.getMail().getSmtp().getAuth().toString() - ); - javaMailProperties.setProperty( - "mail.smtp.ssl.enable", - applicationProperties.getMail().getSmtp().getSslEnable().toString() - ); - javaMailProperties.setProperty( - "mail.smtp.socketFactory.port", - applicationProperties.getMail().getSmtp().getSocketFactoryPort() - ); - javaMailProperties.setProperty( - "mail.smtp.socketFactory.class", - applicationProperties.getMail().getSmtp().getSocketFactoryClass() - ); - JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); - mailSender.setJavaMailProperties(javaMailProperties); - mailSender.setHost(applicationProperties.getMail().getHost()); - mailSender.setPort(applicationProperties.getMail().getPort()); - mailSender.setUsername(applicationProperties.getMail().getUsername()); - mailSender.setPassword(applicationProperties.getMail().getPassword()); - return mailSender; - } - - private final ApplicationProperties applicationProperties; -} +package org.woehlke.simpleworklist.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.session.jdbc.config.annotation.web.http.EnableJdbcHttpSession; + +import java.util.Properties; + +@Configuration +@EnableAsync +@EnableJpaAuditing +@EnableJdbcHttpSession +@EnableJpaRepositories({ + "org.woehlke.simpleworklist.oodm.repository" +}) +@EnableConfigurationProperties({ + ApplicationProperties.class +}) +public class ApplicationConfig { + + @Autowired + public ApplicationConfig(ApplicationProperties applicationProperties) { + this.applicationProperties = applicationProperties; + } + + @Bean + public JavaMailSender mailSender(){ + Properties javaMailProperties = new Properties(); + javaMailProperties.setProperty( + "mail.smtp.auth", + applicationProperties.getMail().getSmtp().getAuth().toString() + ); + javaMailProperties.setProperty( + "mail.smtp.ssl.enable", + applicationProperties.getMail().getSmtp().getSslEnable().toString() + ); + javaMailProperties.setProperty( + "mail.smtp.socketFactory.port", + applicationProperties.getMail().getSmtp().getSocketFactoryPort() + ); + javaMailProperties.setProperty( + "mail.smtp.socketFactory.class", + applicationProperties.getMail().getSmtp().getSocketFactoryClass() + ); + JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); + mailSender.setJavaMailProperties(javaMailProperties); + mailSender.setHost(applicationProperties.getMail().getHost()); + mailSender.setPort(applicationProperties.getMail().getPort()); + mailSender.setUsername(applicationProperties.getMail().getUsername()); + mailSender.setPassword(applicationProperties.getMail().getPassword()); + return mailSender; + } + + private final ApplicationProperties applicationProperties; +} From 6c30369efd0a3822e05aef078559cc0fe38dd7eb Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 17:51:42 +0200 Subject: [PATCH 10/17] migrate spring-boot --- pom.xml | 242 +++++++++++++++++++------------------------------------- 1 file changed, 80 insertions(+), 162 deletions(-) diff --git a/pom.xml b/pom.xml index 8a4cadbe..23325942 100644 --- a/pom.xml +++ b/pom.xml @@ -155,79 +155,6 @@ ckeditor 4.11.3 - org.springframework.session spring-session-jdbc @@ -262,89 +189,89 @@ ${project.artifactId} - - - - - + + + --> org.apache.maven.plugins @@ -478,9 +405,6 @@ testing - - - org.springframework.boot @@ -527,9 +451,6 @@ qa - - - org.springframework.boot @@ -656,9 +577,6 @@ travis - - - org.springframework.boot From 6578b88e6b3b06df37d206c06dbf1480f4073b19 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 18:13:39 +0200 Subject: [PATCH 11/17] migrate spring-boot --- .../control/common/MyErrorController.java | 81 ++++++++++--------- .../resources/templates/error/error-404.html | 14 ++-- .../resources/templates/error/error-500.html | 17 ++-- src/main/resources/templates/error/error.html | 17 ++-- 4 files changed, 68 insertions(+), 61 deletions(-) diff --git a/src/main/java/org/woehlke/simpleworklist/control/common/MyErrorController.java b/src/main/java/org/woehlke/simpleworklist/control/common/MyErrorController.java index 905bdff5..f0c1e0ab 100644 --- a/src/main/java/org/woehlke/simpleworklist/control/common/MyErrorController.java +++ b/src/main/java/org/woehlke/simpleworklist/control/common/MyErrorController.java @@ -1,36 +1,45 @@ -package org.woehlke.simpleworklist.control.common; - -import org.springframework.boot.web.servlet.error.ErrorController; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; - -import javax.servlet.RequestDispatcher; -import javax.servlet.http.HttpServletRequest; - -@Controller -public class MyErrorController implements ErrorController { - - @RequestMapping("/fehler") - public String handleError(HttpServletRequest request, Model model) { - Exception exception = (Exception) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); - Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); - if (status != null) { - Integer statusCode = Integer.valueOf(status.toString()); - if(statusCode == HttpStatus.NOT_FOUND.value()) { - return "error/error-404"; - } - else if(statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) { - return "error/error-500"; - } - } - model.addAttribute("exceptionMessage",exception.getLocalizedMessage()); - return "error/error"; - } - - @Override - public String getErrorPath() { - return "/fehler"; - } -} +package org.woehlke.simpleworklist.control.common; + + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.web.servlet.error.ErrorController; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; + +import javax.servlet.RequestDispatcher; +import javax.servlet.http.HttpServletRequest; + + +@Slf4j +@Controller +public class MyErrorController implements ErrorController { + + @RequestMapping("/fehler") + public String handleError(HttpServletRequest request, Model model) { + Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); + if(statusCode!=null){ + HttpStatus httpStatus = HttpStatus.valueOf(statusCode); + switch (httpStatus){ + case NOT_FOUND: + return "error/error-404"; + case INTERNAL_SERVER_ERROR: + return "error/error-500"; + } + } + String errorMessage = (String) request.getAttribute(RequestDispatcher.ERROR_MESSAGE); + log.warn("errorMessage :"+errorMessage); + Throwable exception = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); + log.warn("errorMessage :"+exception.getMessage()); + for(StackTraceElement elem:exception.getStackTrace()){ + log.warn(elem.getFileName()+":+"+elem.getLineNumber()+" "+elem.getClassName()+"."+elem.getMethodName()); + } + return "error/error"; + } + + @Override + public String getErrorPath() { + return "/fehler"; + } +} diff --git a/src/main/resources/templates/error/error-404.html b/src/main/resources/templates/error/error-404.html index 1802a9b3..6f99ec5f 100644 --- a/src/main/resources/templates/error/error-404.html +++ b/src/main/resources/templates/error/error-404.html @@ -1,7 +1,7 @@ - - - -

Sorry, we couldn't find the page you're looking for.

-Go Home - - \ No newline at end of file + + + +

(404) Sorry, we couldn't find the page you're looking for.

+Return to Startpage + + diff --git a/src/main/resources/templates/error/error-500.html b/src/main/resources/templates/error/error-500.html index 771263f9..6c3d3714 100644 --- a/src/main/resources/templates/error/error-500.html +++ b/src/main/resources/templates/error/error-500.html @@ -1,9 +1,8 @@ - - - -

(500) Something went wrong!

-

Our Engineers are on it

-
exceptionMessage
-Go Home - - \ No newline at end of file + + + +

(500) Something went wrong!

+

Our Engineers are on it

+Return to Startpage + + diff --git a/src/main/resources/templates/error/error.html b/src/main/resources/templates/error/error.html index 47526ab8..8d8bc9fa 100644 --- a/src/main/resources/templates/error/error.html +++ b/src/main/resources/templates/error/error.html @@ -1,9 +1,8 @@ - - - -

Something went wrong!

-

Our Engineers are on it

-
exceptionMessage
-Go Home - - \ No newline at end of file + + + +

Something went wrong!

+

Our Engineers are on it

+Return to Startpage + + From 108b9eada6788fa001a407652686d486de1d8e0b Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 18:24:06 +0200 Subject: [PATCH 12/17] migrate spring-boot --- .../control/common/MyErrorController.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/woehlke/simpleworklist/control/common/MyErrorController.java b/src/main/java/org/woehlke/simpleworklist/control/common/MyErrorController.java index f0c1e0ab..25543bdc 100644 --- a/src/main/java/org/woehlke/simpleworklist/control/common/MyErrorController.java +++ b/src/main/java/org/woehlke/simpleworklist/control/common/MyErrorController.java @@ -18,22 +18,34 @@ public class MyErrorController implements ErrorController { @RequestMapping("/fehler") public String handleError(HttpServletRequest request, Model model) { + String errorMessage = (String) request.getAttribute(RequestDispatcher.ERROR_MESSAGE); + if(errorMessage!=null){ + log.warn("errorMessage :"+errorMessage); + } Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); - if(statusCode!=null){ + if(statusCode != null){ HttpStatus httpStatus = HttpStatus.valueOf(statusCode); + log.warn(httpStatus.value()+""+httpStatus.getReasonPhrase()); switch (httpStatus){ case NOT_FOUND: return "error/error-404"; case INTERNAL_SERVER_ERROR: return "error/error-500"; + case UNAUTHORIZED: + log.warn("##################################################"); + log.warn(" UNAUTHORIZED"); + log.warn("##################################################"); + return "redirect:/"; } } - String errorMessage = (String) request.getAttribute(RequestDispatcher.ERROR_MESSAGE); - log.warn("errorMessage :"+errorMessage); Throwable exception = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); - log.warn("errorMessage :"+exception.getMessage()); - for(StackTraceElement elem:exception.getStackTrace()){ - log.warn(elem.getFileName()+":+"+elem.getLineNumber()+" "+elem.getClassName()+"."+elem.getMethodName()); + if(exception != null) { + log.warn("##################################################"); + log.warn("Exception :" + exception.getMessage()); + for (StackTraceElement elem : exception.getStackTrace()) { + log.warn("Stacktrace: " + elem.getFileName() + ":+" + elem.getLineNumber() + " " + elem.getClassName() + "." + elem.getMethodName()); + } + log.warn("##################################################"); } return "error/error"; } From 40eb46fd6003c3b4ffd834969cbd821cf8a9654c Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 18:26:39 +0200 Subject: [PATCH 13/17] migrate spring-boot --- .../simpleworklist/control/common/MyErrorController.java | 2 +- src/main/resources/application.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/woehlke/simpleworklist/control/common/MyErrorController.java b/src/main/java/org/woehlke/simpleworklist/control/common/MyErrorController.java index 25543bdc..7f4e4a39 100644 --- a/src/main/java/org/woehlke/simpleworklist/control/common/MyErrorController.java +++ b/src/main/java/org/woehlke/simpleworklist/control/common/MyErrorController.java @@ -35,7 +35,7 @@ public String handleError(HttpServletRequest request, Model model) { log.warn("##################################################"); log.warn(" UNAUTHORIZED"); log.warn("##################################################"); - return "redirect:/"; + return "redirect:/login?login_error=1"; } } Throwable exception = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 80b62e6b..0637c3a7 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -30,8 +30,8 @@ spring: open-in-view: true generate-ddl: true hibernate: - #ddl-auto: update - ddl-auto: create-drop + ddl-auto: update + #ddl-auto: create-drop properties: hibernate: dialect: org.hibernate.dialect.PostgreSQL95Dialect From eda5cfb4bb3220eca93a615754986c31ccc4a7e7 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 18:41:11 +0200 Subject: [PATCH 14/17] migrate spring-boot --- pom.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pom.xml b/pom.xml index 23325942..74eeb6d0 100644 --- a/pom.xml +++ b/pom.xml @@ -185,6 +185,18 @@ jsoup 1.8.3
+ + org.junit.jupiter + junit-jupiter-engine + 5.4.0 + test + + + org.junit.jupiter + junit-jupiter-api + 5.4.0 + test + From d6478d35e64b78e2e49d6e1c5131ae9fd116d567 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 18:42:21 +0200 Subject: [PATCH 15/17] migrate spring-boot --- pom.xml | 109 -------------------------------------------------------- 1 file changed, 109 deletions(-) diff --git a/pom.xml b/pom.xml index 74eeb6d0..54031815 100644 --- a/pom.xml +++ b/pom.xml @@ -201,89 +201,6 @@ ${project.artifactId} - org.apache.maven.plugins @@ -299,32 +216,6 @@ true
- From da306c7d7238daf65fdedbfdd174ad1ddbfa2031 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 18:47:29 +0200 Subject: [PATCH 16/17] migrate spring-boot --- .../model/beans/NewUser2UserMessage.java | 93 ++++++++++--------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/src/main/java/org/woehlke/simpleworklist/model/beans/NewUser2UserMessage.java b/src/main/java/org/woehlke/simpleworklist/model/beans/NewUser2UserMessage.java index 3b0272b1..ae3a31ae 100644 --- a/src/main/java/org/woehlke/simpleworklist/model/beans/NewUser2UserMessage.java +++ b/src/main/java/org/woehlke/simpleworklist/model/beans/NewUser2UserMessage.java @@ -1,46 +1,47 @@ -package org.woehlke.simpleworklist.model.beans; - -import org.hibernate.validator.constraints.Length; -import org.hibernate.validator.constraints.SafeHtml; - -import javax.validation.constraints.NotBlank; -import java.io.Serializable; -import java.util.Objects; - -public class NewUser2UserMessage implements Serializable { - - private static final long serialVersionUID = 1576610181966480168L; - - @SafeHtml(whitelistType= SafeHtml.WhiteListType.SIMPLE_TEXT) - @NotBlank - @Length(min=1,max=65535) - private String messageText; - - public String getMessageText() { - return messageText; - } - - public void setMessageText(String messageText) { - this.messageText = messageText; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof NewUser2UserMessage)) return false; - NewUser2UserMessage that = (NewUser2UserMessage) o; - return getMessageText().equals(that.getMessageText()); - } - - @Override - public int hashCode() { - return Objects.hash(getMessageText()); - } - - @Override - public String toString() { - return "NewUser2UserMessage{" + - "messageText='" + messageText + '\'' + - '}'; - } -} +package org.woehlke.simpleworklist.model.beans; + + +import org.hibernate.validator.constraints.Length; +import org.hibernate.validator.constraints.SafeHtml; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.Objects; + +public class NewUser2UserMessage implements Serializable { + + private static final long serialVersionUID = 1576610181966480168L; + + @SafeHtml(whitelistType= SafeHtml.WhiteListType.SIMPLE_TEXT) + @NotBlank + @Length(min=1,max=65535) + private String messageText; + + public String getMessageText() { + return messageText; + } + + public void setMessageText(String messageText) { + this.messageText = messageText; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof NewUser2UserMessage)) return false; + NewUser2UserMessage that = (NewUser2UserMessage) o; + return getMessageText().equals(that.getMessageText()); + } + + @Override + public int hashCode() { + return Objects.hash(getMessageText()); + } + + @Override + public String toString() { + return "NewUser2UserMessage{" + + "messageText='" + messageText + '\'' + + '}'; + } +} From 09d4a6fa2bf25ec04e95e383a3c5f261bbda7ab9 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Thu, 2 Apr 2020 19:00:28 +0200 Subject: [PATCH 17/17] migrate spring-boot --- etc/TODO.md | 6 ++++ pom.xml | 86 ++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 68 insertions(+), 24 deletions(-) create mode 100644 etc/TODO.md diff --git a/etc/TODO.md b/etc/TODO.md new file mode 100644 index 00000000..31431c62 --- /dev/null +++ b/etc/TODO.md @@ -0,0 +1,6 @@ +# TODO + +* https://www.baeldung.com/spring-session +* EmbeddedSolrServer: +* https://docs.spring.io/spring-data/solr/docs/4.1.6.RELEASE/reference/html/#solr.annotation + diff --git a/pom.xml b/pom.xml index 54031815..2aaf0c71 100644 --- a/pom.xml +++ b/pom.xml @@ -70,6 +70,53 @@ pom import + + org.webjars + font-awesome + 5.8.1 + + + org.webjars + jquery + 3.3.1-2 + + + org.webjars + popper.js + 1.14.7 + + + org.webjars + bootstrap + 4.3.1 + + + org.webjars + ckeditor + 4.11.3 + + + io.github.jpenren + thymeleaf-spring-data-dialect + 3.4.0 + + + org.jsoup + jsoup + 1.8.3 + + + org.junit.jupiter + junit-jupiter-engine + 5.4.0 + test + + + org.junit.jupiter + junit-jupiter-api + 5.4.0 + test + @@ -79,17 +126,25 @@ spring-boot-properties-migrator runtime + + org.springframework.boot + spring-boot-starter-data-jdbc + org.springframework.boot spring-boot-starter-data-jpa org.springframework.boot - spring-boot-starter-mail + spring-boot-starter-data-solr org.springframework.boot - spring-boot-starter-security + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-mail org.springframework.boot @@ -101,7 +156,11 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-test org.postgresql @@ -118,42 +177,25 @@ lombok false - - - org.springframework.boot - spring-boot-starter-test - - - org.webjars font-awesome - 5.8.1 org.webjars jquery - 3.3.1-2 org.webjars popper.js - 1.14.7 org.webjars bootstrap - 4.3.1 org.webjars ckeditor - 4.11.3 org.springframework.session @@ -178,23 +220,19 @@ io.github.jpenren thymeleaf-spring-data-dialect - 3.4.0 org.jsoup jsoup - 1.8.3 org.junit.jupiter junit-jupiter-engine - 5.4.0 test org.junit.jupiter junit-jupiter-api - 5.4.0 test