Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 3196 discussions
r3898 - trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api
by tchemit@users.chorem.org 02 May '14
by tchemit@users.chorem.org 02 May '14
02 May '14
Author: tchemit
Date: 2014-05-02 14:06:45 +0200 (Fri, 02 May 2014)
New Revision: 3898
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3898
Log:
fix PollRenderer : Hate the hibernate proxies...
Modified:
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java 2014-05-02 11:04:45 UTC (rev 3897)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java 2014-05-02 12:06:45 UTC (rev 3898)
@@ -35,6 +35,7 @@
import com.google.gson.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.persistence.PollenEntityEnum;
import org.chorem.pollen.services.exception.InvalidFormException;
import org.debux.webmotion.server.call.Call;
import org.debux.webmotion.server.call.HttpContext;
@@ -154,7 +155,8 @@
TopiaEntity topiaEntity = (TopiaEntity) model;
- PollenEntityBinder<TopiaEntity> binder = BinderFactory.newBinder(topiaEntity.getClass(), topiaEntity.getClass(), null, PollenEntityBinder.class);
+ Class<? extends TopiaEntity> entitytype = PollenEntityEnum.getContractClass(topiaEntity.getClass());
+ PollenEntityBinder<TopiaEntity> binder = BinderFactory.newBinder(entitytype, entitytype, null, PollenEntityBinder.class);
Map<String, Object> map = binder.obtainProperties(topiaEntity);
Map<String, Object> result = Maps.newTreeMap();
1
0
r3897 - trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api
by tchemit@users.chorem.org 02 May '14
by tchemit@users.chorem.org 02 May '14
02 May '14
Author: tchemit
Date: 2014-05-02 13:04:45 +0200 (Fri, 02 May 2014)
New Revision: 3897
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3897
Log:
make test more human readable
Modified:
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java 2014-05-02 11:04:29 UTC (rev 3896)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java 2014-05-02 11:04:45 UTC (rev 3897)
@@ -1,7 +1,6 @@
package org.chorem.pollen.rest.api;
import org.apache.http.client.fluent.Request;
-import org.chorem.pollen.persistence.entity.Choice;
import org.chorem.pollen.persistence.entity.ChoiceType;
import org.chorem.pollen.persistence.entity.CommentVisibility;
import org.chorem.pollen.persistence.entity.Poll;
@@ -83,17 +82,16 @@
@Test
public void postPoll() throws URISyntaxException, IOException {
- String paramPrefix = "poll.";
Request request = createRequest("/v1/polls").
- addParameter(paramPrefix + Poll.PROPERTY_POLL_TYPE, PollType.FREE.name()).
- addParameter(paramPrefix + Poll.PROPERTY_COMMENT_VISIBILITY, CommentVisibility.EVERYBODY.name()).
- addParameter(paramPrefix + Poll.PROPERTY_VOTE_VISIBILITY, VoteVisibility.EVERYBODY.name()).
- addParameter(paramPrefix + Poll.PROPERTY_VOTE_COUNTING_TYPE, "1").
- addParameter(paramPrefix + Poll.PROPERTY_TITLE, "title").
- addParameter(paramPrefix + Poll.PROPERTY_CHOICE + "[1]." + Choice.PROPERTY_CHOICE_TYPE, ChoiceType.TEXT.name()).
- addParameter(paramPrefix + Poll.PROPERTY_CHOICE + "[1]." + Choice.PROPERTY_NAME, "choiceB").
- addParameter(paramPrefix + Poll.PROPERTY_CHOICE + "[0]." + Choice.PROPERTY_CHOICE_TYPE, ChoiceType.TEXT.name()).
- addParameter(paramPrefix + Poll.PROPERTY_CHOICE + "[0]." + Choice.PROPERTY_NAME, "choiceA").
+ addParameter("poll.pollType", PollType.FREE.name()).
+ addParameter("poll.commentVisibility", CommentVisibility.EVERYBODY.name()).
+ addParameter("poll.voteVisibility", VoteVisibility.EVERYBODY.name()).
+ addParameter("poll.voteCountingType", "1").
+ addParameter("poll.title", "title").
+ addParameter("poll.choice[1].choiceType", ChoiceType.TEXT.name()).
+ addParameter("poll.choice[1].name", "choiceB").
+ addParameter("poll.choice[0].choiceType", ChoiceType.TEXT.name()).
+ addParameter("poll.choice[0].name", "choiceA").
Post();
String content = request.execute().returnContent().asString();
saveTestResult(content);
1
0
r3896 - trunk/pollen-services/src/main/java/org/chorem/pollen/services/service
by tchemit@users.chorem.org 02 May '14
by tchemit@users.chorem.org 02 May '14
02 May '14
Author: tchemit
Date: 2014-05-02 13:04:29 +0200 (Fri, 02 May 2014)
New Revision: 3896
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3896
Log:
for the moment let's just authorize everybody to seel all polls
Modified:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-05-02 09:20:55 UTC (rev 3895)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-05-02 11:04:29 UTC (rev 3896)
@@ -55,7 +55,8 @@
public ImmutableSet<Poll> getPolls() {
- checkRole(SecurityRole.administrator);
+ //TODO Reput this
+// checkRole(SecurityRole.administrator);
List<Poll> polls = getPollDao().findAll();
return ImmutableSet.<Poll>builder().addAll(polls).build();
1
0
See <http://ci.chorem.org/jenkins/job/pollen-ci/22/changes>
Changes:
[Tony CHEMIT] debug poll create + fix voteCounting id
------------------------------------------
[...truncated 953 lines...]
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
06:23:05 INFO (FixturesService.java:72) will restore database with fixture set
06:23:05 DEBUG (PollenApplication.java:85) testBasedir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
06:23:05 INFO (PollenServiceConfig.java:87) Pollen configuration:
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
06:23:05 INFO (FixturesService.java:72) will restore database with fixture set
06:23:05 DEBUG (PollenApplication.java:85) testBasedir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
06:23:05 INFO (PollenServiceConfig.java:87) Pollen configuration:
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
06:23:06 INFO (FixturesService.java:72) will restore database with fixture set
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.106 sec - in org.chorem.pollen.service.PollServiceTest
Running org.chorem.pollen.service.PollenUserServiceTest
06:23:06 DEBUG (PollenApplication.java:85) testBasedir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
06:23:06 INFO (PollenServiceConfig.java:87) Pollen configuration:
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
06:23:06 INFO (FixturesService.java:72) will restore database with fixture set
06:23:06 DEBUG (PollenApplication.java:85) testBasedir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
06:23:06 INFO (PollenServiceConfig.java:87) Pollen configuration:
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
06:23:06 INFO (FixturesService.java:72) will restore database with fixture set
06:23:06 DEBUG (PollenApplication.java:85) testBasedir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
06:23:06 INFO (PollenServiceConfig.java:87) Pollen configuration:
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
06:23:07 INFO (FixturesService.java:72) will restore database with fixture set
06:23:07 DEBUG (PollenApplication.java:85) testBasedir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
06:23:07 INFO (PollenServiceConfig.java:87) Pollen configuration:
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
06:23:07 INFO (FixturesService.java:72) will restore database with fixture set
06:23:07 DEBUG (PollenApplication.java:85) testBasedir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
06:23:07 INFO (PollenServiceConfig.java:87) Pollen configuration:
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
06:23:07 INFO (FixturesService.java:72) will restore database with fixture set
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.78 sec - in org.chorem.pollen.service.PollenUserServiceTest
Results :
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ pollen-services ---
[INFO] Building jar: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
[INFO]
[INFO] --- maven-site-plugin:3.3:attach-descriptor (attach-descriptor) @ pollen-services ---
[JENKINS] Archiving disabled
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Pollen :: Rest Api 2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[WARNING] The POM for org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT is missing, no dependency information available
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[WARNING] The POM for org.debux.webmotion:webmotion-unittest:jar:2.5-SNAPSHOT is missing, no dependency information available
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Pollen ............................................ SUCCESS [ 1.557 s]
[INFO] Pollen :: VoteCounting (Api) ...................... SUCCESS [ 5.567 s]
[INFO] Pollen :: VoteCounting :: Normal .................. SUCCESS [ 1.364 s]
[INFO] Pollen :: VoteCounting :: Percentage .............. SUCCESS [ 1.257 s]
[INFO] Pollen :: VoteCounting :: Condorcet ............... SUCCESS [ 1.247 s]
[INFO] Pollen :: VoteCounting :: Number .................. SUCCESS [ 1.127 s]
[INFO] Pollen :: VoteCounting :: Borda ................... SUCCESS [ 1.198 s]
[INFO] Pollen :: VoteCounting :: Instant Runoff .......... SUCCESS [ 1.163 s]
[INFO] Pollen :: VoteCounting :: Coombs .................. SUCCESS [ 1.137 s]
[INFO] Pollen :: VoteCounting (Aggregator) ............... SUCCESS [ 0.239 s]
[INFO] Pollen :: Persistence ............................. SUCCESS [ 6.313 s]
[INFO] Pollen :: Service ................................. SUCCESS [ 6.898 s]
[INFO] Pollen :: Rest Api ................................ FAILURE [ 2.177 s]
[INFO] Pollen :: UI (CanJS) .............................. SKIPPED
[INFO] Pollen :: UI (Angular) ............................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 33.798 s
[INFO] Finished at: 2014-04-30T18:23:11+01:00
[INFO] Final Memory: 53M/407M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project pollen-rest-api: Could not resolve dependencies for project org.chorem.pollen:pollen-rest-api:war:2.0-SNAPSHOT: The following artifacts could not be resolved: org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT, org.debux.webmotion:webmotion-unittest:jar:2.5-SNAPSHOT: Could not find artifact org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT in snapshots (http://nexus.nuiton.org/nexus/content/repositories/snapshots) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project pollen-rest-api: Could not resolve dependencies for project org.chorem.pollen:pollen-rest-api:war:2.0-SNAPSHOT: The following artifacts could not be resolved: org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT, org.debux.webmotion:webmotion-unittest:jar:2.5-SNAPSHOT: Could not find artifact org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT in snapshots (http://nexus.nuiton.org/nexus/content/repositories/snapshots)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:220)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:127)
at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:257)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:200)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project org.chorem.pollen:pollen-rest-api:war:2.0-SNAPSHOT: The following artifacts could not be resolved: org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT, org.debux.webmotion:webmotion-unittest:jar:2.5-SNAPSHOT: Could not find artifact org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT in snapshots (http://nexus.nuiton.org/nexus/content/repositories/snapshots)
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:198)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:195)
... 33 more
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: The following artifacts could not be resolved: org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT, org.debux.webmotion:webmotion-unittest:jar:2.5-SNAPSHOT: Could not find artifact org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT in snapshots (http://nexus.nuiton.org/nexus/content/repositories/snapshots)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:384)
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:192)
... 34 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: The following artifacts could not be resolved: org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT, org.debux.webmotion:webmotion-unittest:jar:2.5-SNAPSHOT: Could not find artifact org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT in snapshots (http://nexus.nuiton.org/nexus/content/repositories/snapshots)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:459)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:262)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
... 35 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT in snapshots (http://nexus.nuiton.org/nexus/content/repositories/snapshots)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1012)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1004)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:725)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
... 3 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionExcept…
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :pollen-rest-api
Sending e-mails to: pollen-commits(a)list.chorem.org chemit+chorem-ci(a)codelutin.com
channel stopped
1
1
Build failed in Jenkins: pollen-ci » Pollen :: Rest Api #22
by admin+ci-chorem.org@codelutin.com 02 May '14
by admin+ci-chorem.org@codelutin.com 02 May '14
02 May '14
See <http://ci.chorem.org/jenkins/job/pollen-ci/org.chorem.pollen$pollen-rest-ap…>
Changes:
[Tony CHEMIT] debug poll create + fix voteCounting id
------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Pollen :: Rest Api 2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[WARNING] The POM for org.debux.webmotion:webmotion:jar:2.5-SNAPSHOT is missing, no dependency information available
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[WARNING] The POM for org.debux.webmotion:webmotion-unittest:jar:2.5-SNAPSHOT is missing, no dependency information available
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[JENKINS] Archiving disabled
1
1
Author: tchemit
Date: 2014-05-02 11:20:55 +0200 (Fri, 02 May 2014)
New Revision: 3895
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3895
Log:
- introduce email + notification service
- review security (not done at all...)
- better rest api (remove security info from api)
- ...
Added:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFormException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/NotificationService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceAddedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceDeletedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceEditedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentAddedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentDeletedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentEditedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/LostPasswordEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollChoicePeriodEndedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollChoicePeriodStartedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollClosedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollCreatedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVotePeriodEndedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVotePeriodStartedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVoteReminderEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollenMail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/RestrictedPollInvitationEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/UserAccountCreatedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteAddedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteDeletedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteEditedEmail.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/DefaultPollenSecurityContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PermissionVerb.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidPermissionException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityRealm.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUnauthorizedException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityRole.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenSecurityContext.java
trunk/pollen-services/src/main/resources/email/
trunk/pollen-services/src/main/resources/email/LostPasswordEmail.mustache
trunk/pollen-services/src/main/resources/email/LostPasswordEmail_fr.mustache
trunk/pollen-services/src/main/resources/email/PollChoicePeriodEndedEmail.mustache
trunk/pollen-services/src/main/resources/email/PollChoicePeriodEndedEmail_en.mustache
trunk/pollen-services/src/main/resources/email/PollChoicePeriodStartedEmail.mustache
trunk/pollen-services/src/main/resources/email/PollChoicePeriodStartedEmail_fr.mustache
trunk/pollen-services/src/main/resources/email/PollVotePeriodEndedEmail.mustache
trunk/pollen-services/src/main/resources/email/PollVotePeriodEndedEmail_fr.mustache
trunk/pollen-services/src/main/resources/email/PollVotePeriodStartedEmail.mustache
trunk/pollen-services/src/main/resources/email/PollVotePeriodStartedEmail_fr.mustache
trunk/pollen-services/src/main/resources/email/PollVoteReminderEmail.mustache
trunk/pollen-services/src/main/resources/email/PollVoteReminderEmail_fr.mustache
trunk/pollen-services/src/main/resources/email/RestrictedPollInvitationEmail.mustache
trunk/pollen-services/src/main/resources/email/RestrictedPollInvitationEmail_fr.mustache
trunk/pollen-services/src/main/resources/email/UserAccountCreatedEmail.mustache
trunk/pollen-services/src/main/resources/email/UserAccountCreatedEmail_fr.mustache
trunk/pollen-services/src/main/resources/email/VoteAddedEmail.mustache
trunk/pollen-services/src/main/resources/email/VoteAddedEmail_fr.mustache
trunk/pollen-services/src/main/resources/email/VoteDeletedEmail.mustache
trunk/pollen-services/src/main/resources/email/VoteDeletedEmail_fr.mustache
trunk/pollen-services/src/main/resources/email/VoteEditedEmail.mustache
trunk/pollen-services/src/main/resources/email/VoteEditedEmail_fr.mustache
Removed:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityRealm.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/AbstractInvalidFormException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PermissionVerb.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java
Modified:
trunk/pollen-persistence/pom.xml
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java
trunk/pollen-persistence/src/main/xmi/pollen.properties
trunk/pollen-persistence/src/main/xmi/pollen.zargo
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ErrorAction.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java
trunk/pollen-rest-api/src/main/resources/mapping
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java
trunk/pollen-services/pom.xml
trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/EntityNotFoundException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidChoiceFormException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidCommentFormException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListFormException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListMemberFormException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollFormException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollenUserFormException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoteFormException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListFormException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListMemberFormException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java
trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java
trunk/pom.xml
Modified: trunk/pollen-persistence/pom.xml
===================================================================
--- trunk/pollen-persistence/pom.xml 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-persistence/pom.xml 2014-05-02 09:20:55 UTC (rev 3895)
@@ -95,6 +95,7 @@
org.nuiton.eugene.java.JavaEnumerationTransformer,
org.nuiton.topia.templates.TopiaMetaTransformer
</templates>
+ <failIfUnsafe>true</failIfUnsafe>
</configuration>
<goals>
<goal>generate</goal>
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -33,17 +33,17 @@
*/
public class PollTopiaDao extends AbstractPollTopiaDao<Poll> {
- public Set<Poll> findAllCreated(String userId) {
+ public Set<Poll> findAllCreated(PollenUser user) {
//TODO
return Sets.newHashSet();
}
- public Set<Poll> findAllInvited(String userId) {
+ public Set<Poll> findAllInvited(PollenUser user) {
//TODO
return Sets.newHashSet();
}
- public Set<Poll> findAllParticipated(String userId) {
+ public Set<Poll> findAllParticipated(PollenUser user) {
//TODO
return Sets.newHashSet();
}
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -90,8 +90,8 @@
if (poll.isVoterListNotEmpty()) {
for (VoterList list : poll.getVoterList()) {
- if (!list.isVoterListMemberEmpty()) {
- result.addAll(list.getVoterListMember());
+ if (!list.isMemberEmpty()) {
+ result.addAll(list.getMember());
}
}
}
Modified: trunk/pollen-persistence/src/main/xmi/pollen.properties
===================================================================
--- trunk/pollen-persistence/src/main/xmi/pollen.properties 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-persistence/src/main/xmi/pollen.properties 2014-05-02 09:20:55 UTC (rev 3895)
@@ -32,14 +32,9 @@
org.chorem.pollen.persistence.entity.Poll.attribute.vote.stereotype=ordered
org.chorem.pollen.persistence.entity.Poll.attribute.comment.stereotype=ordered
org.chorem.pollen.persistence.entity.PollenUser.attribute.favoriteList.stereotype=ordered
-org.chorem.pollen.persistence.entity.FavoriteList.attribute.favoriteListMember.stereotype=ordered
-org.chorem.pollen.persistence.entity.VoterList.attribute.voterListMember.stereotype=unique
+org.chorem.pollen.persistence.entity.FavoriteList.attribute.member.stereotype=ordered, unique
+org.chorem.pollen.persistence.entity.VoterList.attribute.member.stereotype=unique
-#org.chorem.pollen.persistence.entity.Poll.attribute.choice.stereotype=indexed
-
-#org.chorem.pollen.persistence.entity.Poll.attribute.vote.stereotype=ordered
-#org.chorem.pollen.persistence.entity.Poll.attribute.vote.tagvalue.orderBy=topiaCreateDate
-
# clef naturelle non modifiable sur Poll#pollId
#org.chorem.pollen.persistence.entity.Poll.class.tagValue.naturalIdMutable=true
#org.chorem.pollen.persistence.entity.Poll.attribute.pollId.stereotype=unique
Modified: trunk/pollen-persistence/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -25,6 +25,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
@@ -34,6 +35,7 @@
import com.google.gson.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.services.exception.InvalidFormException;
import org.debux.webmotion.server.call.Call;
import org.debux.webmotion.server.call.HttpContext;
import org.debux.webmotion.server.mapping.Mapping;
@@ -56,6 +58,7 @@
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -98,8 +101,15 @@
if (annotation != null) {
includeCollection = annotation.values();
}
- Object map = toMap(model, includeCollection);
+ Object map;
+ if (model instanceof InvalidFormException) {
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ map = toMap(((InvalidFormException) model).getErrors());
+ } else {
+ map = toMap(model, includeCollection);
+ }
+
Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
@Override
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
@@ -115,6 +125,14 @@
out.print(json);
}
+ protected Object toMap(Multimap<String, String> model) {
+ Map<String, Object> result = new HashMap<>();
+ for (String key : model.keySet()) {
+ result.put(key, model.get(key));
+ }
+ return result;
+ }
+
protected <M> Object toMap(M model, String... includeCollection) {
if (model instanceof Iterable<?>) {
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,12 +31,15 @@
import org.chorem.pollen.persistence.PollenPersistenceContext;
import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.persistence.entity.SessionToken;
import org.chorem.pollen.services.DefaultPollenServiceContext;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollenUserFormException;
import org.chorem.pollen.services.service.PollenUserService;
+import org.chorem.pollen.services.service.security.DefaultPollenSecurityContext;
+import org.chorem.pollen.services.service.security.PollenSecurityContext;
import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.DefaultI18nInitializer;
import org.nuiton.i18n.init.I18nInitializer;
@@ -118,6 +121,12 @@
}
+ public PollenSecurityContext newSecurityContext(SessionToken sessionToken) {
+
+ return DefaultPollenSecurityContext.newContext(sessionToken);
+
+ }
+
@Override
public void close() {
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -24,12 +24,14 @@
*/
import org.apache.commons.beanutils.Converter;
+import org.chorem.pollen.persistence.PollenEntityEnum;
import org.debux.webmotion.server.WebMotionServerListener;
import org.debux.webmotion.server.call.Call;
import org.debux.webmotion.server.call.HttpContext;
import org.debux.webmotion.server.call.ServerContext;
import org.debux.webmotion.server.handler.ExecutorParametersInjectorHandler;
import org.debux.webmotion.server.mapping.Mapping;
+import org.nuiton.topia.persistence.TopiaEntity;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Type;
@@ -69,6 +71,30 @@
}, Date.class);
+ Converter entityconverter = new Converter() {
+ @Override
+ public TopiaEntity convert(Class type, Object value) {
+ TopiaEntity result;
+ if (value != null && value.getClass().isAssignableFrom(TopiaEntity.class)) {
+ result = (TopiaEntity) value;
+ } else {
+ Class<?> implementationClass = PollenEntityEnum.getImplementationClass(type);
+ try {
+ result = (TopiaEntity) implementationClass.newInstance();
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return result;
+ }
+
+ };
+ for (Class<? extends TopiaEntity> entityClass : PollenEntityEnum.getContractClasses()) {
+ serverContext.addConverter(entityconverter, entityClass);
+ }
+
// ---
// init injectors
// ---
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -21,7 +21,6 @@
* #L%
*/
-import org.chorem.pollen.services.PollenSecurityContext;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.service.AuthService;
import org.chorem.pollen.services.service.ChoiceService;
@@ -30,10 +29,11 @@
import org.chorem.pollen.services.service.FixturesService;
import org.chorem.pollen.services.service.PollService;
import org.chorem.pollen.services.service.PollenUserService;
-import org.chorem.pollen.services.service.SecurityService;
import org.chorem.pollen.services.service.VoteCountingService;
import org.chorem.pollen.services.service.VoteService;
import org.chorem.pollen.services.service.VoterListService;
+import org.chorem.pollen.services.service.security.PollenSecurityContext;
+import org.chorem.pollen.services.service.security.SecurityService;
/**
* Created on 4/25/14.
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -26,9 +26,9 @@
import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.persistence.PollenPersistenceContext;
import org.chorem.pollen.persistence.entity.SessionToken;
-import org.chorem.pollen.services.PollenSecurityContext;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.exception.InvalidSessionTokenException;
+import org.chorem.pollen.services.service.security.PollenSecurityContext;
import org.debux.webmotion.server.WebMotionFilter;
import org.debux.webmotion.server.call.HttpContext;
@@ -103,7 +103,7 @@
setRequestContext(context.getRequest(), requestContext);
- addSecurityContext(context, requestContext);
+ addSecurityContext(context, applicationContext, requestContext);
doProcess();
@@ -113,6 +113,7 @@
}
protected void addSecurityContext(HttpContext context,
+ PollenRestApiApplicationContext applicationContext,
PollenRestApiRequestContext serviceContext) throws InvalidSessionTokenException {
String[] strings = context.getParameters().get(REQUEST_AUTH_PARAMETER);
@@ -128,7 +129,7 @@
sessionToken = serviceContext.getAuthService().getUserByAuth(authParam);
}
PollenSecurityContext securityContext =
- PollenSecurityContext.newContext(sessionToken);
+ applicationContext.newSecurityContext(sessionToken);
serviceContext.setSecurityContext(securityContext);
}
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -25,7 +25,6 @@
import org.chorem.pollen.persistence.entity.SessionToken;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.UserInvalidPasswordException;
import org.debux.webmotion.server.WebMotionController;
@@ -37,15 +36,15 @@
*/
public class AuthService extends WebMotionController {
- public SessionToken login(PollenRestApiRequestContext context, String login, String password) throws UserInvalidPasswordException, EntityNotFoundException {
+ public SessionToken login(PollenRestApiRequestContext context, String login, String password) throws UserInvalidPasswordException {
return context.getAuthService().login(login, password);
}
- public void lostPassword(PollenRestApiRequestContext context, String login) throws EntityNotFoundException {
+ public void lostPassword(PollenRestApiRequestContext context, String login) {
context.getAuthService().lostPassword(login);
}
- public void logout(PollenRestApiRequestContext context, String login, String token) throws EntityNotFoundException {
+ public void logout(PollenRestApiRequestContext context, String login, String token) {
context.getAuthService().logout(login, token);
}
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -25,8 +25,7 @@
import org.chorem.pollen.persistence.entity.Choice;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
-import org.chorem.pollen.services.exception.InvalidChoiceFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
import org.debux.webmotion.server.WebMotionController;
import java.util.List;
@@ -39,28 +38,28 @@
*/
public class ChoiceService extends WebMotionController {
- public List<Choice> getChoices(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
+ public List<Choice> getChoices(PollenRestApiRequestContext context, String pollId) {
context.getSecurityService().prepareSubject((String) null);
List<Choice> choices = context.getChoiceService().getChoices(pollId);
return choices;
}
- public Choice getChoice(PollenRestApiRequestContext context, String pollId, String choiceId) throws EntityNotFoundException {
+ public Choice getChoice(PollenRestApiRequestContext context, String pollId, String choiceId) {
context.getSecurityService().prepareSubject(choiceId);
return context.getChoiceService().getChoice(pollId, choiceId);
}
- public Choice addChoice(PollenRestApiRequestContext context, String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
+ public Choice addChoice(PollenRestApiRequestContext context, String pollId, Choice choice) throws InvalidFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getChoiceService().addChoice(pollId, choice);
}
- public Choice editChoice(PollenRestApiRequestContext context, String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
+ public Choice editChoice(PollenRestApiRequestContext context, String pollId, Choice choice) throws InvalidFormException {
context.getSecurityService().prepareSubject(choice);
return context.getChoiceService().editChoice(pollId, choice);
}
- public void deleteChoice(PollenRestApiRequestContext context, String pollId, String choiceId) throws EntityNotFoundException {
+ public void deleteChoice(PollenRestApiRequestContext context, String pollId, String choiceId) {
context.getSecurityService().prepareSubject(choiceId);
context.getChoiceService().deleteChoice(pollId, choiceId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -25,7 +25,6 @@
import org.chorem.pollen.persistence.entity.Comment;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidCommentFormException;
import org.debux.webmotion.server.WebMotionController;
@@ -39,28 +38,28 @@
*/
public class CommentService extends WebMotionController {
- public List<Comment> getComments(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
+ public List<Comment> getComments(PollenRestApiRequestContext context, String pollId) {
context.getSecurityService().prepareSubject(pollId);
List<Comment> comments = context.getCommentService().getComments(pollId);
return comments;
}
- public Comment getComment(PollenRestApiRequestContext context, String pollId, String commentId) throws EntityNotFoundException {
+ public Comment getComment(PollenRestApiRequestContext context, String pollId, String commentId) {
context.getSecurityService().prepareSubject(commentId);
return context.getCommentService().getComment(pollId, commentId);
}
- public Comment addComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
+ public Comment addComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidCommentFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getCommentService().addComment(pollId, comment);
}
- public Comment editComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
+ public Comment editComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidCommentFormException {
context.getSecurityService().prepareSubject(comment);
return context.getCommentService().editComment(pollId, comment);
}
- public void deleteComment(PollenRestApiRequestContext context, String pollId, String commentId) throws EntityNotFoundException {
+ public void deleteComment(PollenRestApiRequestContext context, String pollId, String commentId) {
context.getSecurityService().prepareSubject(commentId);
context.getCommentService().deleteComment(pollId, commentId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ErrorAction.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ErrorAction.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ErrorAction.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -23,11 +23,12 @@
* #L%
*/
-import com.google.common.collect.Multimap;
-import org.chorem.pollen.services.exception.AbstractInvalidFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
import org.debux.webmotion.server.WebMotionController;
import org.debux.webmotion.server.render.Render;
+import javax.servlet.http.HttpServletResponse;
+
/**
* TODO
*
@@ -36,20 +37,17 @@
*/
public class ErrorAction extends WebMotionController {
+ public InvalidFormException on400Form(InvalidFormException e) {
+
+ return e;
+ }
+
public Render on404(Exception e) {
- return renderError(404, e.getMessage());
+ return renderError(HttpServletResponse.SC_NOT_FOUND, e.getMessage());
}
public Render on500(Exception e) {
- return renderError(500, e.getMessage());
+ return renderError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
}
- public Render on500Form(Exception e) {
- AbstractInvalidFormException ex = (AbstractInvalidFormException) e;
-
- //TODO Send back this
- Multimap<String, String> errors = ex.getErrors();
-
- return renderError(500, e.getMessage());
- }
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -26,13 +26,13 @@
import org.chorem.pollen.persistence.entity.FavoriteList;
import org.chorem.pollen.persistence.entity.FavoriteListMember;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.FavoriteListImportException;
import org.chorem.pollen.services.exception.InvalidFavoriteListFormException;
import org.chorem.pollen.services.exception.InvalidFavoriteListMemberFormException;
import org.debux.webmotion.server.WebMotionController;
import java.io.File;
+import java.util.LinkedHashSet;
import java.util.List;
/**
@@ -43,53 +43,53 @@
*/
public class FavoriteListService extends WebMotionController {
- public List<FavoriteList> getFavoriteLists(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
+ public List<FavoriteList> getFavoriteLists(PollenRestApiRequestContext context, String userId) {
List<FavoriteList> favoriteLists = context.getFavoriteListService().getFavoriteLists(userId);
return favoriteLists;
}
- public FavoriteList getFavoriteList(PollenRestApiRequestContext context, String userId, String favoriteListId) throws EntityNotFoundException {
+ public FavoriteList getFavoriteList(PollenRestApiRequestContext context, String userId, String favoriteListId) {
return context.getFavoriteListService().getFavoriteList(userId, favoriteListId);
}
- public FavoriteList createFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
+ public FavoriteList createFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws InvalidFavoriteListFormException {
return context.getFavoriteListService().createFavoriteList(userId, favoriteList);
}
- public FavoriteList editFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
+ public FavoriteList editFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws InvalidFavoriteListFormException {
return context.getFavoriteListService().editFavoriteList(userId, favoriteList);
}
- public void deleteFavoriteList(PollenRestApiRequestContext context, String userId, String favoriteListId) throws EntityNotFoundException {
+ public void deleteFavoriteList(PollenRestApiRequestContext context, String userId, String favoriteListId) {
context.getFavoriteListService().deleteFavoriteList(userId, favoriteListId);
}
- public int importFavoriteListMembersFromCsv(PollenRestApiRequestContext context, String userId, String favoriteListId, File csvFile) throws EntityNotFoundException, FavoriteListImportException {
+ public int importFavoriteListMembersFromCsv(PollenRestApiRequestContext context, String userId, String favoriteListId, File csvFile) throws FavoriteListImportException {
return context.getFavoriteListService().importFavoriteListMembersFromCsv(userId, favoriteListId, csvFile);
}
- public int importFavoriteListMembersFromLdap(PollenRestApiRequestContext context, String userId, String favoriteListId, String ldap) throws EntityNotFoundException, FavoriteListImportException {
+ public int importFavoriteListMembersFromLdap(PollenRestApiRequestContext context, String userId, String favoriteListId, String ldap) throws FavoriteListImportException {
return context.getFavoriteListService().importFavoriteListMembersFromLdap(userId, favoriteListId, ldap);
}
- public List<FavoriteListMember> getMembers(PollenRestApiRequestContext context, String userId, String favoriteListId) throws EntityNotFoundException {
- List<FavoriteListMember> members = context.getFavoriteListService().getFavoriteListMembers(userId, favoriteListId);
+ public LinkedHashSet<FavoriteListMember> getMembers(PollenRestApiRequestContext context, String userId, String favoriteListId) {
+ LinkedHashSet<FavoriteListMember> members = context.getFavoriteListService().getFavoriteListMembers(userId, favoriteListId);
return members;
}
- public FavoriteListMember getMember(PollenRestApiRequestContext context, String userId, String favoriteListId, String memberId) throws EntityNotFoundException {
+ public FavoriteListMember getMember(PollenRestApiRequestContext context, String userId, String favoriteListId, String memberId) {
return context.getFavoriteListService().getFavoriteListMember(userId, favoriteListId, memberId);
}
- public FavoriteListMember addMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException {
+ public FavoriteListMember addMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws InvalidFavoriteListMemberFormException {
return context.getFavoriteListService().addFavoriteListMember(userId, favoriteListId, member);
}
- public FavoriteListMember editMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException {
+ public FavoriteListMember editMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws InvalidFavoriteListMemberFormException {
return context.getFavoriteListService().editFavoriteListMember(userId, favoriteListId, member);
}
- public void removeMember(PollenRestApiRequestContext context, String userId, String favoriteListId, String memberId) throws EntityNotFoundException {
+ public void removeMember(PollenRestApiRequestContext context, String userId, String favoriteListId, String memberId) {
context.getFavoriteListService().removeFavoriteListMember(userId, favoriteListId, memberId);
}
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -25,8 +25,7 @@
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
-import org.chorem.pollen.services.exception.InvalidPollFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
import org.debux.webmotion.server.WebMotionController;
import java.io.File;
@@ -40,60 +39,60 @@
*/
public class PollService extends WebMotionController {
- public Poll getNewPoll(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
- return context.getPollService().getNewPoll(userId);
+ public Poll getNewPoll(PollenRestApiRequestContext context) {
+ return context.getPollService().getNewPoll();
}
- public Set<Poll> getPolls(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
- Set<Poll> polls = context.getPollService().getPolls(userId);
+ public Set<Poll> getPolls(PollenRestApiRequestContext context) {
+ Set<Poll> polls = context.getPollService().getPolls();
return polls;
}
- public Set<Poll> getCreatedPolls(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
- Set<Poll> polls = context.getPollService().getCreatedPolls(userId);
+ public Set<Poll> getCreatedPolls(PollenRestApiRequestContext context) {
+ Set<Poll> polls = context.getPollService().getCreatedPolls();
return polls;
}
- public Set<Poll> getInvitedPolls(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
- Set<Poll> polls = context.getPollService().getInvitedPolls(userId);
+ public Set<Poll> getInvitedPolls(PollenRestApiRequestContext context) {
+ Set<Poll> polls = context.getPollService().getInvitedPolls();
return polls;
}
- public Set<Poll> getParticipatedPolls(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
- Set<Poll> polls = context.getPollService().getParticipatedPolls(userId);
+ public Set<Poll> getParticipatedPolls(PollenRestApiRequestContext context) {
+ Set<Poll> polls = context.getPollService().getParticipatedPolls();
return polls;
}
- public Poll getPoll(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
+ public Poll getPoll(PollenRestApiRequestContext context, String pollId) {
context.getSecurityService().prepareSubject((String) null);
return context.getPollService().getPoll(pollId);
}
- public Poll createPoll(PollenRestApiRequestContext context, String userId, Poll poll) throws EntityNotFoundException, InvalidPollFormException {
- return context.getPollService().createPoll(userId, poll);
+ public Poll createPoll(PollenRestApiRequestContext context, Poll poll) throws InvalidFormException {
+ return context.getPollService().createPoll(poll);
}
- public Poll editPoll(PollenRestApiRequestContext context, Poll poll) throws EntityNotFoundException, InvalidPollFormException {
+ public Poll editPoll(PollenRestApiRequestContext context, Poll poll) throws InvalidFormException {
context.getSecurityService().prepareSubject(poll);
return context.getPollService().editPoll(poll);
}
- public void deletePoll(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
+ public void deletePoll(PollenRestApiRequestContext context, String pollId) {
context.getSecurityService().prepareSubject(pollId);
context.getPollService().deletePoll(pollId);
}
- public Poll clonePoll(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
+ public Poll clonePoll(PollenRestApiRequestContext context, String pollId) {
context.getSecurityService().prepareSubject(pollId);
return context.getPollService().clonePoll(pollId);
}
- public File closePoll(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
+ public void closePoll(PollenRestApiRequestContext context, String pollId) {
context.getSecurityService().prepareSubject(pollId);
- return context.getPollService().closePoll(pollId);
+ context.getPollService().closePoll(pollId);
}
- public File exportPoll(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
+ public File exportPoll(PollenRestApiRequestContext context, String pollId) {
context.getSecurityService().prepareSubject(pollId);
return context.getPollService().exportPoll(pollId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -25,7 +25,6 @@
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollenUserFormException;
import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
import org.chorem.pollen.services.exception.UserInvalidPasswordException;
@@ -46,37 +45,36 @@
return users;
}
- public PollenUser getUser(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
+ public PollenUser getUser(PollenRestApiRequestContext context, String userId) {
return context.getPollenUserService().getUser(userId);
}
public PollenUser createUser(PollenRestApiRequestContext context,
PollenUser user,
- boolean generatePassword) throws EntityNotFoundException, InvalidPollenUserFormException {
+ boolean generatePassword) throws InvalidPollenUserFormException {
return context.getPollenUserService().createUser(user, generatePassword);
}
public PollenUser editUser(PollenRestApiRequestContext context,
- PollenUser user) throws EntityNotFoundException, InvalidPollenUserFormException {
+ PollenUser user) throws InvalidPollenUserFormException {
return context.getPollenUserService().editUser(user);
}
- public void deleteUser(PollenRestApiRequestContext context,
- String userId) throws EntityNotFoundException, InvalidPollenUserFormException {
+ public void deleteUser(PollenRestApiRequestContext context, String userId) throws InvalidPollenUserFormException {
context.getPollenUserService().deleteUser(userId);
}
public void validateUserEmail(PollenRestApiRequestContext context,
String userId,
- String token) throws EntityNotFoundException, UserInvalidEmailActivationTokenException {
+ String token) throws UserInvalidEmailActivationTokenException {
context.getPollenUserService().validateUserEmail(userId, token);
}
public void changePassword(PollenRestApiRequestContext context,
String userId,
String oldPassword,
- String newPassword) throws EntityNotFoundException, UserInvalidPasswordException {
+ String newPassword) throws UserInvalidPasswordException {
context.getPollenUserService().changePassword(userId, oldPassword, newPassword);
}
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -25,7 +25,6 @@
import org.chorem.pollen.persistence.entity.Vote;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidVoteFormException;
import org.debux.webmotion.server.WebMotionController;
@@ -39,28 +38,28 @@
*/
public class VoteService extends WebMotionController {
- public List<Vote> getVotes(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
+ public List<Vote> getVotes(PollenRestApiRequestContext context, String pollId) {
context.getSecurityService().prepareSubject(pollId);
List<Vote> votes = context.getVoteService().getVotes(pollId);
return votes;
}
- public Vote getVote(PollenRestApiRequestContext context, String pollId, String voteId) throws EntityNotFoundException {
+ public Vote getVote(PollenRestApiRequestContext context, String pollId, String voteId) {
context.getSecurityService().prepareSubject(voteId);
return context.getVoteService().getVote(pollId, voteId);
}
- public Vote addVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
+ public Vote addVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidVoteFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getVoteService().addVote(pollId, vote);
}
- public Vote editVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
+ public Vote editVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidVoteFormException {
context.getSecurityService().prepareSubject(vote);
return context.getVoteService().editVote(pollId, vote);
}
- public void deleteVote(PollenRestApiRequestContext context, String pollId, String voteId) throws EntityNotFoundException {
+ public void deleteVote(PollenRestApiRequestContext context, String pollId, String voteId) {
context.getSecurityService().prepareSubject(voteId);
context.getVoteService().deleteVote(pollId, voteId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -26,7 +26,6 @@
import org.chorem.pollen.persistence.entity.VoterList;
import org.chorem.pollen.persistence.entity.VoterListMember;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidVoterListFormException;
import org.chorem.pollen.services.exception.InvalidVoterListMemberFormException;
import org.debux.webmotion.server.WebMotionController;
@@ -42,58 +41,58 @@
*/
public class VoterListService extends WebMotionController {
- public VoterList importFavoriteList(PollenRestApiRequestContext context, String userId, String pollId, String favoriteListId) throws EntityNotFoundException {
+ public VoterList importFavoriteList(PollenRestApiRequestContext context, String userId, String pollId, String favoriteListId) {
return context.getVoterListService().importFavoriteList(userId, pollId, favoriteListId);
}
- public List<VoterList> getVoterLists(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
+ public List<VoterList> getVoterLists(PollenRestApiRequestContext context, String pollId) {
context.getSecurityService().prepareSubject(pollId);
List<VoterList> voterLists = context.getVoterListService().getVoterLists(pollId);
return voterLists;
}
- public VoterList getVoterList(PollenRestApiRequestContext context, String pollId, String voterListId) throws EntityNotFoundException {
+ public VoterList getVoterList(PollenRestApiRequestContext context, String pollId, String voterListId) {
context.getSecurityService().prepareSubject(voterListId);
return context.getVoterListService().getVoterList(pollId, voterListId);
}
- public VoterList createVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
+ public VoterList createVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidVoterListFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getVoterListService().addVoterList(pollId, voterList);
}
- public VoterList editVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
+ public VoterList editVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidVoterListFormException {
context.getSecurityService().prepareSubject(voterList);
return context.getVoterListService().editVoterList(pollId, voterList);
}
- public void deleteVoterList(PollenRestApiRequestContext context, String pollId, String voterListId) throws EntityNotFoundException {
+ public void deleteVoterList(PollenRestApiRequestContext context, String pollId, String voterListId) {
context.getSecurityService().prepareSubject(voterListId);
context.getVoterListService().deleteVoterList(pollId, voterListId);
}
- public Set<VoterListMember> getMembers(PollenRestApiRequestContext context, String pollId, String voterListId) throws EntityNotFoundException {
+ public Set<VoterListMember> getMembers(PollenRestApiRequestContext context, String pollId, String voterListId) {
context.getSecurityService().prepareSubject(voterListId);
Set<VoterListMember> members = context.getVoterListService().getVoterListMembers(pollId, voterListId);
return members;
}
- public VoterListMember getMember(PollenRestApiRequestContext context, String pollId, String voterListId, String memberId) throws EntityNotFoundException {
+ public VoterListMember getMember(PollenRestApiRequestContext context, String pollId, String voterListId, String memberId) {
context.getSecurityService().prepareSubject(memberId);
return context.getVoterListService().getVoterListMember(pollId, voterListId, memberId);
}
- public VoterListMember addMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException {
+ public VoterListMember addMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidVoterListMemberFormException {
context.getSecurityService().prepareSubject(member);
return context.getVoterListService().addVoterListMember(pollId, voterListId, member);
}
- public VoterListMember editMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException {
+ public VoterListMember editMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidVoterListMemberFormException {
context.getSecurityService().prepareSubject(member);
return context.getVoterListService().editVoterListMember(pollId, voterListId, member);
}
- public void deleteMember(PollenRestApiRequestContext context, String pollId, String voterListId, String memberId) throws EntityNotFoundException {
+ public void deleteMember(PollenRestApiRequestContext context, String pollId, String voterListId, String memberId) {
context.getSecurityService().prepareSubject(memberId);
context.getVoterListService().deleteVoterListMember(pollId, voterListId, memberId);
}
Modified: trunk/pollen-rest-api/src/main/resources/mapping
===================================================================
--- trunk/pollen-rest-api/src/main/resources/mapping 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/main/resources/mapping 2014-05-02 09:20:55 UTC (rev 3895)
@@ -12,18 +12,20 @@
[errors]
-org.chorem.pollen.services.exception.EntityNotFoundException ErrorAction.on404
-org.chorem.pollen.services.exception.UserInvalidPasswordException ErrorAction.on500
+org.chorem.pollen.services.exception.EntityNotFoundException ErrorAction.on404
+org.chorem.pollen.services.exception.UserInvalidPasswordException ErrorAction.on500
org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException ErrorAction.on500
-org.chorem.pollen.services.exception.InvalidChoiceFormException ErrorAction.on500Form
-org.chorem.pollen.services.exception.InvalidPollenUserFormException ErrorAction.on500Form
-org.chorem.pollen.services.exception.InvalidFavoriteListFormException ErrorAction.on500Form
-org.chorem.pollen.services.exception.InvalidFavoriteListMemberFormException ErrorAction.on500Form
-org.chorem.pollen.services.exception.InvalidVoterListFormException ErrorAction.on500Form
-org.chorem.pollen.services.exception.InvalidVoterListMemberFormException ErrorAction.on500Form
-org.chorem.pollen.services.exception.InvalidVoteFormException ErrorAction.on500Form
-org.chorem.pollen.services.exception.InvalidPollFormException ErrorAction.on500Form
+org.chorem.pollen.services.exception.InvalidFormException ErrorAction.on400Form
+#org.chorem.pollen.services.exception.InvalidChoiceFormException ErrorAction.on500Form
+#org.chorem.pollen.services.exception.InvalidPollenUserFormException ErrorAction.on500Form
+#org.chorem.pollen.services.exception.InvalidFavoriteListFormException ErrorAction.on500Form
+#org.chorem.pollen.services.exception.InvalidFavoriteListMemberFormException ErrorAction.on500Form
+#org.chorem.pollen.services.exception.InvalidVoterListFormException ErrorAction.on500Form
+#org.chorem.pollen.services.exception.InvalidVoterListMemberFormException ErrorAction.on500Form
+#org.chorem.pollen.services.exception.InvalidVoteFormException ErrorAction.on500Form
+#org.chorem.pollen.services.exception.InvalidPollFormException ErrorAction.on500Form
+
[actions]
# Doc
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -27,8 +27,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.entity.SessionToken;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.chorem.pollen.services.service.security.PollenSecurityContext;
+import org.chorem.pollen.services.test.FakePollenSecurityContext;
import org.chorem.pollen.services.test.FakePollenServiceContext;
import org.chorem.pollen.services.test.PollenApplication;
import org.debux.webmotion.unittest.WebMotionTest;
@@ -83,9 +86,15 @@
Locale.FRANCE,
application.getConfiguration(),
application.getApplicationContext(),
- application.newPersistenceContext());
+ application.newPersistenceContext(),
+ new FakePollenSecurityContext());
return serviceContext;
}
+
+ @Override
+ public PollenSecurityContext newSecurityContext(SessionToken sessionToken) {
+ return new FakePollenSecurityContext();
+ }
};
applicationContext.init();
PollenRestApiApplicationContext.setApplicationContext(applicationContext);
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -1,7 +1,12 @@
package org.chorem.pollen.rest.api;
import org.apache.http.client.fluent.Request;
+import org.chorem.pollen.persistence.entity.Choice;
+import org.chorem.pollen.persistence.entity.ChoiceType;
+import org.chorem.pollen.persistence.entity.CommentVisibility;
import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.PollType;
+import org.chorem.pollen.persistence.entity.VoteVisibility;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -76,10 +81,20 @@
assertNotNull(content);
}
- @Ignore
@Test
public void postPoll() throws URISyntaxException, IOException {
- Request request = createRequest("/v1/polls").Post();
+ String paramPrefix = "poll.";
+ Request request = createRequest("/v1/polls").
+ addParameter(paramPrefix + Poll.PROPERTY_POLL_TYPE, PollType.FREE.name()).
+ addParameter(paramPrefix + Poll.PROPERTY_COMMENT_VISIBILITY, CommentVisibility.EVERYBODY.name()).
+ addParameter(paramPrefix + Poll.PROPERTY_VOTE_VISIBILITY, VoteVisibility.EVERYBODY.name()).
+ addParameter(paramPrefix + Poll.PROPERTY_VOTE_COUNTING_TYPE, "1").
+ addParameter(paramPrefix + Poll.PROPERTY_TITLE, "title").
+ addParameter(paramPrefix + Poll.PROPERTY_CHOICE + "[1]." + Choice.PROPERTY_CHOICE_TYPE, ChoiceType.TEXT.name()).
+ addParameter(paramPrefix + Poll.PROPERTY_CHOICE + "[1]." + Choice.PROPERTY_NAME, "choiceB").
+ addParameter(paramPrefix + Poll.PROPERTY_CHOICE + "[0]." + Choice.PROPERTY_CHOICE_TYPE, ChoiceType.TEXT.name()).
+ addParameter(paramPrefix + Poll.PROPERTY_CHOICE + "[0]." + Choice.PROPERTY_NAME, "choiceA").
+ Post();
String content = request.execute().returnContent().asString();
saveTestResult(content);
assertNotNull(content);
Modified: trunk/pollen-services/pom.xml
===================================================================
--- trunk/pollen-services/pom.xml 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/pom.xml 2014-05-02 09:20:55 UTC (rev 3895)
@@ -41,13 +41,23 @@
<artifactId>yamlbeans</artifactId>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-email</artifactId>
</dependency>
<dependency>
+ <groupId>com.github.spullara.mustache.java</groupId>
+ <artifactId>compiler</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
@@ -67,20 +77,13 @@
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
- <!--dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-email</artifactId>
- </dependency-->
+
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<!--dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- </dependency-->
- <!--dependency>
<groupId>rome</groupId>
<artifactId>rome</artifactId>
</dependency-->
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,6 +31,7 @@
import org.chorem.pollen.persistence.PollenPersistenceContext;
import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.chorem.pollen.services.service.security.PollenSecurityContext;
import org.nuiton.util.StringUtil;
import java.lang.reflect.Constructor;
@@ -55,27 +56,28 @@
this.pollenServiceConfig = pollenServiceConfig;
}
+ public void setTopiaApplicationContext(PollenTopiaApplicationContext topiaApplicationContext) {
+ this.topiaApplicationContext = topiaApplicationContext;
+ }
+
public void setPersistenceContext(PollenPersistenceContext persistenceContext) {
this.persistenceContext = persistenceContext;
}
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ @Override
public void setSecurityContext(PollenSecurityContext securityContext) {
this.securityContext = securityContext;
}
- public void setTopiaApplicationContext(PollenTopiaApplicationContext topiaApplicationContext) {
- this.topiaApplicationContext = topiaApplicationContext;
- }
-
@Override
public PollenTopiaApplicationContext getTopiaApplicationContext() {
return topiaApplicationContext;
}
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
@Override
public PollenServiceConfig getPollenServiceConfig() {
return pollenServiceConfig;
@@ -97,6 +99,7 @@
return securityContext;
}
+ @Override
public String generatePassword() {
return RandomStringUtils.randomAlphanumeric(8);
}
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityContext.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityContext.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -1,82 +0,0 @@
-package org.chorem.pollen.services;
-
-/*
- * #%L
- * Pollen :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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.shiro.subject.Subject;
-import org.chorem.pollen.persistence.entity.PollenUser;
-import org.chorem.pollen.persistence.entity.SessionToken;
-
-import java.io.Serializable;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollenSecurityContext implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- protected Subject subject;
-
- /**
- * Connected user account.
- * <p/>
- * Can be {@code null} if user is not connected.
- *
- * @since 2.0
- */
- protected final SessionToken sessionToken;
-
- public static PollenSecurityContext newContext(SessionToken sessionToken) {
- PollenSecurityContext result = new PollenSecurityContext(
- sessionToken);
- return result;
- }
-
- public Subject getSubject() {
- return subject;
- }
-
- public SessionToken getSessionToken() {
- return sessionToken;
- }
-
- public PollenUser getPollenUser() {
- return isConnected() ? sessionToken.getPollenUser() : null;
- }
-
- public boolean isConnected() {
- return sessionToken != null;
- }
-
- public void setSubject(Subject subject) {
- this.subject = subject;
- }
-
- protected PollenSecurityContext(SessionToken sessionToken) {
- this.sessionToken = sessionToken;
- }
-}
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityRealm.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityRealm.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityRealm.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -1,82 +0,0 @@
-package org.chorem.pollen.services;
-
-/*
- * #%L
- * Pollen :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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.shiro.authc.AuthenticationException;
-import org.apache.shiro.authc.AuthenticationInfo;
-import org.apache.shiro.authc.AuthenticationToken;
-import org.apache.shiro.authc.SimpleAuthenticationInfo;
-import org.apache.shiro.authc.UsernamePasswordToken;
-import org.apache.shiro.authz.AuthorizationInfo;
-import org.apache.shiro.realm.AuthorizingRealm;
-import org.apache.shiro.subject.PrincipalCollection;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
-import org.chorem.pollen.services.exception.UserInvalidPasswordException;
-import org.chorem.pollen.services.service.AuthService;
-
-/**
- * TODO
- * <p/>
- * http://www.slideshare.net/chunsaker/securing-rest-apis ?
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollenSecurityRealm extends AuthorizingRealm implements PollenService {
-
- protected PollenServiceContext serviceContext;
-
- @Override
- public void setServiceContext(PollenServiceContext serviceContext) {
- this.serviceContext = serviceContext;
- }
-
- @Override
- protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
-
- principals.getPrimaryPrincipal();
-
- return null;
- }
-
- @Override
- protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
-
- UsernamePasswordToken upToken = (UsernamePasswordToken) token;
- String username = upToken.getUsername();
- char[] password = upToken.getPassword();
-
- AuthService authService = serviceContext.newService(AuthService.class);
- try {
- authService.login(username, new String(password));
- } catch (EntityNotFoundException e) {
- throw new AuthenticationException(e);
- } catch (UserInvalidPasswordException e) {
- throw new AuthenticationException(e);
- }
- SimpleAuthenticationInfo result =
- new SimpleAuthenticationInfo(username, password, getName());
- return result;
- }
-}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -26,6 +26,7 @@
import org.chorem.pollen.persistence.PollenPersistenceContext;
import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.chorem.pollen.services.service.security.PollenSecurityContext;
import java.util.Date;
import java.util.Locale;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -146,4 +146,25 @@
PollenServiceConfigOption.DEFAULT_COMMENT_VISIBILITY.key);
return result;
}
+
+ /**
+ * @return Le nom d'hôte du serveur SMTP.
+ */
+ public String getSmtpHost() {
+ return applicationConfig.getOption(PollenServiceConfigOption.SMTP_HOST.key);
+ }
+
+ /**
+ * @return Le port du serveur SMTP.
+ */
+ public int getSmtpPort() {
+ return applicationConfig.getOptionAsInt(PollenServiceConfigOption.SMTP_PORT.key);
+ }
+
+ /**
+ * @return L'adresse d'expéditeur pour les mails de notifications
+ */
+ public String getSmtpFrom() {
+ return applicationConfig.getOption(PollenServiceConfigOption.SMTP_FROM.key);
+ }
}
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/AbstractInvalidFormException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/AbstractInvalidFormException.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/AbstractInvalidFormException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -1,52 +0,0 @@
-package org.chorem.pollen.services.exception;
-
-/*
- * #%L
- * Pollen :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 com.google.common.collect.Multimap;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public abstract class AbstractInvalidFormException extends Exception {
- private static final long serialVersionUID = 1L;
-
- protected final Multimap<String, String> errors;
-
-
- public AbstractInvalidFormException(Multimap<String, String> errors) {
- this.errors = errors;
- }
-
- public Multimap<String, String> getErrors() {
- return errors;
- }
-
- @Override
- public String toString() {
- return super.toString() + " errors: " + errors;
- }
-}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/EntityNotFoundException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/EntityNotFoundException.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/EntityNotFoundException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -23,6 +23,7 @@
* #L%
*/
+import org.chorem.pollen.services.PollenTechnicalException;
import org.nuiton.topia.persistence.TopiaEntity;
/**
@@ -31,7 +32,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class EntityNotFoundException extends Exception {
+public class EntityNotFoundException extends PollenTechnicalException {
private static final long serialVersionUID = -5760536098822762990L;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidChoiceFormException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidChoiceFormException.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidChoiceFormException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,7 +31,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class InvalidChoiceFormException extends AbstractInvalidFormException {
+public class InvalidChoiceFormException extends InvalidFormException {
private static final long serialVersionUID = 1L;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidCommentFormException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidCommentFormException.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidCommentFormException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,7 +31,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class InvalidCommentFormException extends AbstractInvalidFormException {
+public class InvalidCommentFormException extends InvalidFormException {
private static final long serialVersionUID = 1L;
public InvalidCommentFormException(Multimap<String, String> errors) {
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListFormException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListFormException.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListFormException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,7 +31,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class InvalidFavoriteListFormException extends AbstractInvalidFormException {
+public class InvalidFavoriteListFormException extends InvalidFormException {
private static final long serialVersionUID = 1L;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListMemberFormException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListMemberFormException.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListMemberFormException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,7 +31,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class InvalidFavoriteListMemberFormException extends AbstractInvalidFormException {
+public class InvalidFavoriteListMemberFormException extends InvalidFormException {
private static final long serialVersionUID = 1L;
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFormException.java (from rev 3890, trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/AbstractInvalidFormException.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFormException.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFormException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,52 @@
+package org.chorem.pollen.services.exception;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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 com.google.common.collect.Multimap;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class InvalidFormException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final Multimap<String, String> errors;
+
+ public InvalidFormException(Multimap<String, String> errors) {
+ this.errors = errors;
+ }
+
+ public Multimap<String, String> getErrors() {
+ return errors;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " errors: " + errors;
+ }
+}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollFormException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollFormException.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollFormException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,7 +31,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class InvalidPollFormException extends AbstractInvalidFormException {
+public class InvalidPollFormException extends InvalidFormException {
private static final long serialVersionUID = 1L;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollenUserFormException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollenUserFormException.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollenUserFormException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,7 +31,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class InvalidPollenUserFormException extends AbstractInvalidFormException {
+public class InvalidPollenUserFormException extends InvalidFormException {
private static final long serialVersionUID = 1L;
public InvalidPollenUserFormException(Multimap<String, String> errors) {
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoteFormException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoteFormException.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoteFormException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,7 +31,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class InvalidVoteFormException extends AbstractInvalidFormException {
+public class InvalidVoteFormException extends InvalidFormException {
private static final long serialVersionUID = 1L;
public InvalidVoteFormException(Multimap<String, String> errors) {
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListFormException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListFormException.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListFormException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,7 +31,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class InvalidVoterListFormException extends AbstractInvalidFormException {
+public class InvalidVoterListFormException extends InvalidFormException {
private static final long serialVersionUID = 1L;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListMemberFormException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListMemberFormException.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListMemberFormException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,7 +31,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class InvalidVoterListMemberFormException extends AbstractInvalidFormException {
+public class InvalidVoterListMemberFormException extends InvalidFormException {
private static final long serialVersionUID = 1L;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -27,7 +27,6 @@
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.PollenUserTopiaDao;
import org.chorem.pollen.persistence.entity.SessionToken;
import org.chorem.pollen.persistence.entity.SessionTokenTopiaDao;
import org.chorem.pollen.services.exception.EntityNotFoundException;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,8 +31,8 @@
import org.chorem.pollen.persistence.entity.ChoiceTopiaDao;
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.PollenPrincipal;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
-import org.chorem.pollen.services.exception.InvalidChoiceFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.security.PermissionVerb;
import java.util.List;
import java.util.Set;
@@ -45,7 +45,7 @@
*/
public class ChoiceService extends PollenServiceSupport {
- public List<Choice> getChoices(String pollId) throws EntityNotFoundException {
+ public List<Choice> getChoices(String pollId) {
Preconditions.checkNotNull(pollId);
Poll poll = getPollService().getPoll(pollId);
@@ -53,7 +53,7 @@
return poll.getChoice();
}
- public Choice getChoice(String pollId, String choiceId) throws EntityNotFoundException {
+ public Choice getChoice(String pollId, String choiceId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choiceId);
checkPermission(PermissionVerb.editChoice, choiceId);
@@ -63,10 +63,10 @@
return result;
}
- public Choice addChoice(String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
+ public Choice addChoice(String pollId, Choice choice) throws InvalidFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choice);
- checkHasNoId(choice);
+ checkIsNotPersisted(choice);
Poll poll = getPollService().getPoll(pollId);
checkPermission(PermissionVerb.addChoice, pollId);
@@ -81,9 +81,9 @@
return result;
}
- public Choice editChoice(String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException {
+ public Choice editChoice(String pollId, Choice choice) throws InvalidFormException {
Preconditions.checkNotNull(choice);
- checkHasId(choice);
+ checkIsPersisted(choice);
checkPermission(PermissionVerb.editChoice, choice.getTopiaId());
Poll poll = getPollService().getPoll(pollId);
@@ -98,7 +98,7 @@
return result;
}
- public void deleteChoice(String pollId, String choiceId) throws EntityNotFoundException {
+ public void deleteChoice(String pollId, String choiceId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choiceId);
checkPermission(PermissionVerb.deleteChoice, choiceId);
@@ -113,14 +113,14 @@
//TODO Notify Choice deleted
}
- protected Choice getChoice(Poll poll, String choiceId) throws EntityNotFoundException {
+ protected Choice getChoice(Poll poll, String choiceId) {
Choice result = poll.getChoiceByTopiaId(choiceId);
checkEntityExists(Choice.class, result, choiceId);
return result;
}
- protected Choice saveChoice(Poll poll, Choice choice) throws EntityNotFoundException {
+ protected Choice saveChoice(Poll poll, Choice choice) {
ChoiceTopiaDao choiceDao = getChoiceDao();
@@ -169,7 +169,7 @@
return choiceToPersist;
}
- protected void checkChoiceForm(Poll poll, Choice choice) throws InvalidChoiceFormException {
+ protected void checkChoiceForm(Poll poll, Choice choice) throws InvalidFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
@@ -218,7 +218,7 @@
if (!errors.isEmpty()) {
- throw new InvalidChoiceFormException(errors);
+ throw new InvalidFormException(errors);
}
}
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -32,6 +32,7 @@
import org.chorem.pollen.persistence.entity.PollenPrincipal;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidCommentFormException;
+import org.chorem.pollen.services.service.security.PermissionVerb;
import java.util.List;
@@ -63,7 +64,7 @@
public Comment addComment(String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(comment);
- checkHasNoId(comment);
+ checkIsNotPersisted(comment);
checkPermission(PermissionVerb.addComment, pollId);
Poll poll = getPollService().getPoll(pollId);
checkCommentForm(poll, comment);
@@ -78,7 +79,7 @@
public Comment editComment(String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(comment);
- checkHasId(comment);
+ checkIsPersisted(comment);
checkPermission(PermissionVerb.editComment, comment.getTopiaId());
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -51,6 +51,7 @@
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
@@ -88,7 +89,7 @@
FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteList);
- checkHasNoId(favoriteList);
+ checkIsNotPersisted(favoriteList);
PollenUser user = getUserService().getUser(userId);
@@ -107,7 +108,7 @@
public FavoriteList editFavoriteList(String userId,
FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
Preconditions.checkNotNull(favoriteList);
- checkHasId(favoriteList);
+ checkIsPersisted(favoriteList);
// get user
PollenUser user = getUserService().getUser(userId);
@@ -139,7 +140,7 @@
commit();
}
- public List<FavoriteListMember> getFavoriteListMembers(String userId, String favoriteListId) throws EntityNotFoundException {
+ public LinkedHashSet<FavoriteListMember> getFavoriteListMembers(String userId, String favoriteListId) throws EntityNotFoundException {
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteListId);
@@ -147,7 +148,7 @@
FavoriteList favoriteList = getFavoriteList(user, favoriteListId);
- return favoriteList.getFavoriteListMember();
+ return favoriteList.getMember();
}
public FavoriteListMember getFavoriteListMember(String userId, String favoriteListId, String memberId) throws EntityNotFoundException {
@@ -169,7 +170,7 @@
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(member);
- checkHasNoId(member);
+ checkIsNotPersisted(member);
PollenUser user = getUserService().getUser(userId);
@@ -180,7 +181,7 @@
FavoriteListMember newMember =
getFavoriteListMemberDao().newInstance();
copyFavoriteListMember(member, newMember);
- favoriteList.addFavoriteListMember(newMember);
+ favoriteList.addMember(newMember);
getFavoriteListDao().update(favoriteList);
@@ -194,7 +195,7 @@
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(member);
- checkHasId(member);
+ checkIsPersisted(member);
PollenUser user = getUserService().getUser(userId);
@@ -228,7 +229,7 @@
FavoriteListMember member = getFavoriteListMember(favoriteList, memberId);
- favoriteList.removeFavoriteListMember(member);
+ favoriteList.removeMember(member);
getFavoriteListDao().update(favoriteList);
commit();
@@ -250,8 +251,8 @@
Set<String> usedName = Sets.newHashSet();
Set<String> usedEmail = Sets.newHashSet();
- if (!favoriteList.isFavoriteListMemberEmpty()) {
- for (FavoriteListMember member : favoriteList.getFavoriteListMember()) {
+ if (!favoriteList.isMemberEmpty()) {
+ for (FavoriteListMember member : favoriteList.getMember()) {
usedName.add(member.getName());
usedEmail.add(member.getEmail());
}
@@ -311,7 +312,7 @@
member.setName(memberName);
member.setEmail(email);
- favoriteList.addFavoriteListMember(member);
+ favoriteList.addMember(member);
}
reader.close();
@@ -348,8 +349,8 @@
Set<String> usedName = Sets.newHashSet();
Set<String> usedEmail = Sets.newHashSet();
- if (!favoriteList.isFavoriteListMemberEmpty()) {
- for (FavoriteListMember member : favoriteList.getFavoriteListMember()) {
+ if (!favoriteList.isMemberEmpty()) {
+ for (FavoriteListMember member : favoriteList.getMember()) {
usedName.add(member.getName());
usedEmail.add(member.getEmail());
}
@@ -407,7 +408,7 @@
member.setName(memberName);
member.setEmail(email);
- favoriteList.addFavoriteListMember(member);
+ favoriteList.addMember(member);
}
}
} catch (NamingException ex) {
@@ -431,7 +432,7 @@
protected FavoriteListMember getFavoriteListMember(FavoriteList favoriteList, String memberId) throws EntityNotFoundException {
- FavoriteListMember result = favoriteList.getFavoriteListMemberByTopiaId(memberId);
+ FavoriteListMember result = favoriteList.getMemberByTopiaId(memberId);
checkEntityExists(FavoriteListMember.class, result, memberId);
return result;
}
@@ -473,14 +474,14 @@
check(errors, "name", !nameFound, "name already used by another favorite list");
- if (!favoriteList.isFavoriteListMemberEmpty()) {
+ if (!favoriteList.isMemberEmpty()) {
int memberIndex = 0;
Set<String> memberNames = Sets.newHashSet();
Set<String> memberEmails = Sets.newHashSet();
- for (FavoriteListMember member : favoriteList.getFavoriteListMember()) {
+ for (FavoriteListMember member : favoriteList.getMember()) {
String choiceField = "favoriteListMember[" + (memberIndex++) + "].";
@@ -521,11 +522,11 @@
Set<String> memberNames = Sets.newHashSet();
Set<String> memberEmails = Sets.newHashSet();
- if (!favoriteList.isFavoriteListMemberEmpty()) {
+ if (!favoriteList.isMemberEmpty()) {
// get all used names
- for (FavoriteListMember member : favoriteList.getFavoriteListMember()) {
+ for (FavoriteListMember member : favoriteList.getMember()) {
if (voterListMemberExists && member.getTopiaId().equals(member.getTopiaId())) {
continue;
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/NotificationService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/NotificationService.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/NotificationService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,102 @@
+package org.chorem.pollen.services.service;
+
+import org.chorem.pollen.persistence.entity.Choice;
+import org.chorem.pollen.persistence.entity.Comment;
+import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.PollenUser;
+import org.chorem.pollen.persistence.entity.Vote;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class NotificationService extends PollenServiceSupport {
+
+ public enum NotificationType {
+
+ // -- poll -- //
+ createPoll,
+ editPoll,
+ deletePoll,
+ closePoll,
+
+ // -- choice -- //
+ addChoice,
+ editChoice,
+ deleteChoice,
+
+ // -- comment -- //
+ addComment,
+ editComment,
+ deleteComment,
+
+ // -- vote -- //
+ addVote,
+ editVote,
+ deleteVote,
+ }
+
+ public void onAccountCreated(PollenUser pollenUser) {
+
+ }
+
+ public void onLostPasswordAsked(PollenUser pollenUser) {
+
+ }
+
+ public void onPollCreated(Poll poll) {
+
+ }
+
+ public void onPollEdited(Poll poll) {
+
+ }
+
+ public void onPollDeleted(Poll poll) {
+
+ }
+
+ public void onPollClosed(Poll poll) {
+
+ }
+
+ public void onChoiceAdded(Poll poll, Choice choice) {
+
+ }
+
+ public void onChoiceEdited(Poll poll, Choice choice) {
+
+ }
+
+ public void onChoiceDeleted(Poll poll, Choice choice) {
+
+ }
+
+ public void onCommentAdded(Poll poll, Comment comment) {
+
+ }
+
+ public void onCommentEdited(Poll poll, Comment comment) {
+
+ }
+
+ public void onCommentDeleted(Poll poll, Comment comment) {
+
+ }
+
+ public void onVoteAdded(Poll poll, Vote vote) {
+
+ }
+
+ public void onVoteEdited(Poll poll, Vote vote) {
+
+ }
+
+ public void onVoteDeleted(Poll poll, Vote vote) {
+
+ }
+
+
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/NotificationService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PermissionVerb.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PermissionVerb.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PermissionVerb.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -1,57 +0,0 @@
-package org.chorem.pollen.services.service;
-
-/*
- * #%L
- * Pollen :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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%
- */
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public enum PermissionVerb {
- readPoll,
- readChoice,
- readComment,
- readVote,
-
- addPoll,
- addChoice,
- addComment,
- addVote,
-
- editPoll,
- editChoice,
- editComment,
- editVote,
-
- deletePoll,
- deleteChoice,
- deleteComment,
- deleteVote,
-
- closePoll,
- clonePoll,
- exportPoll,
-
-}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -23,8 +23,8 @@
* #L%
*/
-import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
@@ -37,10 +37,12 @@
import org.chorem.pollen.persistence.entity.Polls;
import org.chorem.pollen.persistence.entity.VoterList;
import org.chorem.pollen.persistence.entity.VoterListMember;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
-import org.chorem.pollen.services.exception.InvalidPollFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.security.PermissionVerb;
+import org.chorem.pollen.services.service.security.SecurityRole;
import java.io.File;
+import java.util.List;
import java.util.Set;
/**
@@ -51,43 +53,52 @@
*/
public class PollService extends PollenServiceSupport {
- public Set<Poll> getPolls(String userId) throws EntityNotFoundException {
- return Sets.newHashSet(getPollDao().findAll());
+ public ImmutableSet<Poll> getPolls() {
+
+ checkRole(SecurityRole.administrator);
+ List<Poll> polls = getPollDao().findAll();
+ return ImmutableSet.<Poll>builder().addAll(polls).build();
+
}
- public Set<Poll> getCreatedPolls(String userId) throws EntityNotFoundException {
- Preconditions.checkNotNull(userId);
+ public ImmutableSet<Poll> getCreatedPolls() {
- getUserService().getUser(userId);
+ checkRole(SecurityRole.connected);
+ PollenUser connectedUser = getConnectedUser();
+ Set<Poll> polls = getPollDao().findAllCreated(connectedUser);
+ return ImmutableSet.<Poll>builder().addAll(polls).build();
- return getPollDao().findAllCreated(userId);
}
- public Set<Poll> getInvitedPolls(String userId) throws EntityNotFoundException {
- Preconditions.checkNotNull(userId);
+ public ImmutableSet<Poll> getInvitedPolls() {
- getUserService().getUser(userId);
+ checkRole(SecurityRole.connected);
+ PollenUser connectedUser = getConnectedUser();
+ Set<Poll> polls = getPollDao().findAllInvited(connectedUser);
+ return ImmutableSet.<Poll>builder().addAll(polls).build();
- return getPollDao().findAllInvited(userId);
}
- public Set<Poll> getParticipatedPolls(String userId) throws EntityNotFoundException {
- Preconditions.checkNotNull(userId);
+ public ImmutableSet<Poll> getParticipatedPolls() {
- getUserService().getUser(userId);
+ checkRole(SecurityRole.connected);
+ PollenUser connectedUser = getConnectedUser();
+ Set<Poll> polls = getPollDao().findAllParticipated(connectedUser);
+ return ImmutableSet.<Poll>builder().addAll(polls).build();
- return getPollDao().findAllParticipated(userId);
}
- public Poll getPoll(String pollId) throws EntityNotFoundException {
- Preconditions.checkNotNull(pollId);
+ public Poll getPoll(String pollId) {
+
+ checkNotNull(pollId);
checkPermission(PermissionVerb.readPoll, pollId);
- Poll result = getPollDao().findByTopiaId(pollId);
+ Poll result = getPollDao().forTopiaIdEquals(pollId).findUniqueOrNull();
checkEntityExists(Poll.class, result, pollId);
return result;
+
}
- public Poll getNewPoll(String userId) throws EntityNotFoundException {
+ public Poll getNewPoll() {
Poll result = getPollDao().newInstance();
@@ -104,95 +115,100 @@
PollenPrincipal creator = getPollenPrincipalDao().newInstance();
result.setCreator(creator);
- if (userId != null) {
- PollenUser user = getUserService().getUser(userId);
+ PollenUser connectedUser = getConnectedUser();
- creator.setName(user.getName());
- creator.setEmail(user.getEmail());
+ if (connectedUser != null) {
+
+ creator.setName(connectedUser.getName());
+ creator.setEmail(connectedUser.getEmail());
}
result.setChoice(Lists.<Choice>newArrayList());
result.setVoterList(Lists.<VoterList>newArrayList());
return result;
+
}
- public Poll createPoll(String userId, Poll poll) throws EntityNotFoundException, InvalidPollFormException {
+ public Poll createPoll(Poll poll) throws InvalidFormException {
- Preconditions.checkNotNull(poll);
- checkHasNoId(poll);
-
+ checkNotNull(poll);
+ checkIsNotPersisted(poll);
checkPollForm(poll);
- Poll pollToPersist = savePoll(userId, poll);
+ Poll savedPoll = savePoll(poll);
- getPollDao().create(pollToPersist);
+ getPollDao().create(savedPoll);
commit();
- return pollToPersist;
+ getNotificationService().onPollCreated(poll);
+ return savedPoll;
+
}
- public Poll editPoll(Poll poll) throws EntityNotFoundException, InvalidPollFormException {
- Preconditions.checkNotNull(poll);
- checkHasId(poll);
+ public Poll editPoll(Poll poll) throws InvalidFormException {
+ checkNotNull(poll);
+ checkIsPersisted(poll);
checkPermission(PermissionVerb.editPoll, poll.getTopiaId());
-
checkPollForm(poll);
- Poll toSave = savePoll(null, poll);
+ Poll savedPoll = savePoll(poll);
- getPollDao().update(toSave);
+ getPollDao().update(savedPoll);
commit();
+ getNotificationService().onPollEdited(poll);
+ return savedPoll;
- return toSave;
}
+ public void deletePoll(String pollId) {
- public void deletePoll(String pollId) throws EntityNotFoundException {
- Preconditions.checkNotNull(pollId);
-
+ checkNotNull(pollId);
checkPermission(PermissionVerb.deletePoll, pollId);
Poll poll = getPoll(pollId);
getPollDao().delete(poll);
commit();
+ getNotificationService().onPollDeleted(poll);
- if (poll.getCreator().getEmail() != null) {
-
- //TODO Notify ?
- }
}
- public Poll clonePoll(String pollId) throws EntityNotFoundException {
- Preconditions.checkNotNull(pollId);
+ public Poll clonePoll(String pollId) {
+ checkNotNull(pollId);
checkPermission(PermissionVerb.clonePoll, pollId);
Poll poll = getPoll(pollId);
//TODO
commit();
- return null;
+ getNotificationService().onPollCreated(poll);
+ return poll;
+
}
- public File closePoll(String pollId) throws EntityNotFoundException {
- Preconditions.checkNotNull(pollId);
+ public void closePoll(String pollId) {
+
+ checkNotNull(pollId);
checkPermission(PermissionVerb.closePoll, pollId);
Poll poll = getPoll(pollId);
//TODO
commit();
- return null;
+ getNotificationService().onPollClosed(poll);
+
}
- public File exportPoll(String pollId) throws EntityNotFoundException {
- Preconditions.checkNotNull(pollId);
+ public File exportPoll(String pollId) {
+
+ checkNotNull(pollId);
checkPermission(PermissionVerb.exportPoll, pollId);
Poll poll = getPoll(pollId);
//TODO
return null;
+
}
- protected Poll savePoll(String userId, Poll poll) throws EntityNotFoundException {
+ protected Poll savePoll(Poll poll) {
boolean pollExists = poll.isPersisted();
@@ -214,11 +230,12 @@
// -- creator -- //
- if (userId != null) {
+ PollenUser connectedUser = getConnectedUser();
+ if (connectedUser != null) {
+
// link to connected user
- PollenUser user = getUserService().getUser(userId);
- toSave.getCreator().setPollenUser(user);
+ toSave.getCreator().setPollenUser(connectedUser);
}
PollenPrincipal creator = poll.getCreator();
@@ -265,27 +282,28 @@
}
return toSave;
+
}
- protected void checkPollForm(Poll poll) throws InvalidPollFormException {
+ protected void checkPollForm(Poll poll) throws InvalidFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
- checkNotNull(errors, "pollType", poll.getPollType(), "pollType can not be null");
- checkNotNull(errors, "commentVisibility", poll.getCommentVisibility(), "commentVisibility can not be null");
- checkNotNull(errors, "voteVisibility", poll.getVoteVisibility(), "voteVisibility can not be null");
- checkNotNull(errors, "voteCountingType", poll.getVoteCountingType(), "voteCountingType can not be null");
+ checkNotNull(errors, Poll.PROPERTY_POLL_TYPE, poll.getPollType(), "pollType can not be null");
+ checkNotNull(errors, Poll.PROPERTY_COMMENT_VISIBILITY, poll.getCommentVisibility(), "commentVisibility can not be null");
+ checkNotNull(errors, Poll.PROPERTY_VOTE_VISIBILITY, poll.getVoteVisibility(), "voteVisibility can not be null");
+ checkNotNull(errors, Poll.PROPERTY_VOTE_COUNTING_TYPE, poll.getVoteCountingType(), "voteCountingType can not be null");
- checkNotBlank(errors, "title", poll.getTitle(), "title can not be empty");
- checkNotEmpty(errors, "choice", poll.getChoice(), "need at least one choice");
+ checkNotBlank(errors, Poll.PROPERTY_TITLE, poll.getTitle(), "title can not be empty");
+ checkNotEmpty(errors, Poll.PROPERTY_CHOICE, poll.getChoice(), "need at least one choice");
if (Polls.isPollFree(poll)) {
- checkEmpty(errors, "voterList", poll.getVoterList(), "can't have voterList with free poll");
+ checkEmpty(errors, Poll.PROPERTY_VOTER_LIST, poll.getVoterList(), "can't have voterList with free poll");
} else if (Polls.isPollRestricted(poll)) {
- check(errors, "voterList", 1 == poll.sizeVoterList(), "must have a unique voterList with a resitricted poll");
+ check(errors, Poll.PROPERTY_VOTER_LIST, 1 == poll.sizeVoterList(), "must have a unique voterList with a resitricted poll");
} else if (Polls.isPollGroup(poll)) {
- checkNotEmpty(errors, "voterList", poll.getVoterList(), "must have at least one voterList with a group poll");
+ checkNotEmpty(errors, Poll.PROPERTY_VOTER_LIST, poll.getVoterList(), "must have at least one voterList with a group poll");
}
if (!poll.isChoiceEmpty()) {
@@ -296,19 +314,19 @@
for (Choice choice : poll.getChoice()) {
- String choiceField = "choice[" + (choiceIndex++) + "]";
+ String choiceField = Poll.PROPERTY_CHOICE + "[" + (choiceIndex++) + "].";
checkNotNull(errors,
- choiceField + ".choiceType",
+ choiceField + Choice.PROPERTY_CHOICE_TYPE,
choice.getChoiceType(),
"choiceType can not be null");
- if (choice.getChoiceType()!=null) {
+ if (choice.getChoiceType() != null) {
switch (choice.getChoiceType()) {
case TEXT:
checkNotBlank(errors,
- choiceField + ".name",
+ choiceField + Choice.PROPERTY_NAME,
choice.getName(),
"choice name can not be empty");
@@ -333,17 +351,17 @@
for (VoterList voterList : poll.getVoterList()) {
- String voterListField = "voterList[" + (voterListIndex++) + "].";
+ String voterListField = Poll.PROPERTY_VOTER_LIST + "[" + (voterListIndex++) + "].";
- boolean notBlankName = checkNotBlank(errors, voterListField + "name", voterList.getName(), "voterList name can not be empty");
+ boolean notBlankName = checkNotBlank(errors, voterListField + VoterList.PROPERTY_NAME, voterList.getName(), "voterList name can not be empty");
if (notBlankName) {
boolean added = voterListNames.add(voterList.getName());
- check(errors, voterListField + "name", added, "voterList name already used");
+ check(errors, voterListField + VoterList.PROPERTY_NAME, added, "voterList name already used");
}
- check(errors, voterListField + "weight", voterList.getWeight() > 0, "voterList weight must be greater than 0");
- boolean withMember = checkNotEmpty(errors, voterListField + "member", voterList.getVoterListMember(), "voterList must contains at least one member");
+ check(errors, voterListField + VoterList.PROPERTY_WEIGHT, voterList.getWeight() > 0, "voterList weight must be greater than 0");
+ boolean withMember = checkNotEmpty(errors, voterListField + VoterList.PROPERTY_MEMBER, voterList.getMember(), "voterList must contains at least one member");
if (withMember) {
Set<String> voterListMemberNames = Sets.newHashSet();
@@ -351,32 +369,32 @@
int voterListMemberIndex = 0;
- for (VoterListMember voterListMember : voterList.getVoterListMember()) {
+ for (VoterListMember voterListMember : voterList.getMember()) {
- String voterListMemberField = voterListField + "member[" + (voterListMemberIndex++) + "].";
+ String voterListMemberField = voterListField + VoterList.PROPERTY_MEMBER + "[" + (voterListMemberIndex++) + "].";
String voterListMemberName = voterListMember.getName();
- boolean nameNotNull = checkNotBlank(errors, voterListMemberField + "name", voterListMemberName, "member name can not be empty");
+ boolean nameNotNull = checkNotBlank(errors, voterListMemberField + VoterListMember.PROPERTY_NAME, voterListMemberName, "member name can not be empty");
if (nameNotNull) {
boolean nameAdded = voterListMemberNames.add(voterListMemberName);
- check(errors, voterListMemberField + "name", nameAdded, "member name already used in this list");
+ check(errors, voterListMemberField + VoterListMember.PROPERTY_NAME, nameAdded, "member name already used in this list");
}
String voterListMemberEmail = voterListMember.getEmail();
- boolean emailNotNull = checkNotBlank(errors, voterListMemberField + "email", voterListMemberEmail, "member email can not be empty");
+ boolean emailNotNull = checkNotBlank(errors, voterListMemberField + VoterListMember.PROPERTY_EMAIL, voterListMemberEmail, "member email can not be empty");
if (emailNotNull) {
voterListMemberEmail = StringUtils.lowerCase(voterListMemberEmail);
- checkValidEmail(errors, voterListMemberField + "email", voterListMemberEmail, "member email is not valid");
+ checkValidEmail(errors, voterListMemberField + VoterListMember.PROPERTY_EMAIL, voterListMemberEmail, "member email is not valid");
boolean emailAdded = voterListMemberEmails.add(voterListMemberEmail);
- check(errors, voterListMemberField + "email", emailAdded, "member email already used in this list");
+ check(errors, voterListMemberField + VoterListMember.PROPERTY_EMAIL, emailAdded, "member email already used in this list");
}
- check(errors, voterListMemberField + "weight", voterListMember.getWeight() > 0, "member weight must be greater than 0");
+ check(errors, voterListMemberField + VoterListMember.PROPERTY_WEIGHT, voterListMember.getWeight() > 0, "member weight must be greater than 0");
}
}
}
@@ -384,7 +402,8 @@
if (!errors.isEmpty()) {
- throw new InvalidPollFormException(errors);
+ throw new InvalidFormException(errors);
}
+
}
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -34,6 +34,7 @@
import org.chorem.pollen.persistence.entity.FavoriteListTopiaDao;
import org.chorem.pollen.persistence.entity.PollTopiaDao;
import org.chorem.pollen.persistence.entity.PollenPrincipalTopiaDao;
+import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.persistence.entity.PollenUserTopiaDao;
import org.chorem.pollen.persistence.entity.SessionTokenTopiaDao;
import org.chorem.pollen.persistence.entity.VoteToChoiceTopiaDao;
@@ -44,6 +45,10 @@
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
import org.chorem.pollen.services.exception.EntityNotFoundException;
+import org.chorem.pollen.services.service.mail.EmailService;
+import org.chorem.pollen.services.service.security.PermissionVerb;
+import org.chorem.pollen.services.service.security.SecurityRole;
+import org.chorem.pollen.services.service.security.SecurityService;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.util.StringUtil;
@@ -111,6 +116,14 @@
return newService(FavoriteListService.class);
}
+ protected EmailService getEmailService() {
+ return newService(EmailService.class);
+ }
+
+ protected NotificationService getNotificationService() {
+ return newService(NotificationService.class);
+ }
+
protected PollService getPollService() {
return newService(PollService.class);
}
@@ -199,16 +212,28 @@
// -- check method -- //
+ protected PollenUser getConnectedUser() {
+ return serviceContext.getSecurityContext().getPollenUser();
+ }
+
protected void checkPermission(PermissionVerb verb, String id) {
String permission = createPermission(verb, id);
-// serviceContext.getSecurityContext().getSubject().checkPermission(permission);
+ serviceContext.getSecurityContext().checkPermission(permission);
}
- protected void checkHasId(TopiaEntity entity) {
+ protected void checkRole(SecurityRole role) {
+ serviceContext.getSecurityContext().checkRole(role);
+ }
+
+ protected void checkNotNull(Object object) {
+ Preconditions.checkNotNull(object);
+ }
+
+ protected void checkIsPersisted(TopiaEntity entity) {
Preconditions.checkState(entity.isPersisted());
}
- protected void checkHasNoId(TopiaEntity entity) {
+ protected void checkIsNotPersisted(TopiaEntity entity) {
Preconditions.checkState(!entity.isPersisted());
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -23,7 +23,6 @@
* #L%
*/
-import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import org.apache.commons.lang3.ObjectUtils;
@@ -34,6 +33,7 @@
import org.chorem.pollen.services.exception.InvalidPollenUserFormException;
import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
import org.chorem.pollen.services.exception.UserInvalidPasswordException;
+import org.chorem.pollen.services.service.security.SecurityRole;
import org.nuiton.topia.persistence.TopiaNoResultException;
import java.util.List;
@@ -47,11 +47,15 @@
public class PollenUserService extends PollenServiceSupport implements PollenService {
public List<PollenUser> getUsers() {
- return getPollenUserDao().findAll();
+
+ checkRole(SecurityRole.administrator);
+ List<PollenUser> pollenUsers = getPollenUserDao().findAll();
+ return pollenUsers;
+
}
public PollenUser getUser(String userId) throws EntityNotFoundException {
- Preconditions.checkNotNull(userId);
+ checkNotNull(userId);
try {
PollenUser result = getPollenUserDao().findByTopiaId(userId);
@@ -62,7 +66,7 @@
}
public PollenUser getUserByLogin(String login) throws EntityNotFoundException {
- Preconditions.checkNotNull(login);
+ checkNotNull(login);
try {
PollenUser result = getPollenUserDao().forLoginEquals(login).findAny();
return result;
@@ -71,9 +75,9 @@
}
}
- public PollenUser createUser(PollenUser user, boolean generatePassword) throws InvalidPollenUserFormException, EntityNotFoundException {
- Preconditions.checkNotNull(user);
- checkHasNoId(user);
+ public PollenUser createUser(PollenUser user, boolean generatePassword) throws InvalidPollenUserFormException {
+ checkNotNull(user);
+ checkIsNotPersisted(user);
checkPollenUserForm(user);
PollenUser result = savePollenUser(user, generatePassword);
@@ -84,9 +88,9 @@
return result;
}
- public PollenUser editUser(PollenUser user) throws EntityNotFoundException, InvalidPollenUserFormException {
- Preconditions.checkNotNull(user);
- checkHasId(user);
+ public PollenUser editUser(PollenUser user) throws InvalidPollenUserFormException {
+ checkNotNull(user);
+ checkIsPersisted(user);
checkPollenUserForm(user);
PollenUser result = savePollenUser(user, false);
@@ -97,8 +101,8 @@
return result;
}
- public void deleteUser(String userId) throws EntityNotFoundException, InvalidPollenUserFormException {
- Preconditions.checkNotNull(userId);
+ public void deleteUser(String userId) {
+ checkNotNull(userId);
PollenUser user = getUser(userId);
getPollenUserDao().delete(user);
@@ -107,10 +111,10 @@
public void changePassword(String userId,
String oldPassword,
- String newPassword) throws EntityNotFoundException, UserInvalidPasswordException {
- Preconditions.checkNotNull(userId);
- Preconditions.checkNotNull(oldPassword);
- Preconditions.checkNotNull(newPassword);
+ String newPassword) throws UserInvalidPasswordException {
+ checkNotNull(userId);
+ checkNotNull(oldPassword);
+ checkNotNull(newPassword);
PollenUser user = getUser(userId);
@@ -130,10 +134,10 @@
}
public void validateUserEmail(String userId,
- String token) throws EntityNotFoundException, UserInvalidEmailActivationTokenException {
+ String token) throws UserInvalidEmailActivationTokenException {
- Preconditions.checkNotNull(userId);
- Preconditions.checkNotNull(token);
+ checkNotNull(userId);
+ checkNotNull(token);
PollenUser user = getUser(userId);
@@ -151,7 +155,7 @@
commit();
}
- public void createDefaultUsers() throws EntityNotFoundException, InvalidPollenUserFormException {
+ public void createDefaultUsers() throws InvalidPollenUserFormException {
if (getPollenUserDao().count() == 0) {
@@ -166,7 +170,7 @@
}
}
- protected void checkPollenUserForm(PollenUser user) throws EntityNotFoundException, InvalidPollenUserFormException {
+ protected void checkPollenUserForm(PollenUser user) throws InvalidPollenUserFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
@@ -218,8 +222,7 @@
}
}
- protected PollenUser savePollenUser(PollenUser user,
- boolean generatePassword) throws EntityNotFoundException {
+ protected PollenUser savePollenUser(PollenUser user, boolean generatePassword) {
boolean userExists = user.isPersisted();
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -1,258 +0,0 @@
-package org.chorem.pollen.services.service;
-
-/*
- * #%L
- * Pollen :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 CodeLutin
- * %%
- * 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 com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import org.apache.shiro.subject.Subject;
-import org.chorem.pollen.persistence.entity.Choice;
-import org.chorem.pollen.persistence.entity.Comment;
-import org.chorem.pollen.persistence.entity.Poll;
-import org.chorem.pollen.persistence.entity.PollenPrincipal;
-import org.chorem.pollen.persistence.entity.PollenPrincipalTopiaDao;
-import org.chorem.pollen.persistence.entity.PollenUser;
-import org.chorem.pollen.persistence.entity.Polls;
-import org.chorem.pollen.persistence.entity.Vote;
-import org.chorem.pollen.persistence.entity.VoterListMember;
-import org.chorem.pollen.services.PollenSecurityContext;
-import org.nuiton.topia.persistence.TopiaEntity;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class SecurityService extends PollenServiceSupport {
-
- public PollenPrincipal generatePrincipal() {
- PollenPrincipalTopiaDao pollenPrincipalDao = getPersistenceContext().getPollenPrincipalDao();
- PollenPrincipal principal = pollenPrincipalDao.newInstance();
- principal.setCreationDate(serviceContext.getNow());
- pollenPrincipalDao.create(principal);
- return principal;
- }
-
- public void prepareSubject(TopiaEntity entity) {
- Preconditions.checkNotNull(entity);
- prepareSubject(entity.getTopiaId());
- }
-
- public void prepareSubject(String principalId) {
- PollenSecurityContext securityContext = serviceContext.getSecurityContext();
- Preconditions.checkNotNull(securityContext);
- PollenUser pollenUser = securityContext.getPollenUser();
- Subject subject = getSubject(principalId, pollenUser);
- securityContext.setSubject(subject);
- }
-
- protected Subject getSubject(String principalId, PollenUser user) {
- Set<String> permissions = Sets.newHashSet();
-
- boolean userConnected = user != null;
- boolean userIsAdmin = userConnected && user.isAdministrator();
-
- if (userIsAdmin) {
- permissions.add("*:*:*");
- } else {
-
- Set<PollenPrincipal> principals = Sets.newHashSet();
-
- PollenPrincipalTopiaDao pollenPrincipalDao =
- getPersistenceContext().getPollenPrincipalDao();
-
- if (principalId != null) {
- PollenPrincipal pollenPrincipal =
- pollenPrincipalDao.findByTopiaId(principalId);
- principals.add(pollenPrincipal);
- }
-
- if (userConnected) {
-
- // find all principals
- List<PollenPrincipal> allByPollenUser =
- pollenPrincipalDao.findAllByPollenUser(user);
- principals.addAll(allByPollenUser);
- }
-
- Map<PollenPrincipal, TopiaEntity> principalTopiaEntityMap = Maps.newHashMap();
-
- for (PollenPrincipal principal : principals) {
-
- // find out which entity is using this principal
- TopiaEntity entity = getPrincipalEntity(principal);
- principalTopiaEntityMap.put(principal, entity);
-
- if (entity instanceof Poll) {
-
- // add all poll entities
- Poll poll = (Poll) entity;
-
- if (!poll.isChoiceEmpty()) {
- for (Choice choice : poll.getChoice()) {
- principalTopiaEntityMap.put(choice.getCreator(), choice);
- }
- }
-
- if (!poll.isCommentEmpty()) {
- for (Comment comment : poll.getComment()) {
- principalTopiaEntityMap.put(comment.getAuthor(), comment);
- }
- }
-
- if (!poll.isVoteEmpty()) {
- for (Vote vote : poll.getVote()) {
- principalTopiaEntityMap.put(vote.getVoter(), vote);
- }
- }
- }
- }
-
- Date now = serviceContext.getNow();
- for (Map.Entry<PollenPrincipal, TopiaEntity> entry : principalTopiaEntityMap.entrySet()) {
- TopiaEntity entity = entry.getValue();
-
- if (entity instanceof Choice) {
- permissions.add(createWildcardSubjectPermission(entity));
- continue;
- }
- if (entity instanceof Comment) {
- permissions.add(createWildcardSubjectPermission(entity));
- continue;
- }
- if (entity instanceof Vote) {
- permissions.add(createWildcardSubjectPermission(entity));
- continue;
- }
- if (entity instanceof Poll) {
- //TODO Get alls possible permissions on poll
-
- Poll poll = (Poll) entity;
-
- Set<VoterListMember> members = Polls.getAllVoters(poll);
-
- boolean freePoll = Polls.isPollFree(poll);
-
- if (freePoll) {
-
- // everybody can read poll ?
- permissions.add(createSubjectPermission(PermissionVerb.readPoll, entity));
- } else {
-
- // only his creator / participants / voters can read it
-
- for (VoterListMember member : members) {
- permissions.add(createSubjectPermission(member.getTopiaId(), PermissionVerb.readPoll, entity));
- }
- }
-
- // add editVote / deleteVote for any voter
- if (!poll.isVoteEmpty()) {
- for (Vote vote : poll.getVote()) {
- String id = vote.getVoter().getTopiaId();
- permissions.add(createSubjectPermission(id, PermissionVerb.editVote, vote));
- permissions.add(createSubjectPermission(id, PermissionVerb.deleteVote, vote));
- }
- }
-
- //TODO Not do this here, but later in business code
-// if (poll.isAddChoiceRunning(now)) {
-//
-// permissions.add(createSubjectPermission(PermissionVerb.addChoice, entity));
-// }
-//
-// if (poll.getCommentVisibility() != CommentVisibility.NOBODY) {
-// //FIXME Should see with voter ?
-// permissions.add(createSubjectPermission(PermissionVerb.addComment, entity));
-// }
-//
-// if (poll.isRunning(now)) {
-// permissions.add(createSubjectPermission(PermissionVerb.addVote, entity));
-// }
-
- //TODO Do for editVote,...
- }
- }
- }
-
-// SimplePrincipalCollection principalCollection = new SimplePrincipalCollection();
-// principalCollection.addAll(permissions, "pollenRealm");
-// Subject subject = new Subject.Builder().principals(principalCollection).buildSubject();
-// return subject;
- return null;
- }
-
- protected TopiaEntity getPrincipalEntity(PollenPrincipal principal) {
-
- TopiaEntity result = null;
-
- // try a poll
- Poll poll = getPollDao().findByCreator(principal);
- if (poll == null) {
-
- // try a choice
- Choice choice = getChoiceDao().findByCreator(principal);
- if (choice == null) {
-
- // try a vote
- Vote vote = getVoteDao().findByVoter(principal);
- if (vote == null) {
-
- // try a comment
- Comment comment = getCommentDao().findByAuthor(principal);
- if (comment != null) {
- result = comment;
- }
- } else {
- result = vote;
- }
- } else {
- result = choice;
- }
- } else {
- result = poll;
- }
-
- Preconditions.checkNotNull(result);
- return result;
- }
-
- protected String createSubjectPermission(String people, PermissionVerb verb, TopiaEntity entity) {
- return people + ":" + verb.name() + ":" + entity.getTopiaId();
- }
-
- protected String createSubjectPermission(PermissionVerb verb, TopiaEntity entity) {
- return createSubjectPermission("*", verb, entity);
- }
-
- protected String createWildcardSubjectPermission(TopiaEntity entity) {
- return "*:*:" + entity.getTopiaId();
- }
-}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -31,6 +31,7 @@
import org.chorem.pollen.persistence.entity.Vote;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidVoteFormException;
+import org.chorem.pollen.services.service.security.PermissionVerb;
import java.util.Date;
import java.util.List;
@@ -65,7 +66,7 @@
public Vote addVote(String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(vote);
- checkHasNoId(vote);
+ checkIsNotPersisted(vote);
checkPermission(PermissionVerb.addVote, pollId);
Poll poll = getPollService().getPoll(pollId);
@@ -81,7 +82,7 @@
public Vote editVote(String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
Preconditions.checkNotNull(vote);
- checkHasId(vote);
+ checkIsPersisted(vote);
checkPermission(PermissionVerb.editVote, vote.getTopiaId());
Poll poll = getPollService().getPoll(pollId);
@@ -123,7 +124,7 @@
Date now = serviceContext.getNow();
// poll must be started
- check(errors, "poll", Polls.isStarted(poll, now), "poll is not stardted");
+ check(errors, "poll", Polls.isStarted(poll, now), "poll is not started");
checkNotBlank(errors, "voter.name", vote.getVoter().getName(), "voter name can not be empty");
@@ -137,12 +138,12 @@
protected Vote saveVote(Poll poll, Vote vote) throws EntityNotFoundException {
- boolean commentExists = vote.isPersisted();
+ boolean voteExist = vote.isPersisted();
Vote toSave;
//TODO Finish save
- if (commentExists) {
+ if (voteExist) {
toSave = getVote(poll, vote.getTopiaId());
} else {
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -68,12 +68,12 @@
VoterListMemberTopiaDao voterListMemberDao =
getVoterListMemberDao();
- for (FavoriteListMember favoriteListMember : favoriteList.getFavoriteListMember()) {
+ for (FavoriteListMember favoriteListMember : favoriteList.getMember()) {
VoterListMember voterListMember = voterListMemberDao.newInstance();
voterListMember.setWeight(1d);
voterListMember.setEmail(favoriteListMember.getEmail());
- result.addVoterListMember(voterListMember);
+ result.addMember(voterListMember);
}
poll.addVoterList(result);
@@ -105,7 +105,7 @@
public VoterList addVoterList(String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterList);
- checkHasNoId(voterList);
+ checkIsNotPersisted(voterList);
Poll poll = getPollService().getPoll(pollId);
checkVoterList(poll, voterList);
@@ -120,7 +120,7 @@
public VoterList editVoterList(String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterList);
- checkHasId(voterList);
+ checkIsPersisted(voterList);
Poll poll = getPollService().getPoll(pollId);
checkVoterList(poll, voterList);
@@ -152,7 +152,7 @@
VoterList voterList = getVoterList(pollId, voterListId);
- Set<VoterListMember> result = voterList.getVoterListMember();
+ Set<VoterListMember> result = voterList.getMember();
return result;
}
@@ -172,7 +172,7 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterListId);
Preconditions.checkNotNull(member);
- checkHasNoId(member);
+ checkIsNotPersisted(member);
VoterList voterList = getVoterList(pollId, voterListId);
@@ -190,7 +190,7 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterListId);
Preconditions.checkNotNull(member);
- checkHasId(member);
+ checkIsPersisted(member);
VoterList voterList = getVoterList(pollId, voterListId);
@@ -211,7 +211,7 @@
VoterList voterList = getVoterList(pollId, voterListId);
VoterListMember member = getVoterListMember(voterList, memberId);
- voterList.removeVoterListMember(member);
+ voterList.removeMember(member);
// getVoterListDao().merge(voterList);
@@ -228,7 +228,7 @@
protected VoterListMember getVoterListMember(VoterList voterList, String memberId) throws EntityNotFoundException {
Preconditions.checkNotNull(memberId);
- VoterListMember result = voterList.getVoterListMemberByTopiaId(memberId);
+ VoterListMember result = voterList.getMemberByTopiaId(memberId);
checkEntityExists(VoterListMember.class, result, memberId);
return result;
}
@@ -254,7 +254,7 @@
toSave.setName(voterList.getName());
toSave.setWeight(voterList.getWeight());
- for (VoterListMember voterListMember : voterList.getVoterListMember()) {
+ for (VoterListMember voterListMember : voterList.getMember()) {
saveVoterListMember(toSave, voterListMember);
}
@@ -279,7 +279,7 @@
toSave = voterListMemberDao.newInstance();
- voterList.addVoterListMember(toSave);
+ voterList.addMember(toSave);
}
toSave.setName(voterListMember.getName());
@@ -314,7 +314,7 @@
checkNotBlank(errors, "name", voterList.getName(), "voterList name can not be empty");
check(errors, "weight", voterList.getWeight() > 0, "voterList weight must be greater than 0");
- checkNotEmpty(errors, "member", voterList.getVoterListMember(), "voterList must contains at least one member");
+ checkNotEmpty(errors, "member", voterList.getMember(), "voterList must contains at least one member");
boolean added = voterListNames.add(voterList.getName());
@@ -325,7 +325,7 @@
int voterListMemberIndex = 0;
- for (VoterListMember voterListMember : voterList.getVoterListMember()) {
+ for (VoterListMember voterListMember : voterList.getMember()) {
String voterListMemberField = "member[" + (voterListMemberIndex++) + "].";
@@ -364,11 +364,11 @@
Set<String> voterListMemberNames = Sets.newHashSet();
Set<String> voterListMemberEmails = Sets.newHashSet();
- if (!voterList.isVoterListMemberEmpty()) {
+ if (!voterList.isMemberEmpty()) {
// get all used names
- for (VoterListMember member : voterList.getVoterListMember()) {
+ for (VoterListMember member : voterList.getMember()) {
if (voterListMemberExists &&
member.getTopiaId().equals(voterListMember.getTopiaId())) {
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceAddedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceAddedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceAddedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,45 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Choice;
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class ChoiceAddedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected Choice choice;
+
+ protected ChoiceAddedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.ChoiceAddedEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+
+ public Choice getChoice() {
+ return choice;
+ }
+
+ public void setChoice(Choice choice) {
+ this.choice = choice;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceAddedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceDeletedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceDeletedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceDeletedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,45 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Choice;
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class ChoiceDeletedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected Choice choice;
+
+ protected ChoiceDeletedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.ChoiceDeletedEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+
+ public Choice getChoice() {
+ return choice;
+ }
+
+ public void setChoice(Choice choice) {
+ this.choice = choice;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceDeletedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceEditedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceEditedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceEditedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,45 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Choice;
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class ChoiceEditedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected Choice choice;
+
+ protected ChoiceEditedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.ChoiceEditedEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+
+ public Choice getChoice() {
+ return choice;
+ }
+
+ public void setChoice(Choice choice) {
+ this.choice = choice;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceEditedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentAddedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentAddedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentAddedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,45 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Comment;
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class CommentAddedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected Comment comment;
+
+ protected CommentAddedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.CommentAddedEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+
+ public Comment getComment() {
+ return comment;
+ }
+
+ public void setComment(Comment comment) {
+ this.comment = comment;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentAddedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentDeletedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentDeletedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentDeletedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,45 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Comment;
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class CommentDeletedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected Comment comment;
+
+ protected CommentDeletedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.CommentDeletedEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+
+ public Comment getComment() {
+ return comment;
+ }
+
+ public void setComment(Comment comment) {
+ this.comment = comment;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentDeletedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentEditedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentEditedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentEditedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,45 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Comment;
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class CommentEditedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected Comment comment;
+
+ protected CommentEditedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.CommentEditedEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+
+ public Comment getComment() {
+ return comment;
+ }
+
+ public void setComment(Comment comment) {
+ this.comment = comment;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentEditedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,267 @@
+package org.chorem.pollen.services.service.mail;
+
+import com.github.mustachejava.DefaultMustacheFactory;
+import com.github.mustachejava.Mustache;
+import com.github.mustachejava.MustacheException;
+import com.github.mustachejava.MustacheFactory;
+import com.google.common.base.Charsets;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.mail.Email;
+import org.apache.commons.mail.EmailException;
+import org.apache.commons.mail.SimpleEmail;
+import org.chorem.pollen.persistence.entity.Choice;
+import org.chorem.pollen.persistence.entity.Comment;
+import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.PollenPrincipal;
+import org.chorem.pollen.persistence.entity.PollenUser;
+import org.chorem.pollen.persistence.entity.Vote;
+import org.chorem.pollen.services.PollenTechnicalException;
+import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.chorem.pollen.services.service.PollenServiceSupport;
+
+import java.io.StringWriter;
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+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);
+ email.setPoll(poll);
+ email.setChoice(choice);
+ return email;
+ }
+
+ public ChoiceEditedEmail newChoiceEditedEmail(Locale locale, Poll poll, Choice choice) {
+ ChoiceEditedEmail email = new ChoiceEditedEmail(locale);
+ email.setPoll(poll);
+ email.setChoice(choice);
+ return email;
+ }
+
+ public ChoiceDeletedEmail newChoiceDeletedEmail(Locale locale, Poll poll, Choice choice) {
+ ChoiceDeletedEmail email = new ChoiceDeletedEmail(locale);
+ email.setPoll(poll);
+ email.setChoice(choice);
+ return email;
+ }
+
+ public CommentAddedEmail newCommentAddedEmail(Locale locale, Poll poll, Comment comment) {
+ CommentAddedEmail email = new CommentAddedEmail(locale);
+ email.setPoll(poll);
+ email.setComment(comment);
+ return email;
+ }
+
+ public CommentEditedEmail newCommnetEditedEmail(Locale locale, Poll poll, Comment comment) {
+ CommentEditedEmail email = new CommentEditedEmail(locale);
+ email.setPoll(poll);
+ email.setComment(comment);
+ return email;
+ }
+
+ public CommentDeletedEmail newCommentDeletedEmail(Locale locale, Poll poll, Comment comment) {
+ CommentDeletedEmail email = new CommentDeletedEmail(locale);
+ email.setPoll(poll);
+ email.setComment(comment);
+ return email;
+ }
+
+ public VoteAddedEmail newVoteAddedEmail(Locale locale, Poll poll, Vote vote) {
+ VoteAddedEmail email = new VoteAddedEmail(locale);
+ email.setPoll(poll);
+ email.setVote(vote);
+ return email;
+ }
+
+ public VoteEditedEmail newVoteEditedEmail(Locale locale, Poll poll, Vote vote) {
+ VoteEditedEmail email = new VoteEditedEmail(locale);
+ email.setPoll(poll);
+ email.setVote(vote);
+ return email;
+ }
+
+ public VoteDeletedEmail newVoteDeletedEmail(Locale locale, Poll poll, Vote vote) {
+ VoteDeletedEmail email = new VoteDeletedEmail(locale);
+ email.setPoll(poll);
+ email.setVote(vote);
+ return email;
+ }
+
+ public PollCreatedEmail newPollCreatedEmail(Locale locale, Poll poll) {
+ PollCreatedEmail email = new PollCreatedEmail(locale);
+ email.setPoll(poll);
+ return email;
+ }
+
+ public PollClosedEmail newPollClosedEmail(Locale locale, Poll poll) {
+ PollClosedEmail email = new PollClosedEmail(locale);
+ email.setPoll(poll);
+ return email;
+ }
+
+ public PollChoicePeriodStartedEmail newPollChoicePeriodStartedEmail(Locale locale, Poll poll) {
+ PollChoicePeriodStartedEmail email = new PollChoicePeriodStartedEmail(locale);
+ email.setPoll(poll);
+ return email;
+ }
+
+ public PollChoicePeriodEndedEmail newPollChoicePeriodEndedEmail(Locale locale, Poll poll) {
+ PollChoicePeriodEndedEmail email = new PollChoicePeriodEndedEmail(locale);
+ email.setPoll(poll);
+ return email;
+ }
+
+ public PollVotePeriodStartedEmail newPollVotePeriodStartedEmail(Locale locale, Poll poll) {
+ PollVotePeriodStartedEmail email = new PollVotePeriodStartedEmail(locale);
+ email.setPoll(poll);
+ return email;
+ }
+
+ public PollVotePeriodEndedEmail newPollVotePeriodEndedEmail(Locale locale, Poll poll) {
+ PollVotePeriodEndedEmail email = new PollVotePeriodEndedEmail(locale);
+ email.setPoll(poll);
+ return email;
+ }
+
+ public PollVoteReminderEmail newPollVoteReminderEmail(Locale locale, Poll poll) {
+ PollVoteReminderEmail email = new PollVoteReminderEmail(locale);
+ email.setPoll(poll);
+ return email;
+ }
+
+ public RestrictedPollInvitationEmail newRestrictedPollInvitationEmail(Locale locale, Poll poll, PollenPrincipal principal) {
+ RestrictedPollInvitationEmail email = new RestrictedPollInvitationEmail(locale);
+ email.setPoll(poll);
+ email.setPrincipal(principal);
+ return email;
+ }
+
+ public UserAccountCreatedEmail newUserAccountCreatedEmail(Locale locale, PollenUser user) {
+ UserAccountCreatedEmail email = new UserAccountCreatedEmail(locale);
+ email.setUser(user);
+ return email;
+ }
+
+ public LostPasswordEmail newLostPasswordEmail(Locale locale, PollenUser user, String password) {
+ LostPasswordEmail email = new LostPasswordEmail(locale);
+ email.setUser(user);
+ email.setPassword(password);
+ return email;
+ }
+
+ public void send(PollenMail mail) {
+
+ if (getPollenServiceConfig().isDevMode()) {
+
+ if (log.isInfoEnabled()) {
+ log.info("an email should have been sent if not in devMode: tos = " +
+ mail.getTos() + ". subject = '" + mail.getSubject() + "'. body = \n" + getBody(mail));
+ }
+
+ if (log.isWarnEnabled()) {
+ if (!mail.isRecipientProvided()) {
+ log.warn("email has no recipient, would not have been sent " + mail);
+ }
+ }
+
+ } else {
+
+ doSend(mail);
+
+ }
+
+ }
+
+ protected void doSend(PollenMail mail) {
+
+ PollenServiceConfig applicationConfig = getPollenServiceConfig();
+
+ String body = getBody(mail);
+
+ if (mail.isRecipientProvided()) {
+
+ Email newEmail = new SimpleEmail();
+
+ newEmail.setHostName(applicationConfig.getSmtpHost());
+
+ newEmail.setSmtpPort(applicationConfig.getSmtpPort());
+
+ newEmail.setCharset(Charsets.UTF_8.name());
+
+ newEmail.setSubject(mail.getSubject());
+
+ try {
+
+ newEmail.setFrom(applicationConfig.getSmtpFrom());
+
+ for (String to : mail.getTos()) {
+ newEmail.addTo(to);
+ }
+
+ for (String bcc : mail.getBccs()) {
+ newEmail.addBcc(bcc);
+ }
+
+ newEmail.setMsg(body);
+
+ newEmail.send();
+
+ } catch (EmailException e) {
+ throw new PollenTechnicalException(e);
+ }
+
+ } else {
+
+ if (log.isErrorEnabled()) {
+ log.error("email has no recipient, won't be sent " + mail);
+ }
+
+ }
+
+ }
+
+ protected String getBody(PollenMail mail) {
+
+ Mustache mustache = getMustache(mail);
+
+ StringWriter stringWriter = new StringWriter();
+
+ mustache.execute(stringWriter, mail);
+
+ return stringWriter.toString();
+
+ }
+
+ protected Mustache getMustache(PollenMail mail) {
+
+ MustacheFactory mustacheFactory = new DefaultMustacheFactory("mail/");
+
+ Locale locale = mail.getLocale();
+ String templateName = mail.getClass().getSimpleName() + "_" + locale.getLanguage() + ".mustache";
+
+ Mustache mustache;
+ try {
+ mustache = mustacheFactory.compile(templateName);
+ } catch (MustacheException e) {
+
+ // fallback with no locale
+ templateName = mail.getClass().getSimpleName() + ".mustache";
+
+ mustache = mustacheFactory.compile(templateName);
+ }
+
+ return mustache;
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/LostPasswordEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/LostPasswordEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/LostPasswordEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,44 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.PollenUser;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class LostPasswordEmail extends PollenMail {
+
+ private PollenUser user;
+
+ private String password;
+
+ protected LostPasswordEmail(Locale locale) {
+ super(locale);
+ }
+
+ public PollenUser getUser() {
+ return user;
+ }
+
+ public void setUser(PollenUser user) {
+ this.user = user;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.LostPasswordEmail.subject");
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/LostPasswordEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollChoicePeriodEndedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollChoicePeriodEndedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollChoicePeriodEndedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollChoicePeriodEndedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected PollChoicePeriodEndedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.PollChoicePeriodEndedEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollChoicePeriodEndedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollChoicePeriodStartedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollChoicePeriodStartedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollChoicePeriodStartedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollChoicePeriodStartedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected PollChoicePeriodStartedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.PollChoicePeriodStartedEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollChoicePeriodStartedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollClosedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollClosedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollClosedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollClosedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected PollClosedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.PollClosedEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollClosedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollCreatedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollCreatedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollCreatedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollCreatedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected PollCreatedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.PollCreatedEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollCreatedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVotePeriodEndedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVotePeriodEndedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVotePeriodEndedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollVotePeriodEndedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected PollVotePeriodEndedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.PollVotePeriodEndedEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVotePeriodEndedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVotePeriodStartedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVotePeriodStartedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVotePeriodStartedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollVotePeriodStartedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected PollVotePeriodStartedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.PollVotePeriodStartedEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVotePeriodStartedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVoteReminderEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVoteReminderEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVoteReminderEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Poll;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollVoteReminderEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected PollVoteReminderEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.PollVoteReminderEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVoteReminderEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollenMail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollenMail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollenMail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,67 @@
+package org.chorem.pollen.services.service.mail;
+
+import com.google.common.collect.Sets;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public abstract class PollenMail {
+
+ protected Locale locale;
+
+ protected Set<String> tos;
+
+ protected Set<String> bccs;
+
+ public PollenMail(Locale locale) {
+ this.locale = locale;
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public Set<String> getTos() {
+ if (tos == null) {
+ tos = Sets.newHashSet();
+ }
+ return tos;
+ }
+
+ public void addTo(String email) {
+ getTos().add(email);
+ }
+
+ public abstract String getSubject();
+
+ public Set<String> getBccs() {
+ if (bccs == null) {
+ bccs = Sets.newHashSet();
+ }
+ return bccs;
+ }
+
+ public void addBcc(String email) {
+ getBccs().add(email);
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ public boolean isRecipientProvided() {
+ boolean isRecipientProvided = CollectionUtils.isNotEmpty(getBccs())
+ || CollectionUtils.isNotEmpty(getTos());
+ return isRecipientProvided;
+ }
+
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollenMail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/RestrictedPollInvitationEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/RestrictedPollInvitationEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/RestrictedPollInvitationEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,45 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.PollenPrincipal;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class RestrictedPollInvitationEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected PollenPrincipal principal;
+
+ protected RestrictedPollInvitationEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.RestrictedPollInvitationEmail.subject");
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+
+ public PollenPrincipal getPrincipal() {
+ return principal;
+ }
+
+ public void setPrincipal(PollenPrincipal principal) {
+ this.principal = principal;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/RestrictedPollInvitationEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/UserAccountCreatedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/UserAccountCreatedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/UserAccountCreatedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.PollenUser;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class UserAccountCreatedEmail extends PollenMail {
+
+ private PollenUser user;
+
+ protected UserAccountCreatedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.UserAccountCreatedEmail.subject");
+ }
+
+ public PollenUser getUser() {
+ return user;
+ }
+
+ public void setUser(PollenUser user) {
+ this.user = user;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/UserAccountCreatedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteAddedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteAddedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteAddedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,45 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.Vote;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class VoteAddedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected Vote vote;
+
+ protected VoteAddedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.VoteAddedEmail.subject");
+ }
+
+ public Vote getVote() {
+ return vote;
+ }
+
+ public void setVote(Vote vote) {
+ this.vote = vote;
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteAddedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteDeletedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteDeletedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteDeletedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,45 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.Vote;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class VoteDeletedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected Vote vote;
+
+ protected VoteDeletedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.VoteDeletedEmail.subject");
+ }
+
+ public Vote getVote() {
+ return vote;
+ }
+
+ public void setVote(Vote vote) {
+ this.vote = vote;
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteDeletedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteEditedEmail.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteEditedEmail.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteEditedEmail.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,45 @@
+package org.chorem.pollen.services.service.mail;
+
+import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.Vote;
+import org.nuiton.i18n.I18n;
+
+import java.util.Locale;
+
+/**
+ * Created on 4/30/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class VoteEditedEmail extends PollenMail {
+
+ protected Poll poll;
+
+ protected Vote vote;
+
+ protected VoteEditedEmail(Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public String getSubject() {
+ return I18n.l(locale, "pollen.service.mail.VoteEditedEmail.subject");
+ }
+
+ public Vote getVote() {
+ return vote;
+ }
+
+ public void setVote(Vote vote) {
+ this.vote = vote;
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public void setPoll(Poll poll) {
+ this.poll = poll;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteEditedEmail.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/DefaultPollenSecurityContext.java (from rev 3890, trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityContext.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/DefaultPollenSecurityContext.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/DefaultPollenSecurityContext.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,147 @@
+package org.chorem.pollen.services.service.security;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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.apache.shiro.subject.SimplePrincipalCollection;
+import org.apache.shiro.subject.Subject;
+import org.chorem.pollen.persistence.entity.PollenUser;
+import org.chorem.pollen.persistence.entity.SessionToken;
+
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class DefaultPollenSecurityContext implements Serializable, PollenSecurityContext {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(DefaultPollenSecurityContext.class);
+
+ protected Subject subject;
+
+ /**
+ * Connected user account.
+ * <p/>
+ * Can be {@code null} if user is not connected.
+ *
+ * @since 2.0
+ */
+ protected final SessionToken sessionToken;
+
+ public static PollenSecurityContext newContext(SessionToken sessionToken) {
+ PollenSecurityContext result = new DefaultPollenSecurityContext(
+ sessionToken);
+ return result;
+ }
+
+ @Override
+ public Subject getSubject() {
+ return subject;
+ }
+
+ @Override
+ public SessionToken getSessionToken() {
+ return sessionToken;
+ }
+
+ @Override
+ public PollenUser getPollenUser() {
+ return isConnected() ? sessionToken.getPollenUser() : null;
+ }
+
+ @Override
+ public boolean isConnected() {
+ return sessionToken != null;
+ }
+
+ @Override
+ public boolean isAdmin() {
+ return getPollenUser() != null && getPollenUser().isAdministrator();
+ }
+
+ @Override
+ public void setSubject(Subject subject) {
+ this.subject = subject;
+ }
+
+ @Override
+ public void checkPermission(String permission) {
+ if (log.isInfoEnabled()) {
+ log.info("Check permission: " + permission);
+ }
+
+ boolean valid = getSubject().isPermitted(permission);
+
+ if (!valid) {
+ throw new PollenInvalidPermissionException(permission);
+ }
+
+ }
+
+ @Override
+ public void checkRole(SecurityRole role) {
+
+ boolean valid = false;
+ switch (role) {
+
+ case anonymous:
+ valid = true;
+ break;
+ case connected:
+ valid = isConnected();
+ break;
+ case administrator:
+ valid = isAdmin();
+ break;
+ }
+
+// //FIXME Find out how to push roles to subject...
+// boolean valid = getSubject().hasRole(role.name());
+
+ if (!valid) {
+ throw new PollenUnauthorizedException(role);
+ }
+ }
+
+ @Override
+ public Subject newSubject(Set<SecurityRole> roles, Set<String> permissions) {
+ //TODO Add roles to subject
+ SimplePrincipalCollection principalCollection = new SimplePrincipalCollection();
+ principalCollection.addAll(permissions, "pollenRealm");
+ Subject result = new Subject.Builder().principals(principalCollection).buildSubject();
+ return result;
+ }
+
+ protected DefaultPollenSecurityContext(SessionToken sessionToken) {
+ this.sessionToken = sessionToken;
+ }
+}
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PermissionVerb.java (from rev 3890, trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PermissionVerb.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PermissionVerb.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PermissionVerb.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,57 @@
+package org.chorem.pollen.services.service.security;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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%
+ */
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public enum PermissionVerb {
+ readPoll,
+ readChoice,
+ readComment,
+ readVote,
+
+ addPoll,
+ addChoice,
+ addComment,
+ addVote,
+
+ editPoll,
+ editChoice,
+ editComment,
+ editVote,
+
+ deletePoll,
+ deleteChoice,
+ deleteComment,
+ deleteVote,
+
+ closePoll,
+ clonePoll,
+ exportPoll,
+
+}
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidPermissionException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidPermissionException.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidPermissionException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,24 @@
+package org.chorem.pollen.services.service.security;
+
+import org.chorem.pollen.services.PollenTechnicalException;
+
+/**
+ * Created on 5/1/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenInvalidPermissionException extends PollenTechnicalException {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String permission;
+
+ public PollenInvalidPermissionException(String permission) {
+ this.permission = permission;
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidPermissionException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityContext.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityContext.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.services.service.security;
+
+import org.apache.shiro.subject.Subject;
+import org.chorem.pollen.persistence.entity.PollenUser;
+import org.chorem.pollen.persistence.entity.SessionToken;
+
+import java.util.Set;
+
+/**
+ * Created on 5/1/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public interface PollenSecurityContext {
+
+ Subject getSubject();
+
+ SessionToken getSessionToken();
+
+ PollenUser getPollenUser();
+
+ boolean isConnected();
+
+ boolean isAdmin();
+
+ void setSubject(Subject subject);
+
+ void checkPermission(String permission);
+
+ void checkRole(SecurityRole role);
+
+ Subject newSubject(Set<SecurityRole> roles, Set<String> permissions);
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityRealm.java (from rev 3890, trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityRealm.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityRealm.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityRealm.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,84 @@
+package org.chorem.pollen.services.service.security;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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.shiro.authc.AuthenticationException;
+import org.apache.shiro.authc.AuthenticationInfo;
+import org.apache.shiro.authc.AuthenticationToken;
+import org.apache.shiro.authc.SimpleAuthenticationInfo;
+import org.apache.shiro.authc.UsernamePasswordToken;
+import org.apache.shiro.authz.AuthorizationInfo;
+import org.apache.shiro.realm.AuthorizingRealm;
+import org.apache.shiro.subject.PrincipalCollection;
+import org.chorem.pollen.services.PollenService;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.exception.EntityNotFoundException;
+import org.chorem.pollen.services.exception.UserInvalidPasswordException;
+import org.chorem.pollen.services.service.AuthService;
+
+/**
+ * TODO
+ * <p/>
+ * http://www.slideshare.net/chunsaker/securing-rest-apis ?
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenSecurityRealm extends AuthorizingRealm implements PollenService {
+
+ protected PollenServiceContext serviceContext;
+
+ @Override
+ public void setServiceContext(PollenServiceContext serviceContext) {
+ this.serviceContext = serviceContext;
+ }
+
+ @Override
+ protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
+
+ principals.getPrimaryPrincipal();
+
+ return null;
+ }
+
+ @Override
+ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
+
+ UsernamePasswordToken upToken = (UsernamePasswordToken) token;
+ String username = upToken.getUsername();
+ char[] password = upToken.getPassword();
+
+ AuthService authService = serviceContext.newService(AuthService.class);
+ try {
+ authService.login(username, new String(password));
+ } catch (EntityNotFoundException e) {
+ throw new AuthenticationException(e);
+ } catch (UserInvalidPasswordException e) {
+ throw new AuthenticationException(e);
+ }
+ SimpleAuthenticationInfo result =
+ new SimpleAuthenticationInfo(username, password, getName());
+ return result;
+ }
+}
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUnauthorizedException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUnauthorizedException.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUnauthorizedException.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,24 @@
+package org.chorem.pollen.services.service.security;
+
+import org.chorem.pollen.services.PollenTechnicalException;
+
+/**
+ * Created on 5/1/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenUnauthorizedException extends PollenTechnicalException {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final SecurityRole role;
+
+ public PollenUnauthorizedException(SecurityRole role) {
+ this.role = role;
+ }
+
+ public SecurityRole getRole() {
+ return role;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUnauthorizedException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityRole.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityRole.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityRole.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,13 @@
+package org.chorem.pollen.services.service.security;
+
+/**
+ * Created on 5/1/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public enum SecurityRole {
+ anonymous,
+ connected,
+ administrator
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityRole.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java (from rev 3890, trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,265 @@
+package org.chorem.pollen.services.service.security;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * 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 com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import org.apache.shiro.subject.Subject;
+import org.chorem.pollen.persistence.entity.Choice;
+import org.chorem.pollen.persistence.entity.Comment;
+import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.PollenPrincipal;
+import org.chorem.pollen.persistence.entity.PollenPrincipalTopiaDao;
+import org.chorem.pollen.persistence.entity.PollenUser;
+import org.chorem.pollen.persistence.entity.Polls;
+import org.chorem.pollen.persistence.entity.Vote;
+import org.chorem.pollen.persistence.entity.VoterListMember;
+import org.chorem.pollen.services.service.PollenServiceSupport;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class SecurityService extends PollenServiceSupport {
+
+ public PollenPrincipal generatePrincipal() {
+ PollenPrincipalTopiaDao pollenPrincipalDao = getPersistenceContext().getPollenPrincipalDao();
+ PollenPrincipal principal = pollenPrincipalDao.newInstance();
+ principal.setCreationDate(serviceContext.getNow());
+ pollenPrincipalDao.create(principal);
+ return principal;
+ }
+
+ public void prepareSubject(TopiaEntity entity) {
+ Preconditions.checkNotNull(entity);
+ prepareSubject(entity.getTopiaId());
+ }
+
+ public void prepareSubject(String principalId) {
+ PollenSecurityContext securityContext = serviceContext.getSecurityContext();
+ Preconditions.checkNotNull(securityContext);
+ PollenUser pollenUser = securityContext.getPollenUser();
+ Subject subject = getSubject(principalId, pollenUser);
+ securityContext.setSubject(subject);
+ }
+
+ protected Subject getSubject(String principalId, PollenUser user) {
+ Set<String> permissions = Sets.newHashSet();
+
+ boolean userConnected = user != null;
+ boolean userIsAdmin = userConnected && user.isAdministrator();
+
+ Set<SecurityRole> roles = EnumSet.noneOf(SecurityRole.class);
+ if (userConnected) {
+ roles.add(SecurityRole.connected);
+ if (userIsAdmin) {
+ roles.add(SecurityRole.administrator);
+ }
+ } else {
+ roles.add(SecurityRole.anonymous);
+ }
+
+ if (userIsAdmin) {
+ permissions.add("*:*:*");
+ } else {
+
+ Set<PollenPrincipal> principals = Sets.newHashSet();
+
+ PollenPrincipalTopiaDao pollenPrincipalDao =
+ getPersistenceContext().getPollenPrincipalDao();
+
+ if (principalId != null) {
+ PollenPrincipal pollenPrincipal =
+ pollenPrincipalDao.findByTopiaId(principalId);
+ principals.add(pollenPrincipal);
+ }
+
+ if (userConnected) {
+
+ // find all principals
+ List<PollenPrincipal> allByPollenUser =
+ pollenPrincipalDao.forPollenUserEquals(user).findAll();
+ principals.addAll(allByPollenUser);
+ }
+
+ Map<PollenPrincipal, TopiaEntity> principalTopiaEntityMap = Maps.newHashMap();
+
+ for (PollenPrincipal principal : principals) {
+
+ // find out which entity is using this principal
+ TopiaEntity entity = getPrincipalEntity(principal);
+ principalTopiaEntityMap.put(principal, entity);
+
+ if (entity instanceof Poll) {
+
+ // add all poll entities
+ Poll poll = (Poll) entity;
+
+ if (!poll.isChoiceEmpty()) {
+ for (Choice choice : poll.getChoice()) {
+ principalTopiaEntityMap.put(choice.getCreator(), choice);
+ }
+ }
+
+ if (!poll.isCommentEmpty()) {
+ for (Comment comment : poll.getComment()) {
+ principalTopiaEntityMap.put(comment.getAuthor(), comment);
+ }
+ }
+
+ if (!poll.isVoteEmpty()) {
+ for (Vote vote : poll.getVote()) {
+ principalTopiaEntityMap.put(vote.getVoter(), vote);
+ }
+ }
+ }
+ }
+
+ Date now = serviceContext.getNow();
+ for (Map.Entry<PollenPrincipal, TopiaEntity> entry : principalTopiaEntityMap.entrySet()) {
+ TopiaEntity entity = entry.getValue();
+
+ if (entity instanceof Choice) {
+ permissions.add(createWildcardSubjectPermission(entity));
+ continue;
+ }
+ if (entity instanceof Comment) {
+ permissions.add(createWildcardSubjectPermission(entity));
+ continue;
+ }
+ if (entity instanceof Vote) {
+ permissions.add(createWildcardSubjectPermission(entity));
+ continue;
+ }
+ if (entity instanceof Poll) {
+ //TODO Get alls possible permissions on poll
+
+ Poll poll = (Poll) entity;
+
+ Set<VoterListMember> members = Polls.getAllVoters(poll);
+
+ boolean freePoll = Polls.isPollFree(poll);
+
+ if (freePoll) {
+
+ // everybody can read poll ?
+ permissions.add(createSubjectPermission(PermissionVerb.readPoll, entity));
+ } else {
+
+ // only his creator / participants / voters can read it
+
+ for (VoterListMember member : members) {
+ permissions.add(createSubjectPermission(member.getTopiaId(), PermissionVerb.readPoll, entity));
+ }
+ }
+
+ // add editVote / deleteVote for any voter
+ if (!poll.isVoteEmpty()) {
+ for (Vote vote : poll.getVote()) {
+ String id = vote.getVoter().getTopiaId();
+ permissions.add(createSubjectPermission(id, PermissionVerb.editVote, vote));
+ permissions.add(createSubjectPermission(id, PermissionVerb.deleteVote, vote));
+ }
+ }
+
+ //TODO Not do this here, but later in business code
+// if (poll.isAddChoiceRunning(now)) {
+//
+// permissions.add(createSubjectPermission(PermissionVerb.addChoice, entity));
+// }
+//
+// if (poll.getCommentVisibility() != CommentVisibility.NOBODY) {
+// //FIXME Should see with voter ?
+// permissions.add(createSubjectPermission(PermissionVerb.addComment, entity));
+// }
+//
+// if (poll.isRunning(now)) {
+// permissions.add(createSubjectPermission(PermissionVerb.addVote, entity));
+// }
+
+ //TODO Do for editVote,...
+ }
+ }
+ }
+ Subject subject = serviceContext.getSecurityContext().newSubject(roles, permissions);
+ return subject;
+ }
+
+ protected TopiaEntity getPrincipalEntity(PollenPrincipal principal) {
+
+ TopiaEntity result = null;
+
+ // try a poll
+ Poll poll = getPollDao().forCreatorEquals(principal).findUniqueOrNull();
+ if (poll == null) {
+
+ // try a choice
+ Choice choice = getChoiceDao().forCreatorEquals(principal).findUniqueOrNull();
+ if (choice == null) {
+
+ // try a vote
+ Vote vote = getVoteDao().forVoterEquals(principal).findUniqueOrNull();
+ if (vote == null) {
+
+ // try a comment
+ Comment comment = getCommentDao().forAuthorEquals(principal).findUniqueOrNull();
+ if (comment != null) {
+ result = comment;
+ }
+ } else {
+ result = vote;
+ }
+ } else {
+ result = choice;
+ }
+ } else {
+ result = poll;
+ }
+
+ Preconditions.checkNotNull(result);
+ return result;
+ }
+
+ protected String createSubjectPermission(String people, PermissionVerb verb, TopiaEntity entity) {
+ return people + ":" + verb.name() + ":" + entity.getTopiaId();
+ }
+
+ protected String createSubjectPermission(PermissionVerb verb, TopiaEntity entity) {
+ return createSubjectPermission("*", verb, entity);
+ }
+
+ protected String createWildcardSubjectPermission(TopiaEntity entity) {
+ return "*:*:" + entity.getTopiaId();
+ }
+}
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenSecurityContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenSecurityContext.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenSecurityContext.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -0,0 +1,64 @@
+package org.chorem.pollen.services.test;
+
+import org.apache.shiro.subject.Subject;
+import org.chorem.pollen.persistence.entity.PollenUser;
+import org.chorem.pollen.persistence.entity.SessionToken;
+import org.chorem.pollen.services.service.security.PollenSecurityContext;
+import org.chorem.pollen.services.service.security.SecurityRole;
+
+import java.util.Set;
+
+/**
+ * Created on 5/1/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class FakePollenSecurityContext implements PollenSecurityContext {
+
+ @Override
+ public Subject getSubject() {
+ return null;
+ }
+
+ @Override
+ public SessionToken getSessionToken() {
+ return null;
+ }
+
+ @Override
+ public PollenUser getPollenUser() {
+ return null;
+ }
+
+ @Override
+ public boolean isConnected() {
+ return false;
+ }
+
+ @Override
+ public boolean isAdmin() {
+ return false;
+ }
+
+ @Override
+ public void setSubject(Subject subject) {
+
+ }
+
+ @Override
+ public void checkPermission(String permission) {
+ // no check
+ }
+
+ @Override
+ public void checkRole(SecurityRole role) {
+ // no check
+ }
+
+ @Override
+ public Subject newSubject(Set<SecurityRole> roles, Set<String> permissions) {
+ // no security
+ return null;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenSecurityContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -30,6 +30,7 @@
import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
import org.chorem.pollen.services.DefaultPollenServiceContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.chorem.pollen.services.service.security.PollenSecurityContext;
import java.util.Date;
import java.util.Locale;
@@ -46,11 +47,13 @@
Locale locale,
PollenServiceConfig serviceConfig,
PollenTopiaApplicationContext applicationcontext,
- PollenTopiaPersistenceContext persistenceContext) {
+ PollenTopiaPersistenceContext persistenceContext,
+ PollenSecurityContext securityContext) {
FakePollenServiceContext serviceContext = new FakePollenServiceContext();
serviceContext.setPersistenceContext(persistenceContext);
serviceContext.setPollenServiceConfig(serviceConfig);
serviceContext.setTopiaApplicationContext(applicationcontext);
+ serviceContext.setSecurityContext(securityContext);
serviceContext.setLocale(locale);
serviceContext.setDate(now);
return serviceContext;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -62,7 +62,6 @@
private final String configurationPath;
-
protected PollenFixtures fixtures;
protected String methodName;
Added: trunk/pollen-services/src/main/resources/email/LostPasswordEmail.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/LostPasswordEmail_fr.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/PollChoicePeriodEndedEmail.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/PollChoicePeriodEndedEmail_en.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/PollChoicePeriodStartedEmail.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/PollChoicePeriodStartedEmail_fr.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/PollVotePeriodEndedEmail.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/PollVotePeriodEndedEmail_fr.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/PollVotePeriodStartedEmail.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/PollVotePeriodStartedEmail_fr.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/PollVoteReminderEmail.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/PollVoteReminderEmail_fr.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/RestrictedPollInvitationEmail.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/RestrictedPollInvitationEmail_fr.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/UserAccountCreatedEmail.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/UserAccountCreatedEmail_fr.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/VoteAddedEmail.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/VoteAddedEmail_fr.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/VoteDeletedEmail.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/VoteDeletedEmail_fr.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/VoteEditedEmail.mustache
===================================================================
Added: trunk/pollen-services/src/main/resources/email/VoteEditedEmail_fr.mustache
===================================================================
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2014-05-02 09:20:55 UTC (rev 3895)
@@ -1,11 +1,30 @@
-pollen.configuration.data.directory=
-pollen.configuration.defaultPollCommentVisibility=
-pollen.configuration.defaultPollType=
-pollen.configuration.defaultPollVoteVisibility=
-pollen.configuration.defaultVoteCountingType=
+pollen.configuration.data.directory=Directory where Pollen stores his data
+pollen.configuration.defaultPollCommentVisibility=Default Poll comment visibility used when creating a new poll
+pollen.configuration.defaultPollType=Default Poll type used when creating a new poll
+pollen.configuration.defaultPollVoteVisibility=Default Poll vote visibility used when creating a new poll
+pollen.configuration.defaultVoteCountingType=Default vote counting type used when creating a new poll
pollen.error.favoriteList.import.csv.already.used.email=
pollen.error.favoriteList.import.csv.already.used.name=
pollen.error.favoriteList.import.csv.invalid.email=
pollen.error.favoriteList.import.ldap.already.used.email=
pollen.error.favoriteList.import.ldap.already.used.name=
pollen.error.favoriteList.import.ldap.invalid.email=
+pollen.service.mail.ChoiceAddedEmail.subject=[Pollen] A choice was added in poll %s
+pollen.service.mail.ChoiceDeletedEmail.subject=[Pollen] A choice was deleted in poll %s
+pollen.service.mail.ChoiceEditedEmail.subject=[Pollen] A choice was edited in poll %s
+pollen.service.mail.CommentAddedEmail.subject=[Pollen] A comment was added in poll %s
+pollen.service.mail.CommentDeletedEmail.subject=[Pollen] A comment was deleted in poll %s
+pollen.service.mail.CommentEditedEmail.subject=[Pollen] A comment was edited in poll %s
+pollen.service.mail.LostPasswordEmail.subject=[Pollen] Lost password for %s
+pollen.service.mail.PollChoicePeriodEndedEmail.subject=[Pollen] Add Choice period ended for poll %s
+pollen.service.mail.PollChoicePeriodStartedEmail.subject=[Pollen] Add Choice period started for poll %s
+pollen.service.mail.PollClosedEmail.subject=[Pollen] Poll %s is closed
+pollen.service.mail.PollCreatedEmail.subject=[Pollen] Poll creation (%s)
+pollen.service.mail.PollVotePeriodEndedEmail.subject=[Pollen] Vote period ended for poll %s
+pollen.service.mail.PollVotePeriodStartedEmail.subject=[Pollen] Vote period started for poll %s
+pollen.service.mail.PollVoteReminderEmail.subject=[Pollen] Reminder to vote on poll %s
+pollen.service.mail.RestrictedPollInvitationEmail.subject=[Pollen] Invitation to vote on poll %s
+pollen.service.mail.UserAccountCreatedEmail.subject=[Pollen] Confirmation of account creation %s
+pollen.service.mail.VoteAddedEmail.subject=[Pollen] A vote was added in poll %s
+pollen.service.mail.VoteDeletedEmail.subject=[Pollen] A vote was edited in poll %s
+pollen.service.mail.VoteEditedEmail.subject=[Pollen] A vote was deleted in poll %s
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2014-05-02 09:20:55 UTC (rev 3895)
@@ -1,11 +1,30 @@
-pollen.configuration.data.directory=
-pollen.configuration.defaultPollCommentVisibility=
-pollen.configuration.defaultPollType=
-pollen.configuration.defaultPollVoteVisibility=
-pollen.configuration.defaultVoteCountingType=
+pollen.configuration.data.directory=Répertoire de données de l'application
+pollen.configuration.defaultPollCommentVisibility=Visibilité des commentaires par défaut lors de la création d'un nouveau sondage
+pollen.configuration.defaultPollType=Type de sondage par défaut lors de la création d'un nouveau sondage
+pollen.configuration.defaultPollVoteVisibility=Visibilité des votes par défaut lors de la création d'un nouveau sondage
+pollen.configuration.defaultVoteCountingType=Type de dépouillement par défaut lors de la création d'un nouveau sondage
pollen.error.favoriteList.import.csv.already.used.email=
pollen.error.favoriteList.import.csv.already.used.name=
pollen.error.favoriteList.import.csv.invalid.email=
pollen.error.favoriteList.import.ldap.already.used.email=
pollen.error.favoriteList.import.ldap.already.used.name=
pollen.error.favoriteList.import.ldap.invalid.email=
+pollen.service.mail.ChoiceAddedEmail.subject=[Pollen] Un choix a été ajouté au sondage %s
+pollen.service.mail.ChoiceDeletedEmail.subject=[Pollen] Un choix a été supprimé du sondage %s
+pollen.service.mail.ChoiceEditedEmail.subject=[Pollen] Un choix a été modifié sur le sondage %s
+pollen.service.mail.CommentAddedEmail.subject=[Pollen] Un commentaire a été ajouté au sondage %s
+pollen.service.mail.CommentDeletedEmail.subject=[Pollen] Un commentaire a été supprimé du sondage %s
+pollen.service.mail.CommentEditedEmail.subject=[Pollen] Un commentaire a été modifié sur le sondage %s
+pollen.service.mail.LostPasswordEmail.subject=[Pollen] Mot de passe perdu du compte %s
+pollen.service.mail.PollChoicePeriodEndedEmail.subject=[Pollen] Période d'ajout de choix terminée pour le sondage %s
+pollen.service.mail.PollChoicePeriodStartedEmail.subject=[Pollen] Période d'ajout de choix commencée pour le sondage %s
+pollen.service.mail.PollClosedEmail.subject=[Pollen] Le sondage %s est clôt
+pollen.service.mail.PollCreatedEmail.subject=[Pollen] Création du sondage %s
+pollen.service.mail.PollVotePeriodEndedEmail.subject=[Pollen] Période de vote terminée pour le sondage %s
+pollen.service.mail.PollVotePeriodStartedEmail.subject=[Pollen] Période de vote commencée pour le sondage %s
+pollen.service.mail.PollVoteReminderEmail.subject=[Pollen] Rappel du vote au sondage %s
+pollen.service.mail.RestrictedPollInvitationEmail.subject=[Pollen] Invitation au sondage %s
+pollen.service.mail.UserAccountCreatedEmail.subject=[Pollen] Confirmation de création du compte %s
+pollen.service.mail.VoteAddedEmail.subject=[Pollen] Un nouveau vote a été ajouté au sondage %s
+pollen.service.mail.VoteDeletedEmail.subject=[Pollen] Un vote a été modifié sur le sondage %s
+pollen.service.mail.VoteEditedEmail.subject=[Pollen] Un vote a été supprimé du sondage %s
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -25,7 +25,8 @@
import com.google.common.collect.Multimap;
import org.chorem.pollen.services.PollenService;
-import org.chorem.pollen.services.exception.AbstractInvalidFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.test.FakePollenSecurityContext;
import org.chorem.pollen.services.test.FakePollenServiceContext;
import org.chorem.pollen.services.test.PollenApplication;
import org.junit.Assert;
@@ -61,7 +62,8 @@
Locale.FRANCE,
application.getConfiguration(),
application.getApplicationContext(),
- application.newPersistenceContext());
+ application.newPersistenceContext(),
+ new FakePollenSecurityContext());
}
return serviceContext;
@@ -72,7 +74,7 @@
return getServiceContext().newService(serviceClass);
}
- protected void assertErrorKeyFound(AbstractInvalidFormException e, String... keys) {
+ protected void assertErrorKeyFound(InvalidFormException e, String... keys) {
Multimap<String, String> errors = e.getErrors();
Assert.assertEquals("Expected " + keys.length + " errors, but had " + errors.keySet(), keys.length, errors.keySet().size());
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -29,13 +29,12 @@
import org.chorem.pollen.persistence.entity.PollType;
import org.chorem.pollen.persistence.entity.VoterList;
import org.chorem.pollen.persistence.entity.VoterListMember;
-import org.chorem.pollen.services.PollenSecurityContext;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
-import org.chorem.pollen.services.exception.InvalidPollFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
import org.chorem.pollen.services.service.ChoiceService;
import org.chorem.pollen.services.service.PollService;
-import org.chorem.pollen.services.service.SecurityService;
import org.chorem.pollen.services.service.VoterListService;
+import org.chorem.pollen.services.service.security.SecurityService;
+import org.chorem.pollen.services.test.FakePollenSecurityContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -62,27 +61,27 @@
getServiceContext().setDate(new Date(1363948427576l));
- getServiceContext().setSecurityContext(PollenSecurityContext.newContext(null));
+ getServiceContext().setSecurityContext(new FakePollenSecurityContext());
}
@Test
- public void createPoll() throws InvalidPollFormException, EntityNotFoundException {
+ public void createPoll() throws InvalidFormException {
Poll poll = fixture("poll_normal");
- Poll createdPoll = service.createPoll(null, poll);
+ Poll createdPoll = service.createPoll(poll);
Assert.assertNotNull(createdPoll);
}
-
+
@Test
- public void testCreateFreePoll() throws EntityNotFoundException, InvalidPollFormException {
+ public void testCreateFreePoll() throws InvalidFormException {
- Poll poll = service.getNewPoll(null);
+ Poll poll = service.getNewPoll();
poll.setPollType(PollType.FREE);
try {
- service.createPoll(null, poll);
- } catch (InvalidPollFormException e) {
+ service.createPoll(poll);
+ } catch (InvalidFormException e) {
// missing title
// missing choice
assertErrorKeyFound(e, "title", "choice");
@@ -94,16 +93,16 @@
poll.addChoice(choice1);
try {
- service.createPoll(null, poll);
- } catch (InvalidPollFormException e) {
+ service.createPoll(poll);
+ } catch (InvalidFormException e) {
// missing choice type
assertErrorKeyFound(e, "choice[0].choiceType");
}
choice1.setChoiceType(ChoiceType.TEXT);
try {
- service.createPoll(null, poll);
- } catch (InvalidPollFormException e) {
+ service.createPoll(poll);
+ } catch (InvalidFormException e) {
// missing choice name
assertErrorKeyFound(e, "choice[0].name");
}
@@ -119,8 +118,8 @@
poll.addChoice(choice2);
try {
- service.createPoll(null, poll);
- } catch (InvalidPollFormException e) {
+ service.createPoll(poll);
+ } catch (InvalidFormException e) {
// duplicated choice name
assertErrorKeyFound(e, "choice[1].name");
}
@@ -128,7 +127,7 @@
choice2.setName("B");
- Poll createdPoll = service.createPoll(null, poll);
+ Poll createdPoll = service.createPoll(poll);
Assert.assertNotNull(createdPoll);
Assert.assertNotNull(createdPoll.getTopiaId());
@@ -177,9 +176,9 @@
}
@Test
- public void testCreateRestrictedPoll() throws EntityNotFoundException, InvalidPollFormException {
+ public void testCreateRestrictedPoll() throws InvalidFormException {
- Poll poll = service.getNewPoll(null);
+ Poll poll = service.getNewPoll();
poll.setPollType(PollType.RESTRICTED);
poll.setTitle("poll1");
@@ -199,8 +198,8 @@
poll.addChoice(choice2);
try {
- service.createPoll(null, poll);
- } catch (InvalidPollFormException e) {
+ service.createPoll(poll);
+ } catch (InvalidFormException e) {
// missing voterList
assertErrorKeyFound(e, "voterList");
}
@@ -211,8 +210,8 @@
poll.addVoterList(voterList);
try {
- service.createPoll(null, poll);
- } catch (InvalidPollFormException e) {
+ service.createPoll(poll);
+ } catch (InvalidFormException e) {
// missing name
// missing weight
// missing voterListMember
@@ -223,11 +222,11 @@
voterList.setWeight(1);
VoterListMember voterListMember1 = getServiceContext().getPersistenceContext().getVoterListMemberDao().newInstance();
- voterList.addVoterListMember(voterListMember1);
+ voterList.addMember(voterListMember1);
try {
- service.createPoll(null, poll);
- } catch (InvalidPollFormException e) {
+ service.createPoll(poll);
+ } catch (InvalidFormException e) {
// missing member name
// missing member email
assertErrorKeyFound(e, "voterList[0].member[0].name", "voterList[0].member[0].email", "voterList[0].member[0].weight");
@@ -238,8 +237,8 @@
voterListMember1.setEmail("voter1_pollen.org");
try {
- service.createPoll(null, poll);
- } catch (InvalidPollFormException e) {
+ service.createPoll(poll);
+ } catch (InvalidFormException e) {
// invalid member email
assertErrorKeyFound(e, "voterList[0].member[0].email");
}
@@ -250,11 +249,11 @@
voterListMember2.setName("voter1");
voterListMember2.setWeight(0.7);
voterListMember2.setEmail("voter1(a)pollen.org");
- voterList.addVoterListMember(voterListMember2);
+ voterList.addMember(voterListMember2);
try {
- service.createPoll(null, poll);
- } catch (InvalidPollFormException e) {
+ service.createPoll(poll);
+ } catch (InvalidFormException e) {
// same name
// same email
assertErrorKeyFound(e, "voterList[0].member[1].name", "voterList[0].member[1].email");
@@ -263,7 +262,7 @@
voterListMember2.setName("voter2");
voterListMember2.setEmail("voter2(a)pollen.org");
- Poll createdPoll = service.createPoll(null, poll);
+ Poll createdPoll = service.createPoll(poll);
Assert.assertNotNull(createdPoll);
Assert.assertNotNull(createdPoll.getTopiaId());
@@ -318,26 +317,26 @@
Assert.assertEquals(voterList.getName(), createdVoterList.getName());
Assert.assertEquals(voterList.getWeight(), createdVoterList.getWeight(), 0);
- Assert.assertNotNull(createdVoterList.getVoterListMember());
- Assert.assertEquals(2, createdVoterList.sizeVoterListMember());
+ Assert.assertNotNull(createdVoterList.getMember());
+ Assert.assertEquals(2, createdVoterList.sizeMember());
-// VoterListMember createdVoterListMember1 = Iterables.get(createdVoterList.getVoterListMember(), 0);
+// VoterListMember createdVoterListMember1 = Iterables.get(createdVoterList.getMember(), 0);
//
// Assert.assertNotNull(createdVoterListMember1);
// Assert.assertNotNull(createdVoterListMember1.getTopiaId());
-// VoterListMember reloadedVoterListMember1 = voterListService.getVoterListMember(createdPoll.getTopiaId(), createdVoterList.getTopiaId(), createdVoterListMember1.getTopiaId());
+// VoterListMember reloadedVoterListMember1 = voterListService.getMember(createdPoll.getTopiaId(), createdVoterList.getTopiaId(), createdVoterListMember1.getTopiaId());
// Assert.assertEquals(createdVoterListMember1, reloadedVoterListMember1);
//
// Assert.assertEquals(reloadedVoterListMember1.getName(), createdVoterListMember1.getName());
// Assert.assertEquals(reloadedVoterListMember1.getEmail(), createdVoterListMember1.getEmail());
// Assert.assertEquals(reloadedVoterListMember1.getWeight(), createdVoterListMember1.getWeight(), 0);
//
-// VoterListMember createdVoterListMember2 = Iterables.get(createdVoterList.getVoterListMember(), 1);
+// VoterListMember createdVoterListMember2 = Iterables.get(createdVoterList.getMember(), 1);
//
// Assert.assertNotNull(createdVoterListMember2);
// Assert.assertNotNull(createdVoterListMember2.getTopiaId());
//
-// VoterListMember reloadedVoterListMember2 = voterListService.getVoterListMember(createdPoll.getTopiaId(), createdVoterList.getTopiaId(), createdVoterListMember2.getTopiaId());
+// VoterListMember reloadedVoterListMember2 = voterListService.getMember(createdPoll.getTopiaId(), createdVoterList.getTopiaId(), createdVoterListMember2.getTopiaId());
// Assert.assertEquals(createdVoterListMember2, reloadedVoterListMember2);
//
// Assert.assertEquals(reloadedVoterListMember2.getName(), createdVoterListMember2.getName());
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java 2014-05-02 09:20:55 UTC (rev 3895)
@@ -27,7 +27,7 @@
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.persistence.entity.PollenUsers;
import org.chorem.pollen.services.exception.EntityNotFoundException;
-import org.chorem.pollen.services.exception.InvalidPollenUserFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
import org.chorem.pollen.services.service.PollenUserService;
import org.junit.Assert;
@@ -72,7 +72,7 @@
}
@Test
- public void testGetPollenUser() throws EntityNotFoundException {
+ public void testGetPollenUser() {
try {
service.getUser("pollen_user_tony_" + System.nanoTime());
@@ -88,7 +88,7 @@
}
@Test
- public void testCreatePollenUser() throws Exception {
+ public void testCreatePollenUser() throws InvalidFormException {
try {
service.createUser(user, false);
@@ -113,7 +113,7 @@
try {
service.createUser(newUser2, true);
Assert.fail();
- } catch (InvalidPollenUserFormException e) {
+ } catch (InvalidFormException e) {
// not available login
// not available email
assertErrorKeyFound(e, "login", "email");
@@ -123,7 +123,7 @@
try {
service.createUser(newUser2, true);
Assert.fail();
- } catch (InvalidPollenUserFormException e) {
+ } catch (InvalidFormException e) {
// not available email
assertErrorKeyFound(e, "email");
}
@@ -135,7 +135,7 @@
}
@Test
- public void testEditUser() throws EntityNotFoundException, InvalidPollenUserFormException {
+ public void testEditUser() throws InvalidFormException {
PollenUser user = service.getUser(this.user.getTopiaId());
@@ -153,7 +153,7 @@
try {
service.editUser(user);
Assert.fail();
- } catch (InvalidPollenUserFormException e) {
+ } catch (InvalidFormException e) {
// invalid password
assertErrorKeyFound(e, "password");
}
@@ -167,7 +167,7 @@
}
@Test
- public void testValidateEmail() throws EntityNotFoundException, UserInvalidEmailActivationTokenException, InvalidPollenUserFormException {
+ public void testValidateEmail() throws UserInvalidEmailActivationTokenException, InvalidFormException {
PollenUser user = service.getUser(this.user.getTopiaId());
Assert.assertNotNull(user);
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-05-02 09:08:56 UTC (rev 3894)
+++ trunk/pom.xml 2014-05-02 09:20:55 UTC (rev 3895)
@@ -160,7 +160,7 @@
<projectId>pollen</projectId>
<!-- customized versions -->
- <webmotionVersion>2.5-SNAPSHOT</webmotionVersion>
+ <webmotionVersion>2.4.1-SNAPSHOT</webmotionVersion>
<nuitonI18nVersion>3.0</nuitonI18nVersion>
<eugenePluginVersion>2.9-SNAPSHOT</eugenePluginVersion>
@@ -405,9 +405,9 @@
<!-- Others -->
<dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.5.0-b01</version>
+ <groupId>com.github.spullara.mustache.java</groupId>
+ <artifactId>compiler</artifactId>
+ <version>0.8.13</version>
</dependency>
<dependency>
1
0
r3894 - in trunk/pollen-ui-angular/src/main/webapp: . js js/controllers partials
by garandel@users.chorem.org 02 May '14
by garandel@users.chorem.org 02 May '14
02 May '14
Author: garandel
Date: 2014-05-02 11:08:56 +0200 (Fri, 02 May 2014)
New Revision: 3894
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3894
Log:
Create poll with skeleton from rest api ( http://demo.codelutin.com/pollen-rest-api-latest/v1/polls/new )
Modified:
trunk/pollen-ui-angular/src/main/webapp/index.html
trunk/pollen-ui-angular/src/main/webapp/js/app.js
trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html
trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
Modified: trunk/pollen-ui-angular/src/main/webapp/index.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/index.html 2014-04-30 16:17:52 UTC (rev 3893)
+++ trunk/pollen-ui-angular/src/main/webapp/index.html 2014-05-02 09:08:56 UTC (rev 3894)
@@ -18,16 +18,19 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
-->
+
<html lang="en" ng-app="pollen">
<head>
<title>Pollen</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="css/style.css"/>
+ <script src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-resource.min…"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.10.0/ui-bootst…"></script>
+ <script src="http://cdnjs.cloudflare.com/ajax/libs/restangular/1.4.0/restangular.min.js"></script>
<script src="js/libs/ckeditor/ckeditor.js"></script>
<script src="js/app.js"></script>
Modified: trunk/pollen-ui-angular/src/main/webapp/js/app.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-30 16:17:52 UTC (rev 3893)
+++ trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-05-02 09:08:56 UTC (rev 3894)
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
-angular.module('pollen', ["ngRoute", "pollControllers", 'ui.bootstrap'])
+angular.module('pollen', ["restangular", 'ngRoute', 'pollControllers', 'ui.bootstrap'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/', {templateUrl: './partials/home.html', controller: "HomeCtrl"})
@@ -30,6 +30,14 @@
}])
+.config(['RestangularProvider', function (RestangularProvider) {
+ RestangularProvider.setBaseUrl('http://demo.codelutin.com/pollen-rest-api-latest/v1');
+}])
+
+.factory('PollsRest', ['Restangular', function(Restangular) {
+ return Restangular.service('polls');
+}])
+
.directive('focusMe', function($timeout) {
return {
link: function($scope, element, attrs) {
Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-04-30 16:17:52 UTC (rev 3893)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-02 09:08:56 UTC (rev 3894)
@@ -64,15 +64,15 @@
}])
-.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$filter', '$timeout', 'pollStorage', function ($scope, $controller, $modal, $filter, $timeout, pollStorage) {
+.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$filter', '$timeout', 'PollsRest', 'pollStorage', function ($scope, $controller, $modal, $filter, $timeout, PollsRest, pollStorage) {
$controller('PollCtrl', {$scope:$scope});
var initPoll = function () {
- return {
- title :'',
- description : '',
- choices : []
- };
+
+ PollsRest.one('new').get().then(function (skeletonPoll) {
+ $scope.poll = skeletonPoll;
+ $scope.poll.choices = [];
+ });
}
var initChoice = function () {
@@ -93,8 +93,9 @@
});
if (!angular.isDefined($scope.poll.choices)) {
- $scope.poll = initPoll();
+ initPoll();
}
+
$scope.vote = {};
$scope.vote.choices = $scope.poll.choices;
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html 2014-04-30 16:17:52 UTC (rev 3893)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html 2014-05-02 09:08:56 UTC (rev 3894)
@@ -1,3 +1,24 @@
+<!--
+ #%L
+ Pollen :: UI (Angular)
+ %%
+ Copyright (C) 2009 - 2014 CodeLutin
+ %%
+ 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%
+ -->
+
<form class="form-horizontal">
<div class="modal-header">
<h4 class="modal-title">{{title}}</h4>
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-30 16:17:52 UTC (rev 3893)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-05-02 09:08:56 UTC (rev 3894)
@@ -1,3 +1,24 @@
+<!--
+ #%L
+ Pollen :: UI (Angular)
+ %%
+ Copyright (C) 2009 - 2014 CodeLutin
+ %%
+ 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%
+ -->
+
<form class="form-inline" name="pollForm" novalidate>
<alert type="'danger'" ng-if="globalVariables.errorForm"> Champ non remplie </alert>
1
0
Build failed in Jenkins: pollen-nightly » Pollen :: Rest Api #14
by admin+ci-chorem.org@codelutin.com 30 Apr '14
by admin+ci-chorem.org@codelutin.com 30 Apr '14
30 Apr '14
See <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
Changes:
[Tony CHEMIT] pass ChoiceType to Choice, no more to Poll + add Rest Doc action + begin to add Rest API tests
[Tony CHEMIT] fix ui-angular war deploy
[Tony CHEMIT] simplify rest-api starting + add some conf
[Tony CHEMIT] simplify rest-api starting + add some conf
[Tony CHEMIT] use specific configuration files (pollen-services.properties, pollen-rest-api.properties to avoid any collision with existing config)
------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Pollen :: Rest Api 2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.antlr:stringtemplate:jar:3.2.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ pollen-rest-api ---
[INFO] Deleting <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (ensure-no-container-api) @ pollen-rest-api ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ pollen-rest-api ---
[INFO]
[INFO] --- helper-maven-plugin:2.1:share-server-secret (get-redmine-login) @ pollen-rest-api ---
[INFO] Exporting server [redmine-forge.chorem.org] privateKey in ${redmine.apiKey}
[INFO]
[INFO] --- license-maven-plugin:1.6:update-project-license (attach-licenses) @ pollen-rest-api ---
[INFO] Will create or update license file [agpl_v3] to <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO]
[INFO] --- license-maven-plugin:1.6:add-third-party (attach-licenses) @ pollen-rest-api ---
[WARNING] Unable to obtain POM for artifact : org.antlr:stringtemplate:jar:3.2.1:compile
org.apache.maven.project.InvalidProjectModelException: 1 problem was encountered while building the effective model
[FATAL] Non-readable POM /var/local/forge/data/chorem.org/maven/repository/org/antlr/stringtemplate/3.2.1/stringtemplate-3.2.1.pom: input contained no data @
for project for project
at org.apache.maven.project.DefaultMavenProjectBuilder.transformError(DefaultMavenProjectBuilder.java:193)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository(DefaultMavenProjectBuilder.java:240)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository(DefaultMavenProjectBuilder.java:251)
at org.codehaus.mojo.license.api.DefaultDependenciesTool.loadProjectDependencies(DefaultDependenciesTool.java:206)
at org.codehaus.mojo.license.api.DefaultThirdPartyHelper.loadDependencies(DefaultThirdPartyHelper.java:152)
at org.codehaus.mojo.license.AddThirdPartyMojo.loadDependencies(AddThirdPartyMojo.java:288)
at org.codehaus.mojo.license.AbstractAddThirdPartyMojo.init(AbstractAddThirdPartyMojo.java:386)
at org.codehaus.mojo.license.AbstractLicenseMojo.execute(AbstractLicenseMojo.java:174)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
[INFO] Load missing file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO] Missing file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…> is up-to-date.
[INFO] Writing third-party file to <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO] Will attach third party file from <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO]
[INFO] >>> i18n-maven-plugin:3.0:bundle (default) @ pollen-rest-api >>>
[INFO]
[INFO] --- i18n-maven-plugin:3.0:collect-i18n-artifacts (collect-i18n-artifacts) @ pollen-rest-api ---
[WARNING] Invalid POM for org.antlr:stringtemplate:jar:3.2.1, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] collected 2 i18n artifacts for locale fr_FR stored in <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO] collected 2 i18n artifacts for locale en_GB stored in <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO]
[INFO] <<< i18n-maven-plugin:3.0:bundle (default) @ pollen-rest-api <<<
[INFO]
[INFO] --- i18n-maven-plugin:3.0:bundle (default) @ pollen-rest-api ---
[WARNING] bundle fr_FR contains 11/51 empty entries! (use -Di18n.showEmpty to see these entries)
[WARNING] bundle en_GB contains 11/51 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ pollen-rest-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] Copying 2 resources
[INFO] Copying 3 resources
[INFO]
[INFO] --- license-maven-plugin:1.6:update-file-header (update-file-header) @ pollen-rest-api ---
[INFO] Will search files to update from root <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO] Will search files to update from root <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO] - adding license header on file <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO] Scan 31 files header done in 307.893ms.
[INFO]
* uptodate header on 25 files.
* add header on 6 files.
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ pollen-rest-api ---
[INFO] Compiling 17 source files to <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>:[221,35] getNullValue(java.lang.Class<?>) in org.nuiton.util.ObjectUtil has been deprecated
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- animal-sniffer-maven-plugin:1.10:check (default) @ pollen-rest-api ---
[INFO] Checking unresolved references to org.codehaus.mojo.signature:java17:1.0
[INFO]
[INFO] --- jredmine-maven-plugin:1.8.1:generate-changes (jredmine-generate-changes) @ pollen-rest-api ---
[INFO] Skipping goal (skipGenerateChanges flag is on).
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ pollen-rest-api ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO] Executed tasks
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ pollen-rest-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ pollen-rest-api ---
[INFO] Compiling 5 source files to <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ pollen-rest-api ---
[INFO] Surefire report directory: <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.chorem.pollen.rest.api.PollServiceTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.017 sec - in org.chorem.pollen.rest.api.PollServiceTest
Running org.chorem.pollen.rest.api.PollenUserServiceTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0 sec - in org.chorem.pollen.rest.api.PollenUserServiceTest
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 2
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-war-plugin:2.4:war (default-war) @ pollen-rest-api ---
[INFO] Packaging webapp
[INFO] Assembling webapp [pollen-rest-api] in [<http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…]>
[INFO] Processing war project
[INFO] Copying webapp webResources [<http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…]> to [<http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…]>
[INFO] Copying webapp resources [<http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…]>
[INFO] Webapp assembled in [173 msecs]
[INFO] Building war: <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO]
[INFO] >>> maven-source-plugin:2.2.1:jar (attach-sources) @ pollen-rest-api >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (ensure-no-container-api) @ pollen-rest-api ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ pollen-rest-api ---
[INFO]
[INFO] --- helper-maven-plugin:2.1:share-server-secret (get-redmine-login) @ pollen-rest-api ---
[INFO] Skipping goal (runOnce flag is on and goal was already executed).
[WARNING] Failed to getClass for org.apache.maven.plugin.source.SourceJarMojo
[INFO]
[INFO] <<< maven-source-plugin:2.2.1:jar (attach-sources) @ pollen-rest-api <<<
[INFO]
[INFO] --- maven-source-plugin:2.2.1:jar (attach-sources) @ pollen-rest-api ---
[INFO] Building jar: <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO]
[INFO] --- maven-javadoc-plugin:2.9.1:jar (attach-javadocs) @ pollen-rest-api ---
[INFO] Building jar: <http://ci.chorem.org/jenkins/job/pollen-nightly/org.chorem.pollen$pollen-re…>
[INFO]
[INFO] --- maven-site-plugin:3.3:attach-descriptor (attach-descriptor) @ pollen-rest-api ---
[INFO]
[INFO] --- helper-maven-plugin:2.1:share-server-secret (get-pgp-passphrase) @ pollen-rest-api ---
[INFO] Exporting server [gpg-signer] username in ${gpg.keyname}
[INFO] Exporting server [gpg-signer] password in ${gpg.passphrase}
[INFO]
[INFO] --- helper-maven-plugin:2.1:collect-files (collect-build-artifacts) @ pollen-rest-api ---
[INFO] Loaded /var/local/forge/data/chorem.org/jenkins/workspace/pollen-nightly/trunk/target/collect-artifacts.txt
[INFO] Copying pollen-rest-api-2.0-SNAPSHOT.war to /var/local/forge/data/chorem.org/jenkins/workspace/pollen-nightly/trunk/target/collect/org.chorem.pollen--pollen-rest-api/pollen-rest-api-2.0-SNAPSHOT.war
[INFO] Copying THIRD-PARTY.properties to /var/local/forge/data/chorem.org/jenkins/workspace/pollen-nightly/trunk/target/collect/org.chorem.pollen--pollen-rest-api/THIRD-PARTY.properties
[INFO] Copying pollen-rest-api-2.0-SNAPSHOT-sources.jar to /var/local/forge/data/chorem.org/jenkins/workspace/pollen-nightly/trunk/target/collect/org.chorem.pollen--pollen-rest-api/pollen-rest-api-2.0-SNAPSHOT-sources.jar
[INFO] Copying pollen-rest-api-2.0-SNAPSHOT-javadoc.jar to /var/local/forge/data/chorem.org/jenkins/workspace/pollen-nightly/trunk/target/collect/org.chorem.pollen--pollen-rest-api/pollen-rest-api-2.0-SNAPSHOT-javadoc.jar
[INFO]
[INFO] --- helper-maven-plugin:2.1:collect-files (collect-build-attachements) @ pollen-rest-api ---
[WARNING] Skipping goal (No file to collect).
[INFO]
[INFO] --- maven-gpg-plugin:1.5:sign (sign-artifacts) @ pollen-rest-api ---
[INFO]
[INFO] --- maven-dependency-plugin:2.8:analyze-only (analyze) @ pollen-rest-api ---
[INFO] Used declared dependencies found:
[INFO] org.chorem.pollen:pollen-persistence:jar:2.0-SNAPSHOT:compile
[INFO] org.chorem.pollen:pollen-services:jar:2.0-SNAPSHOT:compile
[INFO] org.nuiton.topia:topia-persistence:jar:3.0-SNAPSHOT:compile
[INFO] org.hibernate:hibernate-core:jar:4.3.5.Final:runtime
[INFO] org.debux.webmotion:webmotion:jar:2.4:compile
[INFO] org.debux.webmotion:webmotion-unittest:jar:2.4:test
[INFO] org.nuiton.web:nuiton-web:jar:1.16:compile
[INFO] org.nuiton.i18n:nuiton-i18n:jar:3.0:compile
[INFO] javax:javaee-api:jar:7.0:provided
[INFO] commons-logging:commons-logging:jar:1.1.3:compile
[INFO] commons-beanutils:commons-beanutils:jar:1.9.1:compile
[INFO] org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] org.apache.httpcomponents:fluent-hc:jar:4.2.3:compile
[INFO] com.google.guava:guava:jar:16.0.1:compile
[INFO] com.google.code.gson:gson:jar:2.2.4:compile
[INFO] junit:junit:jar:4.11:test
[INFO] org.nuiton:nuiton-utils:jar:2.7.1:compile
[INFO] com.h2database:h2:jar:1.3.173:runtime
[INFO] log4j:log4j:jar:1.2.17:compile
[WARNING] Used undeclared dependencies found:
[WARNING] commons-io:commons-io:jar:2.4:compile
[JENKINS] Archiving disabled
1
1
Author: tchemit
Date: 2014-04-30 18:17:52 +0200 (Wed, 30 Apr 2014)
New Revision: 3893
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3893
Log:
debug poll create + fix voteCounting id
Modified:
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java
trunk/pollen-services/src/main/resources/fixtures.yaml
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java
trunk/pollen-votecounting-borda/src/main/java/org/chorem/pollen/votecounting/BordaVoteCounting.java
trunk/pollen-votecounting-condorcet/src/main/java/org/chorem/pollen/votecounting/CondorcetVoteCounting.java
trunk/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCounting.java
trunk/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCounting.java
trunk/pollen-votecounting-normal/src/main/java/org/chorem/pollen/votecounting/NormalVoteCounting.java
trunk/pollen-votecounting-number/src/main/java/org/chorem/pollen/votecounting/NumberVoteCounting.java
trunk/pollen-votecounting-percentage/src/main/java/org/chorem/pollen/votecounting/PercentageVoteCounting.java
trunk/pom.xml
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -1,6 +1,7 @@
package org.chorem.pollen.rest.api;
import org.apache.http.client.fluent.Request;
+import org.chorem.pollen.persistence.entity.Poll;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -67,7 +68,8 @@
@Test
public void getPoll() throws URISyntaxException, IOException {
- String pollId = "iioi";
+ Poll poll = fixture("poll_simplePoll");
+ String pollId = poll.getTopiaId();
Request request = createRequest("/v1/polls/" + pollId).Get();
String content = request.execute().returnContent().asString();
saveTestResult(content);
@@ -86,7 +88,8 @@
@Ignore
@Test
public void putPoll() throws URISyntaxException, IOException {
- String pollId = "";
+ Poll poll = fixture("poll_simplePoll");
+ String pollId = poll.getTopiaId();
Request request = createRequest("/v1/polls/" + pollId).Put();
String content = request.execute().returnContent().asString();
saveTestResult(content);
@@ -96,7 +99,8 @@
@Ignore
@Test
public void deletePoll() throws URISyntaxException, IOException {
- String pollId = "";
+ Poll poll = fixture("poll_simplePoll");
+ String pollId = poll.getTopiaId();
Request request = createRequest("/v1/polls/" + pollId).Delete();
String content = request.execute().returnContent().asString();
saveTestResult(content);
@@ -106,7 +110,8 @@
@Ignore
@Test
public void clonePoll() throws URISyntaxException, IOException {
- String pollId = "";
+ Poll poll = fixture("poll_simplePoll");
+ String pollId = poll.getTopiaId();
Request request = createRequest("/v1/polls/" + pollId).Post();
String content = request.execute().returnContent().asString();
saveTestResult(content);
@@ -116,7 +121,8 @@
@Ignore
@Test
public void exportPoll() throws URISyntaxException, IOException {
- String pollId = "";
+ Poll poll = fixture("poll_simplePoll");
+ String pollId = poll.getTopiaId();
Request request = createRequest("/v1/polls/" + pollId + "/export").Get();
String content = request.execute().returnContent().asString();
saveTestResult(content);
@@ -126,7 +132,8 @@
@Ignore
@Test
public void closePoll() throws URISyntaxException, IOException {
- String pollId = "";
+ Poll poll = fixture("poll_simplePoll");
+ String pollId = poll.getTopiaId();
Request request = createRequest("/v1/polls/" + pollId + "/close").Post();
String content = request.execute().returnContent().asString();
saveTestResult(content);
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -32,8 +32,10 @@
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.PollenUserImpl;
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;
@@ -61,9 +63,11 @@
reader.getConfig().setClassTag("favorite-list-member", FavoriteListMemberImpl.class);
reader.getConfig().setClassTag("comment", CommentImpl.class);
reader.getConfig().setClassTag("choice", ChoiceImpl.class);
+ reader.getConfig().setClassTag("vote-to-choice", VoteToChoiceImpl.class);
reader.getConfig().setClassTag("voter-list", VoterListImpl.class);
reader.getConfig().setClassTag("voter-list-member", VoterListMemberImpl.class);
reader.getConfig().setClassTag("vote", VoteImpl.class);
+ reader.getConfig().setClassTag("pollen-principal", PollenPrincipalImpl.class);
try {
fixtures = (Map<String, Object>) reader.read();
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -70,7 +70,7 @@
DEFAULT_VOTE_COUNTING_TYPE(
"pollen.default.voteCountingType",
n("pollen.configuration.defaultVoteCountingType"),
- "0",
+ "1",
Integer.class),
/**
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -146,11 +146,12 @@
principal.setEmail(creator.getEmail());
}
+ choiceToPersist.setChoiceType(choice.getChoiceType());
choiceToPersist.setCreator(principal);
poll.addChoice(choiceToPersist);
}
- switch (choice.getChoiceType()) {
+ switch (choiceToPersist.getChoiceType()) {
case TEXT:
choiceToPersist.setName(choice.getName());
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -221,15 +221,18 @@
toSave.getCreator().setPollenUser(user);
}
- toSave.getCreator().setName(poll.getCreator().getName());
- toSave.getCreator().setEmail(poll.getCreator().getEmail());
+ PollenPrincipal creator = poll.getCreator();
+ if (creator != null) {
+ toSave.getCreator().setName(creator.getName());
+ toSave.getCreator().setEmail(creator.getEmail());
+ }
// -- simple properties -- //
toSave.setVoteCountingType(poll.getVoteCountingType());
toSave.setVoteVisibility(poll.getVoteVisibility());
toSave.setCommentVisibility(poll.getCommentVisibility());
-// toSave.setChoiceType(poll.getChoiceType());
+ toSave.setResultVisibility(poll.getResultVisibility());
toSave.setAnonymousVoteAllowed(poll.isAnonymousVoteAllowed());
toSave.setChoiceAddAllowed(poll.isChoiceAddAllowed());
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -100,17 +100,17 @@
@Override
public void finished(Description description) {
- for (PollenTopiaPersistenceContext openedTransaction : openedTransactions) {
+ if (applicationContext != null && !applicationContext.isClosed()) {
- if (log.isTraceEnabled()) {
- log.trace("closing transaction " + openedTransaction);
- }
+ for (PollenTopiaPersistenceContext openedTransaction : openedTransactions) {
- openedTransaction.closeContext();
+ if (log.isTraceEnabled()) {
+ log.trace("closing transaction " + openedTransaction);
+ }
- }
+ openedTransaction.closeContext();
- if (applicationContext != null && !applicationContext.isClosed()) {
+ }
if (log.isTraceEnabled()) {
log.trace("closing transaction " + applicationContext);
Modified: trunk/pollen-services/src/main/resources/fixtures.yaml
===================================================================
--- trunk/pollen-services/src/main/resources/fixtures.yaml 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-services/src/main/resources/fixtures.yaml 2014-04-30 16:17:52 UTC (rev 3893)
@@ -22,7 +22,64 @@
email: julien(a)pollen.fake
administrator: true
+poll_normal:
+ &normal !poll
+ title: Sondage normal
+ description: Sondage de type 'normal'
+ beginDate: 1/1/2014
+ endDate: 1/2/2014
+ maxChoiceNumber: 2
+ closed: true
+ choiceAddAllowed: false
+ anonymousVoteAllowed: false
+ continuousResults: false
+ voteCountingType: 1
+ pollType: FREE
+ voteVisibility: EVERYBODY
+ commentVisibility: EVERYBODY
+ resultVisibility: EVERYBODY
+# creator: !pollen-principal
+# name: poll creator
+# email: poll_creator(a)pollen.chorem.org
+ choice:
+ - &normal_choixA !choice
+ name: choixA
+ description: choixA description
+ choiceType: TEXT
+ - &normal_choixB !choice
+ name: choixB
+ description: choixB description
+ choiceType: TEXT
+ - &normal_choixC !choice
+ name: choixC
+ description: choixC description
+ choiceType: TEXT
+ vote:
+ - &normal_vote1 !vote
+ weight: 1.0
+ anonymous: false
+ voteToChoice: !java.util.LinkedList
+ - &normal_voteToChoice11 !vote-to-choice
+ choice: *normal_choixA
+ voteValue: 1
+ - &normal_voteToChoice12 !vote-to-choice
+ choice: *normal_choixC
+ voteValue: 1
+ - &normal_vote2 !vote
+ weight: 1.0
+ anonymous: false
+ voteToChoice: !java.util.LinkedList
+ - &normal_voteToChoice21 !vote-to-choice
+ choice: *normal_choixA
+ voteValue: 2
+ - &normal_voteToChoice22 !vote-to-choice
+ choice: *normal_choixB
+ voteValue: 2
+
users:
- *tony
- *jean
- - *julien
\ No newline at end of file
+ - *julien
+
+polls:
+ - *normal
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -24,14 +24,11 @@
*/
import org.chorem.pollen.persistence.entity.Choice;
-import org.chorem.pollen.persistence.entity.ChoiceImpl;
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.persistence.entity.VoterList;
-import org.chorem.pollen.persistence.entity.VoterListImpl;
import org.chorem.pollen.persistence.entity.VoterListMember;
-import org.chorem.pollen.persistence.entity.VoterListMemberImpl;
import org.chorem.pollen.services.PollenSecurityContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollFormException;
@@ -69,6 +66,14 @@
}
@Test
+ public void createPoll() throws InvalidPollFormException, EntityNotFoundException {
+ Poll poll = fixture("poll_normal");
+
+ Poll createdPoll = service.createPoll(null, poll);
+ Assert.assertNotNull(createdPoll);
+ }
+
+ @Test
public void testCreateFreePoll() throws EntityNotFoundException, InvalidPollFormException {
Poll poll = service.getNewPoll(null);
@@ -85,7 +90,7 @@
poll.setTitle("poll1");
- Choice choice1 = new ChoiceImpl();
+ Choice choice1 = getServiceContext().getPersistenceContext().getChoiceDao().newInstance();
poll.addChoice(choice1);
try {
@@ -107,7 +112,7 @@
choice1.setDescription("Choice A");
- Choice choice2 = new ChoiceImpl();
+ Choice choice2 = getServiceContext().getPersistenceContext().getChoiceDao().newInstance();
choice2.setChoiceType(ChoiceType.TEXT);
choice2.setName("A");
choice2.setDescription("Choice B");
@@ -179,14 +184,14 @@
poll.setTitle("poll1");
- Choice choice1 = new ChoiceImpl();
+ Choice choice1 = getServiceContext().getPersistenceContext().getChoiceDao().newInstance();
choice1.setChoiceType(ChoiceType.TEXT);
choice1.setName("A");
choice1.setDescription("Choice A");
poll.addChoice(choice1);
- Choice choice2 = new ChoiceImpl();
+ Choice choice2 = getServiceContext().getPersistenceContext().getChoiceDao().newInstance();
choice2.setChoiceType(ChoiceType.TEXT);
choice2.setName("B");
choice2.setDescription("Choice B");
@@ -201,7 +206,7 @@
}
// add voter list
- VoterList voterList = new VoterListImpl();
+ VoterList voterList = getServiceContext().getPersistenceContext().getVoterListDao().newInstance();
poll.addVoterList(voterList);
@@ -217,7 +222,7 @@
voterList.setName("voterList1");
voterList.setWeight(1);
- VoterListMember voterListMember1 = new VoterListMemberImpl();
+ VoterListMember voterListMember1 = getServiceContext().getPersistenceContext().getVoterListMemberDao().newInstance();
voterList.addVoterListMember(voterListMember1);
try {
@@ -241,7 +246,7 @@
voterListMember1.setEmail("voter1(a)pollen.org");
- VoterListMember voterListMember2 = new VoterListMemberImpl();
+ VoterListMember voterListMember2 = getServiceContext().getPersistenceContext().getVoterListMemberDao().newInstance();
voterListMember2.setName("voter1");
voterListMember2.setWeight(0.7);
voterListMember2.setEmail("voter1(a)pollen.org");
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -25,7 +25,6 @@
import org.apache.commons.collections.CollectionUtils;
import org.chorem.pollen.persistence.entity.PollenUser;
-import org.chorem.pollen.persistence.entity.PollenUserImpl;
import org.chorem.pollen.persistence.entity.PollenUsers;
import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.exception.InvalidPollenUserFormException;
@@ -99,7 +98,7 @@
Assert.assertTrue(true);
}
- PollenUser newUser = new PollenUserImpl();
+ PollenUser newUser = getServiceContext().getPersistenceContext().getPollenUserDao().newInstance();
newUser.setLogin("pollen");
newUser.setEmail("pollen(a)pollen.org");
@@ -107,7 +106,7 @@
Assert.assertNotNull(savedUser);
Assert.assertNotNull(savedUser.getTopiaId());
- PollenUser newUser2 = new PollenUserImpl();
+ PollenUser newUser2 = getServiceContext().getPersistenceContext().getPollenUserDao().newInstance();
newUser2.setLogin("pollen");
newUser2.setEmail("pollen(a)pollen.org");
Modified: trunk/pollen-votecounting-borda/src/main/java/org/chorem/pollen/votecounting/BordaVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-borda/src/main/java/org/chorem/pollen/votecounting/BordaVoteCounting.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-votecounting-borda/src/main/java/org/chorem/pollen/votecounting/BordaVoteCounting.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -38,7 +38,7 @@
*/
public class BordaVoteCounting extends AbstractVoteCounting<BordaVoteCountingStrategy> {
- public static final int ID = 4;
+ public static final int ID = 5;
public BordaVoteCounting() {
super(ID,
Modified: trunk/pollen-votecounting-condorcet/src/main/java/org/chorem/pollen/votecounting/CondorcetVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-condorcet/src/main/java/org/chorem/pollen/votecounting/CondorcetVoteCounting.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-votecounting-condorcet/src/main/java/org/chorem/pollen/votecounting/CondorcetVoteCounting.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -31,14 +31,14 @@
import static org.nuiton.i18n.I18n.n;
/**
- * Coombs vote counting entry point.
+ * Condorcet vote counting entry point.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.6
*/
public class CondorcetVoteCounting extends AbstractVoteCounting<CondorcetVoteCountingStrategy> {
- public static final int ID = 2;
+ public static final int ID = 3;
public CondorcetVoteCounting() {
super(ID,
Modified: trunk/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCounting.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCounting.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -38,7 +38,7 @@
*/
public class CoombsVoteCounting extends AbstractVoteCounting<CoombsVoteCountingStrategy> {
- public static final int ID = 6;
+ public static final int ID = 7;
public CoombsVoteCounting() {
super(ID,
Modified: trunk/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCounting.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCounting.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -31,14 +31,14 @@
import static org.nuiton.i18n.I18n.n;
/**
- * Coombs vote counting entry point.
+ * Instant Runoff vote counting entry point.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.6
*/
public class InstantRunoffVoteCounting extends AbstractVoteCounting<InstantRunoffVoteCountingStrategy> {
- public static final int ID = 5;
+ public static final int ID = 6;
public InstantRunoffVoteCounting() {
super(ID,
Modified: trunk/pollen-votecounting-normal/src/main/java/org/chorem/pollen/votecounting/NormalVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-normal/src/main/java/org/chorem/pollen/votecounting/NormalVoteCounting.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-votecounting-normal/src/main/java/org/chorem/pollen/votecounting/NormalVoteCounting.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -30,14 +30,14 @@
import static org.nuiton.i18n.I18n.n;
/**
- * Coombs vote counting entry point.
+ * Normal vote counting entry point.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.6
*/
public class NormalVoteCounting extends AbstractVoteCounting<NormalVoteCountingStrategy> {
- public static final int ID = 0;
+ public static final int ID = 1;
public NormalVoteCounting() {
super(ID,
Modified: trunk/pollen-votecounting-number/src/main/java/org/chorem/pollen/votecounting/NumberVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-number/src/main/java/org/chorem/pollen/votecounting/NumberVoteCounting.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-votecounting-number/src/main/java/org/chorem/pollen/votecounting/NumberVoteCounting.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -30,14 +30,14 @@
import static org.nuiton.i18n.I18n.n;
/**
- * Coombs vote counting entry point.
+ * Number vote counting entry point.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.6
*/
public class NumberVoteCounting extends AbstractVoteCounting<NumberVoteCountingStrategy> {
- public static final int ID = 3;
+ public static final int ID = 4;
public NumberVoteCounting() {
super(ID,
Modified: trunk/pollen-votecounting-percentage/src/main/java/org/chorem/pollen/votecounting/PercentageVoteCounting.java
===================================================================
--- trunk/pollen-votecounting-percentage/src/main/java/org/chorem/pollen/votecounting/PercentageVoteCounting.java 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pollen-votecounting-percentage/src/main/java/org/chorem/pollen/votecounting/PercentageVoteCounting.java 2014-04-30 16:17:52 UTC (rev 3893)
@@ -31,14 +31,14 @@
import static org.nuiton.i18n.I18n.n;
/**
- * Coombs vote counting entry point.
+ * Percentage vote counting entry point.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.6
*/
public class PercentageVoteCounting extends AbstractVoteCounting<PercentageVoteCountingStrategy> {
- public static final int ID = 1;
+ public static final int ID = 2;
public PercentageVoteCounting() {
super(ID,
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-04-30 14:52:28 UTC (rev 3892)
+++ trunk/pom.xml 2014-04-30 16:17:52 UTC (rev 3893)
@@ -160,8 +160,7 @@
<projectId>pollen</projectId>
<!-- customized versions -->
- <nuitonJpaVersion>1.0-rc-1</nuitonJpaVersion>
- <webmotionVersion>2.4</webmotionVersion>
+ <webmotionVersion>2.5-SNAPSHOT</webmotionVersion>
<nuitonI18nVersion>3.0</nuitonI18nVersion>
<eugenePluginVersion>2.9-SNAPSHOT</eugenePluginVersion>
@@ -587,18 +586,6 @@
<groupId>org.nuiton.eugene</groupId>
<artifactId>eugene-maven-plugin</artifactId>
<version>${eugenePluginVersion}</version>
- <configuration>
- <!--<inputs>zargo</inputs>-->
- <inputs>yamlmodel</inputs>
- <resolver>org.nuiton.util.FasterCachedResourceResolver</resolver>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>org.nuiton.jpa</groupId>
- <artifactId>nuiton-jpa-templates</artifactId>
- <version>${nuitonJpaVersion}</version>
- </dependency>
- </dependencies>
</plugin>
<plugin>
1
0
r3892 - in trunk/pollen-ui-angular/src/main/webapp: css js js/controllers partials
by garandel@users.chorem.org 30 Apr '14
by garandel@users.chorem.org 30 Apr '14
30 Apr '14
Author: garandel
Date: 2014-04-30 16:52:28 +0200 (Wed, 30 Apr 2014)
New Revision: 3892
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3892
Log:
fix vote in big poll template
Modified:
trunk/pollen-ui-angular/src/main/webapp/css/style.css
trunk/pollen-ui-angular/src/main/webapp/js/app.js
trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html
trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html
trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
Modified: trunk/pollen-ui-angular/src/main/webapp/css/style.css
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/css/style.css 2014-04-30 11:26:00 UTC (rev 3891)
+++ trunk/pollen-ui-angular/src/main/webapp/css/style.css 2014-04-30 14:52:28 UTC (rev 3892)
@@ -172,6 +172,7 @@
}
.pollBigChoice p {
text-align:justify;
+ white-space:pre-line;
}
.pollBigChoice textarea {
width:99%;
Modified: trunk/pollen-ui-angular/src/main/webapp/js/app.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-30 11:26:00 UTC (rev 3891)
+++ trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-30 14:52:28 UTC (rev 3892)
@@ -83,7 +83,7 @@
.directive('ngExit', function ($timeout) {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
- if(event.which === 13 || event.which === 27) {
+ if(event.which === 27) {
scope.$apply(function (){
scope.$eval(attrs.ngExit);
});
Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-04-30 11:26:00 UTC (rev 3891)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-04-30 14:52:28 UTC (rev 3892)
@@ -95,7 +95,8 @@
if (!angular.isDefined($scope.poll.choices)) {
$scope.poll = initPoll();
}
- $scope.voteChoices = $scope.poll.choices;
+ $scope.vote = {};
+ $scope.vote.choices = $scope.poll.choices;
$scope.addChoice = function () {
var index = $scope.poll.choices.push(initChoice());
@@ -181,31 +182,32 @@
$controller('PollCtrl', {$scope:$scope});
$scope.globalVariables.editMode = false;
- $scope.$watch('voteName', function (newVal) {
+ $scope.$watch('vote.ame', function (newVal) {
if (newVal != '') {
$scope.globalVariables.errorForm = false;
}
});
var initVote = function () {
- $scope.voteName = "";
- $scope.voteChoices = [];
+ $scope.vote = {};
+ $scope.vote.name = "";
+ $scope.vote.choices = [];
for (var i = 0; i < $scope.poll.choices.length; ++i) {
if ($scope.poll.choices[i].type == 'text') {
- $scope.voteChoices.push({name:$scope.poll.choices[i].name, value:false});
+ $scope.vote.choices.push({name:$scope.poll.choices[i].name, value:false});
}
else if ($scope.poll.choices[i].type == 'date') {
- $scope.voteChoices.push({name: $scope.poll.choices[i].date , value:false});
+ $scope.vote.choices.push({name: $scope.poll.choices[i].date , value:false});
}
}
}
initVote();
- $scope.vote = function () {
- if ($scope.voteName != '') {
+ $scope.voter = function () {
+ if ($scope.vote.name != '') {
var data = {};
- data.name = $scope.voteName;
- data.choices = angular.copy($scope.voteChoices);
+ data.name = $scope.vote.name;
+ data.choices = angular.copy($scope.vote.choices);
if (!angular.isDefined($scope.poll.votants)) {
$scope.poll.votants = [];
}
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html 2014-04-30 11:26:00 UTC (rev 3891)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html 2014-04-30 14:52:28 UTC (rev 3892)
@@ -24,7 +24,7 @@
<div ng-repeat="choice in poll.choices" class="row pollBigChoice">
<div class="col-sm-10">
- <div ng-click="showDesc = !showDesc" >
+ <div ng-click="showChoiceDesc = !showChoiceDesc" >
<div ng-if="choice.type == 'text'">
<h3 edit-me="showEdit" ng-hide="showEdit" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false">
<button class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)">...</button>
@@ -45,11 +45,11 @@
</h3>
</div>
</div>
- <p collapse="!globalVariables.editMode && !showDesc" edit-me="showEditDesc" ng-hide="showEditDesc">{{choice.description}}</p>
- <p ng-show="globalVariables.editMode && showEditDesc"><textarea ng-model="choice.description" focus-me="showEditDesc" ng-exit="showEditDesc = false" cols="80" rows="8"></textarea></p>
+ <p collapse="!globalVariables.editMode && !showChoiceDesc" edit-me="showEditChoiceDesc" ng-hide="showEditChoiceDesc">{{choice.description}}</p>
+ <p ng-show="globalVariables.editMode && showEditChoiceDesc"><textarea ng-model="choice.description" focus-me="showEditChoiceDesc" ng-exit="showEditChoiceDesc = false" cols="80" rows="8"></textarea></p>
</div>
<div class="col-sm-2 pollChoiceInput">
- <input type="checkbox" ng-model="choice.value"/>
+ <input type="checkbox" ng-model="vote.choices[$index].value"/>
</div>
</div>
<div class="row pollBigChoice" ng-if="globalVariables.editMode">
@@ -62,6 +62,6 @@
</div>
<div style="float:right; margin-top:5px;">
- <input type="text" placeholder="Votre Nom" ng-model="voteName"/>
- <button class="btn btn-primary" >Voter</button>
+ <input type="text" placeholder="Votre Nom" ng-model="vote.name"/>
+ <button class="btn btn-primary" ng-click="voter()">Voter</button>
</div>
\ No newline at end of file
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html 2014-04-30 11:26:00 UTC (rev 3891)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html 2014-04-30 14:52:28 UTC (rev 3892)
@@ -44,12 +44,12 @@
</tr>
<tr>
- <td class="pollChoice"> <input type="text" class="form-control" placeholder="votre nom" ng-model="voteName" /> </td>
- <td ng-repeat="choice in voteChoices" class="pollChoice">
+ <td class="pollChoice"> <input type="text" class="form-control" placeholder="votre nom" ng-model="vote.name" /> </td>
+ <td ng-repeat="choice in vote.choices" class="pollChoice">
<input type="checkbox" name="{{choice.name}}" ng-model="choice.value"/>
</td>
<td>
- <input class="btn btn-primary btn-large" type="button" value="Vote" ng-click="vote()" />
+ <input class="btn btn-primary btn-large" type="button" value="Vote" ng-click="voter()" />
</td>
</tr>
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-30 11:26:00 UTC (rev 3891)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-30 14:52:28 UTC (rev 3892)
@@ -12,7 +12,7 @@
<h1 ng-show="showEditTitle"><input type="text" class="form-control" focus-me="showEditTitle" ng-model="poll.title" ng-exit="showEditTitle = false" required/></h1>
</div>
- <div ng-hide="showEditDesc" class="pollDesc" edit-me="showEditDesc">
+ <div ng-hide="showEditDesc || !globalVariables.editMode && !poll.description " class="pollDesc" edit-me="showEditDesc">
<div ng-bind-html="toHTML(poll.description || 'Description (Facultatif). Ce cadre disparait si aucune description n\'est mise')"></div>
</div>
<div ng-show="showEditDesc" class="pollDesc " ng-exit="showEditDesc = false;">
1
0