branch feature/delete_ui_url_in_back_conf created (now 9fcf2f6)
This is an automated email from the git hooks/post-receive script. New change to branch feature/delete_ui_url_in_back_conf in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git at 9fcf2f6 ajout des urls dans l'uicontext This branch includes the following new commits: new a6a1d68 back: remove ui urls from conf new 9fcf2f6 ajout des urls dans l'uicontext The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 9fcf2f6461f157a96d291534d66b0a508c776cc0 Author: Kevin Morin <morin@codelutin.com> Date: Thu Mar 2 15:48:05 2017 +0100 ajout des urls dans l'uicontext commit a6a1d685b4b7e8fef7aa8e3829fe08ba904cbed1 Author: Kevin Morin <morin@codelutin.com> Date: Thu Mar 2 15:45:26 2017 +0100 back: remove ui urls from conf -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/delete_ui_url_in_back_conf in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit a6a1d685b4b7e8fef7aa8e3829fe08ba904cbed1 Author: Kevin Morin <morin@codelutin.com> Date: Thu Mar 2 15:45:26 2017 +0100 back: remove ui urls from conf --- .../org/chorem/pollen/rest/api/v1/PollApi.java | 10 +-- .../org/chorem/pollen/rest/api/PollApiTest.java | 3 + pollen-services/src/main/config/PollenServices.ini | 30 --------- .../chorem/pollen/services/PollenUIContext.java | 31 +++++++++ .../pollen/services/service/FixturesService.java | 3 +- .../services/service/NotificationService.java | 8 +-- .../pollen/services/service/PollService.java | 9 +-- .../services/service/PollenUIUrlRenderService.java | 74 ++++++++++---------- .../pollen/services/service/mail/EmailService.java | 78 +++++++++++----------- .../pollen/services/service/PollServiceTest.java | 13 ++-- .../service/PollenUIUrlRenderServiceTest.java | 48 +++++++------ .../services/service/VoteCountingServiceTest.java | 3 +- .../services/service/VoterListServiceTest.java | 5 +- 13 files changed, 165 insertions(+), 150 deletions(-) diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java index 27d4383..94302e9 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java @@ -24,6 +24,7 @@ package org.chorem.pollen.rest.api.v1; import com.google.common.collect.Lists; import org.chorem.pollen.persistence.entity.ChoiceType; import org.chorem.pollen.persistence.entity.Poll; +import org.chorem.pollen.services.PollenUIContext; import org.chorem.pollen.services.bean.ChoiceBean; import org.chorem.pollen.services.bean.PaginationParameterBean; import org.chorem.pollen.services.bean.PaginationResultBean; @@ -83,11 +84,12 @@ public class PollApi extends WebMotionController { public PollenEntityRef<Poll> createPoll(PollService pollService, PollBean poll, - ChoiceBean... choices) throws InvalidFormException { + ChoiceBean[] choices, + PollenUIContext pollenUIContext) throws InvalidFormException { List<ChoiceBean> choiceList = Lists.newArrayList(choices); - return pollService.createPoll(poll, choiceList); + return pollService.createPoll(poll, choiceList, pollenUIContext); } @@ -103,9 +105,9 @@ public class PollApi extends WebMotionController { } - public PollenEntityRef<Poll> clonePoll(PollService pollService, PollenEntityId<Poll> pollId) { + public PollenEntityRef<Poll> clonePoll(PollService pollService, PollenEntityId<Poll> pollId, PollenUIContext pollenUIContext) { - return pollService.clonePoll(pollId.getEntityId()); + return pollService.clonePoll(pollId.getEntityId(), pollenUIContext); } diff --git a/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java b/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java index 41c11f1..e29032b 100644 --- a/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java +++ b/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java @@ -32,6 +32,7 @@ import org.chorem.pollen.persistence.entity.PollType; import org.chorem.pollen.persistence.entity.ResultVisibility; import org.chorem.pollen.persistence.entity.VoteVisibility; import org.chorem.pollen.services.PollenFixtures; +import org.chorem.pollen.services.PollenUIContext; import org.chorem.pollen.services.bean.ChoiceBean; import org.junit.Before; import org.junit.Ignore; @@ -144,6 +145,7 @@ public class PollApiTest extends AbstractPollenRestApiTest { Request request = createRequest(RestApiFixtures.polls(null, null)) .addParameter("poll", pollStr) .addParameter("choices", choiceStr) + .addParameter("pollenUIContext", getJsonHelper().toJson(new PollenUIContext())) .Post(); String content = request.execute().returnContent().asString(); @@ -171,6 +173,7 @@ public class PollApiTest extends AbstractPollenRestApiTest { Request request = createRequest(RestApiFixtures.polls(null, null)) .addParameter("poll", pollStr) .addParameter("choices", choiceStr) + .addParameter("pollenUIContext", getJsonHelper().toJson(new PollenUIContext())) .Post(); String content = request.execute().returnContent().asString(); diff --git a/pollen-services/src/main/config/PollenServices.ini b/pollen-services/src/main/config/PollenServices.ini index e45fdb2..cdc1678 100644 --- a/pollen-services/src/main/config/PollenServices.ini +++ b/pollen-services/src/main/config/PollenServices.ini @@ -126,33 +126,3 @@ type = string defaultValue = sa transient = true final = true - -[option uiEndPoint] -description = pollen.configuration.uiEndPoint -key = pollen.ui.host -type = url -defaultValue = http://localhost:8888/app - -[option uiUrlPollEdit] -description = pollen.configuration.uiUrlPollEdit -key = pollen.ui.url.poll.edit -type = string -defaultValue = ${pollen.ui.host}#poll/edit/{pollId}/{pollToken} - -[option uiUrlPollVote] -description = pollen.configuration.uiUrlPollVote -key = pollen.ui.url.poll.vote -type = url -defaultValue = ${pollen.ui.host}#poll/vote/{pollId}/{pollToken} - -[option uiUrlPollVoteEdit] -description = pollen.configurqtion.uiUrlPollVoteEdit -key = pollen.ui.url.poll.vote.edit -type = url -defaultValue = ${pollen.ui.url.poll.vote}/vote/{voteToken} - -[option uiUrlUserValidate] -description = pollen.configurqtion.uiUrlUserValidate -key = pollen.ui.url.user.validate -type = url -defaultValue = ${pollen.ui.host}#signcheck/{userId}/{token} diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/PollenUIContext.java b/pollen-services/src/main/java/org/chorem/pollen/services/PollenUIContext.java index 36b62eb..01d0a13 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/PollenUIContext.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/PollenUIContext.java @@ -11,6 +11,13 @@ public class PollenUIContext implements Serializable { private String userValidateUrl; + private String pollVoteUrl; + + private String pollVoteEditUrl; + + private String pollEditUrl; + + public String getUiEndPoint() { return uiEndPoint; } @@ -26,4 +33,28 @@ public class PollenUIContext implements Serializable { public void setUserValidateUrl(String userValidateUrl) { this.userValidateUrl = userValidateUrl; } + + public String getPollVoteUrl() { + return pollVoteUrl; + } + + public void setPollVoteUrl(String pollVoteUrl) { + this.pollVoteUrl = pollVoteUrl; + } + + public String getPollVoteEditUrl() { + return pollVoteEditUrl; + } + + public void setPollVoteEditUrl(String pollVoteEditUrl) { + this.pollVoteEditUrl = pollVoteEditUrl; + } + + public String getPollEditUrl() { + return pollEditUrl; + } + + public void setPollEditUrl(String pollEditUrl) { + this.pollEditUrl = pollEditUrl; + } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java index 4e08d8f..ed0bb3a 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java @@ -34,6 +34,7 @@ import org.chorem.pollen.persistence.entity.PollenUser; import org.chorem.pollen.persistence.entity.PollenUserTopiaDao; import org.chorem.pollen.services.PollenFixtures; import org.chorem.pollen.services.PollenTechnicalException; +import org.chorem.pollen.services.PollenUIContext; import org.chorem.pollen.services.bean.ChoiceBean; import org.chorem.pollen.services.bean.PollBean; import org.chorem.pollen.services.bean.PollenEntityRef; @@ -120,7 +121,7 @@ public class FixturesService extends PollenServiceSupport { try { PollBean pollBean = new PollBean(); pollBean.fromEntity(poll); - PollenEntityRef<Poll> createdPoll = pollService.createPoll(pollBean, choicesBean); + PollenEntityRef<Poll> createdPoll = pollService.createPoll(pollBean, choicesBean, new PollenUIContext()); poll.setTopiaId(createdPoll.getEntityId()); PollenPrincipal principal = securityService.getPollenPrincipalByPermissionToken(createdPoll.getPermission()); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/NotificationService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/NotificationService.java index aa50850..8323ab4 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/NotificationService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/NotificationService.java @@ -83,7 +83,7 @@ public class NotificationService extends PollenServiceSupport { public void onUserLostPasswordAsked(PollenUser user, String newPassword) { EmailService emailService = getEmailService(); - LostPasswordEmail email = emailService.newLostPasswordEmail(getLocale(), user, newPassword); + LostPasswordEmail email = emailService.newLostPasswordEmail(user, newPassword); email.addTo(user.getEmail()); @@ -103,10 +103,10 @@ public class NotificationService extends PollenServiceSupport { // TODO } - public void onPollCreated(Poll poll) { + public void onPollCreated(Poll poll, PollenUIContext pollenUIContext) { EmailService emailService = getEmailService(); - PollCreatedEmail email = emailService.newPollCreatedEmail(getLocale(), poll); + PollCreatedEmail email = emailService.newPollCreatedEmail(poll, pollenUIContext); email.addTo(poll.getCreator().getEmail()); @@ -125,7 +125,7 @@ public class NotificationService extends PollenServiceSupport { public void onPollClosed(Poll poll) { EmailService emailService = getEmailService(); - PollClosedEmail email = emailService.newPollClosedEmail(getLocale(), poll); + PollClosedEmail email = emailService.newPollClosedEmail(poll); //email.addTo(poll.getCreator().getEmail()); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java index 13be554..242cdf5 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java @@ -31,6 +31,7 @@ import org.chorem.pollen.persistence.entity.PollType; import org.chorem.pollen.persistence.entity.PollenPrincipal; import org.chorem.pollen.persistence.entity.PollenUser; import org.chorem.pollen.persistence.entity.VoterList; +import org.chorem.pollen.services.PollenUIContext; import org.chorem.pollen.services.bean.ChoiceBean; import org.chorem.pollen.services.bean.PaginationParameterBean; import org.chorem.pollen.services.bean.PaginationResultBean; @@ -185,7 +186,7 @@ public class PollService extends PollenServiceSupport { } - public PollenEntityRef<Poll> createPoll(PollBean poll, List<ChoiceBean> choices) throws InvalidFormException { + public PollenEntityRef<Poll> createPoll(PollBean poll, List<ChoiceBean> choices, PollenUIContext pollenUIContext) throws InvalidFormException { checkNotNull(poll); checkIsNotPersisted(poll); @@ -223,7 +224,7 @@ public class PollService extends PollenServiceSupport { } commit(); - getNotificationService().onPollCreated(savedPoll); + getNotificationService().onPollCreated(savedPoll, pollenUIContext); return PollenEntityRef.of(savedPoll); @@ -262,7 +263,7 @@ public class PollService extends PollenServiceSupport { } - public PollenEntityRef<Poll> clonePoll(String pollId) { + public PollenEntityRef<Poll> clonePoll(String pollId, PollenUIContext pollenUIContext) { checkNotNull(pollId); checkPermission(PermissionVerb.clonePoll, pollId); @@ -308,7 +309,7 @@ public class PollService extends PollenServiceSupport { } commit(); - getNotificationService().onPollCreated(savedPoll); + getNotificationService().onPollCreated(savedPoll, pollenUIContext); return PollenEntityRef.of(savedPoll); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUIUrlRenderService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUIUrlRenderService.java index efb6532..517f50f 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUIUrlRenderService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUIUrlRenderService.java @@ -28,66 +28,70 @@ package org.chorem.pollen.services.service; */ public class PollenUIUrlRenderService extends PollenServiceSupport { - public String getPollenUrl() { - return serviceContext.getPollenServicesConfig().getUiEndPoint().toString(); - } - - public String getPollEditUrl(String pollId, String token) { - checkNotNull(pollId); + public String getPollEditUrl(String pollEditUrl, String pollId, String token) { + String url = null; - String url = serviceContext.getPollenServicesConfig().getUiUrlPollEdit(); + if (pollEditUrl != null) { + checkNotNull(pollId); - url = url.replace("{pollId}", pollId); + url = pollEditUrl.replace("{pollId}", pollId); - if (token == null) { - url = url.replace("/{pollToken}", ""); - } else { - url = url.replace("{pollToken}", token); + if (token == null) { + url = url.replace("/{pollToken}", ""); + } else { + url = url.replace("{pollToken}", token); + } } - return url; } - public String getPollVoteUrl(String pollId, String token) { - checkNotNull(pollId); - String url = serviceContext.getPollenServicesConfig().getUiUrlPollVote().toString(); + public String getPollVoteUrl(String pollVoteUrl, String pollId, String token) { + String url = null; + + if (pollVoteUrl != null) { + checkNotNull(pollId); - url = url.replace("{pollId}", pollId); + url = pollVoteUrl.replace("{pollId}", pollId); - if (token == null) { - url = url.replace("/{pollToken}", ""); - } else { - url = url.replace("{pollToken}", token); + if (token == null) { + url = url.replace("/{pollToken}", ""); + } else { + url = url.replace("{pollToken}", token); + } } return url; } - public String getPollVoteEditUrl(String pollId, String pollToken, String voteToken) { - checkNotNull(pollId); - checkNotNull(voteToken); + public String getPollVoteEditUrl(String pollVoteEditUrl, String pollId, String pollToken, String voteToken) { + String url = null; - String url = serviceContext.getPollenServicesConfig().getUiUrlPollVoteEdit().toString(); - url = url.replace("{pollId}", pollId); + if (pollVoteEditUrl != null) { + checkNotNull(pollId); + checkNotNull(voteToken); - if (pollToken == null) { - url = url.replace("/{pollToken}", ""); - } else { - url = url.replace("{pollToken}", pollToken); - } + url = pollVoteEditUrl.replace("{pollId}", pollId); - url = url.replace("{voteToken}", voteToken); + if (pollToken == null) { + url = url.replace("/{pollToken}", ""); + } else { + url = url.replace("{pollToken}", pollToken); + } + + url = url.replace("{voteToken}", voteToken); + } return url; } - public String getUserValidateUrl(String validateUrl, String userId, String token) { + public String getUserValidateUrl(String userValidateUrl, String userId, String token) { String url = null; - if (validateUrl != null) { + + if (userValidateUrl != null) { checkNotNull(userId); checkNotNull(token); - url = validateUrl.replace("{userId}", userId); + url = userValidateUrl.replace("{userId}", userId); url = url.replace("{token}", token); } return url; diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java index 6c75e66..7edc5d2 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java @@ -57,122 +57,124 @@ public class EmailService extends PollenServiceSupport { /** Logger. */ private static final Log log = LogFactory.getLog(EmailService.class); - public ChoiceAddedEmail newChoiceAddedEmail(Locale locale, Poll poll, Choice choice) { - ChoiceAddedEmail email = new ChoiceAddedEmail(locale); + public ChoiceAddedEmail newChoiceAddedEmail(Poll poll, Choice choice) { + ChoiceAddedEmail email = new ChoiceAddedEmail(getLocale()); email.setPoll(poll); email.setChoice(choice); return email; } - public ChoiceEditedEmail newChoiceEditedEmail(Locale locale, Poll poll, Choice choice) { - ChoiceEditedEmail email = new ChoiceEditedEmail(locale); + public ChoiceEditedEmail newChoiceEditedEmail(Poll poll, Choice choice) { + ChoiceEditedEmail email = new ChoiceEditedEmail(getLocale()); email.setPoll(poll); email.setChoice(choice); return email; } - public ChoiceDeletedEmail newChoiceDeletedEmail(Locale locale, Poll poll, Choice choice) { - ChoiceDeletedEmail email = new ChoiceDeletedEmail(locale); + public ChoiceDeletedEmail newChoiceDeletedEmail(Poll poll, Choice choice) { + ChoiceDeletedEmail email = new ChoiceDeletedEmail(getLocale()); email.setPoll(poll); email.setChoice(choice); return email; } - public CommentAddedEmail newCommentAddedEmail(Locale locale, Poll poll, Comment comment) { - CommentAddedEmail email = new CommentAddedEmail(locale); + public CommentAddedEmail newCommentAddedEmail(Poll poll, Comment comment) { + CommentAddedEmail email = new CommentAddedEmail(getLocale()); email.setPoll(poll); email.setComment(comment); return email; } - public CommentEditedEmail newCommentEditedEmail(Locale locale, Poll poll, Comment comment) { - CommentEditedEmail email = new CommentEditedEmail(locale); + public CommentEditedEmail newCommentEditedEmail(Poll poll, Comment comment) { + CommentEditedEmail email = new CommentEditedEmail(getLocale()); email.setPoll(poll); email.setComment(comment); return email; } - public CommentDeletedEmail newCommentDeletedEmail(Locale locale, Poll poll, Comment comment) { - CommentDeletedEmail email = new CommentDeletedEmail(locale); + public CommentDeletedEmail newCommentDeletedEmail(Poll poll, Comment comment) { + CommentDeletedEmail email = new CommentDeletedEmail(getLocale()); email.setPoll(poll); email.setComment(comment); return email; } - public VoteAddedEmail newVoteAddedEmail(Locale locale, Poll poll, Vote vote) { - VoteAddedEmail email = new VoteAddedEmail(locale); + public VoteAddedEmail newVoteAddedEmail(Poll poll, Vote vote) { + VoteAddedEmail email = new VoteAddedEmail(getLocale()); email.setPoll(poll); email.setVote(vote); return email; } - public VoteEditedEmail newVoteEditedEmail(Locale locale, Poll poll, Vote vote) { - VoteEditedEmail email = new VoteEditedEmail(locale); + public VoteEditedEmail newVoteEditedEmail(Poll poll, Vote vote) { + VoteEditedEmail email = new VoteEditedEmail(getLocale()); email.setPoll(poll); email.setVote(vote); return email; } - public VoteDeletedEmail newVoteDeletedEmail(Locale locale, Poll poll, Vote vote) { - VoteDeletedEmail email = new VoteDeletedEmail(locale); + public VoteDeletedEmail newVoteDeletedEmail(Poll poll, Vote vote) { + VoteDeletedEmail email = new VoteDeletedEmail(getLocale()); email.setPoll(poll); email.setVote(vote); return email; } - public PollCreatedEmail newPollCreatedEmail(Locale locale, Poll poll) { - PollCreatedEmail email = new PollCreatedEmail(locale); + public PollCreatedEmail newPollCreatedEmail(Poll poll, PollenUIContext pollenUIContext) { + PollCreatedEmail email = new PollCreatedEmail(getLocale()); email.setPoll(poll); - email.setPollenUrl(getPollenUIUrlRenderService().getPollenUrl()); + email.setPollenUrl(pollenUIContext.getUiEndPoint()); PollenEntityId<Poll> pollId = PollenEntityId.newId(Poll.class); pollId.setEntityId(poll.getTopiaId()); pollId.encode(serviceContext.getTopiaApplicationContext().getTopiaIdFactory()); - email.setUrl(getPollenUIUrlRenderService().getPollEditUrl(pollId.getReducedId(), poll.getCreator().getPermission().getToken())); + email.setUrl(getPollenUIUrlRenderService().getPollEditUrl(pollenUIContext.getPollEditUrl(), + pollId.getReducedId(), + poll.getCreator().getPermission().getToken())); return email; } - public PollClosedEmail newPollClosedEmail(Locale locale, Poll poll) { - PollClosedEmail email = new PollClosedEmail(locale); + public PollClosedEmail newPollClosedEmail(Poll poll) { + PollClosedEmail email = new PollClosedEmail(getLocale()); email.setPoll(poll); return email; } - public PollChoicePeriodStartedEmail newPollChoicePeriodStartedEmail(Locale locale, Poll poll) { - PollChoicePeriodStartedEmail email = new PollChoicePeriodStartedEmail(locale); + public PollChoicePeriodStartedEmail newPollChoicePeriodStartedEmail(Poll poll) { + PollChoicePeriodStartedEmail email = new PollChoicePeriodStartedEmail(getLocale()); email.setPoll(poll); return email; } - public PollChoicePeriodEndedEmail newPollChoicePeriodEndedEmail(Locale locale, Poll poll) { - PollChoicePeriodEndedEmail email = new PollChoicePeriodEndedEmail(locale); + public PollChoicePeriodEndedEmail newPollChoicePeriodEndedEmail(Poll poll) { + PollChoicePeriodEndedEmail email = new PollChoicePeriodEndedEmail(getLocale()); email.setPoll(poll); return email; } - public PollVotePeriodStartedEmail newPollVotePeriodStartedEmail(Locale locale, Poll poll) { - PollVotePeriodStartedEmail email = new PollVotePeriodStartedEmail(locale); + public PollVotePeriodStartedEmail newPollVotePeriodStartedEmail(Poll poll) { + PollVotePeriodStartedEmail email = new PollVotePeriodStartedEmail(getLocale()); email.setPoll(poll); return email; } - public PollVotePeriodEndedEmail newPollVotePeriodEndedEmail(Locale locale, Poll poll) { - PollVotePeriodEndedEmail email = new PollVotePeriodEndedEmail(locale); + public PollVotePeriodEndedEmail newPollVotePeriodEndedEmail(Poll poll) { + PollVotePeriodEndedEmail email = new PollVotePeriodEndedEmail(getLocale()); email.setPoll(poll); return email; } - public PollVoteReminderEmail newPollVoteReminderEmail(Locale locale, Poll poll) { - PollVoteReminderEmail email = new PollVoteReminderEmail(locale); + public PollVoteReminderEmail newPollVoteReminderEmail(Poll poll) { + PollVoteReminderEmail email = new PollVoteReminderEmail(getLocale()); email.setPoll(poll); return email; } - public RestrictedPollInvitationEmail newRestrictedPollInvitationEmail(Locale locale, Poll poll, PollenPrincipal principal) { - RestrictedPollInvitationEmail email = new RestrictedPollInvitationEmail(locale); + public RestrictedPollInvitationEmail newRestrictedPollInvitationEmail(Poll poll, PollenPrincipal principal) { + RestrictedPollInvitationEmail email = new RestrictedPollInvitationEmail(getLocale()); email.setPoll(poll); email.setPrincipal(principal); return email; @@ -211,8 +213,8 @@ public class EmailService extends PollenServiceSupport { return email; } - public LostPasswordEmail newLostPasswordEmail(Locale locale, PollenUser user, String password) { - LostPasswordEmail email = new LostPasswordEmail(locale); + public LostPasswordEmail newLostPasswordEmail(PollenUser user, String password) { + LostPasswordEmail email = new LostPasswordEmail(getLocale()); email.setUser(user); email.setPassword(password); return email; diff --git a/pollen-services/src/test/java/org/chorem/pollen/services/service/PollServiceTest.java b/pollen-services/src/test/java/org/chorem/pollen/services/service/PollServiceTest.java index 11d0cd6..8673736 100644 --- a/pollen-services/src/test/java/org/chorem/pollen/services/service/PollServiceTest.java +++ b/pollen-services/src/test/java/org/chorem/pollen/services/service/PollServiceTest.java @@ -25,6 +25,7 @@ import org.chorem.pollen.persistence.entity.ChoiceType; import org.chorem.pollen.persistence.entity.Poll; import org.chorem.pollen.persistence.entity.PollType; import org.chorem.pollen.services.AbstractPollenServiceTest; +import org.chorem.pollen.services.PollenUIContext; import org.chorem.pollen.services.bean.ChoiceBean; import org.chorem.pollen.services.bean.PollBean; import org.chorem.pollen.services.bean.PollenEntityRef; @@ -93,7 +94,7 @@ public class PollServiceTest extends AbstractPollenServiceTest { choice2.setDescription("Choice B"); choices.add(choice2); - PollenEntityRef<Poll> createdPoll = service.createPoll(poll, choices); + PollenEntityRef<Poll> createdPoll = service.createPoll(poll, choices, new PollenUIContext()); Assert.assertNotNull(createdPoll); String createdPollId = createdPoll.getEntityId(); Assert.assertNotNull(createdPollId); @@ -139,7 +140,7 @@ public class PollServiceTest extends AbstractPollenServiceTest { poll.setPollType(PollType.FREE); try { - service.createPoll(poll, null); + service.createPoll(poll, null, new PollenUIContext()); Assert.fail(); } catch (InvalidFormException e) { // missing title @@ -154,7 +155,7 @@ public class PollServiceTest extends AbstractPollenServiceTest { choices.add(choice1); try { - service.createPoll(poll, choices); + service.createPoll(poll, choices, new PollenUIContext()); Assert.fail(); } catch (InvalidFormException e) { // missing choice type @@ -163,7 +164,7 @@ public class PollServiceTest extends AbstractPollenServiceTest { choice1.setChoiceType(ChoiceType.TEXT); try { - service.createPoll(poll, choices); + service.createPoll(poll, choices, new PollenUIContext()); Assert.fail(); } catch (InvalidFormException e) { // missing choice name @@ -181,7 +182,7 @@ public class PollServiceTest extends AbstractPollenServiceTest { choices.add(choice2); try { - service.createPoll(poll, choices); + service.createPoll(poll, choices, new PollenUIContext()); Assert.fail(); } catch (InvalidFormException e) { // duplicated choice name @@ -191,7 +192,7 @@ public class PollServiceTest extends AbstractPollenServiceTest { choice2.setChoiceValue("B"); - PollenEntityRef<Poll> createdPoll = service.createPoll(poll, choices); + PollenEntityRef<Poll> createdPoll = service.createPoll(poll, choices, new PollenUIContext()); Assert.assertNotNull(createdPoll); String createdPollId = createdPoll.getEntityId(); Assert.assertNotNull(createdPollId); diff --git a/pollen-services/src/test/java/org/chorem/pollen/services/service/PollenUIUrlRenderServiceTest.java b/pollen-services/src/test/java/org/chorem/pollen/services/service/PollenUIUrlRenderServiceTest.java index b98f4ba..a5035bd 100644 --- a/pollen-services/src/test/java/org/chorem/pollen/services/service/PollenUIUrlRenderServiceTest.java +++ b/pollen-services/src/test/java/org/chorem/pollen/services/service/PollenUIUrlRenderServiceTest.java @@ -23,6 +23,7 @@ package org.chorem.pollen.services.service; import org.chorem.pollen.services.AbstractPollenServiceTest; +import org.chorem.pollen.services.PollenUIContext; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -30,70 +31,67 @@ import org.junit.Test; import java.text.ParseException; public class PollenUIUrlRenderServiceTest extends AbstractPollenServiceTest { + protected PollenUIUrlRenderService service; + protected PollenUIContext pollenUIContext; - public static final String UI_END_POINT = "http://localhost:8080"; - public static final String USER_VALIDATE_URL = UI_END_POINT + "/#signcheck/{userId}/{token}"; + protected static final String UI_END_POINT = "http://localhost:8080"; @Before public void setUp() throws ParseException { - service = newService(PollenUIUrlRenderService.class); - } - - @Test - public void pollenUrlTest() { - String url; - url = service.getPollenUrl(); - - Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint().toString(), url); + pollenUIContext = new PollenUIContext(); + pollenUIContext.setUiEndPoint(UI_END_POINT); + pollenUIContext.setUserValidateUrl(UI_END_POINT + "/#signcheck/{userId}/{token}"); + pollenUIContext.setPollEditUrl(UI_END_POINT + "/#poll/edit/{pollId}/{pollToken}"); + pollenUIContext.setPollVoteUrl(UI_END_POINT + "/#poll/vote/{pollId}/{pollToken}"); + pollenUIContext.setPollVoteEditUrl(UI_END_POINT + "/#poll/vote/{pollId}/{pollToken}/vote/{voteToken}"); } @Test public void pollEditUrlTest() { String url; - url = service.getPollEditUrl("PollId", null); + url = service.getPollEditUrl(pollenUIContext.getPollEditUrl(), "PollId", null); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#poll/edit/PollId", url); + Assert.assertEquals(UI_END_POINT + "/#poll/edit/PollId", url); - url = service.getPollEditUrl("PollId", "Token"); + url = service.getPollEditUrl(pollenUIContext.getPollEditUrl(),"PollId", "Token"); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#poll/edit/PollId/Token", url); + Assert.assertEquals(UI_END_POINT + "/#poll/edit/PollId/Token", url); } @Test public void pollVoteUrlTest() { String url; - url = service.getPollVoteUrl("PollId", null); + url = service.getPollVoteUrl(pollenUIContext.getPollVoteUrl(),"PollId", null); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#poll/vote/PollId", url); + Assert.assertEquals(UI_END_POINT + "/#poll/vote/PollId", url); - url = service.getPollVoteUrl("PollId", "Token"); + url = service.getPollVoteUrl(pollenUIContext.getPollVoteUrl(),"PollId", "Token"); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#poll/vote/PollId/Token", url); + Assert.assertEquals(UI_END_POINT + "/#poll/vote/PollId/Token", url); } @Test public void pollVoteEditUrlTest() { String url; - url = service.getPollVoteEditUrl("PollId", null, "VoteToken"); + url = service.getPollVoteEditUrl(pollenUIContext.getPollVoteEditUrl(),"PollId", null, "VoteToken"); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#poll/vote/PollId/vote/VoteToken", url); + Assert.assertEquals(UI_END_POINT+ "/#poll/vote/PollId/vote/VoteToken", url); - url = service.getPollVoteEditUrl("PollId", "Token", "VoteToken"); + url = service.getPollVoteEditUrl(pollenUIContext.getPollVoteEditUrl(),"PollId", "Token", "VoteToken"); Assert.assertNotNull(url); - Assert.assertEquals(serviceContext.getPollenServicesConfig().getUiEndPoint() + "#poll/vote/PollId/Token/vote/VoteToken", url); + Assert.assertEquals(UI_END_POINT + "/#poll/vote/PollId/Token/vote/VoteToken", url); } @Test public void userValidateUrl() { - String url = service.getUserValidateUrl(USER_VALIDATE_URL,"UserId", "Token"); + String url = service.getUserValidateUrl(pollenUIContext.getUserValidateUrl(),"UserId", "Token"); Assert.assertNotNull(url); Assert.assertEquals(UI_END_POINT + "/#signcheck/UserId/Token", url); diff --git a/pollen-services/src/test/java/org/chorem/pollen/services/service/VoteCountingServiceTest.java b/pollen-services/src/test/java/org/chorem/pollen/services/service/VoteCountingServiceTest.java index a86d904..cc42ecb 100644 --- a/pollen-services/src/test/java/org/chorem/pollen/services/service/VoteCountingServiceTest.java +++ b/pollen-services/src/test/java/org/chorem/pollen/services/service/VoteCountingServiceTest.java @@ -25,6 +25,7 @@ import org.apache.commons.lang3.time.DateUtils; import org.chorem.pollen.persistence.entity.ChoiceType; import org.chorem.pollen.persistence.entity.Poll; import org.chorem.pollen.services.AbstractPollenServiceTest; +import org.chorem.pollen.services.PollenUIContext; import org.chorem.pollen.services.bean.ChoiceBean; import org.chorem.pollen.services.bean.PollBean; import org.chorem.pollen.services.bean.PollenEntityRef; @@ -94,7 +95,7 @@ public class VoteCountingServiceTest extends AbstractPollenServiceTest { choice2.setDescription("Choice B"); choices.add(choice2); - PollenEntityRef<Poll> createdPollRef = pollService.createPoll(poll, choices); + PollenEntityRef<Poll> createdPollRef = pollService.createPoll(poll, choices, new PollenUIContext()); String pollId = createdPollRef.getEntityId(); diff --git a/pollen-services/src/test/java/org/chorem/pollen/services/service/VoterListServiceTest.java b/pollen-services/src/test/java/org/chorem/pollen/services/service/VoterListServiceTest.java index adf3caa..9ddffcb 100644 --- a/pollen-services/src/test/java/org/chorem/pollen/services/service/VoterListServiceTest.java +++ b/pollen-services/src/test/java/org/chorem/pollen/services/service/VoterListServiceTest.java @@ -30,6 +30,7 @@ import org.chorem.pollen.persistence.entity.PollType; import org.chorem.pollen.persistence.entity.PollenUser; import org.chorem.pollen.persistence.entity.VoterList; import org.chorem.pollen.services.AbstractPollenServiceTest; +import org.chorem.pollen.services.PollenUIContext; import org.chorem.pollen.services.bean.ChoiceBean; import org.chorem.pollen.services.bean.FavoriteListBean; import org.chorem.pollen.services.bean.PollBean; @@ -131,7 +132,7 @@ public class VoterListServiceTest extends AbstractPollenServiceTest { choice2.setDescription("Choice B"); choices.add(choice2); - PollenEntityRef<Poll> createdPoll = pollService.createPoll(poll, choices); + PollenEntityRef<Poll> createdPoll = pollService.createPoll(poll, choices, new PollenUIContext()); Assert.assertNotNull(createdPoll); String pollId = createdPoll.getEntityId(); @@ -169,7 +170,7 @@ public class VoterListServiceTest extends AbstractPollenServiceTest { choice2.setDescription("Choice B"); choices.add(choice2); - PollenEntityRef<Poll> createdPoll = pollService.createPoll(poll, choices); + PollenEntityRef<Poll> createdPoll = pollService.createPoll(poll, choices, new PollenUIContext()); Assert.assertNotNull(createdPoll); String pollId = createdPoll.getEntityId(); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/delete_ui_url_in_back_conf in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 9fcf2f6461f157a96d291534d66b0a508c776cc0 Author: Kevin Morin <morin@codelutin.com> Date: Thu Mar 2 15:48:05 2017 +0100 ajout des urls dans l'uicontext --- pollen-ui-riot-js/src/main/web/js/Session.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pollen-ui-riot-js/src/main/web/js/Session.js b/pollen-ui-riot-js/src/main/web/js/Session.js index 9bfbc03..9dcaf17 100644 --- a/pollen-ui-riot-js/src/main/web/js/Session.js +++ b/pollen-ui-riot-js/src/main/web/js/Session.js @@ -33,7 +33,10 @@ class Session { // pour contenir les données à envoyer au serveur à chaque appel this.pollenUIContext = { uiEndPoint: window.location.origin, - userValidateUrl: window.location.origin + "/#signcheck/{userId}/{token}" + userValidateUrl: window.location.origin + "/#signcheck/{userId}/{token}", + pollVoteUrl: window.location.origin + "/#poll/vote/{pollId}/{pollToken}", + pollVoteEditUrl: window.location.origin + "/#poll/vote/{pollId}/{pollToken}/vote/{voteToken}", + pollEditUrl: window.location.origin + "/#poll/edit/{pollId}/{pollToken}" }; // pour contenir les traductions this.i18n = require("../i18n.json"); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm