This is an automated email from the git hooks/post-receive script. New commit to branch revert-12127879 in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 348333459a736fa09c74add2d3c9432e043f045b Author: Killian Herbreteau <killian.herbreteau@epitech.eu> Date: Thu Sep 19 11:50:07 2019 +0200 Revert "Merge branch 'feature/spgeed' into 'develop'" This reverts merge request !24 --- pollen-persistence/pom.xml | 16 -- .../Dao/PollenChildFavoriteListSpgeedDao.java | 15 -- .../persistence/Dao/PollenChoiceSpgeedDao.java | 15 -- .../persistence/Dao/PollenCommentSpgeedDao.java | 13 -- .../Dao/PollenFavoriteListMemberSpgeedDao.java | 15 -- .../Dao/PollenFavoriteListSpgeedDao.java | 22 --- .../persistence/Dao/PollenPollSpgeedDao.java | 66 ------- .../persistence/Dao/PollenPrincipalSpgeedDao.java | 43 ----- .../persistence/Dao/PollenRessourceSpgeedDao.java | 23 --- .../Dao/PollenSessionTokenSpgeedDao.java | 16 -- .../persistence/Dao/PollenTokenSpgeedDao.java | 12 -- .../Dao/PollenUserEmailAddressSpgeedDao.java | 38 ---- .../persistence/Dao/PollenUserSpgeedDao.java | 39 ---- .../persistence/Dao/PollenVoteSpgeedDao.java | 15 -- .../Dao/PollenVoterListMemberSpgeedDao.java | 14 -- .../persistence/Dao/PollenVoterListSpgeedDao.java | 22 --- .../pollen/persistence/Dao/SpgeedDaoUtils.java | 37 ---- .../chorem/pollen/persistence/PollenConfig.java | 72 ------- .../chorem/pollen/persistence/PollenMapper.java | 40 ---- .../PollenSpgeedApplicationContext.java | 59 ------ .../entity/ChildFavoriteListTopiaDao.java | 5 - .../pollen/persistence/entity/PollTopiaDao.java | 2 +- .../persistence/entity/PollenPrincipals.java | 2 - .../pollen/persistence/entity/PollenUserImpl.java | 3 - pollen-rest-api/pom.xml | 1 + .../rest/api/PollenRestApiApplicationContext.java | 34 +--- .../rest/api/PollenRestApiRequestFilter.java | 2 +- .../chorem/pollen/rest/api/v1/TransverseApi.java | 17 -- .../resources/#pollen-rest-api-test.properties# | 31 --- .../resources/.#pollen-rest-api-test.properties | 1 - .../pollen/services/PollenApplicationContext.java | 3 - .../org/chorem/pollen/services/PollenFixtures.java | 16 +- .../services/config/PollenServicesConfig.java | 11 -- .../pollen/services/service/PollenUserService.java | 11 +- .../pollen/services/service/TransverseService.java | 31 --- .../services/service/security/SpgeedDao.java | 31 --- .../service/security/SpgeedDummyService.java | 110 ----------- .../test/FakePollenApplicationContext.java | 9 - .../chorem/pollen/services/SpgeedDaoUtilsTest.java | 211 --------------------- .../org/chorem/pollen/services/SpgeedTest.java | 136 ------------- pom.xml | 16 -- 41 files changed, 30 insertions(+), 1245 deletions(-) diff --git a/pollen-persistence/pom.xml b/pollen-persistence/pom.xml index de373136..c13d3b37 100644 --- a/pollen-persistence/pom.xml +++ b/pollen-persistence/pom.xml @@ -38,17 +38,6 @@ <dependencies> - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-config</artifactId> - <version>3.3</version> - </dependency> - - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>spgeed</artifactId> - </dependency> - <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> @@ -84,11 +73,6 @@ <artifactId>hibernate-core</artifactId> </dependency> - <dependency> - <groupId>org.postgresql</groupId> - <artifactId>postgresql</artifactId> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenChildFavoriteListSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenChildFavoriteListSpgeedDao.java deleted file mode 100644 index cd64d5e5..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenChildFavoriteListSpgeedDao.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.entity.ChildFavoriteList; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.addStringToArray; -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.getProperty; - -public interface PollenChildFavoriteListSpgeedDao { - - String propertieswoForeignKey[] = {ChildFavoriteList.PROPERTY_WEIGHT, ChildFavoriteList.TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, ChildFavoriteList.PROPERTY_PARENT, ChildFavoriteList.PROPERTY_CHILD); - - String woForeignKey = getProperty(propertieswoForeignKey); -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenChoiceSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenChoiceSpgeedDao.java deleted file mode 100644 index bb476bc8..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenChoiceSpgeedDao.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.entity.Choice; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.addStringToArray; -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.getProperty; - -public interface PollenChoiceSpgeedDao { - String propertieswoForeignKey[] = {Choice.PROPERTY_CHOICE_VALUE, Choice.PROPERTY_DESCRIPTION, Choice.PROPERTY_CHOICE_ORDER, Choice.TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, Choice.PROPERTY_QUESTION, Choice.PROPERTY_CREATOR, Choice.PROPERTY_CHOICE_TYPE); - - String woForeignKey = getProperty(propertieswoForeignKey); - -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenCommentSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenCommentSpgeedDao.java deleted file mode 100644 index 60cb7125..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenCommentSpgeedDao.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.entity.Comment; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.*; - -public interface PollenCommentSpgeedDao { - String propertieswoForeignKey[] = {Comment.PROPERTY_TEXT, Comment.PROPERTY_POST_DATE, Comment.TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, Comment.PROPERTY_POLL, Comment.PROPERTY_AUTHOR, Comment.PROPERTY_QUESTION); - - String woForeignKey = getProperty(propertieswoForeignKey); -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenFavoriteListMemberSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenFavoriteListMemberSpgeedDao.java deleted file mode 100644 index e90847e1..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenFavoriteListMemberSpgeedDao.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.entity.FavoriteList; -import org.chorem.pollen.persistence.entity.FavoriteListMember; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.*; - -public interface PollenFavoriteListMemberSpgeedDao { - - String propertieswoForeignKey[] = {FavoriteListMember.PROPERTY_NAME, FavoriteListMember.PROPERTY_EMAIL, FavoriteListMember.PROPERTY_WEIGHT, FavoriteList.TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, FavoriteListMember.PROPERTY_FAVORITE_LIST); - - String woForeignKey = getProperty(propertieswoForeignKey); -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenFavoriteListSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenFavoriteListSpgeedDao.java deleted file mode 100644 index ac7768d7..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenFavoriteListSpgeedDao.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.PollenMapper; -import org.chorem.pollen.persistence.entity.FavoriteList; -import org.chorem.pollen.persistence.entity.Poll; -import org.chorem.pollen.persistence.entity.VoterList; -import org.nuiton.spgeed.annotations.Select; -import org.nuiton.spgeed.annotations.Update; - -import java.sql.Date; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.addStringToArray; -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.getProperty; - -public interface PollenFavoriteListSpgeedDao { - - String propertieswoForeignKey[] = {FavoriteList.PROPERTY_NAME, FavoriteList.TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, FavoriteList.PROPERTY_POLLEN_USER, FavoriteList.PROPERTY_OWNER, FavoriteList.PROPERTY_PARENT_LISTS); - - String woForeignKey = getProperty(propertieswoForeignKey); -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenPollSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenPollSpgeedDao.java deleted file mode 100644 index a933a4a3..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenPollSpgeedDao.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.PollenMapper; -import org.chorem.pollen.persistence.entity.Poll; -import org.nuiton.spgeed.annotations.Select; -import org.nuiton.spgeed.annotations.Update; - -import java.sql.Date; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.*; - -public interface PollenPollSpgeedDao { - - String propertieswoForeignKey[] = {Poll.PROPERTY_TITLE, Poll.PROPERTY_DESCRIPTION, Poll.PROPERTY_BEGIN_DATE, Poll.PROPERTY_END_DATE, - Poll.PROPERTY_ANONYMOUS_VOTE_ALLOWED, Poll.PROPERTY_CONTINUOUS_RESULTS, Poll.PROPERTY_NOTIFY_ME_HOURS_BEFORE_POLL_ENDS, - Poll.PROPERTY_POLL_END_REMINDER_SENT, Poll.PROPERTY_NOTIFICATION_LOCALE, Poll.PROPERTY_VOTE_NOTIFICATION, Poll.PROPERTY_FEED_CONTENT, - Poll.PROPERTY_COMMENT_NOTIFICATION, Poll.PROPERTY_NEW_CHOICE_NOTIFICATION, Poll.PROPERTY_GTU_VALIDATION_DATE, Poll.PROPERTY_PREMIUM, - Poll.PROPERTY_NOTIFICATION_MAX_VOTER_SEND, Poll.PROPERTY_EMAIL_ADDRESS_SUFFIXES, Poll.PROPERTY_POLL_TYPE, Poll.PROPERTY_VOTE_VISIBILITY, - Poll.PROPERTY_COMMENT_VISIBILITY, Poll.PROPERTY_RESULT_VISIBILITY, Poll.PROPERTY_TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, Poll.PROPERTY_CREATOR); - - String woForeignKey = getProperty(propertieswoForeignKey); - - String command = "WITH " + - "email_agg AS (" + - " SELECT emailaddress, topiaid, pollenuser" + - " FROM pollenuseremailaddress" + - ")," + - "users_agg AS (" + - " SELECT userx.topiaid, json_agg(demail.*)->0 AS defaultemailaddress, json_agg(emails.*) AS emailaddresses" + - " FROM email_agg demail, email_agg emails, pollenuser userx" + - " WHERE demail.topiaid = userx.defaultemailaddress AND emails.pollenuser = userx.topiaid" + - " GROUP BY userx.topiaid" + - ")," + - "principals_agg AS (" + - " SELECT principals.topiaid, json_agg(userx.*)->0 AS pollenuser" + - " FROM users_agg userx, pollenprincipal principals" + - " WHERE userx.topiaid = principals.pollenuser" + - " GROUP BY principals.topiaid" + - "), " + - "polls_agg AS (" + - " SELECT p.topiaid, json_agg(a.*)->0 AS creator" + - " FROM principals_agg a, poll p" + - " WHERE a.topiaid = p.creator" + - " GROUP BY p.topiaid" + - ") " + - "SELECT * FROM polls_agg"; - - @Select(sql = command, mapper = PollenMapper.class) - Poll[] getallpoll(); - - @Update(sql = "insert into poll (title, description, begindate, enddate, anonymousvoteallowed, " + - "continuousresults, notifymehoursbeforepollends, pollendremindersent, " + - "notificationlocale, votenotification, feedcontent, commentnotification, " + - "newchoicenotification, gtuvalidationdate, premium, notificationmaxvotersend, " + - "emailaddresssuffixes) values ($(title), $(description), $(begindate), $(enddate), $(anonymousvoteallowed), " + - "$(continuousresults), $(notifymehoursbeforepollends), $(pollendremindersent), " + - "$(notificationlocale), $(votenotification), $(feedcontent), $(commentnotification), " + - "$(newchoicenotification), $(gtuvalidationdate), $(premium), $(notificationmaxvotersend), " + - "$(emailaddresssuffixes)))", mapper = PollenMapper.class) - int new_poll(String title, String description, Date begindate, Date enddate, boolean anonymousvoteallowed, boolean continuousresults, - int notifymehoursbeforepollends, boolean pollendremindersent, String notificationlocale, boolean votenotification, - String feedcontent, boolean commentnotification, boolean newchoicenotification, Date gtuvalidationdate, boolean premium, - boolean notificationmaxvotersend, String emailaddresssuffixes); -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenPrincipalSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenPrincipalSpgeedDao.java deleted file mode 100644 index df8dea4a..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenPrincipalSpgeedDao.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.entity.FavoriteList; -import org.chorem.pollen.persistence.entity.PollenPrincipal; - -import java.security.Principal; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.*; - -public interface PollenPrincipalSpgeedDao { - - - String propertieswoForeignKey[] = {PollenPrincipal.PROPERTY_NAME, PollenPrincipal.PROPERTY_EMAIL, PollenPrincipal.PROPERTY_INVALID, PollenPrincipal.TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, PollenPrincipal.PROPERTY_PERMISSION, PollenPrincipal.PROPERTY_POLLEN_USER); - - String woForeignKey = getProperty(propertieswoForeignKey); - - String command = "WITH " + - "email_agg AS (" + - " SELECT emailaddress, topiaid, pollenuser" + - " FROM pollenuseremailaddress" + - ")," + - "users_agg AS (" + - " SELECT userx.topiaid, json_agg(demail.*)->0 AS defaultemailaddress, json_agg(emails.*) AS emailaddresses" + - " FROM email_agg demail, email_agg emails, pollenuser userx" + - " WHERE demail.topiaid = userx.defaultemailaddress AND emails.pollenuser = userx.topiaid" + - " GROUP BY userx.topiaid" + - ")," + - "principals_agg AS (" + - " SELECT principals.topiaid, json_agg(userx.*)->0 AS pollenuser" + - " FROM users_agg userx, pollenprincipal principals" + - " WHERE userx.topiaid = principals.pollenuser" + - " GROUP BY principals.topiaid" + - "), " + - "polls_agg AS (" + - " SELECT p.topiaid, json_agg(a.*)->0 AS creator" + - " FROM principals_agg a, poll p" + - " WHERE a.topiaid = p.creator" + - " GROUP BY p.topiaid" + - ") " + - "SELECT * FROM polls_agg"; -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenRessourceSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenRessourceSpgeedDao.java deleted file mode 100644 index 3a8b37c7..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenRessourceSpgeedDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.PollenMapper; -import org.chorem.pollen.persistence.entity.FavoriteList; -import org.chorem.pollen.persistence.entity.Poll; -import org.chorem.pollen.persistence.entity.PollenResource; -import org.nuiton.spgeed.annotations.Select; -import org.nuiton.spgeed.annotations.Update; - -import java.sql.Date; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.addStringToArray; -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.getProperty; - -public interface PollenRessourceSpgeedDao { - - String propertieswoForeignKey[] = {PollenResource.PROPERTY_RESOURCE_CONTENT, PollenResource.PROPERTY_CONTENT_TYPE, - PollenResource.PROPERTY_NAME, PollenResource.PROPERTY_SIZE, PollenResource.TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, PollenResource.PROPERTY_RESOURCE_TYPE); - - String woForeignKey = getProperty(propertieswoForeignKey); -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenSessionTokenSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenSessionTokenSpgeedDao.java deleted file mode 100644 index 594e6bc3..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenSessionTokenSpgeedDao.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.entity.SessionToken; -import org.chorem.pollen.persistence.entity.VoterList; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.addStringToArray; -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.getProperty; - -public interface PollenSessionTokenSpgeedDao { - - String propertieswoForeignKey[] = {SessionToken.PROPERTY_TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, SessionToken.PROPERTY_POLLEN_TOKEN, SessionToken.PROPERTY_POLLEN_USER, SessionToken.TOPIA_ID); - - String woForeignKey = getProperty(propertieswoForeignKey); -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenTokenSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenTokenSpgeedDao.java deleted file mode 100644 index 4e07e7b7..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenTokenSpgeedDao.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.entity.PollenToken; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.*; - -public interface PollenTokenSpgeedDao { - - String propertieswoForeignKey[] = {PollenToken.PROPERTY_TOKEN, PollenToken.PROPERTY_CREATION_DATE, PollenToken.PROPERTY_END_DATE, PollenToken.TOPIA_ID}; - - String woForeignKey = getProperty(propertieswoForeignKey); -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenUserEmailAddressSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenUserEmailAddressSpgeedDao.java deleted file mode 100644 index 65524df2..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenUserEmailAddressSpgeedDao.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.entity.PollenUserEmailAddress; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.getProperty; - -public interface PollenUserEmailAddressSpgeedDao { - - String properties[] = {PollenUserEmailAddress.PROPERTY_EMAIL_ADDRESS, PollenUserEmailAddress.PROPERTY_PGP_PUBLIC_KEY, - PollenUserEmailAddress.PROPERTY_VALIDATED, PollenUserEmailAddress.TOPIA_ID}; - - String formatedProperties = getProperty(properties); - - String command = "WITH " + - "email_agg AS (" + - " SELECT " + formatedProperties + - " FROM pollenuseremailaddress" + - ")," + - "users_agg AS (" + - " SELECT userx.topiaid, json_agg(demail.*)->0 AS defaultemailaddress, json_agg(emails.*) AS emailaddresses" + - " FROM email_agg demail, email_agg emails, pollenuser userx" + - " WHERE demail.topiaid = userx.defaultemailaddress AND emails.pollenuser = userx.topiaid" + - " GROUP BY userx.topiaid" + - ")," + - "principals_agg AS (" + - " SELECT principals.topiaid, json_agg(userx.*)->0 AS pollenuser" + - " FROM users_agg userx, pollenprincipal principals" + - " WHERE userx.topiaid = principals.pollenuser" + - " GROUP BY principals.topiaid" + - "), " + - "polls_agg AS (" + - " SELECT p.topiaid, json_agg(a.*)->0 AS creator" + - " FROM principals_agg a, poll p" + - " WHERE a.topiaid = p.creator" + - " GROUP BY p.topiaid" + - ") " + - "SELECT * FROM polls_agg"; -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenUserSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenUserSpgeedDao.java deleted file mode 100644 index 313e8557..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenUserSpgeedDao.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.PollenMapper; -import org.chorem.pollen.persistence.entity.PollenUser; -import org.chorem.pollen.persistence.entity.PollenUserEmailAddress; -import org.nuiton.spgeed.annotations.Select; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.*; - -public interface PollenUserSpgeedDao { - - String propertieswoForeignKey[] = {PollenUser.PROPERTY_NAME, PollenUser.PROPERTY_ADMINISTRATOR, PollenUser.PROPERTY_LANGUAGE, PollenUser.PROPERTY_PASSWORD, - PollenUser.PROPERTY_SALT, PollenUser.PROPERTY_BANNED, PollenUser.PROPERTY_GTU_VALIDATION_DATE, PollenUser.PROPERTY_PREMIUM_TO, - PollenUser.PROPERTY_CAN_CREATE_POLL, PollenUser.PROPERTY_TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, PollenUser.PROPERTY_USER_CREDENTIAL, PollenUser.PROPERTY_DEFAULT_EMAIL_ADDRESS, - PollenUser.PROPERTY_EMAIL_ADDRESSES, PollenUser.PROPERTY_AVATAR); - - String woForeignKey = getProperty(propertieswoForeignKey); - - String getuser = "with pollenu as " + - "((select json_agg(e) as emailaddresses from pollenuseremailaddress e where e.pollenuser = u.topiaid), " + - "(select json_agg(d)->0 as defaultemailaddress from pollenuseremailaddress d where d.pollenuser = u.defaultemailaddress)," + - "select u.* " + - " from pollenuser u)" + - " select json_agg(pu) from pollenu pu"; - - @Select(sql = getuser, mapper = PollenMapper.class) - PollenUser getFirstUser(); - - @Select(sql = getuser, mapper = PollenMapper.class) - PollenUser[] getallUser(); - - @Select(sql = "select json_agg(m.*) from pollenuseremailaddress m", mapper = PollenMapper.class) - PollenUserEmailAddress getUserEmail(); - - @Select(sql = "SELECT count(*) FROM PollenUser", mapper = PollenMapper.class) - int getUserCount(); -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenVoteSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenVoteSpgeedDao.java deleted file mode 100644 index 14f6bb97..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenVoteSpgeedDao.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.entity.Vote; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.*; - -public interface PollenVoteSpgeedDao { - - String propertieswoForeignKey[] = {Vote.PROPERTY_WEIGHT, Vote.PROPERTY_ANONYMOUS, Vote.PROPERTY_TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, Vote.PROPERTY_QUESTION, Vote.PROPERTY_VOTE_TO_CHOICE, - Vote.PROPERTY_VOTER_LIST_MEMBER, Vote.PROPERTY_VOTER); - - String woForeignKey = getProperty(propertieswoForeignKey); -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenVoterListMemberSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenVoterListMemberSpgeedDao.java deleted file mode 100644 index 0d2bacd6..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenVoterListMemberSpgeedDao.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.entity.VoterListMember; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.*; - -public interface PollenVoterListMemberSpgeedDao { - - String propertieswoForeignKey[] = {VoterListMember.PROPERTY_WEIGHT, VoterListMember.PROPERTY_INVITATION_SENT, VoterListMember.PROPERTY_TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, VoterListMember.PROPERTY_VOTER_LIST, VoterListMember.PROPERTY_MEMBER); - - String woForeignKey = getProperty(propertieswoForeignKey); -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenVoterListSpgeedDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenVoterListSpgeedDao.java deleted file mode 100644 index 8e2f283b..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/PollenVoterListSpgeedDao.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.PollenMapper; -import org.chorem.pollen.persistence.entity.Poll; -import org.chorem.pollen.persistence.entity.VoterList; -import org.nuiton.spgeed.annotations.Select; -import org.nuiton.spgeed.annotations.Update; - -import java.sql.Date; - -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.addStringToArray; -import static org.chorem.pollen.persistence.Dao.SpgeedDaoUtils.getProperty; - -public interface PollenVoterListSpgeedDao { - - String propertieswoForeignKey[] = {VoterList.PROPERTY_NAME, VoterList.PROPERTY_WEIGHT, VoterList.TOPIA_ID}; - - String Properties[] = addStringToArray(propertieswoForeignKey, VoterList.PROPERTY_POLL, VoterList.PROPERTY_PARENT); - - String woForeignKey = getProperty(propertieswoForeignKey); - -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/SpgeedDaoUtils.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/SpgeedDaoUtils.java deleted file mode 100644 index ac1a19ec..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/Dao/SpgeedDaoUtils.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.apache.commons.lang3.StringUtils; - -import java.sql.SQLException; - -public class SpgeedDaoUtils { - public static String getProperty(String ...properties) { - return StringUtils.join(properties, ", "); - } - - public static String[] propertiesToParameters(String format, String[] array) throws SQLException { - if (!format.contains("%s") || format.indexOf("%s") != format.lastIndexOf("%s")) { - System.err.println("Error: propertiesToParameters format's need to contain one : \"%s\""); - throw new SQLException(); - } - - int j = format.indexOf("%s"); - - for (int i = 0; i < array.length; i++) { - array[i] = format.substring(0, j).concat(array[i]); - array[i] = array[i].concat(format.substring(j + 2)); - } - return array; - } - - public static String []addStringToArray(String Array[], String ...Values) { - String result[] = new String[Array.length + Values.length]; - for (int i = 0; i < Array.length; i++) { - result[i] = Array[i]; - } - for (int i = 0; i < Values.length; i++) { - result[i + Array.length] = Values[i]; - } - return result; - } -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenConfig.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenConfig.java deleted file mode 100644 index 73e91e54..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenConfig.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.chorem.pollen.persistence; - -/* - * #%L - * Pollen :: Persistence - * %% - * Copyright (C) 2009 - 2017 Code Lutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.config.ApplicationConfig; -import org.nuiton.config.ArgumentsParserException; - -/** - * Created by couteau on 27/01/17. - */ -public class PollenConfig { - - final static private Log log = LogFactory.getLog(PollenConfig.class); - - protected static PollenConfig instance = new PollenConfig(); - - public static PollenConfig get() { - return instance; - } - - protected ApplicationConfig config; - - protected PollenConfig() { - ApplicationConfig configDefault = new ApplicationConfig("pollen.properties"); - try { - configDefault.parse(); - } catch (ArgumentsParserException e) { - log.error("Parse config error", e); - } - - this.config = new ApplicationConfig(configDefault.getFlatOptions(), "pollen-test.properties"); - try { - this.config.parse(); - } catch (ArgumentsParserException e) { - log.error("Parse config error", e); - } - } - - public String getDataSourceUrl() { - return this.config.getOption("pollen.datasource.url"); - } - - public String getDataSourceUser() { - return this.config.getOption("pollen.datasource.user"); - } - - public String getDataSourcePassword() { - return this.config.getOption("pollen.datasource.password"); - } - -} diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenMapper.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenMapper.java deleted file mode 100644 index be4da17a..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenMapper.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.chorem.pollen.persistence; - -import com.fasterxml.jackson.core.Version; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver; -import com.fasterxml.jackson.databind.module.SimpleModule; -import org.chorem.pollen.persistence.entity.*; -import org.nuiton.spgeed.mapper.JsonMapper; - -public class PollenMapper extends JsonMapper { - - @Override - public void configureObjectMapper(ObjectMapper mapper) { - - super.configureObjectMapper(mapper); - SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion()); - - SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver(); - - resolver.addMapping(PollenUser.class, PollenUserImpl.class); - resolver.addMapping(PollenUserEmailAddress.class, PollenUserEmailAddressImpl.class); - resolver.addMapping(Poll.class, PollImpl.class); - resolver.addMapping(PollenPrincipal.class, PollenPrincipalImpl.class); - resolver.addMapping(PollenToken.class, PollenTokenImpl.class); - resolver.addMapping(PollenResource.class, PollenResourceImpl.class); - resolver.addMapping(Choice.class, ChoiceImpl.class); - resolver.addMapping(VoterList.class, VoterListImpl.class); - resolver.addMapping(Vote.class, VoteImpl.class); - resolver.addMapping(VoterListMember.class, VoterListMemberImpl.class); - resolver.addMapping(Comment.class, CommentImpl.class); - resolver.addMapping(FavoriteList.class, FavoriteListImpl.class); - resolver.addMapping(FavoriteListMember.class, FavoriteListMemberImpl.class); - resolver.addMapping(ChildFavoriteList.class, ChildFavoriteListImpl.class); - resolver.addMapping(SessionToken.class, SessionTokenImpl.class); - - module.setAbstractTypes(resolver); - - mapper.registerModule(module); - } -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenSpgeedApplicationContext.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenSpgeedApplicationContext.java deleted file mode 100644 index 7d61e2f2..00000000 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenSpgeedApplicationContext.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.chorem.pollen.persistence; - -/* - * #%L - * Pollen :: Persistence - * %% - * Copyright (C) 2009 - 2017 Code Lutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import javax.sql.DataSource; -import org.postgresql.ds.PGSimpleDataSource; - -public class PollenSpgeedApplicationContext { - - protected DataSource dataSource; - - protected PGSimpleDataSource ds; - - public DataSource getDataSource() { - if (this.dataSource == null) { - PollenConfig Config = PollenConfig.get(); - PGSimpleDataSource ds = new PGSimpleDataSource(); - - ds.setUrl(Config.getDataSourceUrl()); - ds.setUser(Config.getDataSourceUser()); - ds.setPassword(Config.getDataSourcePassword()); - this.dataSource = ds; - } - return (dataSource); - } - - public void setDataSource(DataSource dataSource) { - this.dataSource = dataSource; - } - - public void setDataSource(String url, String password, String user) { - if (this.ds == null) { - this.ds = new PGSimpleDataSource(); - } - this.ds.setUser(user); - this.ds.setPassword(password); - this.ds.setUrl(url); - this.dataSource = this.ds; - } -} \ No newline at end of file diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/ChildFavoriteListTopiaDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/ChildFavoriteListTopiaDao.java index 6c2315e0..30524305 100644 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/ChildFavoriteListTopiaDao.java +++ b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/ChildFavoriteListTopiaDao.java @@ -39,9 +39,4 @@ public class ChildFavoriteListTopiaDao extends AbstractChildFavoriteListTopiaDao return findPage(builder.getHql(), builder.getHqlParameters(), page); } - - public static class PollenUserEmailAddressImpl extends PollenUserEmailAddressAbstract { - - private static final long serialVersionUID = 7293078431378782306L; - } //PollenUserEmailAddressImpl } diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java index 6baa8462..72c0a479 100644 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java +++ b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java @@ -15,7 +15,7 @@ package org.chorem.pollen.persistence.entity; * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenPrincipals.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenPrincipals.java index 5a8b799c..e7b5d1ec 100644 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenPrincipals.java +++ b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenPrincipals.java @@ -21,7 +21,6 @@ package org.chorem.pollen.persistence.entity; * #L% */ -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import org.nuiton.topia.persistence.TopiaEntity; /** @@ -30,7 +29,6 @@ import org.nuiton.topia.persistence.TopiaEntity; * @author Tony Chemit - dev@tchemit.fr * @since 2.0 */ -@JsonDeserialize(as = PollenPrincipalImpl.class) public class PollenPrincipals { public static <E extends TopiaEntity> PollenPrincipal getPrincipal(E entity) { diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java index e0d5ade6..2ae14757 100644 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java +++ b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserImpl.java @@ -21,12 +21,9 @@ package org.chorem.pollen.persistence.entity; * #L% */ -import java.util.Collection; - /** * @author Kevin Morin (Code Lutin) */ - public class PollenUserImpl extends PollenUserAbstract { @Override diff --git a/pollen-rest-api/pom.xml b/pollen-rest-api/pom.xml index f1929532..75c62f34 100644 --- a/pollen-rest-api/pom.xml +++ b/pollen-rest-api/pom.xml @@ -241,6 +241,7 @@ <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> + <scope>runtime</scope> </dependency> <dependency> diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java index 4671d566..3d07f18f 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java @@ -26,7 +26,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.LogManager; import org.apache.log4j.PropertyConfigurator; -import org.chorem.pollen.persistence.*; +import org.chorem.pollen.persistence.PollenPersistenceContext; +import org.chorem.pollen.persistence.PollenTopiaApplicationContext; +import org.chorem.pollen.persistence.PollenTopiaPersistenceContext; import org.chorem.pollen.persistence.entity.PollenPrincipal; import org.chorem.pollen.persistence.entity.PollenUser; import org.chorem.pollen.services.DefaultPollenServiceContext; @@ -70,18 +72,12 @@ public class PollenRestApiApplicationContext implements PollenApplicationContext PollenServicesConfig applicationConfig = new PollenServicesConfig("pollen-rest-api.properties"); - PollenSpgeedApplicationContext pollenSpgeedApplicationContext = new PollenSpgeedApplicationContext(); - Map<String, String> topiaProperties = applicationConfig.getTopiaProperties(); BeanTopiaConfiguration topiaConfiguration = new TopiaConfigurationBuilder().readMap(topiaProperties); - PollenTopiaApplicationContext pollenTopiaApplicationContext = new PollenTopiaApplicationContext(topiaConfiguration); - applicationContext = new PollenRestApiApplicationContext( - applicationConfig, - pollenTopiaApplicationContext, - pollenSpgeedApplicationContext); + applicationContext = new PollenRestApiApplicationContext(applicationConfig, pollenTopiaApplicationContext); applicationContext.init(); } @@ -108,8 +104,6 @@ public class PollenRestApiApplicationContext implements PollenApplicationContext protected final PollenTopiaApplicationContext topiaApplicationContext; - protected PollenSpgeedApplicationContext spgeedApplicationContext; - protected final PollenServicesConfig applicationConfig; protected VoteCountingFactory voteCountingFactory; @@ -125,21 +119,6 @@ public class PollenRestApiApplicationContext implements PollenApplicationContext this.closed = new AtomicBoolean(false); } - protected PollenRestApiApplicationContext(PollenServicesConfig applicationConfig, - PollenTopiaApplicationContext topiaApplicationContext, - PollenSpgeedApplicationContext spgeedApplicationContext) { - - Preconditions.checkNotNull(applicationConfig, "Configuration can not be null!"); - Preconditions.checkNotNull(topiaApplicationContext, "topiaApplicationContext can not be null!"); - Preconditions.checkNotNull(spgeedApplicationContext, "spgeedApplicationContext can not be null!"); - - this.applicationConfig = applicationConfig; - this.topiaApplicationContext = topiaApplicationContext; - this.spgeedApplicationContext = spgeedApplicationContext; - this.started = new AtomicBoolean(false); - this.closed = new AtomicBoolean(false); - } - @Override public PollenTopiaApplicationContext getTopiaApplicationContext() { return topiaApplicationContext; @@ -150,11 +129,6 @@ public class PollenRestApiApplicationContext implements PollenApplicationContext return applicationConfig; } - @Override - public PollenSpgeedApplicationContext getSpgeedDataSource() { - return spgeedApplicationContext; - } - @Override public VoteCountingFactory getVoteCountingFactory() { diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java index 1804c4e4..ce6e30b6 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java @@ -62,7 +62,6 @@ import org.chorem.pollen.services.service.security.SecurityService; import org.jboss.resteasy.spi.ResteasyProviderFactory; import javax.servlet.http.HttpServletRequest; -import javax.sql.DataSource; import javax.ws.rs.HttpMethod; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerRequestFilter; @@ -234,6 +233,7 @@ public class PollenRestApiRequestFilter implements ContainerRequestFilter, Conta ResteasyProviderFactory.pushContext(PollenServiceContext.class, serviceContext); + PollenSecurityContext securityContext = createSecurityContext(context, applicationContext, serviceContext); serviceContext.setSecurityContext(securityContext); ResteasyProviderFactory.pushContext(PollenSecurityContext.class, securityContext); diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/TransverseApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/TransverseApi.java index 64fa6be0..470fa9f3 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/TransverseApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/TransverseApi.java @@ -23,8 +23,6 @@ package org.chorem.pollen.rest.api.v1; import org.chorem.pollen.services.bean.ConfigurationBean; import org.chorem.pollen.services.bean.PollenStatus; -import org.chorem.pollen.services.bean.PollenUserBean; -import org.chorem.pollen.services.bean.PollenUserEmailAddressBean; import org.chorem.pollen.services.service.TransverseService; import javax.ws.rs.Consumes; @@ -58,20 +56,5 @@ public class TransverseApi { } - @Path("/spgeed") - @GET - public PollenUserBean getSpgeed(@Context TransverseService transverseService) { - - return transverseService.getSpgeed(); - - } - - @Path("/email") - @GET - public PollenUserEmailAddressBean getEmail(@Context TransverseService transverseService) { - - return transverseService.getEmail(); - } - } diff --git a/pollen-rest-api/src/test/resources/#pollen-rest-api-test.properties# b/pollen-rest-api/src/test/resources/#pollen-rest-api-test.properties# deleted file mode 100644 index 1674773a..00000000 --- a/pollen-rest-api/src/test/resources/#pollen-rest-api-test.properties# +++ /dev/null @@ -1,31 +0,0 @@ -### -# #%L -# Pollen :: Service -# %% -# Copyright (C) 2009 - 2017 Code Lutin, Tony Chemit -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# #L% -### - -hibernate.dialect=org.hibernate.dialect.postgreSQLDialect -hibernate.connection.url=jdbc:postgresql://localhost:5432/pollenprod?allowMultiQueries=true -hibernate.connection.username=pollen -hibernate.connection.password=pollen -hibernate.connection.driver_class=org.postgresql.Driver -#hibernate.hbm2ddl.auto=update -pollen.version=${project.version} -topia.persistence.topiaIdFactoryClassName=org.nuiton.topia.persistence.internal.ShortTopiaIdFactory -topia.service.migration=org.chorem.pollen.persistence.PollenFlywayServiceImpl -pollen.devMode=true diff --git a/pollen-rest-api/src/test/resources/.#pollen-rest-api-test.properties b/pollen-rest-api/src/test/resources/.#pollen-rest-api-test.properties deleted file mode 120000 index db2ccc70..00000000 --- a/pollen-rest-api/src/test/resources/.#pollen-rest-api-test.properties +++ /dev/null @@ -1 +0,0 @@ -Killian_H@localhost.localdomain.4769:1566378066 \ No newline at end of file diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java b/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java index db7ad59e..0cde7f7a 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java @@ -22,7 +22,6 @@ package org.chorem.pollen.services; */ import org.chorem.pollen.persistence.PollenPersistenceContext; -import org.chorem.pollen.persistence.PollenSpgeedApplicationContext; import org.chorem.pollen.persistence.PollenTopiaApplicationContext; import org.chorem.pollen.persistence.PollenTopiaPersistenceContext; import org.chorem.pollen.persistence.entity.PollenPrincipal; @@ -46,8 +45,6 @@ public interface PollenApplicationContext extends Closeable { PollenServicesConfig getApplicationConfig(); - PollenSpgeedApplicationContext getSpgeedDataSource(); - VoteCountingFactory getVoteCountingFactory(); PollenTopiaPersistenceContext newPersistenceContext(); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java b/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java index 22a3fd79..07cf0668 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java @@ -24,7 +24,19 @@ package org.chorem.pollen.services; import com.esotericsoftware.yamlbeans.YamlException; import com.esotericsoftware.yamlbeans.YamlReader; import org.apache.commons.io.IOUtils; -import org.chorem.pollen.persistence.entity.*; +import org.chorem.pollen.persistence.entity.ChoiceImpl; +import org.chorem.pollen.persistence.entity.CommentImpl; +import org.chorem.pollen.persistence.entity.FavoriteListImpl; +import org.chorem.pollen.persistence.entity.FavoriteListMemberImpl; +import org.chorem.pollen.persistence.entity.PollImpl; +import org.chorem.pollen.persistence.entity.PollenPrincipalImpl; +import org.chorem.pollen.persistence.entity.PollenUserEmailAddressImpl; +import org.chorem.pollen.persistence.entity.PollenUserImpl; +import org.chorem.pollen.persistence.entity.QuestionImpl; +import org.chorem.pollen.persistence.entity.VoteImpl; +import org.chorem.pollen.persistence.entity.VoteToChoiceImpl; +import org.chorem.pollen.persistence.entity.VoterListImpl; +import org.chorem.pollen.persistence.entity.VoterListMemberImpl; import java.io.IOException; import java.io.InputStream; @@ -60,7 +72,7 @@ public class PollenFixtures { reader.getConfig().setClassTag("vote", VoteImpl.class); reader.getConfig().setClassTag("pollen-principal", PollenPrincipalImpl.class); reader.getConfig().setClassTag("pollenUIContext", PollenUIContext.class); - reader.getConfig().setClassTag("email-address", ChildFavoriteListTopiaDao.PollenUserEmailAddressImpl.class); + reader.getConfig().setClassTag("email-address", PollenUserEmailAddressImpl.class); reader.getConfig().setClassTag("array-list", ArrayList.class); try { diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServicesConfig.java b/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServicesConfig.java index 0e991fa2..b19988dc 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServicesConfig.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServicesConfig.java @@ -179,15 +179,4 @@ public class PollenServicesConfig extends GeneratedPollenServicesConfig { return Base64.getDecoder().decode(secret); } - public String getDataSourceUrl() { - return get().getOption("hibernate.connection.url"); - } - - public String getDataSourcePassword() { - return get().getOption("hibernate.connection.password"); - } - - public String getDataSourceUser() { - return get().getOption("hibernate.connection.username"); - } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java index ef6ee3c2..9b060618 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java @@ -21,12 +21,19 @@ package org.chorem.pollen.services.service; * #L% */ -import com.google.common.base.Preconditions; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.pollen.persistence.entity.*; +import org.chorem.pollen.persistence.entity.Comment; +import org.chorem.pollen.persistence.entity.PollenPrincipal; +import org.chorem.pollen.persistence.entity.PollenResource; +import org.chorem.pollen.persistence.entity.PollenUser; +import org.chorem.pollen.persistence.entity.PollenUserEmailAddress; +import org.chorem.pollen.persistence.entity.ResourceType; +import org.chorem.pollen.persistence.entity.UserCredential; +import org.chorem.pollen.persistence.entity.Vote; +import org.chorem.pollen.persistence.entity.VoteTopiaDao; import org.chorem.pollen.services.PollenService; import org.chorem.pollen.services.bean.PaginationParameterBean; import org.chorem.pollen.services.bean.PaginationResultBean; diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/TransverseService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/TransverseService.java index 7347cdcc..d2bd4ba9 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/TransverseService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/TransverseService.java @@ -21,26 +21,13 @@ package org.chorem.pollen.services.service; * #L% */ -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.type.CollectionType; -import com.fasterxml.jackson.databind.type.TypeFactory; import com.google.common.collect.Lists; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.pollen.persistence.entity.PollenUser; -import org.chorem.pollen.persistence.entity.PollenUserEmailAddress; -import org.chorem.pollen.services.PollenTechnicalException; import org.chorem.pollen.services.UnitHuman; import org.chorem.pollen.services.bean.ConfigurationBean; import org.chorem.pollen.services.bean.PollenStatus; -import org.chorem.pollen.services.bean.PollenUserBean; -import org.chorem.pollen.services.bean.PollenUserEmailAddressBean; -import org.chorem.pollen.services.service.security.SpgeedDummyService; -import java.io.IOException; import java.lang.management.ManagementFactory; import java.lang.management.OperatingSystemMXBean; import java.util.List; @@ -60,24 +47,6 @@ public class TransverseService extends PollenServiceSupport { return bean; } - public PollenUserBean getSpgeed() { - - SpgeedDummyService spgeedDummyService = new SpgeedDummyService(); - PollenUser user = spgeedDummyService.getPollenUser(); - PollenUserService pollenUserService = newService(PollenUserService.class); - - return pollenUserService.toPollenUserBean(user); - } - - public PollenUserEmailAddressBean getEmail() { - - SpgeedDummyService spgeedDummyService = new SpgeedDummyService(); - PollenUserEmailAddress email = spgeedDummyService.getPollenUserEmailaddress(); - PollenUserService pollenUserService = newService(PollenUserService.class); - - return pollenUserService.toPollenUserEmailAddressBean(email); - } - public PollenStatus getStatus() { long statusStart = System.currentTimeMillis(); List<String> errors = Lists.newArrayList(); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SpgeedDao.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SpgeedDao.java deleted file mode 100644 index 8d3dd98b..00000000 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SpgeedDao.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.chorem.pollen.persistence.Dao; - -import org.chorem.pollen.persistence.PollenSpgeedApplicationContext; - -import javax.sql.DataSource; - -public class SpgeedDao { - - DataSource dataSource = null; - - public DataSource getdb() { - - if (dataSource == null) { - PollenSpgeedApplicationContext pollenSpgeedApplicationContext = new PollenSpgeedApplicationContext(); - - PollenServicesConfig pollenServicesConfig = new PollenServicesConfig("pollen-rest-api.properties"); - - String dburl = pollenServicesConfig.getDataSourceUrl(); - String dbpassword = pollenServicesConfig.getDataSourcePassword(); - String dbuser = pollenServicesConfig.getDataSourceUser(); - - pollenSpgeedApplicationContext.setDataSource(dburl, dbuser, dbpassword); - this.dataSource = pollenSpgeedApplicationContext.getDataSource(); - } - return (dataSource); - } - - public static SpgeedUserDao getUserDao() { - - } -} \ No newline at end of file diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SpgeedDummyService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SpgeedDummyService.java deleted file mode 100644 index 5fb09f43..00000000 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SpgeedDummyService.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.chorem.pollen.services.service.security; - -import org.chorem.pollen.persistence.PollenSpgeedApplicationContext; -import org.chorem.pollen.persistence.Dao.PollenUserSpgeedDao; -import org.chorem.pollen.persistence.Dao.PollenPollSpgeedDao; -import org.chorem.pollen.persistence.entity.Poll; -import org.chorem.pollen.persistence.entity.PollenUser; -import org.chorem.pollen.persistence.entity.PollenUserEmailAddress; -import org.chorem.pollen.persistence.entity.Polls; -import org.chorem.pollen.services.PollenServiceContext; -import org.chorem.pollen.services.PollenTechnicalException; -import org.chorem.pollen.services.config.PollenServicesConfig; -import org.nuiton.spgeed.SqlSession; - -import javax.sql.DataSource; -import java.sql.SQLException; - -public class SpgeedDummyService { - - DataSource dataSource = null; - - public DataSource getdb() { - - if (dataSource == null) { - PollenSpgeedApplicationContext pollenSpgeedApplicationContext = new PollenSpgeedApplicationContext(); - - PollenServicesConfig pollenServicesConfig = new PollenServicesConfig("pollen-rest-api.properties"); - - String dburl = pollenServicesConfig.getDataSourceUrl(); - String dbpassword = pollenServicesConfig.getDataSourcePassword(); - String dbuser = pollenServicesConfig.getDataSourceUser(); - - pollenSpgeedApplicationContext.setDataSource(dburl, dbuser, dbpassword); - this.dataSource = pollenSpgeedApplicationContext.getDataSource(); - } - return (dataSource); - } - - public Poll[] getallPoll() { - DataSource ds = getdb(); - - try (SqlSession session = new SqlSession(ds)) { - - PollenPollSpgeedDao dao = session.getDao(PollenPollSpgeedDao.class); - - return (dao.getallpoll()); - } catch(SQLException e) { - throw new PollenTechnicalException("erreur lors du chargement d'un sondage", e); - } - } - - public PollenUser getPollenUser() { - - DataSource ds = getdb(); - - try (SqlSession session = new SqlSession(ds)) { - - PollenUserSpgeedDao dao = session.getDao(PollenUserSpgeedDao.class); - - return (dao.getUser()); - } catch(SQLException e) { - throw new PollenTechnicalException("erreur lors du chargement d'un utilisateur", e); - } - - } - - public PollenUser[] getallPollenUser() { - - DataSource ds = getdb(); - - try (SqlSession session = new SqlSession(ds)) { - - PollenUserSpgeedDao dao = session.getDao(PollenUserSpgeedDao.class); - - return (dao.getallUser()); - } catch(SQLException e) { - throw new PollenTechnicalException("erreur lors du chargement d'un utilisateur", e); - } - - } - - public PollenUserEmailAddress getPollenUserEmailaddress() { - - DataSource ds = getdb(); - - try (SqlSession session = new SqlSession(ds)) { - - PollenUserSpgeedDao dao = session.getDao(PollenUserSpgeedDao.class); - - return (dao.getUserEmail()); - } catch(SQLException e) { - throw new PollenTechnicalException("erreur lors du chargement d'une address mail", e); - } - } - - public int getPollenUsercount() { - - DataSource ds = getdb(); - - try (SqlSession session = new SqlSession(ds)) { - - PollenUserSpgeedDao dao = session.getDao(PollenUserSpgeedDao.class); - - return (dao.getUserCount()); - } catch(SQLException e) { - throw new PollenTechnicalException("erreur lors du chargement d'un utilisateur", e); - } - } -} - diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java b/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java index ea75fa6d..bf39e898 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java @@ -28,7 +28,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.pollen.persistence.PollenPersistenceContext; -import org.chorem.pollen.persistence.PollenSpgeedApplicationContext; import org.chorem.pollen.persistence.PollenTopiaApplicationContext; import org.chorem.pollen.persistence.PollenTopiaPersistenceContext; import org.chorem.pollen.persistence.entity.PollenPrincipal; @@ -40,7 +39,6 @@ import org.chorem.pollen.services.config.PollenServicesConfig; import org.chorem.pollen.services.config.PollenServicesConfigOption; import org.chorem.pollen.services.service.FixturesService; import org.chorem.pollen.votecounting.VoteCountingFactory; -import org.junit.Assert; import org.junit.rules.TestWatcher; import org.junit.runner.Description; import org.nuiton.topia.persistence.BeanTopiaConfiguration; @@ -140,8 +138,6 @@ public class FakePollenApplicationContext extends TestWatcher implements PollenA // --- create configuration --- // Properties defaultvalues = new Properties(); - Assert.assertNotNull(PollenServicesConfigOption.DATA_DIRECTORY); - Assert.assertNotNull(testBasedir); defaultvalues.put(PollenServicesConfigOption.DATA_DIRECTORY.getKey(), testBasedir.getAbsolutePath()); configuration = new PollenServicesConfig(configurationPath, defaultvalues); @@ -192,11 +188,6 @@ public class FakePollenApplicationContext extends TestWatcher implements PollenA return configuration; } - @Override - public PollenSpgeedApplicationContext getSpgeedDataSource() { - return null; - } - @Override public VoteCountingFactory getVoteCountingFactory() { diff --git a/pollen-services/src/test/java/org/chorem/pollen/services/SpgeedDaoUtilsTest.java b/pollen-services/src/test/java/org/chorem/pollen/services/SpgeedDaoUtilsTest.java deleted file mode 100644 index 29a3c39f..00000000 --- a/pollen-services/src/test/java/org/chorem/pollen/services/SpgeedDaoUtilsTest.java +++ /dev/null @@ -1,211 +0,0 @@ -package org.chorem.pollen.services; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.chorem.pollen.persistence.PollenTopiaApplicationContext; -import org.chorem.pollen.persistence.PollenTopiaPersistenceContext; -import org.chorem.pollen.persistence.entity.*; -import org.chorem.pollen.services.service.security.SpgeedDummyService; -import org.chorem.pollen.services.test.FakePollenApplicationContext; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; - -import java.util.List; - -/** - * @author ymartel (martel@codelutin.com) - */ -public class SpgeedTest { - - @Rule - public final FakePollenApplicationContext application = new FakePollenApplicationContext("pollen-rest-api.properties"); - - public static final String EMAIL_JSON = "{ " + - " \"topiaid\":\"PollenUserEmailAddress_M-wGbZ74QQCUr_hwl6JXmw\"," + - " \"topiaversion\":1," + - " \"topiacreatedate\":\"2019-07-19T10:00:30.962\"," + - " \"emailaddress\":\"admin@chorem.org\"," + - " \"pgppublickey\":null," + - " \"validated\":true," + - " \"pollenuser\":\"PollenUser_6qdaqbgBTyCBa8Dvz5SeHQ\"" + - "}"; - - public static final String USER_JSON = "{" + - " \"name\":\"admin\"," + - " \"administrator\":true," + - " \"language\":null," + - " \"password\":\"m7LAmO/AeLrjPI6kkzS0wTmU6fpbG/nxptfi/P7fg0BToZoIAV6xVre3tcttYxnLTDrXjtq7YOpggTFRz7mTjA==\"," + - " \"banned\":false," + - " \"gtuvalidationdate\":null," + - " \"premiumto\":null," + - " \"cancreatepoll\":false," + - " \"emailaddresses\":[" + - " {" + - " \"topiaid\":\"PollenUserEmailAddress_M-wGbZ74QQCUr_hwl6JXmw\"," + - " \"topiaversion\":1," + - " \"topiacreatedate\":\"2019-07-19T10:00:30.962\"," + - " \"emailaddress\":\"admin@chorem.org\"," + - " \"pgppublickey\":null," + - " \"validated\":true," + - " \"pollenuser\":\"PollenUser_6qdaqbgBTyCBa8Dvz5SeHQ\"" + - " }" + - " ]," + - " \"defaultemailaddress\":" + - " {" + - " \"topiaid\":\"PollenUserEmailAddress_M-wGbZ74QQCUr_hwl6JXmw\"," + - " \"topiaversion\":1," + - " \"topiacreatedate\":\"2019-07-19T10:00:30.962\"," + - " \"emailaddress\":\"admin@chorem.org\"," + - " \"pgppublickey\":null," + - " \"validated\":true," + - " \"pollenuser\":\"PollenUser_6qdaqbgBTyCBa8Dvz5SeHQ\"" + - " }" + - "}"; - - @Test - public void testEmailDeserialization() throws Exception { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); - PollenUserEmailAddress email = mapper.readValue(EMAIL_JSON, PollenUserEmailAddress.class); - - Assert.assertNotNull(email); - Assert.assertEquals("admin@chorem.org", email.getEmailAddress()); - } - - @Test - public void testUserDeserialization() throws Exception { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); - PollenUser pollenUser = mapper.readValue(USER_JSON, PollenUser.class); - - Assert.assertNotNull(pollenUser); - Assert.assertNotNull(pollenUser.getEmailAddresses()); - Assert.assertNotNull(pollenUser.getDefaultEmailAddress()); - Assert.assertEquals("admin@chorem.org", pollenUser.getDefaultEmailAddress().getEmailAddress()); - Assert.assertEquals("admin", pollenUser.getName()); - Assert.assertTrue(pollenUser.isAdministrator()); - } - - @Test - public void testUserDeserializationCallDB() { - SpgeedDummyService spgeedDummyService = new SpgeedDummyService(); - PollenUser[] pollenUser = spgeedDummyService.getallPollenUser(); - Assert.assertNotNull(pollenUser); - } - - @Test - public void testPoll() { - SpgeedDummyService spgeedDummyService = new SpgeedDummyService(); - Poll[] polls = spgeedDummyService.getallPoll(); - PollenUser[] user = spgeedDummyService.getallPollenUser(); - - System.out.println(spgeedDummyService.getPollenUsercount()); - Assert.assertNotNull(polls); - } - - public List<Poll> getTopiaPolls() { - List<Poll> topiaPoll = null; - - try (PollenTopiaApplicationContext topiaApplicationContext = application.getTopiaApplicationContext()) { - try (PollenTopiaPersistenceContext topiaPersistenceContext = topiaApplicationContext.newPersistenceContext()) { - for (int i = 0; i < 1; i++) { - PollTopiaDao pollDao = topiaPersistenceContext.getPollDao(); - topiaPoll = pollDao.findAll(); - for (int j = 0; j < topiaPoll.size(); j++) { - Assert.assertNotNull(topiaPoll.get(j)); - Assert.assertNotNull(topiaPoll.get(j).getCreator()); - Assert.assertNotNull(topiaPoll.get(j).getCreator().getPollenUser()); - Assert.assertNotNull(topiaPoll.get(j).getCreator().getPollenUser().getDefaultEmailAddress()); - Assert.assertNotNull(topiaPoll.get(j).getCreator().getPollenUser().getDefaultEmailAddress().getEmailAddress()); - topiaPoll.get(j).getTitle(); - topiaPoll.get(j).getEndDate(); - topiaPoll.get(j).getVoteVisibility(); - topiaPoll.get(j).getCommentVisibility(); - topiaPoll.get(j).getResultVisibility(); - topiaPoll.get(j).getBeginDate(); - topiaPoll.get(j).getPollType(); - topiaPoll.get(j).getNotifyMeHoursBeforePollEnds(); - topiaPoll.get(j).getFeedContent(); - topiaPoll.get(j).getNotificationLocale(); - topiaPoll.get(j).getDescription(); - topiaPoll.get(j).getEmailAddressSuffixes(); - topiaPoll.get(j).getGtuValidationDate(); - topiaPoll.get(j).getClass(); - topiaPoll.get(j).getTopiaVersion(); - topiaPoll.get(j).getTopiaId(); - topiaPoll.get(j).getTopiaCreateDate(); - } - } - } - } - return topiaPoll; - } - - public Poll[] getSpgeedPolls() { - SpgeedDummyService spgeedDummyService = new SpgeedDummyService(); - Poll[] spgeedPollArray = null; - - for (int i = 0; i < 1; i++) { - spgeedPollArray = spgeedDummyService.getallPoll(); - } - return spgeedPollArray; - } - - - @Test - public void testPollLink() { - SpgeedDummyService spgeedDummyService = new SpgeedDummyService(); - Poll[] PollArray = spgeedDummyService.getallPoll(); - /* Testing foreign key value */ - Assert.assertNotNull(PollArray); - Assert.assertNotNull(PollArray[0]); - Assert.assertNotNull(PollArray[0].getCreator().getPollenUser()); - Assert.assertNotNull(PollArray[0].getCreator().getPollenUser().getEmailAddresses()); - Assert.assertNotNull(PollArray[0].getCreator().getPollenUser().getDefaultEmailAddress()); - - /* Testing Poll filling */ - Assert.assertNotNull(PollArray[0].getTitle()); - Assert.assertNotNull(PollArray[0].getEndDate()); - Assert.assertNotNull(PollArray[0].getVoteVisibility()); - Assert.assertNotNull(PollArray[0].getCommentVisibility()); - Assert.assertNotNull(PollArray[0].getResultVisibility()); - Assert.assertNotNull(PollArray[0].getBeginDate()); - Assert.assertNotNull(PollArray[0].getNotifyMeHoursBeforePollEnds()); - Assert.assertNotNull(PollArray[0].getFeedContent()); - Assert.assertNotNull(PollArray[0].getNotificationLocale()); - Assert.assertNotNull(PollArray[0].getEmailAddressSuffixes()); - Assert.assertNotNull(PollArray[0].getGtuValidationDate()); - Assert.assertNotNull(PollArray[0].getTopiaId()); - Assert.assertNotNull(PollArray[0].getClass()); - Assert.assertNotNull(PollArray[0].getTopiaVersion()); - Assert.assertNotNull(PollArray[0].getTopiaCreateDate()); - Assert.assertNotNull(PollArray[0].getDescription()); - Assert.assertNotNull(PollArray[0].getCreator()); - } - @Test - public void testPerformance() { - Poll[] spgeedPollArray; - List<Poll> topiaPoll; - long beforSpgeed = System.currentTimeMillis(); - - spgeedPollArray = getSpgeedPolls(); - - long afterSpgeed = System.currentTimeMillis(); - - topiaPoll = getTopiaPolls(); - - long topiaExecutionTime = System.currentTimeMillis() - afterSpgeed; - Assert.assertNotNull(spgeedPollArray); - Assert.assertNotNull(topiaPoll); - Assert.assertEquals(topiaPoll.size(), spgeedPollArray.length); - long spgeedExecutionTime = afterSpgeed - beforSpgeed; - System.out.println(topiaExecutionTime + " "+spgeedExecutionTime); - Assert.assertTrue(topiaExecutionTime > spgeedExecutionTime); - } -} \ No newline at end of file diff --git a/pollen-services/src/test/java/org/chorem/pollen/services/SpgeedTest.java b/pollen-services/src/test/java/org/chorem/pollen/services/SpgeedTest.java deleted file mode 100644 index c3fa52b9..00000000 --- a/pollen-services/src/test/java/org/chorem/pollen/services/SpgeedTest.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.chorem.pollen.services; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.chorem.pollen.persistence.PollenTopiaApplicationContext; -import org.chorem.pollen.persistence.entity.Poll; -import org.chorem.pollen.persistence.entity.PollenUser; -import org.chorem.pollen.persistence.entity.PollenUserEmailAddress; -import org.chorem.pollen.services.config.PollenServicesConfig; -import org.chorem.pollen.services.config.PollenServicesConfigOption; -import org.chorem.pollen.services.service.PollenServiceSupport; -import org.chorem.pollen.services.service.security.SpgeedDummyService; -import org.chorem.pollen.services.test.FakePollenApplicationContext; -import org.chorem.pollen.services.test.FakePollenServiceContext; -import org.junit.Assert; -import org.junit.Test; -import org.nuiton.topia.persistence.BeanTopiaConfiguration; -import org.nuiton.topia.persistence.TopiaApplicationContext; -import org.nuiton.topia.persistence.TopiaConfigurationBuilder; - -import java.io.File; -import java.util.Date; -import java.util.Map; -import java.util.Properties; - -/** - * @author ymartel (martel@codelutin.com) - */ -public class SpgeedTest { - - public static final String EMAIL_JSON = "{ " + - " \"topiaid\":\"PollenUserEmailAddress_M-wGbZ74QQCUr_hwl6JXmw\"," + - " \"topiaversion\":1," + - " \"topiacreatedate\":\"2019-07-19T10:00:30.962\"," + - " \"emailaddress\":\"admin@chorem.org\"," + - " \"pgppublickey\":null," + - " \"validated\":true," + - " \"pollenuser\":\"PollenUser_6qdaqbgBTyCBa8Dvz5SeHQ\"" + - "}"; - - public static final String USER_JSON = "{" + - " \"name\":\"admin\"," + - " \"administrator\":true," + - " \"language\":null," + - " \"password\":\"m7LAmO/AeLrjPI6kkzS0wTmU6fpbG/nxptfi/P7fg0BToZoIAV6xVre3tcttYxnLTDrXjtq7YOpggTFRz7mTjA==\"," + - " \"banned\":false," + - " \"gtuvalidationdate\":null," + - " \"premiumto\":null," + - " \"cancreatepoll\":false," + - " \"emailaddresses\":[" + - " {" + - " \"topiaid\":\"PollenUserEmailAddress_M-wGbZ74QQCUr_hwl6JXmw\"," + - " \"topiaversion\":1," + - " \"topiacreatedate\":\"2019-07-19T10:00:30.962\"," + - " \"emailaddress\":\"admin@chorem.org\"," + - " \"pgppublickey\":null," + - " \"validated\":true," + - " \"pollenuser\":\"PollenUser_6qdaqbgBTyCBa8Dvz5SeHQ\"" + - " }" + - " ]," + - " \"defaultemailaddress\":" + - " {" + - " \"topiaid\":\"PollenUserEmailAddress_M-wGbZ74QQCUr_hwl6JXmw\"," + - " \"topiaversion\":1," + - " \"topiacreatedate\":\"2019-07-19T10:00:30.962\"," + - " \"emailaddress\":\"admin@chorem.org\"," + - " \"pgppublickey\":null," + - " \"validated\":true," + - " \"pollenuser\":\"PollenUser_6qdaqbgBTyCBa8Dvz5SeHQ\"" + - " }" + - "}"; - - @Test - public void testEmailDeserialization() throws Exception { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); - PollenUserEmailAddress email = mapper.readValue(EMAIL_JSON, PollenUserEmailAddress.class); - - Assert.assertNotNull(email); - Assert.assertEquals("admin@chorem.org", email.getEmailAddress()); - } - - @Test - public void testUserDeserialization() throws Exception { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); - PollenUser pollenUser = mapper.readValue(USER_JSON, PollenUser.class); - - Assert.assertNotNull(pollenUser); - Assert.assertNotNull(pollenUser.getEmailAddresses()); - Assert.assertNotNull(pollenUser.getDefaultEmailAddress()); - Assert.assertEquals("admin@chorem.org", pollenUser.getDefaultEmailAddress().getEmailAddress()); - Assert.assertEquals("admin", pollenUser.getName()); - Assert.assertTrue(pollenUser.isAdministrator()); - } - - @Test - public void testUserDeserializationCallDB() { - Date now = new Date(); - long start = now.getTime(); - SpgeedDummyService spgeedDummyService = new SpgeedDummyService(); - PollenUser[] pollenUser = spgeedDummyService.getallPollenUser(); - now = new Date(); - long spgeed_time = now.getTime(); - FakePollenApplicationContext applicationContext = new FakePollenApplicationContext("pollen-service.properties"); - applicationContext.init(); - TopiaApplicationContext topiaApplicationContext = applicationContext.getTopiaApplicationContext(); - PollenServiceContext serviceContext = topiaApplicationContext.getServices(); - //PollTopiaDao dao = get - //PollenUser[] topiauser = getAll; - now = new Date(); - long topia_hibernate_time = now.getTime(); - - System.out.println(spgeed_time - start); - System.out.println("Spgeed time: "+ (spgeed_time - start) + "\nTopia & hibernate time: "+(topia_hibernate_time - spgeed_time)); - Assert.assertTrue(spgeed_time - start < topia_hibernate_time - spgeed_time); - } - - @Test - public void testPoll() { - SpgeedDummyService spgeedDummyService = new SpgeedDummyService(); - Poll[] polls = spgeedDummyService.getallPoll(); - - Assert.assertNotNull(polls); - Poll first = polls[0]; - Assert.assertEquals(polls.length, 1); - Assert.assertEquals(first.getTitle(), "Sondage"); - Assert.assertEquals(first.getDescription(), "cc"); - } - -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 87a20642..0186c9f4 100644 --- a/pom.xml +++ b/pom.xml @@ -180,8 +180,6 @@ <nuitonI18nVersion>3.7</nuitonI18nVersion> <eugenePluginVersion>3.0-alpha-10</eugenePluginVersion> <topiaVersion>3.5</topiaVersion> - <spgeedVersion>1.0.11-SNAPSHOT</spgeedVersion> - <flywayVersion>5.0.0</flywayVersion> <nuitonWebVersion>1.20</nuitonWebVersion> @@ -301,11 +299,6 @@ <!-- persistence module dependencies --> - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>spgeed</artifactId> - <version>${spgeedVersion}</version> - </dependency> <dependency> <groupId>org.nuiton.topia</groupId> <artifactId>topia-persistence</artifactId> @@ -637,15 +630,6 @@ <pluginManagement> <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <compilerArgs> - <arg>-parameters</arg> - </compilerArgs> - </configuration> - </plugin> <plugin> <artifactId>maven-site-plugin</artifactId> <dependencies> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.