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
May 2014
- 5 participants
- 203 discussions
Author: tchemit
Date: 2014-05-04 02:50:55 +0200 (Sun, 04 May 2014)
New Revision: 3904
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3904
Log:
optimize dependenceis + add license headers + use commons-collections4
Modified:
trunk/pollen-rest-api/pom.xml
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/RoleRequired.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocApi.java
trunk/pollen-rest-api/src/main/resources/pollen-rest-api.properties
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java
trunk/pollen-services/pom.xml
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.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/PollenServiceSupport.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java
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/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/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/test/FakePollenApplicationContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenSecurityContext.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java
trunk/pollen-services/src/test/resources/pollen-services.properties
trunk/pollen-votecounting-coombs/pom.xml
trunk/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCountingStrategy.java
trunk/pollen-votecounting-instant-runoff/pom.xml
trunk/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCountingStrategy.java
Modified: trunk/pollen-rest-api/pom.xml
===================================================================
--- trunk/pollen-rest-api/pom.xml 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-rest-api/pom.xml 2014-05-04 00:50:55 UTC (rev 3904)
@@ -86,17 +86,14 @@
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
</dependency>
- <!--dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- </dependency-->
<dependency>
<groupId>com.google.guava</groupId>
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-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -22,16 +22,6 @@
*/
import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.service.AuthService;
-import org.chorem.pollen.services.service.ChoiceService;
-import org.chorem.pollen.services.service.CommentService;
-import org.chorem.pollen.services.service.FavoriteListService;
-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.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;
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/RoleRequired.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/RoleRequired.java 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/RoleRequired.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.rest.api;
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.services.service.security.SecurityRole;
import java.lang.annotation.ElementType;
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocApi.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocApi.java 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocApi.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.rest.api.v1;
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * %%
+ * 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%
+ */
+
import org.apache.commons.io.IOUtils;
import org.debux.webmotion.server.WebMotionController;
import org.debux.webmotion.server.render.Render;
Modified: trunk/pollen-rest-api/src/main/resources/pollen-rest-api.properties
===================================================================
--- trunk/pollen-rest-api/src/main/resources/pollen-rest-api.properties 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-rest-api/src/main/resources/pollen-rest-api.properties 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,3 +1,23 @@
+###
+# #%L
+# Pollen :: Rest Api
+# %%
+# 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%
+###
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.connection.url=jdbc:h2:file:${pollen.data.directory}/db/pollen-rest-api
hibernate.connection.username=sa
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.rest.api;
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * %%
+ * 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%
+ */
+
import org.apache.http.client.fluent.Request;
import org.chorem.pollen.persistence.entity.ChoiceType;
import org.chorem.pollen.persistence.entity.CommentVisibility;
Modified: trunk/pollen-services/pom.xml
===================================================================
--- trunk/pollen-services/pom.xml 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/pom.xml 2014-05-04 00:50:55 UTC (rev 3904)
@@ -62,8 +62,8 @@
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.PollenPersistenceContext;
import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/NotificationService.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Choice;
import org.chorem.pollen.persistence.entity.Comment;
import org.chorem.pollen.persistence.entity.Poll;
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-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -25,7 +25,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Multimap;
-import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.persistence.PollenPersistenceContext;
import org.chorem.pollen.persistence.entity.ChoiceTopiaDao;
@@ -66,10 +66,6 @@
protected PollenServiceContext serviceContext;
-// public String createPermission(PermissionVerb verb, String id) {
-// return ":" + verb.name() + ":" + id;
-// }
-
@Override
public void setServiceContext(PollenServiceContext serviceContext) {
this.serviceContext = serviceContext;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -26,7 +26,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.services.PollResult;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
/**
* TODO
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceAddedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Choice;
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceDeletedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Choice;
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/ChoiceEditedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Choice;
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentAddedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Comment;
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentDeletedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Comment;
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/CommentEditedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Comment;
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/EmailService.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import com.github.mustachejava.DefaultMustacheFactory;
import com.github.mustachejava.Mustache;
import com.github.mustachejava.MustacheException;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/LostPasswordEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.PollenUser;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollChoicePeriodEndedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollChoicePeriodStartedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollClosedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollCreatedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVotePeriodEndedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVotePeriodStartedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollVoteReminderEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Poll;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/PollenMail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import com.google.common.collect.Sets;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/RestrictedPollInvitationEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.PollenPrincipal;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/UserAccountCreatedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.PollenUser;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteAddedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.Vote;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteDeletedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.Vote;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/mail/VoteEditedEmail.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.mail;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.Vote;
import org.nuiton.i18n.I18n;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidPermissionException.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.security;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.services.PollenTechnicalException;
/**
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityContext.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.security;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.apache.shiro.subject.Subject;
import org.chorem.pollen.persistence.entity.PollenPrincipal;
import org.chorem.pollen.persistence.entity.PollenUser;
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUnauthorizedException.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.security;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.chorem.pollen.services.PollenTechnicalException;
/**
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityRole.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.service.security;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
/**
* Created on 5/1/14.
*
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -9,18 +9,17 @@
* Copyright (C) 2004 - 2014 CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * 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 Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * 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%
*/
Modified: 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 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenSecurityContext.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,5 +1,26 @@
package org.chorem.pollen.services.test;
+/*
+ * #%L
+ * Pollen :: Service
+ * %%
+ * 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%
+ */
+
import org.apache.shiro.subject.Subject;
import org.chorem.pollen.services.service.security.DefaultPollenSecurityContext;
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-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -23,7 +23,7 @@
* #L%
*/
-import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections4.CollectionUtils;
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.persistence.entity.PollenUsers;
import org.chorem.pollen.services.exception.EntityNotFoundException;
Modified: trunk/pollen-services/src/test/resources/pollen-services.properties
===================================================================
--- trunk/pollen-services/src/test/resources/pollen-services.properties 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-services/src/test/resources/pollen-services.properties 2014-05-04 00:50:55 UTC (rev 3904)
@@ -1,3 +1,23 @@
+###
+# #%L
+# Pollen :: Service
+# %%
+# 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%
+###
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.connection.url=jdbc:h2:file:${pollen.data.directory}/db/pollen-rest-api
hibernate.connection.username=sa
Modified: trunk/pollen-votecounting-coombs/pom.xml
===================================================================
--- trunk/pollen-votecounting-coombs/pom.xml 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-votecounting-coombs/pom.xml 2014-05-04 00:50:55 UTC (rev 3904)
@@ -23,8 +23,8 @@
</dependency>
<dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
Modified: trunk/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCountingStrategy.java
===================================================================
--- trunk/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCountingStrategy.java 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-votecounting-coombs/src/main/java/org/chorem/pollen/votecounting/CoombsVoteCountingStrategy.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -25,7 +25,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections4.CollectionUtils;
import org.chorem.pollen.votecounting.model.ChoiceScore;
import org.chorem.pollen.votecounting.model.VoteCountingResult;
import org.chorem.pollen.votecounting.model.Voter;
Modified: trunk/pollen-votecounting-instant-runoff/pom.xml
===================================================================
--- trunk/pollen-votecounting-instant-runoff/pom.xml 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-votecounting-instant-runoff/pom.xml 2014-05-04 00:50:55 UTC (rev 3904)
@@ -28,8 +28,8 @@
</dependency>
<dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
Modified: trunk/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCountingStrategy.java
===================================================================
--- trunk/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCountingStrategy.java 2014-05-04 00:37:08 UTC (rev 3903)
+++ trunk/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCountingStrategy.java 2014-05-04 00:50:55 UTC (rev 3904)
@@ -24,7 +24,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections4.CollectionUtils;
import org.chorem.pollen.votecounting.model.ChoiceScore;
import org.chorem.pollen.votecounting.model.VoteCountingResult;
import org.chorem.pollen.votecounting.model.Voter;
1
0
r3903 - in trunk/pollen-rest-api/src: main/java/org/chorem/pollen/rest/api main/java/org/chorem/pollen/rest/api/v1 main/resources test/java/org/chorem/pollen/rest/api
by tchemit@users.chorem.org 04 May '14
by tchemit@users.chorem.org 04 May '14
04 May '14
Author: tchemit
Date: 2014-05-04 02:37:08 +0200 (Sun, 04 May 2014)
New Revision: 3903
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3903
Log:
improve rest api
Added:
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceApi.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentApi.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocApi.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListApi.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteApi.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingApi.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListApi.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserApiTest.java
Removed:
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/DocService.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/VoteCountingService.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/test/java/org/chorem/pollen/rest/api/PollServiceTest.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java
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/PollenRestApiRequestContext.java
trunk/pollen-rest-api/src/main/resources/mapping
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-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -27,6 +27,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.persistence.PollenEntityEnum;
+import org.chorem.pollen.services.PollenService;
import org.debux.webmotion.server.WebMotionServerListener;
import org.debux.webmotion.server.call.Call;
import org.debux.webmotion.server.call.HttpContext;
@@ -114,6 +115,21 @@
}
});
+ serverContext.addInjector(new ExecutorParametersInjectorHandler.Injector() {
+ @Override
+ public PollenService getValue(Mapping m, Call call, String name, Class type, Type generic) {
+ PollenService result = null;
+ if (PollenService.class.isAssignableFrom(type)) {
+ HttpContext httpContext = call.getContext();
+ HttpServletRequest request = httpContext.getRequest();
+
+ PollenRestApiRequestContext requestContext = PollenRestApiRequestFilter.getRequestContext(request);
+ result = requestContext.getServiceContext().newService(type);
+ }
+ return result;
+ }
+ });
+
// --- init application context --- //
PollenRestApiApplicationContext applicationContext =
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-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -49,6 +49,10 @@
this.serviceContext = serviceContext;
}
+ public PollenServiceContext getServiceContext() {
+ return serviceContext;
+ }
+
public void setSecurityContext(PollenSecurityContext securityContext) {
serviceContext.setSecurityContext(securityContext);
}
@@ -57,46 +61,6 @@
return serviceContext.getSecurityContext();
}
- public AuthService getAuthService() {
- return serviceContext.newService(AuthService.class);
- }
-
- public ChoiceService getChoiceService() {
- return serviceContext.newService(ChoiceService.class);
- }
-
- public CommentService getCommentService() {
- return serviceContext.newService(CommentService.class);
- }
-
- public FavoriteListService getFavoriteListService() {
- return serviceContext.newService(FavoriteListService.class);
- }
-
- public PollService getPollService() {
- return serviceContext.newService(PollService.class);
- }
-
- public PollenUserService getPollenUserService() {
- return serviceContext.newService(PollenUserService.class);
- }
-
- public VoteCountingService getVoteCountingService() {
- return serviceContext.newService(VoteCountingService.class);
- }
-
- public VoterListService getVoterListService() {
- return serviceContext.newService(VoterListService.class);
- }
-
- public VoteService getVoteService() {
- return serviceContext.newService(VoteService.class);
- }
-
- public FixturesService getFixturesService() {
- return serviceContext.newService(FixturesService.class);
- }
-
public SecurityService getSecurityService() {
return serviceContext.newService(SecurityService.class);
}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java (from rev 3895, 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/AuthApi.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -0,0 +1,50 @@
+package org.chorem.pollen.rest.api.v1;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $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.chorem.pollen.persistence.entity.SessionToken;
+import org.chorem.pollen.services.exception.UserInvalidPasswordException;
+import org.chorem.pollen.services.service.AuthService;
+import org.debux.webmotion.server.WebMotionController;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class AuthApi extends WebMotionController {
+
+ public SessionToken login(AuthService authService, String login, String password) throws UserInvalidPasswordException {
+ return authService.login(login, password);
+ }
+
+ public void lostPassword(AuthService authService, String login) {
+ authService.lostPassword(login);
+ }
+
+ public void logout(AuthService authService, String login, String token) {
+ authService.logout(login, token);
+ }
+}
Deleted: 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-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -1,50 +0,0 @@
-package org.chorem.pollen.rest.api.v1;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $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.chorem.pollen.persistence.entity.SessionToken;
-import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.UserInvalidPasswordException;
-import org.debux.webmotion.server.WebMotionController;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class AuthService extends WebMotionController {
-
- public SessionToken login(PollenRestApiRequestContext context, String login, String password) throws UserInvalidPasswordException {
- return context.getAuthService().login(login, password);
- }
-
- public void lostPassword(PollenRestApiRequestContext context, String login) {
- context.getAuthService().lostPassword(login);
- }
-
- public void logout(PollenRestApiRequestContext context, String login, String token) {
- context.getAuthService().logout(login, token);
- }
-}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceApi.java (from rev 3902, 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/ChoiceApi.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceApi.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -0,0 +1,64 @@
+package org.chorem.pollen.rest.api.v1;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $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.chorem.pollen.persistence.entity.Choice;
+import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.ChoiceService;
+import org.debux.webmotion.server.WebMotionController;
+
+import java.util.List;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class ChoiceApi extends WebMotionController {
+
+ public List<Choice> getChoices(ChoiceService choiceService, String pollId) {
+ List<Choice> choices = choiceService.getChoices(pollId);
+ return choices;
+ }
+
+ public Choice getChoice(ChoiceService choiceService, String pollId, String choiceId) {
+ Choice choice = choiceService.getChoice(pollId, choiceId);
+ return choice;
+ }
+
+ public Choice addChoice(ChoiceService choiceService, String pollId, Choice choice) throws InvalidFormException {
+ Choice createdChoice = choiceService.addChoice(pollId, choice);
+ return createdChoice;
+ }
+
+ public Choice editChoice(ChoiceService choiceService, String pollId, Choice choice) throws InvalidFormException {
+ Choice editedChoice = choiceService.editChoice(pollId, choice);
+ return editedChoice;
+ }
+
+ public void deleteChoice(ChoiceService choiceService, String pollId, String choiceId) {
+ choiceService.deleteChoice(pollId, choiceId);
+ }
+}
\ No newline at end of file
Deleted: 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-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -1,64 +0,0 @@
-package org.chorem.pollen.rest.api.v1;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $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.chorem.pollen.persistence.entity.Choice;
-import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.InvalidFormException;
-import org.debux.webmotion.server.WebMotionController;
-
-import java.util.List;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class ChoiceService extends WebMotionController {
-
- public List<Choice> getChoices(PollenRestApiRequestContext context, String pollId) {
- List<Choice> choices = context.getChoiceService().getChoices(pollId);
- return choices;
- }
-
- public Choice getChoice(PollenRestApiRequestContext context, String pollId, String choiceId) {
- Choice choice = context.getChoiceService().getChoice(pollId, choiceId);
- return choice;
- }
-
- public Choice addChoice(PollenRestApiRequestContext context, String pollId, Choice choice) throws InvalidFormException {
- Choice createdChoice = context.getChoiceService().addChoice(pollId, choice);
- return createdChoice;
- }
-
- public Choice editChoice(PollenRestApiRequestContext context, String pollId, Choice choice) throws InvalidFormException {
- Choice editedChoice = context.getChoiceService().editChoice(pollId, choice);
- return editedChoice;
- }
-
- public void deleteChoice(PollenRestApiRequestContext context, String pollId, String choiceId) {
- context.getChoiceService().deleteChoice(pollId, choiceId);
- }
-}
\ No newline at end of file
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentApi.java (from rev 3902, 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/CommentApi.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentApi.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -0,0 +1,64 @@
+package org.chorem.pollen.rest.api.v1;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $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.chorem.pollen.persistence.entity.Comment;
+import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.CommentService;
+import org.debux.webmotion.server.WebMotionController;
+
+import java.util.List;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class CommentApi extends WebMotionController {
+
+ public List<Comment> getComments(CommentService commentService, String pollId) {
+ List<Comment> comments = commentService.getComments(pollId);
+ return comments;
+ }
+
+ public Comment getComment(CommentService commentService, String pollId, String commentId) {
+ Comment comment = commentService.getComment(pollId, commentId);
+ return comment;
+ }
+
+ public Comment addComment(CommentService commentService, String pollId, Comment comment) throws InvalidFormException {
+ Comment createdComment = commentService.addComment(pollId, comment);
+ return createdComment;
+ }
+
+ public Comment editComment(CommentService commentService, String pollId, Comment comment) throws InvalidFormException {
+ Comment editedComment = commentService.editComment(pollId, comment);
+ return editedComment;
+ }
+
+ public void deleteComment(CommentService commentService, String pollId, String commentId) {
+ commentService.deleteComment(pollId, commentId);
+ }
+}
Deleted: 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-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -1,64 +0,0 @@
-package org.chorem.pollen.rest.api.v1;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $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.chorem.pollen.persistence.entity.Comment;
-import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.InvalidFormException;
-import org.debux.webmotion.server.WebMotionController;
-
-import java.util.List;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class CommentService extends WebMotionController {
-
- public List<Comment> getComments(PollenRestApiRequestContext context, String pollId) {
- List<Comment> comments = context.getCommentService().getComments(pollId);
- return comments;
- }
-
- public Comment getComment(PollenRestApiRequestContext context, String pollId, String commentId) {
- Comment comment = context.getCommentService().getComment(pollId, commentId);
- return comment;
- }
-
- public Comment addComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidFormException {
- Comment createdComment = context.getCommentService().addComment(pollId, comment);
- return createdComment;
- }
-
- public Comment editComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidFormException {
- Comment editedComment = context.getCommentService().editComment(pollId, comment);
- return editedComment;
- }
-
- public void deleteComment(PollenRestApiRequestContext context, String pollId, String commentId) {
- context.getCommentService().deleteComment(pollId, commentId);
- }
-}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocApi.java (from rev 3895, trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocService.java)
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocApi.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocApi.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -0,0 +1,29 @@
+package org.chorem.pollen.rest.api.v1;
+
+import org.apache.commons.io.IOUtils;
+import org.debux.webmotion.server.WebMotionController;
+import org.debux.webmotion.server.render.Render;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Created on 4/29/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class DocApi extends WebMotionController {
+
+ public Render showMapping() {
+
+ InputStream mappingUrl = getClass().getResourceAsStream("/mapping");
+ try {
+ String content = IOUtils.toString(mappingUrl);
+ return renderContent(content, "text/plain");
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+}
Deleted: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocService.java 2014-05-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocService.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -1,29 +0,0 @@
-package org.chorem.pollen.rest.api.v1;
-
-import org.apache.commons.io.IOUtils;
-import org.debux.webmotion.server.WebMotionController;
-import org.debux.webmotion.server.render.Render;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Created on 4/29/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class DocService extends WebMotionController {
-
- public Render showMapping() {
-
- InputStream mappingUrl = getClass().getResourceAsStream("/mapping");
- try {
- String content = IOUtils.toString(mappingUrl);
- return renderContent(content, "text/plain");
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- }
-}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListApi.java (from rev 3902, 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/FavoriteListApi.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListApi.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -0,0 +1,116 @@
+package org.chorem.pollen.rest.api.v1;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $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.chorem.pollen.persistence.entity.FavoriteList;
+import org.chorem.pollen.persistence.entity.FavoriteListMember;
+import org.chorem.pollen.rest.api.RoleRequired;
+import org.chorem.pollen.services.exception.FavoriteListImportException;
+import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.FavoriteListService;
+import org.chorem.pollen.services.service.security.SecurityRole;
+import org.debux.webmotion.server.WebMotionController;
+
+import java.io.File;
+import java.util.LinkedHashSet;
+import java.util.List;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class FavoriteListApi extends WebMotionController {
+
+ @RoleRequired(SecurityRole.connected)
+ public List<FavoriteList> getFavoriteLists(FavoriteListService favoriteListService) {
+ List<FavoriteList> favoriteLists = favoriteListService.getFavoriteLists();
+ return favoriteLists;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public FavoriteList getFavoriteList(FavoriteListService favoriteListService, String favoriteListId) {
+ FavoriteList favoriteList = favoriteListService.getFavoriteList(favoriteListId);
+ return favoriteList;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public FavoriteList createFavoriteList(FavoriteListService favoriteListService, FavoriteList favoriteList) throws InvalidFormException {
+ FavoriteList createdFavoriteList = favoriteListService.createFavoriteList(favoriteList);
+ return createdFavoriteList;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public FavoriteList editFavoriteList(FavoriteListService favoriteListService, FavoriteList favoriteList) throws InvalidFormException {
+ FavoriteList editedFavoriteList = favoriteListService.editFavoriteList(favoriteList);
+ return editedFavoriteList;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public void deleteFavoriteList(FavoriteListService favoriteListService, String favoriteListId) {
+ favoriteListService.deleteFavoriteList(favoriteListId);
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public int importFavoriteListMembersFromCsv(FavoriteListService favoriteListService, String favoriteListId, File csvFile) throws FavoriteListImportException {
+ int i = favoriteListService.importFavoriteListMembersFromCsv(favoriteListId, csvFile);
+ return i;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public int importFavoriteListMembersFromLdap(FavoriteListService favoriteListService, String favoriteListId, String ldap) throws FavoriteListImportException {
+ int i = favoriteListService.importFavoriteListMembersFromLdap(favoriteListId, ldap);
+ return i;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public LinkedHashSet<FavoriteListMember> getMembers(FavoriteListService favoriteListService, String favoriteListId) {
+ LinkedHashSet<FavoriteListMember> members = favoriteListService.getFavoriteListMembers(favoriteListId);
+ return members;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public FavoriteListMember getMember(FavoriteListService favoriteListService, String favoriteListId, String memberId) {
+ FavoriteListMember member = favoriteListService.getFavoriteListMember(favoriteListId, memberId);
+ return member;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public FavoriteListMember addMember(FavoriteListService favoriteListService, String favoriteListId, FavoriteListMember member) throws InvalidFormException {
+ FavoriteListMember createdMember = favoriteListService.addFavoriteListMember(favoriteListId, member);
+ return createdMember;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public FavoriteListMember editMember(FavoriteListService favoriteListService, String favoriteListId, FavoriteListMember member) throws InvalidFormException {
+ FavoriteListMember editedMember = favoriteListService.editFavoriteListMember(favoriteListId, member);
+ return editedMember;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public void removeMember(FavoriteListService favoriteListService, String favoriteListId, String memberId) {
+ favoriteListService.removeFavoriteListMember(favoriteListId, memberId);
+ }
+}
Deleted: 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-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -1,116 +0,0 @@
-package org.chorem.pollen.rest.api.v1;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $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.chorem.pollen.persistence.entity.FavoriteList;
-import org.chorem.pollen.persistence.entity.FavoriteListMember;
-import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.rest.api.RoleRequired;
-import org.chorem.pollen.services.exception.FavoriteListImportException;
-import org.chorem.pollen.services.exception.InvalidFormException;
-import org.chorem.pollen.services.service.security.SecurityRole;
-import org.debux.webmotion.server.WebMotionController;
-
-import java.io.File;
-import java.util.LinkedHashSet;
-import java.util.List;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class FavoriteListService extends WebMotionController {
-
- @RoleRequired(SecurityRole.connected)
- public List<FavoriteList> getFavoriteLists(PollenRestApiRequestContext context) {
- List<FavoriteList> favoriteLists = context.getFavoriteListService().getFavoriteLists();
- return favoriteLists;
- }
-
- @RoleRequired(SecurityRole.connected)
- public FavoriteList getFavoriteList(PollenRestApiRequestContext context, String favoriteListId) {
- FavoriteList favoriteList = context.getFavoriteListService().getFavoriteList(favoriteListId);
- return favoriteList;
- }
-
- @RoleRequired(SecurityRole.connected)
- public FavoriteList createFavoriteList(PollenRestApiRequestContext context, FavoriteList favoriteList) throws InvalidFormException {
- FavoriteList createdFavoriteList = context.getFavoriteListService().createFavoriteList(favoriteList);
- return createdFavoriteList;
- }
-
- @RoleRequired(SecurityRole.connected)
- public FavoriteList editFavoriteList(PollenRestApiRequestContext context, FavoriteList favoriteList) throws InvalidFormException {
- FavoriteList editedFavoriteList = context.getFavoriteListService().editFavoriteList(favoriteList);
- return editedFavoriteList;
- }
-
- @RoleRequired(SecurityRole.connected)
- public void deleteFavoriteList(PollenRestApiRequestContext context, String favoriteListId) {
- context.getFavoriteListService().deleteFavoriteList(favoriteListId);
- }
-
- @RoleRequired(SecurityRole.connected)
- public int importFavoriteListMembersFromCsv(PollenRestApiRequestContext context, String favoriteListId, File csvFile) throws FavoriteListImportException {
- int i = context.getFavoriteListService().importFavoriteListMembersFromCsv(favoriteListId, csvFile);
- return i;
- }
-
- @RoleRequired(SecurityRole.connected)
- public int importFavoriteListMembersFromLdap(PollenRestApiRequestContext context, String favoriteListId, String ldap) throws FavoriteListImportException {
- int i = context.getFavoriteListService().importFavoriteListMembersFromLdap(favoriteListId, ldap);
- return i;
- }
-
- @RoleRequired(SecurityRole.connected)
- public LinkedHashSet<FavoriteListMember> getMembers(PollenRestApiRequestContext context, String favoriteListId) {
- LinkedHashSet<FavoriteListMember> members = context.getFavoriteListService().getFavoriteListMembers(favoriteListId);
- return members;
- }
-
- @RoleRequired(SecurityRole.connected)
- public FavoriteListMember getMember(PollenRestApiRequestContext context, String favoriteListId, String memberId) {
- FavoriteListMember member = context.getFavoriteListService().getFavoriteListMember(favoriteListId, memberId);
- return member;
- }
-
- @RoleRequired(SecurityRole.connected)
- public FavoriteListMember addMember(PollenRestApiRequestContext context, String favoriteListId, FavoriteListMember member) throws InvalidFormException {
- FavoriteListMember createdMember = context.getFavoriteListService().addFavoriteListMember(favoriteListId, member);
- return createdMember;
- }
-
- @RoleRequired(SecurityRole.connected)
- public FavoriteListMember editMember(PollenRestApiRequestContext context, String favoriteListId, FavoriteListMember member) throws InvalidFormException {
- FavoriteListMember editedMember = context.getFavoriteListService().editFavoriteListMember(favoriteListId, member);
- return editedMember;
- }
-
- @RoleRequired(SecurityRole.connected)
- public void removeMember(PollenRestApiRequestContext context, String favoriteListId, String memberId) {
- context.getFavoriteListService().removeFavoriteListMember(favoriteListId, memberId);
- }
-}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java (from rev 3902, 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/PollApi.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -0,0 +1,105 @@
+package org.chorem.pollen.rest.api.v1;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $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.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.rest.api.RoleRequired;
+import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.PollService;
+import org.chorem.pollen.services.service.security.SecurityRole;
+import org.debux.webmotion.server.WebMotionController;
+
+import java.io.File;
+import java.util.Set;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollApi extends WebMotionController {
+
+ public Poll getNewPoll(PollService pollService) {
+ Poll newPoll = pollService.getNewPoll();
+ return newPoll;
+ }
+
+ @RoleRequired(SecurityRole.administrator)
+ public Set<Poll> getPolls(PollService pollService) {
+ Set<Poll> polls = pollService.getPolls();
+ return polls;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public Set<Poll> getCreatedPolls(PollService pollService) {
+ Set<Poll> polls = pollService.getCreatedPolls();
+ return polls;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public Set<Poll> getInvitedPolls(PollService pollService) {
+ Set<Poll> polls = pollService.getInvitedPolls();
+ return polls;
+ }
+
+ @RoleRequired(SecurityRole.connected)
+ public Set<Poll> getParticipatedPolls(PollService pollService) {
+ Set<Poll> polls = pollService.getParticipatedPolls();
+ return polls;
+ }
+
+ public Poll getPoll(PollService pollService, String pollId) {
+ Poll poll = pollService.getPoll(pollId);
+ return poll;
+ }
+
+ public Poll createPoll(PollService pollService, Poll poll) throws InvalidFormException {
+ Poll createdPoll = pollService.createPoll(poll);
+ return createdPoll;
+ }
+
+ public Poll editPoll(PollService pollService, Poll poll) throws InvalidFormException {
+ Poll editedPoll = pollService.editPoll(poll);
+ return editedPoll;
+ }
+
+ public void deletePoll(PollService pollService, String pollId) {
+ pollService.deletePoll(pollId);
+ }
+
+ public Poll clonePoll(PollService pollService, String pollId) {
+ Poll clonedPoll = pollService.clonePoll(pollId);
+ return clonedPoll;
+ }
+
+ public void closePoll(PollService pollService, String pollId) {
+ pollService.closePoll(pollId);
+ }
+
+ public File exportPoll(PollService pollService, String pollId) {
+ File exportedPollFile = pollService.exportPoll(pollId);
+ return exportedPollFile;
+ }
+}
Deleted: 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-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -1,105 +0,0 @@
-package org.chorem.pollen.rest.api.v1;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $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.chorem.pollen.persistence.entity.Poll;
-import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.rest.api.RoleRequired;
-import org.chorem.pollen.services.exception.InvalidFormException;
-import org.chorem.pollen.services.service.security.SecurityRole;
-import org.debux.webmotion.server.WebMotionController;
-
-import java.io.File;
-import java.util.Set;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollService extends WebMotionController {
-
- public Poll getNewPoll(PollenRestApiRequestContext context) {
- Poll newPoll = context.getPollService().getNewPoll();
- return newPoll;
- }
-
- @RoleRequired(SecurityRole.administrator)
- public Set<Poll> getPolls(PollenRestApiRequestContext context) {
- Set<Poll> polls = context.getPollService().getPolls();
- return polls;
- }
-
- @RoleRequired(SecurityRole.connected)
- public Set<Poll> getCreatedPolls(PollenRestApiRequestContext context) {
- Set<Poll> polls = context.getPollService().getCreatedPolls();
- return polls;
- }
-
- @RoleRequired(SecurityRole.connected)
- public Set<Poll> getInvitedPolls(PollenRestApiRequestContext context) {
- Set<Poll> polls = context.getPollService().getInvitedPolls();
- return polls;
- }
-
- @RoleRequired(SecurityRole.connected)
- public Set<Poll> getParticipatedPolls(PollenRestApiRequestContext context) {
- Set<Poll> polls = context.getPollService().getParticipatedPolls();
- return polls;
- }
-
- public Poll getPoll(PollenRestApiRequestContext context, String pollId) {
- Poll poll = context.getPollService().getPoll(pollId);
- return poll;
- }
-
- public Poll createPoll(PollenRestApiRequestContext context, Poll poll) throws InvalidFormException {
- Poll createdPoll = context.getPollService().createPoll(poll);
- return createdPoll;
- }
-
- public Poll editPoll(PollenRestApiRequestContext context, Poll poll) throws InvalidFormException {
- Poll editedPoll = context.getPollService().editPoll(poll);
- return editedPoll;
- }
-
- public void deletePoll(PollenRestApiRequestContext context, String pollId) {
- context.getPollService().deletePoll(pollId);
- }
-
- public Poll clonePoll(PollenRestApiRequestContext context, String pollId) {
- Poll clonedPoll = context.getPollService().clonePoll(pollId);
- return clonedPoll;
- }
-
- public void closePoll(PollenRestApiRequestContext context, String pollId) {
- context.getPollService().closePoll(pollId);
- }
-
- public File exportPoll(PollenRestApiRequestContext context, String pollId) {
- File exportedPollFile = context.getPollService().exportPoll(pollId);
- return exportedPollFile;
- }
-}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java (from rev 3902, 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/PollenUserApi.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -0,0 +1,86 @@
+package org.chorem.pollen.rest.api.v1;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $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.chorem.pollen.persistence.entity.PollenUser;
+import org.chorem.pollen.rest.api.RoleRequired;
+import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
+import org.chorem.pollen.services.exception.UserInvalidPasswordException;
+import org.chorem.pollen.services.service.PollenUserService;
+import org.chorem.pollen.services.service.security.SecurityRole;
+import org.debux.webmotion.server.WebMotionController;
+
+import java.util.List;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenUserApi extends WebMotionController {
+
+ @RoleRequired(SecurityRole.administrator)
+ public List<PollenUser> getUsers(PollenUserService pollenUserService) {
+ List<PollenUser> users = pollenUserService.getUsers();
+ return users;
+ }
+
+ public PollenUser getUser(PollenUserService pollenUserService, String userId) {
+ PollenUser user = pollenUserService.getUser(userId);
+ return user;
+ }
+
+ public PollenUser createUser(PollenUserService pollenUserService,
+ PollenUser user,
+ boolean generatePassword) throws InvalidFormException {
+ PollenUser createdUser = pollenUserService.createUser(user, generatePassword);
+ return createdUser;
+
+ }
+
+ public PollenUser editUser(PollenUserService pollenUserService,
+ PollenUser user) throws InvalidFormException {
+ PollenUser editedUser = pollenUserService.editUser(user);
+ return editedUser;
+ }
+
+ public void deleteUser(PollenUserService pollenUserService, String userId) throws InvalidFormException {
+ pollenUserService.deleteUser(userId);
+ }
+
+ public void validateUserEmail(PollenUserService pollenUserService,
+ String userId,
+ String token) throws UserInvalidEmailActivationTokenException {
+ pollenUserService.validateUserEmail(userId, token);
+ }
+
+ public void changePassword(PollenUserService pollenUserService,
+ String userId,
+ String oldPassword,
+ String newPassword) throws UserInvalidPasswordException {
+ pollenUserService.changePassword(userId, oldPassword, newPassword);
+ }
+}
Deleted: 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-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -1,86 +0,0 @@
-package org.chorem.pollen.rest.api.v1;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $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.chorem.pollen.persistence.entity.PollenUser;
-import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.rest.api.RoleRequired;
-import org.chorem.pollen.services.exception.InvalidFormException;
-import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
-import org.chorem.pollen.services.exception.UserInvalidPasswordException;
-import org.chorem.pollen.services.service.security.SecurityRole;
-import org.debux.webmotion.server.WebMotionController;
-
-import java.util.List;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollenUserService extends WebMotionController {
-
- @RoleRequired(SecurityRole.administrator)
- public List<PollenUser> getUsers(PollenRestApiRequestContext context) {
- List<PollenUser> users = context.getPollenUserService().getUsers();
- return users;
- }
-
- public PollenUser getUser(PollenRestApiRequestContext context, String userId) {
- PollenUser user = context.getPollenUserService().getUser(userId);
- return user;
- }
-
- public PollenUser createUser(PollenRestApiRequestContext context,
- PollenUser user,
- boolean generatePassword) throws InvalidFormException {
- PollenUser createdUser = context.getPollenUserService().createUser(user, generatePassword);
- return createdUser;
-
- }
-
- public PollenUser editUser(PollenRestApiRequestContext context,
- PollenUser user) throws InvalidFormException {
- PollenUser editedUser = context.getPollenUserService().editUser(user);
- return editedUser;
- }
-
- public void deleteUser(PollenRestApiRequestContext context, String userId) throws InvalidFormException {
- context.getPollenUserService().deleteUser(userId);
- }
-
- public void validateUserEmail(PollenRestApiRequestContext context,
- String userId,
- String token) throws UserInvalidEmailActivationTokenException {
- context.getPollenUserService().validateUserEmail(userId, token);
- }
-
- public void changePassword(PollenRestApiRequestContext context,
- String userId,
- String oldPassword,
- String newPassword) throws UserInvalidPasswordException {
- context.getPollenUserService().changePassword(userId, oldPassword, newPassword);
- }
-}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteApi.java (from rev 3902, 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/VoteApi.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteApi.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -0,0 +1,64 @@
+package org.chorem.pollen.rest.api.v1;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $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.chorem.pollen.persistence.entity.Vote;
+import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.VoteService;
+import org.debux.webmotion.server.WebMotionController;
+
+import java.util.List;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class VoteApi extends WebMotionController {
+
+ public List<Vote> getVotes(VoteService voteService, String pollId) {
+ List<Vote> votes = voteService.getVotes(pollId);
+ return votes;
+ }
+
+ public Vote getVote(VoteService voteService, String pollId, String voteId) {
+ Vote vote = voteService.getVote(pollId, voteId);
+ return vote;
+ }
+
+ public Vote addVote(VoteService voteService, String pollId, Vote vote) throws InvalidFormException {
+ Vote createdVote = voteService.addVote(pollId, vote);
+ return createdVote;
+ }
+
+ public Vote editVote(VoteService voteService, String pollId, Vote vote) throws InvalidFormException {
+ Vote editedVote = voteService.editVote(pollId, vote);
+ return editedVote;
+ }
+
+ public void deleteVote(VoteService voteService, String pollId, String voteId) {
+ voteService.deleteVote(pollId, voteId);
+ }
+}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingApi.java (from rev 3902, trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java)
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingApi.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingApi.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -0,0 +1,42 @@
+package org.chorem.pollen.rest.api.v1;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $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.chorem.pollen.services.PollResult;
+import org.chorem.pollen.services.service.VoteCountingService;
+import org.debux.webmotion.server.WebMotionController;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class VoteCountingApi extends WebMotionController {
+
+ public PollResult getResult(VoteCountingService voteCountingService, String pollId) {
+ PollResult result = voteCountingService.getResult(pollId);
+ return result;
+ }
+}
Deleted: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java 2014-05-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -1,42 +0,0 @@
-package org.chorem.pollen.rest.api.v1;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $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.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.PollResult;
-import org.debux.webmotion.server.WebMotionController;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class VoteCountingService extends WebMotionController {
-
- public PollResult getResult(PollenRestApiRequestContext context, String pollId) {
- PollResult result = context.getVoteCountingService().getResult(pollId);
- return result;
- }
-}
Deleted: 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-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -1,64 +0,0 @@
-package org.chorem.pollen.rest.api.v1;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $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.chorem.pollen.persistence.entity.Vote;
-import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.InvalidFormException;
-import org.debux.webmotion.server.WebMotionController;
-
-import java.util.List;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class VoteService extends WebMotionController {
-
- public List<Vote> getVotes(PollenRestApiRequestContext context, String pollId) {
- List<Vote> votes = context.getVoteService().getVotes(pollId);
- return votes;
- }
-
- public Vote getVote(PollenRestApiRequestContext context, String pollId, String voteId) {
- Vote vote = context.getVoteService().getVote(pollId, voteId);
- return vote;
- }
-
- public Vote addVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidFormException {
- Vote createdVote = context.getVoteService().addVote(pollId, vote);
- return createdVote;
- }
-
- public Vote editVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidFormException {
- Vote editedVote = context.getVoteService().editVote(pollId, vote);
- return editedVote;
- }
-
- public void deleteVote(PollenRestApiRequestContext context, String pollId, String voteId) {
- context.getVoteService().deleteVote(pollId, voteId);
- }
-}
Copied: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListApi.java (from rev 3902, 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/VoterListApi.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListApi.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -0,0 +1,98 @@
+package org.chorem.pollen.rest.api.v1;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $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.chorem.pollen.persistence.entity.VoterList;
+import org.chorem.pollen.persistence.entity.VoterListMember;
+import org.chorem.pollen.rest.api.RoleRequired;
+import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.VoterListService;
+import org.chorem.pollen.services.service.security.SecurityRole;
+import org.debux.webmotion.server.WebMotionController;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class VoterListApi extends WebMotionController {
+
+ @RoleRequired(SecurityRole.connected)
+ public VoterList importFavoriteList(VoterListService voterListService, String pollId, String favoriteListId) {
+ VoterList importVoterList = voterListService.importFavoriteList(pollId, favoriteListId);
+ return importVoterList;
+ }
+
+ public List<VoterList> getVoterLists(VoterListService voterListService, String pollId) {
+ List<VoterList> voterLists = voterListService.getVoterLists(pollId);
+ return voterLists;
+ }
+
+ public VoterList getVoterList(VoterListService voterListService, String pollId, String voterListId) {
+ VoterList voterList = voterListService.getVoterList(pollId, voterListId);
+ return voterList;
+ }
+
+ public VoterList createVoterList(VoterListService voterListService, String pollId, VoterList voterList) throws InvalidFormException {
+ VoterList createdVoterList = voterListService.addVoterList(pollId, voterList);
+ return createdVoterList;
+ }
+
+ public VoterList editVoterList(VoterListService voterListService, String pollId, VoterList voterList) throws InvalidFormException {
+ VoterList editedVoterList = voterListService.editVoterList(pollId, voterList);
+ return editedVoterList;
+ }
+
+ public void deleteVoterList(VoterListService voterListService, String pollId, String voterListId) {
+ voterListService.deleteVoterList(pollId, voterListId);
+ }
+
+ public Set<VoterListMember> getMembers(VoterListService voterListService, String pollId, String voterListId) {
+ Set<VoterListMember> members = voterListService.getVoterListMembers(pollId, voterListId);
+ return members;
+ }
+
+ public VoterListMember getMember(VoterListService voterListService, String pollId, String voterListId, String memberId) {
+ VoterListMember member = voterListService.getVoterListMember(pollId, voterListId, memberId);
+ return member;
+ }
+
+ public VoterListMember addMember(VoterListService voterListService, String pollId, String voterListId, VoterListMember member) throws InvalidFormException {
+ VoterListMember createdMember = voterListService.addVoterListMember(pollId, voterListId, member);
+ return createdMember;
+ }
+
+ public VoterListMember editMember(VoterListService voterListService, String pollId, String voterListId, VoterListMember member) throws InvalidFormException {
+ VoterListMember editedMember = voterListService.editVoterListMember(pollId, voterListId, member);
+ return editedMember;
+ }
+
+ public void deleteMember(VoterListService voterListService, String pollId, String voterListId, String memberId) {
+ voterListService.deleteVoterListMember(pollId, voterListId, memberId);
+ }
+}
Deleted: 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-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -1,98 +0,0 @@
-package org.chorem.pollen.rest.api.v1;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $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.chorem.pollen.persistence.entity.VoterList;
-import org.chorem.pollen.persistence.entity.VoterListMember;
-import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.rest.api.RoleRequired;
-import org.chorem.pollen.services.exception.InvalidFormException;
-import org.chorem.pollen.services.service.security.SecurityRole;
-import org.debux.webmotion.server.WebMotionController;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class VoterListService extends WebMotionController {
-
- @RoleRequired(SecurityRole.connected)
- public VoterList importFavoriteList(PollenRestApiRequestContext context, String pollId, String favoriteListId) {
- VoterList importVoterList = context.getVoterListService().importFavoriteList(pollId, favoriteListId);
- return importVoterList;
- }
-
- public List<VoterList> getVoterLists(PollenRestApiRequestContext context, String pollId) {
- List<VoterList> voterLists = context.getVoterListService().getVoterLists(pollId);
- return voterLists;
- }
-
- public VoterList getVoterList(PollenRestApiRequestContext context, String pollId, String voterListId) {
- VoterList voterList = context.getVoterListService().getVoterList(pollId, voterListId);
- return voterList;
- }
-
- public VoterList createVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidFormException {
- VoterList createdVoterList = context.getVoterListService().addVoterList(pollId, voterList);
- return createdVoterList;
- }
-
- public VoterList editVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidFormException {
- VoterList editedVoterList = context.getVoterListService().editVoterList(pollId, voterList);
- return editedVoterList;
- }
-
- public void deleteVoterList(PollenRestApiRequestContext context, String pollId, String voterListId) {
- context.getVoterListService().deleteVoterList(pollId, voterListId);
- }
-
- public Set<VoterListMember> getMembers(PollenRestApiRequestContext context, String pollId, String voterListId) {
- Set<VoterListMember> members = context.getVoterListService().getVoterListMembers(pollId, voterListId);
- return members;
- }
-
- public VoterListMember getMember(PollenRestApiRequestContext context, String pollId, String voterListId, String memberId) {
- VoterListMember member = context.getVoterListService().getVoterListMember(pollId, voterListId, memberId);
- return member;
- }
-
- public VoterListMember addMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidFormException {
- VoterListMember createdMember = context.getVoterListService().addVoterListMember(pollId, voterListId, member);
- return createdMember;
- }
-
- public VoterListMember editMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidFormException {
- VoterListMember editedMember = context.getVoterListService().editVoterListMember(pollId, voterListId, member);
- return editedMember;
- }
-
- public void deleteMember(PollenRestApiRequestContext context, String pollId, String voterListId, String 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-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/main/resources/mapping 2014-05-04 00:37:08 UTC (rev 3903)
@@ -10,101 +10,102 @@
[errors]
-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.InvalidFormException ErrorAction.on400Form
+org.chorem.pollen.Apis.exception.EntityNotFoundException ErrorAction.on404
+org.chorem.pollen.Apis.exception.UserInvalidPasswordException ErrorAction.on500
+org.chorem.pollen.Apis.exception.UserInvalidEmailActivationTokenException ErrorAction.on500
+org.chorem.pollen.Apis.exception.InvalidFormException ErrorAction.on400Form
[actions]
-# Doc
+# DocApi
-GET /v1/doc DocService.showMapping
-# AuthService
+GET /v1/doc DocApi.showMapping
-PUT /v1/login AuthService.login
-GET /v1/lostpassword/{token} AuthService.lostPassword
-GET /v1/logout AuthService.logout
+# AuthApi
-# ChoiceService
+PUT /v1/login AuthApi.login
+GET /v1/lostpassword/{token} AuthApi.lostPassword
+GET /v1/logout AuthApi.logout
-GET /v1/polls/{pollId}/choices ChoiceService.getChoices
-POST /v1/polls/{pollId}/choices ChoiceService.addChoice
-GET /v1/polls/{pollId}/choices/{choiceId} ChoiceService.getChoice
-PUT /v1/polls/{pollId}/choices/{choiceId} ChoiceService.editChoice
-DELETE /v1/polls/{pollId}/choices/{choiceId} ChoiceService.deleteChoice
+# ChoiceApi
-# CommentService
+GET /v1/polls/{pollId}/choices ChoiceApi.getChoices
+POST /v1/polls/{pollId}/choices ChoiceApi.addChoice
+GET /v1/polls/{pollId}/choices/{choiceId} ChoiceApi.getChoice
+PUT /v1/polls/{pollId}/choices/{choiceId} ChoiceApi.editChoice
+DELETE /v1/polls/{pollId}/choices/{choiceId} ChoiceApi.deleteChoice
-GET /v1/polls/{pollId}/comments CommentService.getComments
-POST /v1/polls/{pollId}/comments CommentService.addComment
-GET /v1/polls/{pollId}/comments/{commentId} CommentService.getComment
-PUT /v1/polls/{pollId}/comments/{commentId} CommentService.editComment
-DELETE /v1/polls/{pollId}/comments/{commentId} CommentService.deleteComment
+# CommentApi
-# FavoriteListService
+GET /v1/polls/{pollId}/comments CommentApi.getComments
+POST /v1/polls/{pollId}/comments CommentApi.addComment
+GET /v1/polls/{pollId}/comments/{commentId} CommentApi.getComment
+PUT /v1/polls/{pollId}/comments/{commentId} CommentApi.editComment
+DELETE /v1/polls/{pollId}/comments/{commentId} CommentApi.deleteComment
-GET /v1/favoriteLists FavoriteListService.getFavoriteLists
-GET /v1/favoriteLists/{flId} FavoriteListService.getFavoriteList
-POST /v1/favoriteLists/{flId}/importCsv FavoriteListService.importFavoriteListMembersFromCsv
-POST /v1/favoriteLists/{flId}/importLdap FavoriteListService.importFavoriteListMembersFromLdap
-POST /v1/favoriteLists FavoriteListService.createFavoriteList
-PUT /v1/favoriteLists/{flId} FavoriteListService.editFavoriteList
-DELETE /v1/favoriteLists/{flId} FavoriteListService.deleteFavoriteList
-GET /v1/favoriteLists/{flId}/members FavoriteListService.getMembers
-GET /v1/favoriteLists/{flId}/members/{mId} FavoriteListService.getMember
-POST /v1/favoriteLists/{flId}/members FavoriteListService.addMember
-PUT /v1/favoriteLists/{flId}/members/{mId} FavoriteListService.editMember
-DELETE /v1/favoriteLists/{flId}/members/{mId} FavoriteListService.removeMember
+# FavoriteListApi
-# PollService
+GET /v1/favoriteLists FavoriteListApi.getFavoriteLists
+GET /v1/favoriteLists/{flId} FavoriteListApi.getFavoriteList
+POST /v1/favoriteLists/{flId}/importCsv FavoriteListApi.importFavoriteListMembersFromCsv
+POST /v1/favoriteLists/{flId}/importLdap FavoriteListApi.importFavoriteListMembersFromLdap
+POST /v1/favoriteLists FavoriteListApi.createFavoriteList
+PUT /v1/favoriteLists/{flId} FavoriteListApi.editFavoriteList
+DELETE /v1/favoriteLists/{flId} FavoriteListApi.deleteFavoriteList
+GET /v1/favoriteLists/{flId}/members FavoriteListApi.getMembers
+GET /v1/favoriteLists/{flId}/members/{mId} FavoriteListApi.getMember
+POST /v1/favoriteLists/{flId}/members FavoriteListApi.addMember
+PUT /v1/favoriteLists/{flId}/members/{mId} FavoriteListApi.editMember
+DELETE /v1/favoriteLists/{flId}/members/{mId} FavoriteListApi.removeMember
-GET /v1/polls/new PollService.getNewPoll
-GET /v1/polls PollService.getPolls
-GET /v1/polls/created PollService.getCreatedPolls
-GET /v1/polls/invited PollService.getInvitedPolls
-GET /v1/polls/participated PollService.getParticipatedPolls
-POST /v1/polls PollService.createPoll
-GET /v1/polls/create PollService.createPoll
-PUT /v1/polls/{pollId} PollService.editPoll
-GET /v1/polls/{pollId} PollService.getPoll
-DELETE /v1/polls/{pollId} PollService.deletePoll
-POST /v1/polls/{pollId} PollService.clonePoll
-GET /v1/polls/{pollId}/export PollService.exportPoll
-PUT /v1/polls/{pollId}/close PollService.closePoll
+# PollApi
-# PollenUserService
+GET /v1/polls/new PollApi.getNewPoll
+GET /v1/polls PollApi.getPolls
+GET /v1/polls/created PollApi.getCreatedPolls
+GET /v1/polls/invited PollApi.getInvitedPolls
+GET /v1/polls/participated PollApi.getParticipatedPolls
+POST /v1/polls PollApi.createPoll
+GET /v1/polls/create PollApi.createPoll
+PUT /v1/polls/{pollId} PollApi.editPoll
+GET /v1/polls/{pollId} PollApi.getPoll
+DELETE /v1/polls/{pollId} PollApi.deletePoll
+POST /v1/polls/{pollId} PollApi.clonePoll
+GET /v1/polls/{pollId}/export PollApi.exportPoll
+PUT /v1/polls/{pollId}/close PollApi.closePoll
-GET /v1/users PollenUserService.getUsers
-GET /v1/users/{userId} PollenUserService.getUser
-POST /v1/users PollenUserService.createUser
-PUT /v1/users/{userId} PollenUserService.editUser
-DELETE /v1/users/{userId} PollenUserService.deleteUser
-PUT /v1/users/{userId}?token={} PollenUserService.validateUserEmail
+# PollenUserApi
-# VoteCountingService
+GET /v1/users PollenUserApi.getUsers
+GET /v1/users/{userId} PollenUserApi.getUser
+POST /v1/users PollenUserApi.createUser
+PUT /v1/users/{userId} PollenUserApi.editUser
+DELETE /v1/users/{userId} PollenUserApi.deleteUser
+PUT /v1/users/{userId}?token={} PollenUserApi.validateUserEmail
-GET /v1/polls/{pollId}/results VoteCountingService.getResult
+# VoteCountingApi
-# VoterListService
+GET /v1/polls/{pollId}/results VoteCountingApi.getResult
-PUT /v1/polls/{pollId}/favoriteLists/{flId} VoterListService.importFavoriteList
-GET /v1/polls/{pollId}/voterLists VoterListService.getVoterLists
-GET /v1/polls/{pollId}/voterLists/{vlId} VoterListService.getVoterList
-POST /v1/polls/{pollId}/voterLists VoterListService.createVoterList
-PUT /v1/polls/{pollId}/voterLists/{vlId} VoterListService.editVoterList
-DELETE /v1/polls/{pollId}/voterLists/{vlId} VoterListService.deleteVoterList
+# VoterListApi
-GET /v1/polls/{pollId}/voterLists/{vlId}/members VoterListService.getMembers
-GET /v1/polls/{pollId}/voterLists/{vlId}/members/{mId} VoterListService.getMember
-POST /v1/polls/{pollId}/voterLists/{vlId}/members VoterListService.addMember
-PUT /v1/polls/{pollId}/voterLists/{vlId}/members/{mId} VoterListService.editMember
-DELETE /v1/polls/{pollId}/voterLists/{vlId}/members/{mId} VoterListService.deleteMember
+PUT /v1/polls/{pollId}/favoriteLists/{flId} VoterListApi.importFavoriteList
+GET /v1/polls/{pollId}/voterLists VoterListApi.getVoterLists
+GET /v1/polls/{pollId}/voterLists/{vlId} VoterListApi.getVoterList
+POST /v1/polls/{pollId}/voterLists VoterListApi.createVoterList
+PUT /v1/polls/{pollId}/voterLists/{vlId} VoterListApi.editVoterList
+DELETE /v1/polls/{pollId}/voterLists/{vlId} VoterListApi.deleteVoterList
-# VoteService
+GET /v1/polls/{pollId}/voterLists/{vlId}/members VoterListApi.getMembers
+GET /v1/polls/{pollId}/voterLists/{vlId}/members/{mId} VoterListApi.getMember
+POST /v1/polls/{pollId}/voterLists/{vlId}/members VoterListApi.addMember
+PUT /v1/polls/{pollId}/voterLists/{vlId}/members/{mId} VoterListApi.editMember
+DELETE /v1/polls/{pollId}/voterLists/{vlId}/members/{mId} VoterListApi.deleteMember
-GET /v1/polls/{pollId}/votes VoteService.getVotes
-PUT /v1/polls/{pollId}/votes VoteService.addVote
-GET /v1/polls/{pollId}/votes/{voteId} VoteService.getVote
-PUT /v1/polls/{pollId}/votes/{voteId} VoteService.editVote
-DELETE /v1/polls/{pollId}/votes/{voteId} VoteService.deleteVote
+# VoteApi
+
+GET /v1/polls/{pollId}/votes VoteApi.getVotes
+PUT /v1/polls/{pollId}/votes VoteApi.addVote
+GET /v1/polls/{pollId}/votes/{voteId} VoteApi.getVote
+PUT /v1/polls/{pollId}/votes/{voteId} VoteApi.editVote
+DELETE /v1/polls/{pollId}/votes/{voteId} VoteApi.deleteVote
Copied: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java (from rev 3902, 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/PollApiTest.java (rev 0)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -0,0 +1,162 @@
+package org.chorem.pollen.rest.api;
+
+import org.apache.http.client.fluent.Request;
+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.chorem.pollen.services.PollenFixtures;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Created on 4/29/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollApiTest extends AbstractPollenRestApiTest {
+
+ @Before
+ public void setUp() throws Exception {
+
+ loadFixtures("fixtures");
+ }
+
+ @Test
+ public void getPollsNew() throws URISyntaxException, IOException {
+ Request request = createRequest("/v1/polls/new").Get();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertNotNull(content);
+ }
+
+ @Ignore
+ @Test
+ public void getPolls() throws URISyntaxException, IOException {
+
+ //TODO Login as admin before
+ Request request = createRequest("/v1/polls").Get();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertNotNull(content);
+ }
+
+ @Ignore
+ @Test
+ public void getPollsCreated() throws URISyntaxException, IOException {
+ Request request = createRequest("/v1/polls/created").Get();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertNotNull(content);
+ }
+
+ @Ignore
+ @Test
+ public void getPollsInvited() throws URISyntaxException, IOException {
+ Request request = createRequest("/v1/polls/invited").Get();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertNotNull(content);
+ }
+
+ @Ignore
+ @Test
+ public void getPollsParticipated() throws URISyntaxException, IOException {
+ Request request = createRequest("/v1/polls/participated").Get();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertNotNull(content);
+ }
+
+ @Test
+ public void getPoll() throws URISyntaxException, IOException {
+ Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
+ String pollId = poll.getTopiaId();
+ Request request = createRequest("/v1/polls/" + pollId).Get();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertNotNull(content);
+ }
+
+ @Test
+ public void postPoll() throws URISyntaxException, IOException {
+ Request request = createRequest("/v1/polls").
+ 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();
+ showTestResult(content);
+ assertNotNull(content);
+ }
+
+ @Ignore
+ @Test
+ public void putPoll() throws URISyntaxException, IOException {
+ Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
+ String pollId = poll.getTopiaId();
+ Request request = createRequest("/v1/polls/" + pollId).Put();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertNotNull(content);
+ }
+
+ @Test
+ public void deletePoll() throws URISyntaxException, IOException {
+ Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
+ String pollId = poll.getTopiaId();
+ Request request = createRequest("/v1/polls/" + pollId)
+ .addParameter(PollenRestApiRequestFilter.REQUEST_CREDENTIAL_PARAMETER, poll.getCreator().getTopiaId())
+ .Delete();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertNotNull(content);
+ }
+
+ @Ignore
+ @Test
+ public void clonePoll() throws URISyntaxException, IOException {
+ Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
+ String pollId = poll.getTopiaId();
+ Request request = createRequest("/v1/polls/" + pollId).Post();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertNotNull(content);
+ }
+
+ @Ignore
+ @Test
+ public void exportPoll() throws URISyntaxException, IOException {
+ Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
+ String pollId = poll.getTopiaId();
+ Request request = createRequest("/v1/polls/" + pollId + "/export").Get();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertNotNull(content);
+ }
+
+ @Ignore
+ @Test
+ public void closePoll() throws URISyntaxException, IOException {
+ Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
+ String pollId = poll.getTopiaId();
+ Request request = createRequest("/v1/polls/" + pollId + "/close").Post();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertNotNull(content);
+ }
+}
Deleted: 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-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -1,162 +0,0 @@
-package org.chorem.pollen.rest.api;
-
-import org.apache.http.client.fluent.Request;
-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.chorem.pollen.services.PollenFixtures;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Created on 4/29/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollServiceTest extends AbstractPollenRestApiTest {
-
- @Before
- public void setUp() throws Exception {
-
- loadFixtures("fixtures");
- }
-
- @Test
- public void getPollsNew() throws URISyntaxException, IOException {
- Request request = createRequest("/v1/polls/new").Get();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertNotNull(content);
- }
-
- @Ignore
- @Test
- public void getPolls() throws URISyntaxException, IOException {
-
- //TODO Login as admin before
- Request request = createRequest("/v1/polls").Get();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertNotNull(content);
- }
-
- @Ignore
- @Test
- public void getPollsCreated() throws URISyntaxException, IOException {
- Request request = createRequest("/v1/polls/created").Get();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertNotNull(content);
- }
-
- @Ignore
- @Test
- public void getPollsInvited() throws URISyntaxException, IOException {
- Request request = createRequest("/v1/polls/invited").Get();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertNotNull(content);
- }
-
- @Ignore
- @Test
- public void getPollsParticipated() throws URISyntaxException, IOException {
- Request request = createRequest("/v1/polls/participated").Get();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertNotNull(content);
- }
-
- @Test
- public void getPoll() throws URISyntaxException, IOException {
- Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
- String pollId = poll.getTopiaId();
- Request request = createRequest("/v1/polls/" + pollId).Get();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertNotNull(content);
- }
-
- @Test
- public void postPoll() throws URISyntaxException, IOException {
- Request request = createRequest("/v1/polls").
- 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();
- showTestResult(content);
- assertNotNull(content);
- }
-
- @Ignore
- @Test
- public void putPoll() throws URISyntaxException, IOException {
- Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
- String pollId = poll.getTopiaId();
- Request request = createRequest("/v1/polls/" + pollId).Put();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertNotNull(content);
- }
-
- @Test
- public void deletePoll() throws URISyntaxException, IOException {
- Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
- String pollId = poll.getTopiaId();
- Request request = createRequest("/v1/polls/" + pollId)
- .addParameter(PollenRestApiRequestFilter.REQUEST_CREDENTIAL_PARAMETER, poll.getCreator().getTopiaId())
- .Delete();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertNotNull(content);
- }
-
- @Ignore
- @Test
- public void clonePoll() throws URISyntaxException, IOException {
- Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
- String pollId = poll.getTopiaId();
- Request request = createRequest("/v1/polls/" + pollId).Post();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertNotNull(content);
- }
-
- @Ignore
- @Test
- public void exportPoll() throws URISyntaxException, IOException {
- Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
- String pollId = poll.getTopiaId();
- Request request = createRequest("/v1/polls/" + pollId + "/export").Get();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertNotNull(content);
- }
-
- @Ignore
- @Test
- public void closePoll() throws URISyntaxException, IOException {
- Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
- String pollId = poll.getTopiaId();
- Request request = createRequest("/v1/polls/" + pollId + "/close").Post();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertNotNull(content);
- }
-}
Copied: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserApiTest.java (from rev 3902, trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java)
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserApiTest.java (rev 0)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserApiTest.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -0,0 +1,105 @@
+package org.chorem.pollen.rest.api;
+
+/*
+ * #%L
+ * Pollen :: Rest Api
+ * $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.http.client.fluent.Request;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+@Ignore
+public class PollenUserApiTest extends AbstractPollenRestApiTest {
+
+ @Before
+ public void setUp() throws Exception {
+
+ loadFixtures("fixtures");
+ }
+
+ @Test
+ public void getUsers() throws Exception {
+
+ Request request = createRequest("/v1/users").Get();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertTrue(content.contains("email"));
+ }
+
+ @Test
+ public void getUser() throws Exception {
+ String userId = "";
+ Request request = createRequest("/v1/users/" + userId).Get();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertTrue(content.contains("email"));
+ }
+
+ @Ignore
+ @Test
+ public void postUser() throws Exception {
+ Request request = createRequest("/v1/users").Post();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertTrue(content.contains("email2"));
+ }
+
+ @Ignore
+ @Test
+ public void putUser() throws Exception {
+ String userId = "";
+ Request request = createRequest("/v1/users/" + userId).Get();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertTrue(content.contains("email3"));
+ }
+
+ @Ignore
+ @Test
+ public void deleteUser() throws Exception {
+ String userId = "";
+ Request request = createRequest("/v1/users/" + userId).Delete();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertTrue(content.contains("OK!"));
+ }
+
+ @Ignore
+ @Test
+ public void validateUserEmail() throws Exception {
+ String userId = "";
+ String token = "";
+ Request request = createRequest("/v1/users/" + userId + "?token=" + token).Put();
+ String content = request.execute().returnContent().asString();
+ showTestResult(content);
+ assertTrue(content.contains("OK!"));
+ }
+}
Deleted: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java 2014-05-04 00:18:39 UTC (rev 3902)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java 2014-05-04 00:37:08 UTC (rev 3903)
@@ -1,105 +0,0 @@
-package org.chorem.pollen.rest.api;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * $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.http.client.fluent.Request;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-@Ignore
-public class PollenUserServiceTest extends AbstractPollenRestApiTest {
-
- @Before
- public void setUp() throws Exception {
-
- loadFixtures("fixtures");
- }
-
- @Test
- public void getUsers() throws Exception {
-
- Request request = createRequest("/v1/users").Get();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertTrue(content.contains("email"));
- }
-
- @Test
- public void getUser() throws Exception {
- String userId = "";
- Request request = createRequest("/v1/users/" + userId).Get();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertTrue(content.contains("email"));
- }
-
- @Ignore
- @Test
- public void postUser() throws Exception {
- Request request = createRequest("/v1/users").Post();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertTrue(content.contains("email2"));
- }
-
- @Ignore
- @Test
- public void putUser() throws Exception {
- String userId = "";
- Request request = createRequest("/v1/users/" + userId).Get();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertTrue(content.contains("email3"));
- }
-
- @Ignore
- @Test
- public void deleteUser() throws Exception {
- String userId = "";
- Request request = createRequest("/v1/users/" + userId).Delete();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertTrue(content.contains("OK!"));
- }
-
- @Ignore
- @Test
- public void validateUserEmail() throws Exception {
- String userId = "";
- String token = "";
- Request request = createRequest("/v1/users/" + userId + "?token=" + token).Put();
- String content = request.execute().returnContent().asString();
- showTestResult(content);
- assertTrue(content.contains("OK!"));
- }
-}
1
0
Author: tchemit
Date: 2014-05-04 02:18:39 +0200 (Sun, 04 May 2014)
New Revision: 3902
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3902
Log:
continue dev + begin of implements correct security
Added:
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/RoleRequired.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java
Removed:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java
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/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/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/VoteCountingService.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/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-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.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/FixturesService.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/service/security/DefaultPollenSecurityContext.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/java/org/chorem/pollen/services/test/FakePollenServiceContext.java
trunk/pollen-services/src/main/resources/fixtures.yaml
trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollTopiaDao.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -23,6 +23,7 @@
* #L%
*/
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import java.util.Set;
@@ -48,5 +49,9 @@
return Sets.newHashSet();
}
+ public Set<Poll> findAllFreePolls() {
+ return ImmutableSet.copyOf(forPollTypeEquals(PollType.FREE).findAll());
+
+ }
}
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -111,16 +111,28 @@
map = toMap(model, includeCollection);
}
- Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
+ GsonBuilder gsonBuilder = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
@Override
- public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
+ public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext c) {
+ JsonElement result;
+
if (src == null) {
- return JsonNull.INSTANCE;
+ result = JsonNull.INSTANCE;
+ } else {
+ result = new JsonPrimitive(src.getTime());
}
- return new JsonPrimitive(src.getTime());
+ return result;
}
+ });
- }).create();
+ PollenRestApiApplicationContext applicationContext =
+ PollenRestApiRequestFilter.getApplicationContext(context.getServletContext());
+ boolean devMode = applicationContext.getApplicationConfig().isDevMode();
+ if (devMode) {
+ gsonBuilder.setPrettyPrinting();
+ }
+ Gson gson = gsonBuilder.create();
+
String json = gson.toJson(map);
PrintWriter out = context.getOut();
out.print(json);
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -31,8 +31,10 @@
import org.chorem.pollen.persistence.PollenPersistenceContext;
import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.persistence.entity.PollenPrincipal;
import org.chorem.pollen.persistence.entity.SessionToken;
import org.chorem.pollen.services.DefaultPollenServiceContext;
+import org.chorem.pollen.services.PollenApplicationContext;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
import org.chorem.pollen.services.exception.EntityNotFoundException;
@@ -55,7 +57,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class PollenRestApiApplicationContext implements Closeable {
+public class PollenRestApiApplicationContext implements Closeable, PollenApplicationContext {
private static Log log = LogFactory.getLog(PollenRestApiApplicationContext.class);
@@ -95,14 +97,17 @@
this.closed = new AtomicBoolean(false);
}
+ @Override
public PollenTopiaApplicationContext getTopiaApplicationContext() {
return topiaApplicationContext;
}
+ @Override
public PollenServiceConfig getApplicationConfig() {
return applicationConfig;
}
+ @Override
public PollenTopiaPersistenceContext newPersistenceContext() {
PollenTopiaPersistenceContext persistenceContext = topiaApplicationContext.newPersistenceContext();
@@ -110,6 +115,7 @@
}
+ @Override
public PollenServiceContext newServiceContext(PollenPersistenceContext persistenceContext, Locale locale) {
DefaultPollenServiceContext newServiceContext = new DefaultPollenServiceContext();
@@ -121,9 +127,10 @@
}
- public PollenSecurityContext newSecurityContext(SessionToken sessionToken) {
+ @Override
+ public PollenSecurityContext newSecurityContext(SessionToken sessionToken, PollenPrincipal mainPrincipal) {
- return DefaultPollenSecurityContext.newContext(sessionToken);
+ return DefaultPollenSecurityContext.newContext(sessionToken, mainPrincipal);
}
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -24,6 +24,8 @@
*/
import org.apache.commons.beanutils.Converter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.persistence.PollenEntityEnum;
import org.debux.webmotion.server.WebMotionServerListener;
import org.debux.webmotion.server.call.Call;
@@ -45,12 +47,13 @@
*/
public class PollenRestApiApplicationListener implements WebMotionServerListener {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(PollenRestApiApplicationListener.class);
+
@Override
public void onStart(Mapping mapping, ServerContext serverContext) {
- // ---
- // init converters
- // ---
+ // --- init converters --- //
serverContext.addConverter(new Converter() {
@Override
@@ -95,9 +98,7 @@
serverContext.addConverter(entityconverter, entityClass);
}
- // ---
- // init injectors
- // ---
+ // --- init injectors --- //
serverContext.addInjector(new ExecutorParametersInjectorHandler.Injector() {
@Override
@@ -113,9 +114,7 @@
}
});
- // ---
- // init application context
- // ---
+ // --- init application context --- //
PollenRestApiApplicationContext applicationContext =
PollenRestApiApplicationContext.getApplicationContext();
@@ -146,5 +145,4 @@
applicationContext.close();
}
}
-
}
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -53,6 +53,10 @@
serviceContext.setSecurityContext(securityContext);
}
+ public PollenSecurityContext getSecurityContext() {
+ return serviceContext.getSecurityContext();
+ }
+
public AuthService getAuthService() {
return serviceContext.newService(AuthService.class);
}
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -23,19 +23,25 @@
* #L%
*/
-import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.entity.PollenPrincipal;
import org.chorem.pollen.persistence.entity.SessionToken;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.exception.InvalidSessionTokenException;
import org.chorem.pollen.services.service.security.PollenSecurityContext;
+import org.chorem.pollen.services.service.security.SecurityRole;
+import org.chorem.pollen.services.service.security.SecurityService;
import org.debux.webmotion.server.WebMotionFilter;
+import org.debux.webmotion.server.call.Call;
import org.debux.webmotion.server.call.HttpContext;
+import org.debux.webmotion.server.mapping.Mapping;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.lang.reflect.Method;
import java.util.Locale;
+import java.util.Map;
/**
* Inject {@link PollenRestApiRequestContext} in services.
@@ -53,6 +59,8 @@
public static final String REQUEST_AUTH_PARAMETER = "auth";
+ public static final String REQUEST_CREDENTIAL_PARAMETER = "credential";
+
public static PollenRestApiApplicationContext getApplicationContext(ServletContext servletContext) {
PollenRestApiApplicationContext result = (PollenRestApiApplicationContext)
servletContext.getAttribute(APPLICATION_CONTEXT_PARAMETER);
@@ -86,7 +94,7 @@
request.setAttribute(REQUEST_POLLEN_CONNECTED_USER, sessionToken);
}
- public void inject(HttpContext context) throws InvalidSessionTokenException {
+ public void inject(Call call, HttpContext context) throws InvalidSessionTokenException {
PollenRestApiApplicationContext applicationContext =
getApplicationContext(context.getServletContext());
@@ -101,10 +109,10 @@
PollenRestApiRequestContext requestContext = new PollenRestApiRequestContext();
requestContext.setServiceContext(serviceContext);
+ prepareSecurityContext(call, context, applicationContext, requestContext);
+
setRequestContext(context.getRequest(), requestContext);
- addSecurityContext(context, applicationContext, requestContext);
-
doProcess();
HttpServletResponse response = context.getResponse();
@@ -112,24 +120,75 @@
response.addHeader(HttpContext.HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
}
- protected void addSecurityContext(HttpContext context,
- PollenRestApiApplicationContext applicationContext,
- PollenRestApiRequestContext serviceContext) throws InvalidSessionTokenException {
+ @Override
+ public void doProcess() {
+ super.doProcess();
+ }
- String[] strings = context.getParameters().get(REQUEST_AUTH_PARAMETER);
+ @Override
+ public void doProcess(Mapping mapping, Call call) {
+ super.doProcess(mapping, call);
+ }
- String authParam = strings == null || strings.length < 1 ? null : strings[0];
+ protected void prepareSecurityContext(Call call,
+ HttpContext httpContext,
+ PollenRestApiApplicationContext applicationContext,
+ PollenRestApiRequestContext requestContext) throws InvalidSessionTokenException {
- SessionToken sessionToken = null;
+ // --- Create security context --- //
+ PollenSecurityContext securityContext = createSecurityContext(
+ httpContext,
+ applicationContext,
+ requestContext);
- if (StringUtils.isNotBlank(authParam)) {
+ requestContext.setSecurityContext(securityContext);
- // find out the userId from this auth
+ SecurityService securityService = requestContext.getSecurityService();
- sessionToken = serviceContext.getAuthService().getUserByAuth(authParam);
+ Method method = call.getExecutor().getMethod();
+
+ // --- Check roles --- //
+
+ boolean needRole = method.isAnnotationPresent(RoleRequired.class);
+ if (needRole) {
+ RoleRequired roleAnnotation = method.getAnnotation(RoleRequired.class);
+ SecurityRole roleName = roleAnnotation.value();
+
+ securityService.checkRole(roleName);
}
+
+ }
+
+ protected PollenSecurityContext createSecurityContext(HttpContext context,
+ PollenRestApiApplicationContext applicationContext,
+ PollenRestApiRequestContext pollenRestApiRequestContext) throws InvalidSessionTokenException {
+
+ SecurityService securityService = pollenRestApiRequestContext.getSecurityService();
+
+ Map<String, String[]> parameters = context.getParameters();
+
+ // get session token
+ SessionToken sessionToken;
+ {
+
+ String[] strings = parameters.get(REQUEST_AUTH_PARAMETER);
+ String authParam = strings == null || strings.length < 1 ? null : strings[0];
+ sessionToken = securityService.getSessionTokenByToken(authParam);
+ }
+
+ // get mainPrincipal
+ PollenPrincipal mainPrincipal;
+ {
+
+ String[] strings = parameters.get(REQUEST_CREDENTIAL_PARAMETER);
+ String credentialParam = strings == null || strings.length < 1 ? null : strings[0];
+ mainPrincipal = securityService.getPollenPrincipalById(credentialParam);
+ }
+
PollenSecurityContext securityContext =
- applicationContext.newSecurityContext(sessionToken);
- serviceContext.setSecurityContext(securityContext);
+ applicationContext.newSecurityContext(sessionToken, mainPrincipal);
+
+ return securityContext;
}
+
}
Added: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/RoleRequired.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/RoleRequired.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/RoleRequired.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -0,0 +1,22 @@
+package org.chorem.pollen.rest.api;
+
+import org.chorem.pollen.services.service.security.SecurityRole;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Created on 5/3/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+(a)Target(ElementType.METHOD)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface RoleRequired {
+
+ SecurityRole value();
+
+}
Property changes on: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/RoleRequired.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -39,28 +39,26 @@
public class ChoiceService extends WebMotionController {
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) {
- context.getSecurityService().prepareSubject(choiceId);
- return context.getChoiceService().getChoice(pollId, choiceId);
+ Choice choice = context.getChoiceService().getChoice(pollId, choiceId);
+ return choice;
}
public Choice addChoice(PollenRestApiRequestContext context, String pollId, Choice choice) throws InvalidFormException {
- context.getSecurityService().prepareSubject(pollId);
- return context.getChoiceService().addChoice(pollId, choice);
+ Choice createdChoice = context.getChoiceService().addChoice(pollId, choice);
+ return createdChoice;
}
public Choice editChoice(PollenRestApiRequestContext context, String pollId, Choice choice) throws InvalidFormException {
- context.getSecurityService().prepareSubject(choice);
- return context.getChoiceService().editChoice(pollId, choice);
+ Choice editedChoice = context.getChoiceService().editChoice(pollId, choice);
+ return editedChoice;
}
public void deleteChoice(PollenRestApiRequestContext context, String pollId, String choiceId) {
- context.getSecurityService().prepareSubject(choiceId);
context.getChoiceService().deleteChoice(pollId, choiceId);
}
}
\ No newline at end of file
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -39,28 +39,26 @@
public class CommentService extends WebMotionController {
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) {
- context.getSecurityService().prepareSubject(commentId);
- return context.getCommentService().getComment(pollId, commentId);
+ Comment comment = context.getCommentService().getComment(pollId, commentId);
+ return comment;
}
public Comment addComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidFormException {
- context.getSecurityService().prepareSubject(pollId);
- return context.getCommentService().addComment(pollId, comment);
+ Comment createdComment = context.getCommentService().addComment(pollId, comment);
+ return createdComment;
}
public Comment editComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidFormException {
- context.getSecurityService().prepareSubject(comment);
- return context.getCommentService().editComment(pollId, comment);
+ Comment editedComment = context.getCommentService().editComment(pollId, comment);
+ return editedComment;
}
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/FavoriteListService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java 2014-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -26,8 +26,10 @@
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.rest.api.RoleRequired;
import org.chorem.pollen.services.exception.FavoriteListImportException;
import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.security.SecurityRole;
import org.debux.webmotion.server.WebMotionController;
import java.io.File;
@@ -42,53 +44,73 @@
*/
public class FavoriteListService extends WebMotionController {
- public List<FavoriteList> getFavoriteLists(PollenRestApiRequestContext context, String userId) {
- List<FavoriteList> favoriteLists = context.getFavoriteListService().getFavoriteLists(userId);
+ @RoleRequired(SecurityRole.connected)
+ public List<FavoriteList> getFavoriteLists(PollenRestApiRequestContext context) {
+ List<FavoriteList> favoriteLists = context.getFavoriteListService().getFavoriteLists();
return favoriteLists;
}
- public FavoriteList getFavoriteList(PollenRestApiRequestContext context, String userId, String favoriteListId) {
- return context.getFavoriteListService().getFavoriteList(userId, favoriteListId);
+ @RoleRequired(SecurityRole.connected)
+ public FavoriteList getFavoriteList(PollenRestApiRequestContext context, String favoriteListId) {
+ FavoriteList favoriteList = context.getFavoriteListService().getFavoriteList(favoriteListId);
+ return favoriteList;
}
- public FavoriteList createFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws InvalidFormException {
- return context.getFavoriteListService().createFavoriteList(userId, favoriteList);
+ @RoleRequired(SecurityRole.connected)
+ public FavoriteList createFavoriteList(PollenRestApiRequestContext context, FavoriteList favoriteList) throws InvalidFormException {
+ FavoriteList createdFavoriteList = context.getFavoriteListService().createFavoriteList(favoriteList);
+ return createdFavoriteList;
}
- public FavoriteList editFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws InvalidFormException {
- return context.getFavoriteListService().editFavoriteList(userId, favoriteList);
+ @RoleRequired(SecurityRole.connected)
+ public FavoriteList editFavoriteList(PollenRestApiRequestContext context, FavoriteList favoriteList) throws InvalidFormException {
+ FavoriteList editedFavoriteList = context.getFavoriteListService().editFavoriteList(favoriteList);
+ return editedFavoriteList;
}
- public void deleteFavoriteList(PollenRestApiRequestContext context, String userId, String favoriteListId) {
- context.getFavoriteListService().deleteFavoriteList(userId, favoriteListId);
+ @RoleRequired(SecurityRole.connected)
+ public void deleteFavoriteList(PollenRestApiRequestContext context, String favoriteListId) {
+ context.getFavoriteListService().deleteFavoriteList(favoriteListId);
}
- public int importFavoriteListMembersFromCsv(PollenRestApiRequestContext context, String userId, String favoriteListId, File csvFile) throws FavoriteListImportException {
- return context.getFavoriteListService().importFavoriteListMembersFromCsv(userId, favoriteListId, csvFile);
+ @RoleRequired(SecurityRole.connected)
+ public int importFavoriteListMembersFromCsv(PollenRestApiRequestContext context, String favoriteListId, File csvFile) throws FavoriteListImportException {
+ int i = context.getFavoriteListService().importFavoriteListMembersFromCsv(favoriteListId, csvFile);
+ return i;
}
- public int importFavoriteListMembersFromLdap(PollenRestApiRequestContext context, String userId, String favoriteListId, String ldap) throws FavoriteListImportException {
- return context.getFavoriteListService().importFavoriteListMembersFromLdap(userId, favoriteListId, ldap);
+ @RoleRequired(SecurityRole.connected)
+ public int importFavoriteListMembersFromLdap(PollenRestApiRequestContext context, String favoriteListId, String ldap) throws FavoriteListImportException {
+ int i = context.getFavoriteListService().importFavoriteListMembersFromLdap(favoriteListId, ldap);
+ return i;
}
- public LinkedHashSet<FavoriteListMember> getMembers(PollenRestApiRequestContext context, String userId, String favoriteListId) {
- LinkedHashSet<FavoriteListMember> members = context.getFavoriteListService().getFavoriteListMembers(userId, favoriteListId);
+ @RoleRequired(SecurityRole.connected)
+ public LinkedHashSet<FavoriteListMember> getMembers(PollenRestApiRequestContext context, String favoriteListId) {
+ LinkedHashSet<FavoriteListMember> members = context.getFavoriteListService().getFavoriteListMembers(favoriteListId);
return members;
}
- public FavoriteListMember getMember(PollenRestApiRequestContext context, String userId, String favoriteListId, String memberId) {
- return context.getFavoriteListService().getFavoriteListMember(userId, favoriteListId, memberId);
+ @RoleRequired(SecurityRole.connected)
+ public FavoriteListMember getMember(PollenRestApiRequestContext context, String favoriteListId, String memberId) {
+ FavoriteListMember member = context.getFavoriteListService().getFavoriteListMember(favoriteListId, memberId);
+ return member;
}
- public FavoriteListMember addMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws InvalidFormException {
- return context.getFavoriteListService().addFavoriteListMember(userId, favoriteListId, member);
+ @RoleRequired(SecurityRole.connected)
+ public FavoriteListMember addMember(PollenRestApiRequestContext context, String favoriteListId, FavoriteListMember member) throws InvalidFormException {
+ FavoriteListMember createdMember = context.getFavoriteListService().addFavoriteListMember(favoriteListId, member);
+ return createdMember;
}
- public FavoriteListMember editMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws InvalidFormException {
- return context.getFavoriteListService().editFavoriteListMember(userId, favoriteListId, member);
+ @RoleRequired(SecurityRole.connected)
+ public FavoriteListMember editMember(PollenRestApiRequestContext context, String favoriteListId, FavoriteListMember member) throws InvalidFormException {
+ FavoriteListMember editedMember = context.getFavoriteListService().editFavoriteListMember(favoriteListId, member);
+ return editedMember;
}
- public void removeMember(PollenRestApiRequestContext context, String userId, String favoriteListId, String memberId) {
- context.getFavoriteListService().removeFavoriteListMember(userId, favoriteListId, memberId);
+ @RoleRequired(SecurityRole.connected)
+ public void removeMember(PollenRestApiRequestContext context, String favoriteListId, String memberId) {
+ context.getFavoriteListService().removeFavoriteListMember(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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -25,7 +25,9 @@
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
+import org.chorem.pollen.rest.api.RoleRequired;
import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.security.SecurityRole;
import org.debux.webmotion.server.WebMotionController;
import java.io.File;
@@ -40,60 +42,64 @@
public class PollService extends WebMotionController {
public Poll getNewPoll(PollenRestApiRequestContext context) {
- return context.getPollService().getNewPoll();
+ Poll newPoll = context.getPollService().getNewPoll();
+ return newPoll;
}
+ @RoleRequired(SecurityRole.administrator)
public Set<Poll> getPolls(PollenRestApiRequestContext context) {
Set<Poll> polls = context.getPollService().getPolls();
return polls;
}
+ @RoleRequired(SecurityRole.connected)
public Set<Poll> getCreatedPolls(PollenRestApiRequestContext context) {
Set<Poll> polls = context.getPollService().getCreatedPolls();
return polls;
}
+ @RoleRequired(SecurityRole.connected)
public Set<Poll> getInvitedPolls(PollenRestApiRequestContext context) {
Set<Poll> polls = context.getPollService().getInvitedPolls();
return polls;
}
+ @RoleRequired(SecurityRole.connected)
public Set<Poll> getParticipatedPolls(PollenRestApiRequestContext context) {
Set<Poll> polls = context.getPollService().getParticipatedPolls();
return polls;
}
public Poll getPoll(PollenRestApiRequestContext context, String pollId) {
- context.getSecurityService().prepareSubject((String) null);
- return context.getPollService().getPoll(pollId);
+ Poll poll = context.getPollService().getPoll(pollId);
+ return poll;
}
public Poll createPoll(PollenRestApiRequestContext context, Poll poll) throws InvalidFormException {
- return context.getPollService().createPoll(poll);
+ Poll createdPoll = context.getPollService().createPoll(poll);
+ return createdPoll;
}
public Poll editPoll(PollenRestApiRequestContext context, Poll poll) throws InvalidFormException {
- context.getSecurityService().prepareSubject(poll);
- return context.getPollService().editPoll(poll);
+ Poll editedPoll = context.getPollService().editPoll(poll);
+ return editedPoll;
}
public void deletePoll(PollenRestApiRequestContext context, String pollId) {
- context.getSecurityService().prepareSubject(pollId);
context.getPollService().deletePoll(pollId);
}
public Poll clonePoll(PollenRestApiRequestContext context, String pollId) {
- context.getSecurityService().prepareSubject(pollId);
- return context.getPollService().clonePoll(pollId);
+ Poll clonedPoll = context.getPollService().clonePoll(pollId);
+ return clonedPoll;
}
public void closePoll(PollenRestApiRequestContext context, String pollId) {
- context.getSecurityService().prepareSubject(pollId);
context.getPollService().closePoll(pollId);
}
public File exportPoll(PollenRestApiRequestContext context, String pollId) {
- context.getSecurityService().prepareSubject(pollId);
- return context.getPollService().exportPoll(pollId);
+ File exportedPollFile = context.getPollService().exportPoll(pollId);
+ return exportedPollFile;
}
}
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -25,9 +25,11 @@
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
+import org.chorem.pollen.rest.api.RoleRequired;
import org.chorem.pollen.services.exception.InvalidFormException;
import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
import org.chorem.pollen.services.exception.UserInvalidPasswordException;
+import org.chorem.pollen.services.service.security.SecurityRole;
import org.debux.webmotion.server.WebMotionController;
import java.util.List;
@@ -40,25 +42,29 @@
*/
public class PollenUserService extends WebMotionController {
+ @RoleRequired(SecurityRole.administrator)
public List<PollenUser> getUsers(PollenRestApiRequestContext context) {
List<PollenUser> users = context.getPollenUserService().getUsers();
return users;
}
public PollenUser getUser(PollenRestApiRequestContext context, String userId) {
- return context.getPollenUserService().getUser(userId);
+ PollenUser user = context.getPollenUserService().getUser(userId);
+ return user;
}
public PollenUser createUser(PollenRestApiRequestContext context,
PollenUser user,
boolean generatePassword) throws InvalidFormException {
- return context.getPollenUserService().createUser(user, generatePassword);
+ PollenUser createdUser = context.getPollenUserService().createUser(user, generatePassword);
+ return createdUser;
}
public PollenUser editUser(PollenRestApiRequestContext context,
PollenUser user) throws InvalidFormException {
- return context.getPollenUserService().editUser(user);
+ PollenUser editedUser = context.getPollenUserService().editUser(user);
+ return editedUser;
}
public void deleteUser(PollenRestApiRequestContext context, String userId) throws InvalidFormException {
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java 2014-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -36,6 +36,7 @@
public class VoteCountingService extends WebMotionController {
public PollResult getResult(PollenRestApiRequestContext context, String pollId) {
- return context.getVoteCountingService().getResult(pollId);
+ PollResult result = context.getVoteCountingService().getResult(pollId);
+ return result;
}
}
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -39,28 +39,26 @@
public class VoteService extends WebMotionController {
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) {
- context.getSecurityService().prepareSubject(voteId);
- return context.getVoteService().getVote(pollId, voteId);
+ Vote vote = context.getVoteService().getVote(pollId, voteId);
+ return vote;
}
public Vote addVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidFormException {
- context.getSecurityService().prepareSubject(pollId);
- return context.getVoteService().addVote(pollId, vote);
+ Vote createdVote = context.getVoteService().addVote(pollId, vote);
+ return createdVote;
}
public Vote editVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidFormException {
- context.getSecurityService().prepareSubject(vote);
- return context.getVoteService().editVote(pollId, vote);
+ Vote editedVote = context.getVoteService().editVote(pollId, vote);
+ return editedVote;
}
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -26,7 +26,9 @@
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.rest.api.RoleRequired;
import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.security.SecurityRole;
import org.debux.webmotion.server.WebMotionController;
import java.util.List;
@@ -40,59 +42,57 @@
*/
public class VoterListService extends WebMotionController {
- public VoterList importFavoriteList(PollenRestApiRequestContext context, String userId, String pollId, String favoriteListId) {
- return context.getVoterListService().importFavoriteList(userId, pollId, favoriteListId);
+ @RoleRequired(SecurityRole.connected)
+ public VoterList importFavoriteList(PollenRestApiRequestContext context, String pollId, String favoriteListId) {
+ VoterList importVoterList = context.getVoterListService().importFavoriteList(pollId, favoriteListId);
+ return importVoterList;
}
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) {
- context.getSecurityService().prepareSubject(voterListId);
- return context.getVoterListService().getVoterList(pollId, voterListId);
+ VoterList voterList = context.getVoterListService().getVoterList(pollId, voterListId);
+ return voterList;
}
public VoterList createVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidFormException {
- context.getSecurityService().prepareSubject(pollId);
- return context.getVoterListService().addVoterList(pollId, voterList);
+ VoterList createdVoterList = context.getVoterListService().addVoterList(pollId, voterList);
+ return createdVoterList;
}
public VoterList editVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidFormException {
- context.getSecurityService().prepareSubject(voterList);
- return context.getVoterListService().editVoterList(pollId, voterList);
+ VoterList editedVoterList = context.getVoterListService().editVoterList(pollId, voterList);
+ return editedVoterList;
}
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) {
- 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) {
- context.getSecurityService().prepareSubject(memberId);
- return context.getVoterListService().getVoterListMember(pollId, voterListId, memberId);
+ VoterListMember member = context.getVoterListService().getVoterListMember(pollId, voterListId, memberId);
+ return member;
}
public VoterListMember addMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidFormException {
- context.getSecurityService().prepareSubject(member);
- return context.getVoterListService().addVoterListMember(pollId, voterListId, member);
+ VoterListMember createdMember = context.getVoterListService().addVoterListMember(pollId, voterListId, member);
+ return createdMember;
}
public VoterListMember editMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidFormException {
- context.getSecurityService().prepareSubject(member);
- return context.getVoterListService().editVoterListMember(pollId, voterListId, member);
+ VoterListMember editedMember = context.getVoterListService().editVoterListMember(pollId, voterListId, member);
+ return editedMember;
}
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/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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -23,24 +23,22 @@
* #L%
*/
-import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.entity.PollenPrincipal;
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.FakePollenApplicationContext;
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;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.nuiton.util.DateUtil;
-import java.io.File;
import java.io.IOException;
import java.util.Locale;
@@ -56,8 +54,13 @@
private static final Log log = LogFactory.getLog(AbstractPollenRestApiTest.class);
@Rule
- public final PollenApplication application = new PollenApplication("pollen-rest-api.properties");
+ public final FakePollenApplicationContext application = new FakePollenApplicationContext("pollen-rest-api.properties");
+ @Override
+ protected int getPort() {
+ return application.getPort();
+ }
+
protected void loadFixtures(String fixturesSetName) {
PollenRestApiApplicationContext applicationContext = PollenRestApiApplicationContext.getApplicationContext();
@@ -76,24 +79,26 @@
public void startServer() throws Exception {
PollenRestApiApplicationContext applicationContext =
- new PollenRestApiApplicationContext(application.getConfiguration(),
- application.getApplicationContext()) {
+ new PollenRestApiApplicationContext(application.getApplicationConfig(),
+ application.getTopiaApplicationContext()) {
@Override
public PollenServiceContext newServiceContext(PollenPersistenceContext persistenceContext, Locale locale) {
FakePollenServiceContext serviceContext = FakePollenServiceContext.newServiceContext(
DateUtil.createDate(1, 1, 2014),
Locale.FRANCE,
- application.getConfiguration(),
- application.getApplicationContext(),
- application.newPersistenceContext(),
- new FakePollenSecurityContext());
+ application.getApplicationConfig(),
+ application.getTopiaApplicationContext(),
+ application.newPersistenceContext());
return serviceContext;
}
@Override
- public PollenSecurityContext newSecurityContext(SessionToken sessionToken) {
- return new FakePollenSecurityContext();
+ public PollenSecurityContext newSecurityContext(SessionToken sessionToken, PollenPrincipal mainPrincipal) {
+ FakePollenSecurityContext securityContext = new FakePollenSecurityContext();
+ securityContext.setMainPrincipal(mainPrincipal);
+ securityContext.setSessionToken(sessionToken);
+ return securityContext;
}
};
applicationContext.init();
@@ -118,16 +123,19 @@
server.destroy();
}
- protected void saveTestResult(String content) throws IOException {
+ protected void showTestResult(String content) throws IOException {
String testName = application.getMethodName();
-
- PollenServiceConfig applicationConfig = PollenRestApiApplicationContext.getApplicationContext().getApplicationConfig();
- File dataDirectory = applicationConfig.getDataDirectory();
- File resultFile = new File(dataDirectory, testName);
- FileUtils.write(resultFile, content);
if (log.isInfoEnabled()) {
- log.info("ResultFile: " + resultFile);
+ log.info("test *" + testName + "* result\n" + content);
}
+
+// PollenServiceConfig applicationConfig = PollenRestApiApplicationContext.getTopiaApplicationContext().getApplicationConfig();
+// File dataDirectory = applicationConfig.getDataDirectory();
+// File resultFile = new File(dataDirectory, testName);
+// FileUtils.write(resultFile, content);
+// if (log.isInfoEnabled()) {
+// log.info("ResultFile: " + resultFile);
+// }
}
}
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -6,6 +6,7 @@
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.PollType;
import org.chorem.pollen.persistence.entity.VoteVisibility;
+import org.chorem.pollen.services.PollenFixtures;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -21,7 +22,6 @@
* @author Tony Chemit <chemit(a)codelutin.com>
* @since 2.0
*/
-@Ignore
public class PollServiceTest extends AbstractPollenRestApiTest {
@Before
@@ -34,49 +34,55 @@
public void getPollsNew() throws URISyntaxException, IOException {
Request request = createRequest("/v1/polls/new").Get();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertNotNull(content);
}
+ @Ignore
@Test
public void getPolls() throws URISyntaxException, IOException {
+
+ //TODO Login as admin before
Request request = createRequest("/v1/polls").Get();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertNotNull(content);
}
+ @Ignore
@Test
public void getPollsCreated() throws URISyntaxException, IOException {
Request request = createRequest("/v1/polls/created").Get();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertNotNull(content);
}
+ @Ignore
@Test
public void getPollsInvited() throws URISyntaxException, IOException {
Request request = createRequest("/v1/polls/invited").Get();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertNotNull(content);
}
+ @Ignore
@Test
public void getPollsParticipated() throws URISyntaxException, IOException {
Request request = createRequest("/v1/polls/participated").Get();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertNotNull(content);
}
@Test
public void getPoll() throws URISyntaxException, IOException {
- Poll poll = fixture("poll_simplePoll");
+ Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
String pollId = poll.getTopiaId();
Request request = createRequest("/v1/polls/" + pollId).Get();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertNotNull(content);
}
@@ -94,62 +100,63 @@
addParameter("poll.choice[0].name", "choiceA").
Post();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertNotNull(content);
}
@Ignore
@Test
public void putPoll() throws URISyntaxException, IOException {
- Poll poll = fixture("poll_simplePoll");
+ Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
String pollId = poll.getTopiaId();
Request request = createRequest("/v1/polls/" + pollId).Put();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertNotNull(content);
}
- @Ignore
@Test
public void deletePoll() throws URISyntaxException, IOException {
- Poll poll = fixture("poll_simplePoll");
+ Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
String pollId = poll.getTopiaId();
- Request request = createRequest("/v1/polls/" + pollId).Delete();
+ Request request = createRequest("/v1/polls/" + pollId)
+ .addParameter(PollenRestApiRequestFilter.REQUEST_CREDENTIAL_PARAMETER, poll.getCreator().getTopiaId())
+ .Delete();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertNotNull(content);
}
@Ignore
@Test
public void clonePoll() throws URISyntaxException, IOException {
- Poll poll = fixture("poll_simplePoll");
+ Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
String pollId = poll.getTopiaId();
Request request = createRequest("/v1/polls/" + pollId).Post();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertNotNull(content);
}
@Ignore
@Test
public void exportPoll() throws URISyntaxException, IOException {
- Poll poll = fixture("poll_simplePoll");
+ Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
String pollId = poll.getTopiaId();
Request request = createRequest("/v1/polls/" + pollId + "/export").Get();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertNotNull(content);
}
@Ignore
@Test
public void closePoll() throws URISyntaxException, IOException {
- Poll poll = fixture("poll_simplePoll");
+ Poll poll = fixture(PollenFixtures.POLL_NORMAL_ID);
String pollId = poll.getTopiaId();
Request request = createRequest("/v1/polls/" + pollId + "/close").Post();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertNotNull(content);
}
}
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java 2014-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -50,7 +50,7 @@
Request request = createRequest("/v1/users").Get();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertTrue(content.contains("email"));
}
@@ -59,7 +59,7 @@
String userId = "";
Request request = createRequest("/v1/users/" + userId).Get();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertTrue(content.contains("email"));
}
@@ -68,7 +68,7 @@
public void postUser() throws Exception {
Request request = createRequest("/v1/users").Post();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertTrue(content.contains("email2"));
}
@@ -78,7 +78,7 @@
String userId = "";
Request request = createRequest("/v1/users/" + userId).Get();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertTrue(content.contains("email3"));
}
@@ -88,7 +88,7 @@
String userId = "";
Request request = createRequest("/v1/users/" + userId).Delete();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertTrue(content.contains("OK!"));
}
@@ -99,7 +99,7 @@
String token = "";
Request request = createRequest("/v1/users/" + userId + "?token=" + token).Put();
String content = request.execute().returnContent().asString();
- saveTestResult(content);
+ showTestResult(content);
assertTrue(content.contains("OK!"));
}
}
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -0,0 +1,30 @@
+package org.chorem.pollen.services;
+
+import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.persistence.entity.PollenPrincipal;
+import org.chorem.pollen.persistence.entity.SessionToken;
+import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.chorem.pollen.services.service.security.PollenSecurityContext;
+
+import java.util.Locale;
+
+/**
+ * Created on 5/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public interface PollenApplicationContext {
+
+ PollenTopiaApplicationContext getTopiaApplicationContext();
+
+ PollenServiceConfig getApplicationConfig();
+
+ PollenTopiaPersistenceContext newPersistenceContext();
+
+ PollenServiceContext newServiceContext(PollenPersistenceContext persistenceContext, Locale locale);
+
+ PollenSecurityContext newSecurityContext(SessionToken sessionToken, PollenPrincipal mainPrincipal);
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
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-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenFixtures.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -45,6 +45,8 @@
public class PollenFixtures {
+ public static final String POLL_NORMAL_ID = "poll_normal";
+
protected Map<String, Object> fixtures;
public PollenFixtures(String fixturesName) {
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -30,7 +30,6 @@
import org.chorem.pollen.persistence.entity.SessionToken;
import org.chorem.pollen.persistence.entity.SessionTokenTopiaDao;
import org.chorem.pollen.services.exception.EntityNotFoundException;
-import org.chorem.pollen.services.exception.InvalidSessionTokenException;
import org.chorem.pollen.services.exception.UserInvalidPasswordException;
/**
@@ -104,14 +103,4 @@
commit();
}
- public SessionToken getUserByAuth(String authParam) throws InvalidSessionTokenException {
-
- SessionToken sessionToken = getSessionTokenDao().findByTopiaId(authParam);
- if (sessionToken == null) {
- throw new InvalidSessionTokenException();
- }
-
- return sessionToken;
- }
-
}
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -56,7 +56,7 @@
public Choice getChoice(String pollId, String choiceId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choiceId);
- checkPermission(PermissionVerb.editChoice, choiceId);
+ checkPermission(PermissionVerb.readChoice, choiceId);
Poll poll = getPollService().getPoll(pollId);
Choice result = getChoice(poll, choiceId);
@@ -69,7 +69,7 @@
checkIsNotPersisted(choice);
Poll poll = getPollService().getPoll(pollId);
- checkPermission(PermissionVerb.addChoice, pollId);
+ checkPermission(PermissionVerb.editPoll, pollId);
checkChoiceForm(poll, choice);
@@ -138,7 +138,7 @@
choiceToPersist = choiceDao.newInstance();
// create a new principal
- PollenPrincipal principal = getSecurityService().generatePrincipal();
+ PollenPrincipal principal = getSecurityService().generatePollenPrincipal();
PollenPrincipal creator = choice.getCreator();
if (creator != null) {
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -148,7 +148,7 @@
// -- author -- //
- PollenPrincipal author = getSecurityService().generatePrincipal();
+ PollenPrincipal author = getSecurityService().generatePollenPrincipal();
toSave.setAuthor(author);
poll.addComment(toSave);
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -65,31 +65,29 @@
*/
public class FavoriteListService extends PollenServiceSupport {
- public List<FavoriteList> getFavoriteLists(String userId) {
- Preconditions.checkNotNull(userId);
- PollenUser user = getUserService().getUser(userId);
+ public List<FavoriteList> getFavoriteLists() {
+ PollenUser user = getConnectedUser();
List<FavoriteList> result = user.getFavoriteList();
return result;
}
- public FavoriteList getFavoriteList(String userId, String favoriteListId) {
- Preconditions.checkNotNull(userId);
+ public FavoriteList getFavoriteList(String favoriteListId) {
+
Preconditions.checkNotNull(favoriteListId);
- PollenUser user = getUserService().getUser(userId);
+ PollenUser user = getConnectedUser();
FavoriteList result = getFavoriteList(user, favoriteListId);
return result;
}
- public FavoriteList createFavoriteList(String userId,
- FavoriteList favoriteList) throws InvalidFormException {
- Preconditions.checkNotNull(userId);
+ public FavoriteList createFavoriteList(FavoriteList favoriteList) throws InvalidFormException {
+
Preconditions.checkNotNull(favoriteList);
checkIsNotPersisted(favoriteList);
- PollenUser user = getUserService().getUser(userId);
+ PollenUser user = getConnectedUser();
checkFavoriteListForm(user, favoriteList);
@@ -103,13 +101,12 @@
return toSave;
}
- public FavoriteList editFavoriteList(String userId,
- FavoriteList favoriteList) throws InvalidFormException {
+ public FavoriteList editFavoriteList(FavoriteList favoriteList) throws InvalidFormException {
Preconditions.checkNotNull(favoriteList);
checkIsPersisted(favoriteList);
// get user
- PollenUser user = getUserService().getUser(userId);
+ PollenUser user = getConnectedUser();
// get list to save
FavoriteList toSave = getFavoriteList(user, favoriteList.getTopiaId());
@@ -124,11 +121,11 @@
return toSave;
}
- public void deleteFavoriteList(String userId, String favoriteListId) {
- Preconditions.checkNotNull(userId);
+ public void deleteFavoriteList(String favoriteListId) {
+
Preconditions.checkNotNull(favoriteListId);
- PollenUser user = getUserService().getUser(userId);
+ PollenUser user = getConnectedUser();
FavoriteList persisted = getFavoriteList(user, favoriteListId);
@@ -138,23 +135,23 @@
commit();
}
- public LinkedHashSet<FavoriteListMember> getFavoriteListMembers(String userId, String favoriteListId) {
- Preconditions.checkNotNull(userId);
+ public LinkedHashSet<FavoriteListMember> getFavoriteListMembers(String favoriteListId) {
+
Preconditions.checkNotNull(favoriteListId);
- PollenUser user = getUserService().getUser(userId);
+ PollenUser user = getConnectedUser();
FavoriteList favoriteList = getFavoriteList(user, favoriteListId);
return favoriteList.getMember();
}
- public FavoriteListMember getFavoriteListMember(String userId, String favoriteListId, String memberId) {
- Preconditions.checkNotNull(userId);
+ public FavoriteListMember getFavoriteListMember(String favoriteListId, String memberId) {
+
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(memberId);
- PollenUser user = getUserService().getUser(userId);
+ PollenUser user = getConnectedUser();
FavoriteList favoriteList = getFavoriteList(user, favoriteListId);
@@ -162,15 +159,14 @@
return result;
}
- public FavoriteListMember addFavoriteListMember(String userId,
- String favoriteListId,
+ public FavoriteListMember addFavoriteListMember(String favoriteListId,
FavoriteListMember member) throws InvalidFormException {
- Preconditions.checkNotNull(userId);
+
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(member);
checkIsNotPersisted(member);
- PollenUser user = getUserService().getUser(userId);
+ PollenUser user = getConnectedUser();
FavoriteList favoriteList = getFavoriteList(user, favoriteListId);
@@ -187,16 +183,15 @@
return newMember;
}
- public FavoriteListMember editFavoriteListMember(String userId,
- String favoriteListId,
+ public FavoriteListMember editFavoriteListMember(String favoriteListId,
FavoriteListMember member) throws InvalidFormException {
- Preconditions.checkNotNull(userId);
+
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(member);
checkIsPersisted(member);
- PollenUser user = getUserService().getUser(userId);
+ PollenUser user = getConnectedUser();
FavoriteList favoriteList = getFavoriteList(user, favoriteListId);
@@ -214,14 +209,13 @@
return toSave;
}
- public void removeFavoriteListMember(String userId,
- String favoriteListId,
+ public void removeFavoriteListMember(String favoriteListId,
String memberId) {
- Preconditions.checkNotNull(userId);
+
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(memberId);
- PollenUser user = getUserService().getUser(userId);
+ PollenUser user = getConnectedUser();
FavoriteList favoriteList = getFavoriteList(user, favoriteListId);
@@ -233,14 +227,13 @@
commit();
}
- public int importFavoriteListMembersFromCsv(String userId,
- String favoriteListId,
+ public int importFavoriteListMembersFromCsv(String favoriteListId,
File file) throws FavoriteListImportException {
- Preconditions.checkNotNull(userId);
+
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(file);
- PollenUser user = getUserService().getUser(userId);
+ PollenUser user = getConnectedUser();
FavoriteList favoriteList = getFavoriteList(user, favoriteListId);
@@ -332,13 +325,12 @@
return result;
}
- public int importFavoriteListMembersFromLdap(String userId,
- String favoriteListId,
+ public int importFavoriteListMembersFromLdap(String favoriteListId,
String ldap) throws FavoriteListImportException {
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(ldap);
- PollenUser user = getUserService().getUser(userId);
+ PollenUser user = getConnectedUser();
FavoriteList favoriteList = getFavoriteList(user, favoriteListId);
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java 2014-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -29,9 +29,12 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.persistence.PollenPersistenceContext;
import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
+import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.persistence.entity.PollenUserTopiaDao;
import org.chorem.pollen.services.PollenFixtures;
+import org.chorem.pollen.services.PollenTechnicalException;
+import org.chorem.pollen.services.exception.InvalidFormException;
import java.util.Collection;
import java.util.Map;
@@ -90,9 +93,26 @@
for (PollenUser user : users) {
user.setPassword(serviceContext.encodePassword(user.getPassword()));
- userDao.create(user);
+ PollenUser createdUser = userDao.create(user);
+ user.setTopiaId(createdUser.getTopiaId());
}
+ PollService pollService = newService(PollService.class);
+
+ Collection<Poll> polls = fixtures.fixture("polls");
+
+ for (Poll poll : polls) {
+
+ try {
+ Poll createdPoll = pollService.createPoll(poll);
+ poll.setTopiaId(createdPoll.getTopiaId());
+ poll.setCreator(createdPoll.getCreator());
+ poll.setChoice(createdPoll.getChoice());
+ } catch (InvalidFormException e) {
+ throw new PollenTechnicalException(e);
+ }
+ }
+
persistenceContext.commit();
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -39,9 +39,9 @@
import org.chorem.pollen.persistence.entity.VoterListMember;
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.HashSet;
import java.util.List;
import java.util.Set;
@@ -55,8 +55,6 @@
public ImmutableSet<Poll> getPolls() {
- //TODO Reput this
-// checkRole(SecurityRole.administrator);
List<Poll> polls = getPollDao().findAll();
return ImmutableSet.<Poll>builder().addAll(polls).build();
@@ -64,7 +62,6 @@
public ImmutableSet<Poll> getCreatedPolls() {
- checkRole(SecurityRole.connected);
PollenUser connectedUser = getConnectedUser();
Set<Poll> polls = getPollDao().findAllCreated(connectedUser);
return ImmutableSet.<Poll>builder().addAll(polls).build();
@@ -73,7 +70,6 @@
public ImmutableSet<Poll> getInvitedPolls() {
- checkRole(SecurityRole.connected);
PollenUser connectedUser = getConnectedUser();
Set<Poll> polls = getPollDao().findAllInvited(connectedUser);
return ImmutableSet.<Poll>builder().addAll(polls).build();
@@ -82,7 +78,6 @@
public ImmutableSet<Poll> getParticipatedPolls() {
- checkRole(SecurityRole.connected);
PollenUser connectedUser = getConnectedUser();
Set<Poll> polls = getPollDao().findAllParticipated(connectedUser);
return ImmutableSet.<Poll>builder().addAll(polls).build();
@@ -224,7 +219,7 @@
toSave = dao.newInstance();
PollenPrincipal creatorToPersist =
- getSecurityService().generatePrincipal();
+ getSecurityService().generatePollenPrincipal();
toSave.setCreator(creatorToPersist);
}
@@ -311,6 +306,7 @@
// validate choices
+ Set<String> choiceNames = new HashSet<>();
int choiceIndex = 0;
for (Choice choice : poll.getChoice()) {
@@ -326,11 +322,20 @@
case TEXT:
- checkNotBlank(errors,
- choiceField + Choice.PROPERTY_NAME,
- choice.getName(),
- "choice name can not be empty");
+ boolean checkNotBlank = checkNotBlank(errors,
+ choiceField + Choice.PROPERTY_NAME,
+ choice.getName(),
+ "choice name can not be empty");
+ if (checkNotBlank) {
+
+ // check duplicated name
+
+ check(errors,
+ choiceField + Choice.PROPERTY_NAME,
+ choiceNames.add(choice.getName()),
+ "Duplicated choice name");
+ }
break;
case DATE:
throw new IllegalStateException("Not implemented");
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -47,7 +47,6 @@
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;
@@ -67,9 +66,9 @@
protected PollenServiceContext serviceContext;
- public String createPermission(PermissionVerb verb, String id) {
- return ":" + verb.name() + ":" + id;
- }
+// public String createPermission(PermissionVerb verb, String id) {
+// return ":" + verb.name() + ":" + id;
+// }
@Override
public void setServiceContext(PollenServiceContext serviceContext) {
@@ -217,14 +216,10 @@
}
protected void checkPermission(PermissionVerb verb, String id) {
- String permission = createPermission(verb, id);
- serviceContext.getSecurityContext().checkPermission(permission);
+ String permission = getSecurityService().createPermission(verb, id);
+ getSecurityService().checkPermission(permission);
}
- protected void checkRole(SecurityRole role) {
- serviceContext.getSecurityContext().checkRole(role);
- }
-
protected void checkNotNull(Object object) {
Preconditions.checkNotNull(object);
}
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -32,7 +32,6 @@
import org.chorem.pollen.services.exception.InvalidFormException;
import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
import org.chorem.pollen.services.exception.UserInvalidPasswordException;
-import org.chorem.pollen.services.service.security.SecurityRole;
import java.util.List;
import java.util.Objects;
@@ -47,13 +46,13 @@
public List<PollenUser> getUsers() {
- checkRole(SecurityRole.administrator);
List<PollenUser> pollenUsers = getPollenUserDao().findAll();
return pollenUsers;
}
public PollenUser getUser(String userId) {
+
checkNotNull(userId);
PollenUser result = getPollenUserDao().forTopiaIdEquals(userId).findUniqueOrNull();
@@ -63,6 +62,7 @@
}
public PollenUser getUserByLogin(String login) {
+
checkNotNull(login);
PollenUser result = getPollenUserDao().forLoginEquals(login).findUniqueOrNull();
@@ -71,6 +71,7 @@
}
public PollenUser createUser(PollenUser user, boolean generatePassword) throws InvalidFormException {
+
checkNotNull(user);
checkIsNotPersisted(user);
checkPollenUserForm(user);
@@ -81,9 +82,11 @@
commit();
//TODO Notify user created
return result;
+
}
public PollenUser editUser(PollenUser user) throws InvalidFormException {
+
checkNotNull(user);
checkIsPersisted(user);
checkPollenUserForm(user);
@@ -94,19 +97,23 @@
commit();
//TODO Notify user edited
return result;
+
}
public void deleteUser(String userId) {
+
checkNotNull(userId);
PollenUser user = getUser(userId);
getPollenUserDao().delete(user);
commit();
+
}
public void changePassword(String userId,
String oldPassword,
String newPassword) throws UserInvalidPasswordException {
+
checkNotNull(userId);
checkNotNull(oldPassword);
checkNotNull(newPassword);
@@ -126,6 +133,7 @@
getPollenUserDao().update(user);
commit();
//TODO Notify PasswordChanged
+
}
public void validateUserEmail(String userId,
@@ -148,6 +156,7 @@
getPollenUserDao().update(user);
commit();
+
}
public void createDefaultUsers() throws InvalidFormException {
@@ -163,6 +172,7 @@
user.setPassword("admin");
createUser(user, false);
}
+
}
protected void checkPollenUserForm(PollenUser user) throws InvalidFormException {
@@ -215,6 +225,7 @@
throw new InvalidFormException(errors);
}
+
}
protected PollenUser savePollenUser(PollenUser user, boolean generatePassword) {
@@ -274,5 +285,6 @@
}
return toSave;
+
}
}
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -152,7 +152,7 @@
// -- author -- //
-// PollenPrincipal author = getSecurityService().generatePrincipal();
+// PollenPrincipal author = getSecurityService().generatePollenPrincipal();
// toSave.setAuthor(author);
poll.addVote(toSave);
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -48,14 +48,14 @@
*/
public class VoterListService extends PollenServiceSupport {
- public VoterList importFavoriteList(String userId, String pollId,
+ public VoterList importFavoriteList(String pollId,
String favoriteListId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(favoriteListId);
Poll poll = getPollService().getPoll(pollId);
- FavoriteList favoriteList = getFavoriteListService().getFavoriteList(userId, favoriteListId);
+ FavoriteList favoriteList = getFavoriteListService().getFavoriteList(favoriteListId);
VoterListTopiaDao dao = getVoterListDao();
VoterList result = dao.newInstance();
Modified: 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/DefaultPollenSecurityContext.java 2014-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/DefaultPollenSecurityContext.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -23,15 +23,12 @@
* #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.PollenPrincipal;
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.persistence.entity.SessionToken;
import java.io.Serializable;
-import java.util.Set;
/**
* TODO
@@ -43,27 +40,38 @@
private static final long serialVersionUID = 1L;
- /** Logger. */
- private static final Log log = LogFactory.getLog(DefaultPollenSecurityContext.class);
+ /**
+ * Computed shiro subject.
+ */
+ protected transient Subject subject;
- protected Subject subject;
-
/**
* Connected user account.
* <p/>
* Can be {@code null} if user is not connected.
- *
- * @since 2.0
*/
- protected final SessionToken sessionToken;
+ protected SessionToken sessionToken;
- public static PollenSecurityContext newContext(SessionToken sessionToken) {
- PollenSecurityContext result = new DefaultPollenSecurityContext(
- sessionToken);
+ /**
+ * Main principal (mainly to acquire credentials on a data).
+ * <p/>
+ * Can be {@code null} if no credentials is required.
+ */
+ protected PollenPrincipal mainPrincipal;
+
+ public static PollenSecurityContext newContext(SessionToken sessionToken, PollenPrincipal mainPrincipal) {
+ DefaultPollenSecurityContext result = new DefaultPollenSecurityContext();
+ result.setSessionToken(sessionToken);
+ result.setMainPrincipal(mainPrincipal);
return result;
}
@Override
+ public PollenPrincipal getMainPrincipal() {
+ return mainPrincipal;
+ }
+
+ @Override
public Subject getSubject() {
return subject;
}
@@ -75,7 +83,7 @@
@Override
public PollenUser getPollenUser() {
- return isConnected() ? sessionToken.getPollenUser() : null;
+ return sessionToken != null ? sessionToken.getPollenUser() : null;
}
@Override
@@ -93,55 +101,15 @@
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);
- }
-
+ public void setSessionToken(SessionToken sessionToken) {
+ this.sessionToken = sessionToken;
+ // force to reload subject
+ this.subject = null;
}
- @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);
- }
+ public void setMainPrincipal(PollenPrincipal mainPrincipal) {
+ this.mainPrincipal = mainPrincipal;
+ // force to reload subject
+ this.subject = null;
}
-
- @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;
- }
}
Modified: 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 2014-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityContext.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -1,11 +1,10 @@
package org.chorem.pollen.services.service.security;
import org.apache.shiro.subject.Subject;
+import org.chorem.pollen.persistence.entity.PollenPrincipal;
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.persistence.entity.SessionToken;
-import java.util.Set;
-
/**
* Created on 5/1/14.
*
@@ -14,10 +13,17 @@
*/
public interface PollenSecurityContext {
- Subject getSubject();
+ /**
+ * Get an extra credential, this is needed for protected resources, for example an private poll.
+ *
+ * @return optional credential given.
+ */
+ PollenPrincipal getMainPrincipal();
SessionToken getSessionToken();
+ Subject getSubject();
+
PollenUser getPollenUser();
boolean isConnected();
@@ -26,9 +32,4 @@
void setSubject(Subject subject);
- void checkPermission(String permission);
-
- void checkRole(SecurityRole role);
-
- Subject newSubject(Set<SecurityRole> roles, Set<String> permissions);
}
Modified: 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/PollenSecurityRealm.java 2014-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityRealm.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -29,14 +29,18 @@
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.AuthorizationInfo;
+import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
-import org.chorem.pollen.services.PollenService;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.services.PollenApplicationContext;
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;
+import java.util.Locale;
+
/**
* TODO
* <p/>
@@ -45,21 +49,22 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class PollenSecurityRealm extends AuthorizingRealm implements PollenService {
+public class PollenSecurityRealm extends AuthorizingRealm {
- protected PollenServiceContext serviceContext;
+ protected PollenApplicationContext applicationContext;
- @Override
- public void setServiceContext(PollenServiceContext serviceContext) {
- this.serviceContext = serviceContext;
+ public void setApplicationContext(PollenApplicationContext applicationContext) {
+ this.applicationContext = applicationContext;
}
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
- principals.getPrimaryPrincipal();
+ SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo();
- return null;
+ simpleAuthorizationInfo.setStringPermissions(principals.asSet());
+
+ return simpleAuthorizationInfo;
}
@Override
@@ -69,16 +74,24 @@
String username = upToken.getUsername();
char[] password = upToken.getPassword();
- AuthService authService = serviceContext.newService(AuthService.class);
+ PollenTopiaPersistenceContext persistenceContext = applicationContext.newPersistenceContext();
+
try {
- authService.login(username, new String(password));
- } catch (EntityNotFoundException e) {
- throw new AuthenticationException(e);
- } catch (UserInvalidPasswordException e) {
- throw new AuthenticationException(e);
+ PollenServiceContext serviceContext = applicationContext.newServiceContext(persistenceContext, Locale.FRANCE);
+
+ 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;
+ } finally {
+ persistenceContext.closeContext();
}
- SimpleAuthenticationInfo result =
- new SimpleAuthenticationInfo(username, password, getName());
- return result;
}
}
Modified: 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 2014-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenUnauthorizedException.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -12,13 +12,13 @@
private static final long serialVersionUID = 1L;
- protected final SecurityRole role;
+ protected final String role;
- public PollenUnauthorizedException(SecurityRole role) {
+ public PollenUnauthorizedException(String role) {
this.role = role;
}
- public SecurityRole getRole() {
+ public String getRole() {
return role;
}
}
Modified: 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 2014-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityRole.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -7,7 +7,6 @@
* @since 2.0
*/
public enum SecurityRole {
- anonymous,
connected,
administrator
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java 2014-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -23,26 +23,29 @@
* #L%
*/
+import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
+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.Choice;
import org.chorem.pollen.persistence.entity.Comment;
+import org.chorem.pollen.persistence.entity.FavoriteList;
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.SessionToken;
import org.chorem.pollen.persistence.entity.Vote;
-import org.chorem.pollen.persistence.entity.VoterListMember;
+import org.chorem.pollen.services.PollenTechnicalException;
+import org.chorem.pollen.services.exception.InvalidSessionTokenException;
import org.chorem.pollen.services.service.PollenServiceSupport;
import org.nuiton.topia.persistence.TopiaEntity;
-import java.util.Date;
-import java.util.EnumSet;
+import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
/**
@@ -53,213 +56,309 @@
*/
public class SecurityService extends PollenServiceSupport {
- public PollenPrincipal generatePrincipal() {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(SecurityService.class);
+
+ public PollenPrincipal generatePollenPrincipal() {
+
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 SessionToken getSessionTokenByToken(String token) throws InvalidSessionTokenException {
+
+ SessionToken sessionToken = null;
+ if (token != null) {
+ sessionToken = getSessionTokenDao().forTokenEquals(token).findUniqueOrNull();
+ if (sessionToken == null) {
+ throw new InvalidSessionTokenException();
+ }
+ }
+ return sessionToken;
+
}
- public void prepareSubject(String principalId) {
+ public PollenPrincipal getPollenPrincipalById(String principalId) {
+
+ PollenPrincipal principal = null;
+ if (principalId != null) {
+ principal = getPollenPrincipalDao().forTopiaIdEquals(principalId).findUniqueOrNull();
+ checkEntityExists(PollenPrincipal.class, principal, principalId);
+ }
+ return principal;
+
+ }
+
+ public String createPermission(PermissionVerb verb, String id) {
+
+ return ":" + verb.name() + ":" + id;
+
+ }
+
+ public void checkRole(SecurityRole roleName) {
+
+ checkNotNull(roleName);
+
PollenSecurityContext securityContext = serviceContext.getSecurityContext();
- Preconditions.checkNotNull(securityContext);
- PollenUser pollenUser = securityContext.getPollenUser();
- Subject subject = getSubject(principalId, pollenUser);
- securityContext.setSubject(subject);
+ switch (roleName) {
+
+ case connected:
+
+ if (!securityContext.isConnected()) {
+ throw new PollenUnauthorizedException("connected");
+ }
+ break;
+
+ case administrator:
+
+ if (!securityContext.isAdmin()) {
+ throw new PollenUnauthorizedException("administrator");
+ }
+ break;
+
+ default:
+
+ throw new PollenTechnicalException("can't handler security role: " + roleName);
+
+ }
+
}
- protected Subject getSubject(String principalId, PollenUser user) {
- Set<String> permissions = Sets.newHashSet();
+ public void checkPermission(String permission) {
- boolean userConnected = user != null;
- boolean userIsAdmin = userConnected && user.isAdministrator();
+ Subject subject = getSubject();
- Set<SecurityRole> roles = EnumSet.noneOf(SecurityRole.class);
- if (userConnected) {
- roles.add(SecurityRole.connected);
- if (userIsAdmin) {
- roles.add(SecurityRole.administrator);
+ if (log.isInfoEnabled()) {
+ log.info("Check permission: " + permission);
+ }
+
+ boolean valid = subject.isPermitted(permission);
+
+ if (!valid) {
+ throw new PollenInvalidPermissionException(permission);
+ }
+
+ }
+
+ protected Subject getSubject() {
+
+ PollenSecurityContext securityContext = serviceContext.getSecurityContext();
+ Preconditions.checkNotNull(securityContext);
+
+ Subject subject = securityContext.getSubject();
+
+ if (subject == null) {
+
+ // Generate all principals from given security context
+ Set<String> permissions = generatePermissions(securityContext);
+
+ if (log.isInfoEnabled()) {
+ log.info("All permissions:\n" + Joiner.on("\n").join(permissions));
}
- } else {
- roles.add(SecurityRole.anonymous);
+
+ // Create Subject
+ SimplePrincipalCollection principalCollection = new SimplePrincipalCollection();
+ principalCollection.addAll(permissions, "pollenRealm");
+ subject = new Subject.
+ Builder().
+ authenticated(securityContext.isConnected()).
+ principals(principalCollection).
+ buildSubject();
+
+ securityContext.setSubject(subject);
}
+ return subject;
+
+ }
+
+ protected Set<String> generatePermissions(PollenSecurityContext securityContext) {
+
+ boolean userIsAdmin = securityContext.isAdmin();
+
+ Set<String> permissions = Sets.newHashSet();
+
if (userIsAdmin) {
permissions.add("*:*:*");
- } else {
+ return permissions;
+ }
- Set<PollenPrincipal> principals = Sets.newHashSet();
+ PollenPrincipal pollenPrincipal = securityContext.getMainPrincipal();
+ PollenUser user = securityContext.getPollenUser();
- PollenPrincipalTopiaDao pollenPrincipalDao =
- getPersistenceContext().getPollenPrincipalDao();
+ // Get read data
- if (principalId != null) {
- PollenPrincipal pollenPrincipal =
- pollenPrincipalDao.findByTopiaId(principalId);
- principals.add(pollenPrincipal);
+ Set<Poll> polls = getPollDao().findAllFreePolls();
+
+ for (Poll poll : polls) {
+
+ permissions.add(createSubjectPermission(PermissionVerb.readPoll, poll));
+ permissions.add(createSubjectPermission(PermissionVerb.readPoll, poll));
+
+ if (poll.isChoiceNotEmpty()) {
+ for (Choice choice : poll.getChoice()) {
+ permissions.add(createSubjectPermission(PermissionVerb.readChoice, choice));
+ }
}
- if (userConnected) {
+ if (poll.isCommentNotEmpty()) {
+ for (Comment comment : poll.getComment()) {
+ permissions.add(createSubjectPermission(PermissionVerb.readComment, comment));
+ }
+ }
- // find all principals
- List<PollenPrincipal> allByPollenUser =
- pollenPrincipalDao.forPollenUserEquals(user).findAll();
- principals.addAll(allByPollenUser);
+ if (poll.isVoteNotEmpty()) {
+ for (Vote vote : poll.getVote()) {
+ permissions.add(createSubjectPermission(PermissionVerb.readVote, vote));
+ }
}
+ }
- Map<PollenPrincipal, TopiaEntity> principalTopiaEntityMap = Maps.newHashMap();
+ if (user != null && pollenPrincipal != null) {
- for (PollenPrincipal principal : principals) {
+ // no user connected, nor main principal given
+ // get all public objects
- // find out which entity is using this principal
- TopiaEntity entity = getPrincipalEntity(principal);
- principalTopiaEntityMap.put(principal, entity);
+ return permissions;
- if (entity instanceof Poll) {
+ }
- // add all poll entities
- Poll poll = (Poll) entity;
+ // Collect all principals
- if (!poll.isChoiceEmpty()) {
- for (Choice choice : poll.getChoice()) {
- principalTopiaEntityMap.put(choice.getCreator(), choice);
- }
- }
+ Set<PollenPrincipal> principals = Sets.newHashSet();
- if (!poll.isCommentEmpty()) {
- for (Comment comment : poll.getComment()) {
- principalTopiaEntityMap.put(comment.getAuthor(), comment);
- }
- }
+ if (pollenPrincipal != null) {
+ principals.add(pollenPrincipal);
+ }
- if (!poll.isVoteEmpty()) {
- for (Vote vote : poll.getVote()) {
- principalTopiaEntityMap.put(vote.getVoter(), vote);
- }
- }
- }
- }
+ if (user != null) {
- Date now = serviceContext.getNow();
- for (Map.Entry<PollenPrincipal, TopiaEntity> entry : principalTopiaEntityMap.entrySet()) {
- TopiaEntity entity = entry.getValue();
+ // get all principal of the connected user
+ List<PollenPrincipal> allByPollenUser =
+ getPollenPrincipalDao().forPollenUserEquals(user).findAll();
+ principals.addAll(allByPollenUser);
+ }
- if (entity instanceof Choice) {
- permissions.add(createWildcardSubjectPermission(entity));
- continue;
+ PrincipalByType principalByType = resolvePrincipals(principals);
+
+ for (FavoriteList favoriteList : principalByType.favoriteLists) {
+ permissions.add(createWildcardSubjectPermission(favoriteList));
+ }
+
+ for (Comment comment : principalByType.comments) {
+ permissions.add(createWildcardSubjectPermission(comment));
+ }
+
+ for (Choice choice : principalByType.choices) {
+
+ // can only read or edit the choice (only poll creator can delete a choice)
+ permissions.add(createSubjectPermission(PermissionVerb.readChoice, choice));
+ permissions.add(createSubjectPermission(PermissionVerb.editChoice, choice));
+ }
+
+ for (Poll poll : principalByType.polls) {
+
+ // creator has all rights on the poll, choices and comments, but can only read votes
+ permissions.add(createWildcardSubjectPermission(poll));
+
+ if (poll.isChoiceNotEmpty()) {
+ for (Choice choice : poll.getChoice()) {
+ permissions.add(createWildcardSubjectPermission(choice));
}
- if (entity instanceof Comment) {
- permissions.add(createWildcardSubjectPermission(entity));
- continue;
+ }
+ if (poll.isCommentNotEmpty()) {
+ for (Comment comment : poll.getComment()) {
+ permissions.add(createWildcardSubjectPermission(comment));
}
- if (entity instanceof Vote) {
- permissions.add(createWildcardSubjectPermission(entity));
- continue;
+ }
+ if (poll.isVoteNotEmpty()) {
+ for (Vote vote : poll.getVote()) {
+ permissions.add(createSubjectPermission(PermissionVerb.readVote, vote));
}
- if (entity instanceof Poll) {
- //TODO Get alls possible permissions on poll
+ }
+ }
- Poll poll = (Poll) entity;
+ return permissions;
- Set<VoterListMember> members = Polls.getAllVoters(poll);
+ }
- boolean freePoll = Polls.isPollFree(poll);
+ protected PrincipalByType resolvePrincipals(Set<PollenPrincipal> principals) {
- if (freePoll) {
+ PrincipalByType principalByType = new PrincipalByType();
+ for (PollenPrincipal principal : principals) {
+ resolvePrincipal(principalByType, principal);
+ }
+ return principalByType;
- // everybody can read poll ?
- permissions.add(createSubjectPermission(PermissionVerb.readPoll, entity));
- } else {
+ }
- // only his creator / participants / voters can read it
+ class PrincipalByType {
- for (VoterListMember member : members) {
- permissions.add(createSubjectPermission(member.getTopiaId(), PermissionVerb.readPoll, entity));
- }
- }
+ Set<Poll> polls = new HashSet<>();
- // 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));
- }
- }
+ Set<Choice> choices = new HashSet<>();
- //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));
-// }
+ Set<Comment> comments = new HashSet<>();
- //TODO Do for editVote,...
- }
- }
- }
- Subject subject = serviceContext.getSecurityContext().newSubject(roles, permissions);
- return subject;
+ Set<Vote> votes = new HashSet<>();
+
+ Set<FavoriteList> favoriteLists = new HashSet<>();
+
}
- protected TopiaEntity getPrincipalEntity(PollenPrincipal principal) {
+ protected void resolvePrincipal(PrincipalByType principalByType, PollenPrincipal principal) {
- TopiaEntity result = null;
-
// try a poll
Poll poll = getPollDao().forCreatorEquals(principal).findUniqueOrNull();
- if (poll == null) {
+ if (poll != null) {
+ principalByType.polls.add(poll);
+ return;
+ }
- // try a choice
- Choice choice = getChoiceDao().forCreatorEquals(principal).findUniqueOrNull();
- if (choice == null) {
+ Choice choice = getChoiceDao().forCreatorEquals(principal).findUniqueOrNull();
+ if (choice != null) {
+ principalByType.choices.add(choice);
+ return;
+ }
- // try a vote
- Vote vote = getVoteDao().forVoterEquals(principal).findUniqueOrNull();
- if (vote == null) {
+ Vote vote = getVoteDao().forVoterEquals(principal).findUniqueOrNull();
+ if (vote != null) {
+ principalByType.votes.add(vote);
+ return;
+ }
- // try a comment
- Comment comment = getCommentDao().forAuthorEquals(principal).findUniqueOrNull();
- if (comment != null) {
- result = comment;
- }
- } else {
- result = vote;
- }
- } else {
- result = choice;
- }
- } else {
- result = poll;
+ Comment comment = getCommentDao().forAuthorEquals(principal).findUniqueOrNull();
+ if (comment != null) {
+ principalByType.comments.add(comment);
+ return;
}
- Preconditions.checkNotNull(result);
- return result;
+ FavoriteList favoriteList = getFavoriteListDao().forOwnerEquals(principal).findUniqueOrNull();
+ if (favoriteList != null) {
+ principalByType.favoriteLists.add(favoriteList);
+ }
+
}
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();
+
}
}
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java (from rev 3895, trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -0,0 +1,219 @@
+package org.chorem.pollen.services.test;
+
+/*
+ * #%L
+ * ToPIA :: JUnit
+ * $Id$
+ * $HeadURL: http://svn.nuiton.org/svn/topia/trunk/topia-junit/src/main/java/org/nuiton/… $
+ * %%
+ * Copyright (C) 2004 - 2014 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.mgt.DefaultSecurityManager;
+import org.chorem.pollen.persistence.PollenPersistenceContext;
+import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.persistence.entity.PollenPrincipal;
+import org.chorem.pollen.persistence.entity.SessionToken;
+import org.chorem.pollen.services.PollenApplicationContext;
+import org.chorem.pollen.services.PollenFixtures;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.chorem.pollen.services.config.PollenServiceConfigOption;
+import org.chorem.pollen.services.service.FixturesService;
+import org.chorem.pollen.services.service.security.PollenSecurityRealm;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+import org.nuiton.topia.junit.ConfigurationHelper;
+import org.nuiton.util.DateUtil;
+
+import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class FakePollenApplicationContext extends TestWatcher implements PollenApplicationContext {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(FakePollenApplicationContext.class);
+
+ private File testBasedir;
+
+ protected List<PollenTopiaPersistenceContext> openedTransactions = new LinkedList<>();
+
+ private PollenTopiaApplicationContext applicationContext;
+
+ private PollenServiceConfig configuration;
+
+ private final String configurationPath;
+
+ protected PollenFixtures fixtures;
+
+ protected String methodName;
+
+ protected static AtomicInteger portNumberCounter = new AtomicInteger(9999);
+
+ protected int currentPortNumber;
+
+ public FakePollenApplicationContext(String configurationPath) {
+ this.configurationPath = configurationPath;
+ }
+
+ public int getPort() {
+ return currentPortNumber;
+ }
+
+ @Override
+ protected void starting(Description description) {
+
+ PollenSecurityRealm realm = new PollenSecurityRealm();
+ realm.setApplicationContext(this);
+
+ DefaultSecurityManager securityManager = new DefaultSecurityManager(realm);
+ SecurityUtils.setSecurityManager(securityManager);
+
+ currentPortNumber = portNumberCounter.getAndIncrement();
+
+ methodName = description.getMethodName();
+
+ // get test directory
+ testBasedir = ConfigurationHelper.getTestSpecificDirectory(
+ description.getTestClass(),
+ description.getMethodName());
+
+ if (log.isDebugEnabled()) {
+ log.debug("testBasedir: " + testBasedir);
+ }
+
+ // create configuration
+
+ Properties defaultvalues = new Properties();
+ defaultvalues.put(PollenServiceConfigOption.DATA_DIRECTORY.getKey(), testBasedir.getAbsolutePath());
+
+ configuration = new PollenServiceConfig(configurationPath, defaultvalues);
+
+ Map<String, String> topiaProperties = configuration.getTopiaProperties();
+ applicationContext = new PollenTopiaApplicationContext(topiaProperties);
+
+ }
+
+ @Override
+ public void finished(Description description) {
+
+ if (applicationContext != null && !applicationContext.isClosed()) {
+
+ for (PollenTopiaPersistenceContext openedTransaction : openedTransactions) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("closing transaction " + openedTransaction);
+ }
+
+ openedTransaction.closeContext();
+
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace("closing transaction " + applicationContext);
+ }
+
+ applicationContext.closeContext();
+
+ }
+ }
+
+ public File getTestBasedir() {
+ return testBasedir;
+ }
+
+ @Override
+ public PollenTopiaApplicationContext getTopiaApplicationContext() {
+ return applicationContext;
+ }
+
+ @Override
+ public PollenServiceConfig getApplicationConfig() {
+ return configuration;
+ }
+
+ @Override
+ public PollenTopiaPersistenceContext newPersistenceContext() {
+
+ PollenTopiaPersistenceContext persistenceContext;
+
+ persistenceContext = applicationContext.newPersistenceContext();
+
+ if (log.isTraceEnabled()) {
+ log.trace("opened transaction " + persistenceContext);
+ }
+
+ openedTransactions.add(persistenceContext);
+
+ return persistenceContext;
+
+ }
+
+ @Override
+ public FakePollenServiceContext newServiceContext(PollenPersistenceContext persistenceContext, Locale locale) {
+
+ FakePollenServiceContext serviceContext = FakePollenServiceContext.newServiceContext(
+ DateUtil.createDate(1, 1, 2014),
+ Locale.FRANCE,
+ getApplicationConfig(),
+ getTopiaApplicationContext(),
+ newPersistenceContext());
+ return serviceContext;
+
+ }
+
+ @Override
+ public FakePollenSecurityContext newSecurityContext(SessionToken sessionToken, PollenPrincipal mainPrincipal) {
+ FakePollenSecurityContext securityContext = new FakePollenSecurityContext();
+ securityContext.setMainPrincipal(mainPrincipal);
+ securityContext.setSessionToken(sessionToken);
+ return securityContext;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public void loadFixtures(PollenServiceContext serviceContext, String fixturesSetName) {
+
+ FixturesService fixturesService = serviceContext.newService(FixturesService.class);
+
+ fixtures = fixturesService.loadFixtures(fixturesSetName);
+
+ }
+
+ public <E> E fixture(String id) {
+
+ return fixtures.fixture(id);
+
+ }
+
+}
Modified: 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 2014-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenSecurityContext.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -1,39 +1,21 @@
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 org.chorem.pollen.services.service.security.DefaultPollenSecurityContext;
-import java.util.Set;
-
/**
* Created on 5/1/14.
*
* @author Tony Chemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class FakePollenSecurityContext implements PollenSecurityContext {
+public class FakePollenSecurityContext extends DefaultPollenSecurityContext {
- @Override
- public Subject getSubject() {
- return null;
- }
+ private static final long serialVersionUID = 1L;
@Override
- public SessionToken getSessionToken() {
- return null;
- }
-
- @Override
- public PollenUser getPollenUser() {
- return null;
- }
-
- @Override
public boolean isConnected() {
- return false;
+ return true;
}
@Override
@@ -43,22 +25,7 @@
@Override
public void setSubject(Subject subject) {
-
+ this.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;
- }
}
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -30,7 +30,6 @@
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;
@@ -47,13 +46,12 @@
Locale locale,
PollenServiceConfig serviceConfig,
PollenTopiaApplicationContext applicationcontext,
- PollenTopiaPersistenceContext persistenceContext,
- PollenSecurityContext securityContext) {
+ PollenTopiaPersistenceContext persistenceContext) {
FakePollenServiceContext serviceContext = new FakePollenServiceContext();
serviceContext.setPersistenceContext(persistenceContext);
serviceContext.setPollenServiceConfig(serviceConfig);
serviceContext.setTopiaApplicationContext(applicationcontext);
- serviceContext.setSecurityContext(securityContext);
+ serviceContext.setSecurityContext(new FakePollenSecurityContext());
serviceContext.setLocale(locale);
serviceContext.setDate(now);
return serviceContext;
Deleted: 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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -1,169 +0,0 @@
-package org.chorem.pollen.services.test;
-
-/*
- * #%L
- * ToPIA :: JUnit
- * $Id$
- * $HeadURL: http://svn.nuiton.org/svn/topia/trunk/topia-junit/src/main/java/org/nuiton/… $
- * %%
- * Copyright (C) 2004 - 2014 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
-import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
-import org.chorem.pollen.services.PollenFixtures;
-import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.config.PollenServiceConfig;
-import org.chorem.pollen.services.config.PollenServiceConfigOption;
-import org.chorem.pollen.services.service.FixturesService;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-import org.nuiton.topia.junit.ConfigurationHelper;
-
-import java.io.File;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class PollenApplication extends TestWatcher {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(PollenApplication.class);
-
- private File testBasedir;
-
- protected List<PollenTopiaPersistenceContext> openedTransactions = new LinkedList<>();
-
- private PollenTopiaApplicationContext applicationContext;
-
- private PollenServiceConfig configuration;
-
- private final String configurationPath;
-
- protected PollenFixtures fixtures;
-
- protected String methodName;
-
- public PollenApplication(String configurationPath) {
- this.configurationPath = configurationPath;
- }
-
- @Override
- protected void starting(Description description) {
-
- methodName = description.getMethodName();
-
- // get test directory
- testBasedir = ConfigurationHelper.getTestSpecificDirectory(
- description.getTestClass(),
- description.getMethodName());
-
- if (log.isDebugEnabled()) {
- log.debug("testBasedir: " + testBasedir);
- }
-
- // create configuration
-
- Properties defaultvalues = new Properties();
- defaultvalues.put(PollenServiceConfigOption.DATA_DIRECTORY.getKey(), testBasedir.getAbsolutePath());
-
- configuration = new PollenServiceConfig(configurationPath, defaultvalues);
-
- Map<String, String> topiaProperties = configuration.getTopiaProperties();
- applicationContext = new PollenTopiaApplicationContext(topiaProperties);
-
- }
-
- @Override
- public void finished(Description description) {
-
- if (applicationContext != null && !applicationContext.isClosed()) {
-
- for (PollenTopiaPersistenceContext openedTransaction : openedTransactions) {
-
- if (log.isTraceEnabled()) {
- log.trace("closing transaction " + openedTransaction);
- }
-
- openedTransaction.closeContext();
-
- }
-
- if (log.isTraceEnabled()) {
- log.trace("closing transaction " + applicationContext);
- }
-
- applicationContext.closeContext();
-
- }
- }
-
- public File getTestBasedir() {
- return testBasedir;
- }
-
- public PollenTopiaApplicationContext getApplicationContext() {
- return applicationContext;
- }
-
- public PollenServiceConfig getConfiguration() {
- return configuration;
- }
-
- public String getMethodName() {
- return methodName;
- }
-
- public PollenTopiaPersistenceContext newPersistenceContext() {
-
- PollenTopiaPersistenceContext persistenceContext;
-
- persistenceContext = applicationContext.newPersistenceContext();
-
- if (log.isTraceEnabled()) {
- log.trace("opened transaction " + persistenceContext);
- }
-
- openedTransactions.add(persistenceContext);
-
- return persistenceContext;
-
- }
-
- public void loadFixtures(PollenServiceContext serviceContext, String fixturesSetName) {
-
- FixturesService fixturesService = serviceContext.newService(FixturesService.class);
-
- fixtures = fixturesService.loadFixtures(fixturesSetName);
-
- }
-
- public <E> E fixture(String id) {
-
- return fixtures.fixture(id);
-
- }
-
-}
Modified: trunk/pollen-services/src/main/resources/fixtures.yaml
===================================================================
--- trunk/pollen-services/src/main/resources/fixtures.yaml 2014-05-02 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/main/resources/fixtures.yaml 2014-05-04 00:18:39 UTC (rev 3902)
@@ -38,9 +38,9 @@
voteVisibility: EVERYBODY
commentVisibility: EVERYBODY
resultVisibility: EVERYBODY
-# creator: !pollen-principal
-# name: poll creator
-# email: poll_creator(a)pollen.chorem.org
+ creator: !pollen-principal
+ name: poll creator
+ email: poll_creator(a)pollen.chorem.org
choice:
- &normal_choixA !choice
name: choixA
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -26,12 +26,10 @@
import com.google.common.collect.Multimap;
import org.chorem.pollen.services.PollenService;
import org.chorem.pollen.services.exception.InvalidFormException;
-import org.chorem.pollen.services.test.FakePollenSecurityContext;
+import org.chorem.pollen.services.test.FakePollenApplicationContext;
import org.chorem.pollen.services.test.FakePollenServiceContext;
-import org.chorem.pollen.services.test.PollenApplication;
import org.junit.Assert;
import org.junit.Rule;
-import org.nuiton.util.DateUtil;
import java.util.Locale;
@@ -40,7 +38,7 @@
protected static final double DELTA = 0.0001;
@Rule
- public final PollenApplication application = new PollenApplication("pollen-services.properties");
+ public final FakePollenApplicationContext application = new FakePollenApplicationContext("pollen-services.properties");
protected FakePollenServiceContext serviceContext;
@@ -57,13 +55,7 @@
protected FakePollenServiceContext getServiceContext() {
if (serviceContext == null) {
- serviceContext = FakePollenServiceContext.newServiceContext(
- DateUtil.createDate(1, 1, 2014),
- Locale.FRANCE,
- application.getConfiguration(),
- application.getApplicationContext(),
- application.newPersistenceContext(),
- new FakePollenSecurityContext());
+ serviceContext = application.newServiceContext(application.newPersistenceContext(), Locale.FRANCE);
}
return serviceContext;
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 15:30:54 UTC (rev 3901)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2014-05-04 00:18:39 UTC (rev 3902)
@@ -33,7 +33,7 @@
import org.chorem.pollen.services.service.ChoiceService;
import org.chorem.pollen.services.service.PollService;
import org.chorem.pollen.services.service.VoterListService;
-import org.chorem.pollen.services.service.security.SecurityService;
+import org.chorem.pollen.services.service.security.PollenInvalidPermissionException;
import org.chorem.pollen.services.test.FakePollenSecurityContext;
import org.junit.Assert;
import org.junit.Before;
@@ -65,14 +65,6 @@
}
@Test
- public void createPoll() throws InvalidFormException {
- Poll poll = fixture("poll_normal");
-
- Poll createdPoll = service.createPoll(poll);
- Assert.assertNotNull(createdPoll);
- }
-
- @Test
public void testCreateFreePoll() throws InvalidFormException {
Poll poll = service.getNewPoll();
@@ -81,6 +73,7 @@
try {
service.createPoll(poll);
+ Assert.fail();
} catch (InvalidFormException e) {
// missing title
// missing choice
@@ -94,6 +87,7 @@
try {
service.createPoll(poll);
+ Assert.fail();
} catch (InvalidFormException e) {
// missing choice type
assertErrorKeyFound(e, "choice[0].choiceType");
@@ -102,6 +96,7 @@
choice1.setChoiceType(ChoiceType.TEXT);
try {
service.createPoll(poll);
+ Assert.fail();
} catch (InvalidFormException e) {
// missing choice name
assertErrorKeyFound(e, "choice[0].name");
@@ -119,6 +114,7 @@
try {
service.createPoll(poll);
+ Assert.fail();
} catch (InvalidFormException e) {
// duplicated choice name
assertErrorKeyFound(e, "choice[1].name");
@@ -131,8 +127,6 @@
Assert.assertNotNull(createdPoll);
Assert.assertNotNull(createdPoll.getTopiaId());
- newService(SecurityService.class).prepareSubject(createdPoll.getCreator().getTopiaId());
-
Poll reloadedPoll = service.getPoll(createdPoll.getTopiaId());
Assert.assertEquals(createdPoll, reloadedPoll);
@@ -199,6 +193,7 @@
try {
service.createPoll(poll);
+ Assert.fail();
} catch (InvalidFormException e) {
// missing voterList
assertErrorKeyFound(e, "voterList");
@@ -211,6 +206,7 @@
try {
service.createPoll(poll);
+ Assert.fail();
} catch (InvalidFormException e) {
// missing name
// missing weight
@@ -226,6 +222,7 @@
try {
service.createPoll(poll);
+ Assert.fail();
} catch (InvalidFormException e) {
// missing member name
// missing member email
@@ -238,6 +235,7 @@
try {
service.createPoll(poll);
+ Assert.fail();
} catch (InvalidFormException e) {
// invalid member email
assertErrorKeyFound(e, "voterList[0].member[0].email");
@@ -253,6 +251,7 @@
try {
service.createPoll(poll);
+ Assert.fail();
} catch (InvalidFormException e) {
// same name
// same email
@@ -266,6 +265,16 @@
Assert.assertNotNull(createdPoll);
Assert.assertNotNull(createdPoll.getTopiaId());
+ try {
+ service.getPoll(createdPoll.getTopiaId());
+ Assert.fail();
+ } catch (PollenInvalidPermissionException e) {
+ Assert.assertTrue(true);
+ }
+
+ FakePollenSecurityContext securityContext = (FakePollenSecurityContext) serviceContext.getSecurityContext();
+ securityContext.setMainPrincipal(createdPoll.getCreator());
+
Poll reloadedPoll = service.getPoll(createdPoll.getTopiaId());
Assert.assertEquals(createdPoll, reloadedPoll);
1
0
r3901 - 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 17:30:54 +0200 (Fri, 02 May 2014)
New Revision: 3901
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3901
Log:
save poll with $http
Modified:
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-popupChoice.html
trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
Modified: trunk/pollen-ui-angular/src/main/webapp/js/app.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-05-02 12:21:03 UTC (rev 3900)
+++ trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-05-02 15:30:54 UTC (rev 3901)
@@ -18,8 +18,52 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
-angular.module('pollen', ["restangular", 'ngRoute', 'pollControllers', 'ui.bootstrap'])
+angular.module('pollen', ["restangular", 'ngRoute', 'pollControllers', 'ui.bootstrap'], function($httpProvider) {
+ // Use x-www-form-urlencoded Content-Type
+ $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
+ /**
+ * The workhorse; converts an object to x-www-form-urlencoded serialization.
+ * @param {Object} obj
+ * @return {String}
+ */
+ var param = function(obj) {
+ var query = '', name, value, fullSubName, subName, subValue, innerObj, i;
+
+ for(name in obj) {
+ value = obj[name];
+
+ if(value instanceof Array) {
+ for(i=0; i<value.length; ++i) {
+ subValue = value[i];
+ fullSubName = name + '[' + i + ']';
+ innerObj = {};
+ innerObj[fullSubName] = subValue;
+ query += param(innerObj) + '&';
+ }
+ }
+ else if(value instanceof Object) {
+ for(subName in value) {
+ subValue = value[subName];
+ fullSubName = name + '.' + subName ;
+ innerObj = {};
+ innerObj[fullSubName] = subValue;
+ query += param(innerObj) + '&';
+ }
+ }
+ else if(value !== undefined && value !== null)
+ query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&';
+ }
+
+ return query.length ? query.substr(0, query.length - 1) : query;
+ };
+
+ // Override $http service's default transformRequest
+ $httpProvider.defaults.transformRequest = [function(data) {
+ return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
+ }];
+})
+
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/', {templateUrl: './partials/home.html', controller: "HomeCtrl"})
.when('/poll/create', {templateUrl: './partials/poll.html', controller: "PollAdminCtrl"})
@@ -31,7 +75,8 @@
}])
.config(['RestangularProvider', function (RestangularProvider) {
- RestangularProvider.setBaseUrl('http://demo.codelutin.com/pollen-rest-api-latest/v1');
+ //RestangularProvider.setBaseUrl('http://demo.codelutin.com/pollen-rest-api-latest/v1');
+ RestangularProvider.setBaseUrl('http://localhost:8080/pollen-rest-api/v1');
}])
.factory('PollsRest', ['Restangular', function(Restangular) {
@@ -103,7 +148,6 @@
$timeout (function () {
scope.$apply(attrs.ngExit);
}, 150);
- event.preventDefault();
});
};
})
Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-02 12:21:03 UTC (rev 3900)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-02 15:30:54 UTC (rev 3901)
@@ -30,7 +30,7 @@
}, 5000);
});
- $scope.poll = pollStorage.get();
+ $scope.poll = {};
$scope.toHTML = function (data) {
return $sce.trustAsHtml(data);
@@ -64,44 +64,48 @@
}])
-.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$filter', '$timeout', 'PollsRest', 'pollStorage', function ($scope, $controller, $modal, $filter, $timeout, PollsRest, pollStorage) {
+.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$filter', '$timeout', 'PollsRest', '$http', 'pollStorage', function ($scope, $controller, $modal, $filter, $timeout, PollsRest, $http, pollStorage) {
$controller('PollCtrl', {$scope:$scope});
var initPoll = function () {
PollsRest.one('new').get().then(function (skeletonPoll) {
$scope.poll = skeletonPoll;
- $scope.poll.choices = [];
+ $scope.poll.choice = [];
+ $scope.vote = {};
+ $scope.vote.choice = $scope.poll.choice;
+
});
}
var initChoice = function () {
return {
name: '',
- type: $scope.globalVariables.lastType
+ choiceType: $scope.globalVariables.lastType
};
}
$scope.globalVariables.editMode = true;
$scope.globalVariables.create = true;
$scope.globalVariables.voted = angular.isDefined($scope.poll.votants);
- $scope.globalVariables.lastType = 'text';
+ $scope.globalVariables.lastType = 'TEXT';
$scope.$watch('pollForm.$valid', function (newVal) {
$scope.formValid = newVal;
$scope.globalVariables.errorForm = false;
});
- if (!angular.isDefined($scope.poll.choices)) {
+ if (!angular.isDefined($scope.poll.choice)) {
initPoll();
}
+ else {
+ $scope.vote = {};
+ $scope.vote.choice = $scope.poll.choice;
+ }
- $scope.vote = {};
- $scope.vote.choices = $scope.poll.choices;
-
$scope.addChoice = function () {
- var index = $scope.poll.choices.push(initChoice());
- var choice = $scope.poll.choices[index-1];
+ var index = $scope.poll.choice.push(initChoice());
+ var choice = $scope.poll.choice[index-1];
popupChoice(choice, 'Add Choice');
}
@@ -110,9 +114,9 @@
}
var deleteChoice = function (ch) {
- var index = $scope.poll.choices.indexOf(ch);
+ var index = $scope.poll.choice.indexOf(ch);
if (index > -1) {
- $scope.poll.choices.splice(index,1);
+ $scope.poll.choice.splice(index,1);
}
}
@@ -130,14 +134,18 @@
modalInstance.result.then(function (ch) {
deleteChoice(ch);
}, function () {
- $scope.globalVariables.lastType = choice.type;
+ $scope.globalVariables.lastType = choice.choiceType;
});
}
$scope.save = function () {
if ($scope.formValid) {
- pollStorage.put($scope.poll);
- $scope.globalVariables.saved = true;
+ var data = {};
+ data.poll = $scope.poll;
+ $http.post('http://localhost:8080/pollen-rest-api/v1/polls', data).success(function (data) {
+ $scope.globalVariables.saved = true;
+ });
+
}
else {
$scope.globalVariables.errorForm = true;
@@ -147,13 +155,14 @@
$scope.reset = function () {
$scope.poll = initPoll();
- $scope.voteChoices = $scope.poll.choices;
+ $scope.voteChoice = $scope.poll.choice;
pollStorage.put({});
}
$scope.delete = function () {
$scope.poll = initPoll();
- $scope.voteChoices = $scope.poll.choices;
+ $scope.voteChoice= $scope.poll.choice;
+ $scope.globalVariables.voted = false;
pollStorage.put({});
}
@@ -168,7 +177,9 @@
}
$scope.cancelChoice = function () {
- angular.copy(oldChoice, $scope.choice);
+ if (angular.isDefined(oldChoice)) {
+ angular.copy(oldChoice, $scope.choice);
+ }
$modalInstance.dismiss();
}
@@ -179,9 +190,15 @@
}
}])
-.controller('PollVoteCtrl', ['$scope', '$filter', '$controller', 'pollStorage', function ($scope, $filter, $controller, pollStorage) {
+.controller('PollVoteCtrl', ['$scope', '$filter', '$controller', 'Restangular', 'pollStorage', function ($scope, $filter, $controller, Restangular, pollStorage) {
$controller('PollCtrl', {$scope:$scope});
+ Restangular.one('polls').get().then(function (poll) {
+ $scope.poll = poll[0];
+
+ initVote();
+ })
+
$scope.globalVariables.editMode = false;
$scope.$watch('vote.ame', function (newVal) {
if (newVal != '') {
@@ -192,23 +209,22 @@
var initVote = function () {
$scope.vote = {};
$scope.vote.name = "";
- $scope.vote.choices = [];
+ $scope.vote.choice = [];
for (var i = 0; i < $scope.poll.choices.length; ++i) {
- if ($scope.poll.choices[i].type == 'text') {
- $scope.vote.choices.push({name:$scope.poll.choices[i].name, value:false});
+ if ($scope.poll.choices[i].choiceType == 'text') {
+ $scope.vote.choices.push({name:$scope.poll.choice[i].name, value:false});
}
- else if ($scope.poll.choices[i].type == 'date') {
- $scope.vote.choices.push({name: $scope.poll.choices[i].date , value:false});
+ else if ($scope.poll.choices[i].choiceType == 'date') {
+ $scope.vote.choices.push({name: $scope.poll.choice[i].date , value:false});
}
}
}
- initVote();
$scope.voter = function () {
if ($scope.vote.name != '') {
var data = {};
data.name = $scope.vote.name;
- data.choices = angular.copy($scope.vote.choices);
+ data.choice = angular.copy($scope.vote.choice);
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-05-02 12:21:03 UTC (rev 3900)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html 2014-05-02 15:30:54 UTC (rev 3901)
@@ -25,7 +25,7 @@
<div class="col-sm-10">
<div ng-click="showChoiceDesc = !showChoiceDesc" >
- <div ng-if="choice.type == 'text'">
+ <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>
{{choice.name}}
@@ -35,7 +35,7 @@
</h3>
</div>
- <div ng-if="choice.type == 'date'">
+ <div ng-if="choice.type == 'DATE'">
<h3 edit-me="showEdit" ng-hide="showEdit || isOpen" 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>
{{choice.date | date:'dd/MM/yyyy'}}
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html 2014-05-02 12:21:03 UTC (rev 3900)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html 2014-05-02 15:30:54 UTC (rev 3901)
@@ -24,15 +24,15 @@
<table>
<tr>
<td><button ng-if="globalVariables.editMode" ng-click="bigVersion()" class="btn btn-default" >Big version</button></td>
- <td ng-repeat="choice in poll.choices" class="pollChoice pollAnim" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false">
- <div ng-if="choice.type == 'text'" edit-me="showEdit" >
+ <td ng-repeat="choice in poll.choice" class="pollChoice pollAnim" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false">
+ <div ng-if="choice.choiceType == 'TEXT'" edit-me="showEdit" >
<div ng-hide="showEdit && !globalVariables.voted" class="fixe-input" title="{{choice.description}}">{{choice.name}} <input type="button" class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
<div ng-show="showEdit && !globalVariables.voted">
<input type="text" class="form-control" ng-model="choice.name" focus-me="showEdit" ng-exit="showEdit = false" required/>
<input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
</div>
</div>
- <div ng-if="choice.type == 'date'" edit-me="showEdit" >
+ <div ng-if="choice.choiceType == 'DATE'" edit-me="showEdit" >
<div ng-hide="!globalVariables.voted && showEdit || isOpen" class="fixe-input" title="{{choice.description}}">{{choice.date | date:'dd/MM/yyyy'}} <input type="button" class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
<div ng-show="!globalVariables.voted && showEdit || isOpen" >
<input type="text" class="form-control" ng-model="choice.date" focus-me="showEdit" datepicker-popup="dd/MM/yyyy" is-open="isOpen" ng-exit="showEdit = false" required/>
@@ -45,8 +45,8 @@
<tr>
<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 ng-repeat="choice in vote.choice" class="pollChoice">
+ <input type="checkbox" name="$index" ng-model="choice.value"/>
</td>
<td>
<input class="btn btn-primary btn-large" type="button" value="Vote" ng-click="voter()" />
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html 2014-05-02 12:21:03 UTC (rev 3900)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html 2014-05-02 15:30:54 UTC (rev 3901)
@@ -29,13 +29,13 @@
<label class="col-sm-4 control-label">Type de choix :</label>
<div class="col-sm-8 btn-group">
- <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'text'">Text</button>
- <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'date'">Date</button>
- <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'picture'" disabled>Image</button>
+ <button type="button" class="btn btn-default" ng-model="choice.choiceType" btn-radio="'TEXT'">Text</button>
+ <button type="button" class="btn btn-default" ng-model="choice.choiceType" btn-radio="'DATE'">Date</button>
+ <button type="button" class="btn btn-default" ng-model="choice.choiceType" btn-radio="'PICTURE'" disabled>Image</button>
</div>
</div>
- <div class="form-group" ng-if="choice.type == 'text'">
+ <div class="form-group" ng-if="choice.choiceType == 'TEXT'">
<label for="popNameChoiceCheck" class="col-sm-4 control-label">Nom du Choix : </label>
<div class="col-sm-6">
@@ -43,7 +43,7 @@
</div>
</div>
- <div class="form-group" ng-if="choice.type == 'date'">
+ <div class="form-group" ng-if="choice.choiceType == 'DATE'">
<label for="popNameChoiceDate" class="col-sm-4 control-label">Date : </label>
<div class="col-sm-6">
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-05-02 12:21:03 UTC (rev 3900)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-05-02 15:30:54 UTC (rev 3901)
@@ -23,7 +23,7 @@
<alert type="'danger'" ng-if="globalVariables.errorForm"> Champ non remplie </alert>
<alert type="'success'" ng-if="globalVariables.editMode && globalVariables.saved"> Sondage sauvegardé..</alert>
- <alert type="'success'" ng-if="!globalVariables.editMode && globalVariables.saved"> Vote effectué.. </alert>
+ <alert type="'success'" ng-if="!globalVariables.editMode && globalVariables.saved"> Vote effectué.. <pre>{{rest}}</pre></alert>
<alert type="'warning'" ng-if="globalVariables.voted"> Les votes ont commencé, certaine modification sont inaccessible.. </alert>
1
0
Author: tchemit
Date: 2014-05-02 14:21:03 +0200 (Fri, 02 May 2014)
New Revision: 3900
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3900
Log:
fix javassist double in classpath
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-05-02 12:07:13 UTC (rev 3899)
+++ trunk/pom.xml 2014-05-02 12:21:03 UTC (rev 3900)
@@ -304,6 +304,12 @@
<groupId>org.debux.webmotion</groupId>
<artifactId>webmotion</artifactId>
<version>${webmotionVersion}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
1
0
r3899 - in trunk: pollen-rest-api/src/main/java/org/chorem/pollen/rest/api pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1 pollen-rest-api/src/main/resources pollen-services/src/main/java/org/chorem/pollen/services/exception 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 14:07:13 +0200 (Fri, 02 May 2014)
New Revision: 3899
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3899
Log:
simplify form exception (keep only one)
Removed:
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
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/v1/CommentService.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/PollenUserService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.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-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/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/VoteCountingService.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
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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -36,7 +36,7 @@
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.exception.InvalidFormException;
import org.chorem.pollen.services.service.PollenUserService;
import org.chorem.pollen.services.service.security.DefaultPollenSecurityContext;
import org.chorem.pollen.services.service.security.PollenSecurityContext;
@@ -212,7 +212,7 @@
try {
PollenServiceContext serviceContext = newServiceContext(persistenceContext, Locale.FRANCE);
serviceContext.newService(PollenUserService.class).createDefaultUsers();
- } catch (InvalidPollenUserFormException e) {
+ } catch (InvalidFormException e) {
//Can't happen
} catch (EntityNotFoundException e) {
//Can't happen
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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -25,7 +25,7 @@
import org.chorem.pollen.persistence.entity.Comment;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.InvalidCommentFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
import org.debux.webmotion.server.WebMotionController;
import java.util.List;
@@ -49,12 +49,12 @@
return context.getCommentService().getComment(pollId, commentId);
}
- public Comment addComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidCommentFormException {
+ public Comment addComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getCommentService().addComment(pollId, comment);
}
- public Comment editComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidCommentFormException {
+ public Comment editComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidFormException {
context.getSecurityService().prepareSubject(comment);
return context.getCommentService().editComment(pollId, comment);
}
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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -27,8 +27,7 @@
import org.chorem.pollen.persistence.entity.FavoriteListMember;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
import org.chorem.pollen.services.exception.FavoriteListImportException;
-import org.chorem.pollen.services.exception.InvalidFavoriteListFormException;
-import org.chorem.pollen.services.exception.InvalidFavoriteListMemberFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
import org.debux.webmotion.server.WebMotionController;
import java.io.File;
@@ -52,11 +51,11 @@
return context.getFavoriteListService().getFavoriteList(userId, favoriteListId);
}
- public FavoriteList createFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws InvalidFavoriteListFormException {
+ public FavoriteList createFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws InvalidFormException {
return context.getFavoriteListService().createFavoriteList(userId, favoriteList);
}
- public FavoriteList editFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws InvalidFavoriteListFormException {
+ public FavoriteList editFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws InvalidFormException {
return context.getFavoriteListService().editFavoriteList(userId, favoriteList);
}
@@ -81,11 +80,11 @@
return context.getFavoriteListService().getFavoriteListMember(userId, favoriteListId, memberId);
}
- public FavoriteListMember addMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws InvalidFavoriteListMemberFormException {
+ public FavoriteListMember addMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws InvalidFormException {
return context.getFavoriteListService().addFavoriteListMember(userId, favoriteListId, member);
}
- public FavoriteListMember editMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws InvalidFavoriteListMemberFormException {
+ public FavoriteListMember editMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws InvalidFormException {
return context.getFavoriteListService().editFavoriteListMember(userId, favoriteListId, member);
}
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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -25,7 +25,7 @@
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-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.exception.UserInvalidPasswordException;
import org.debux.webmotion.server.WebMotionController;
@@ -51,17 +51,17 @@
public PollenUser createUser(PollenRestApiRequestContext context,
PollenUser user,
- boolean generatePassword) throws InvalidPollenUserFormException {
+ boolean generatePassword) throws InvalidFormException {
return context.getPollenUserService().createUser(user, generatePassword);
}
public PollenUser editUser(PollenRestApiRequestContext context,
- PollenUser user) throws InvalidPollenUserFormException {
+ PollenUser user) throws InvalidFormException {
return context.getPollenUserService().editUser(user);
}
- public void deleteUser(PollenRestApiRequestContext context, String userId) throws InvalidPollenUserFormException {
+ public void deleteUser(PollenRestApiRequestContext context, String userId) throws InvalidFormException {
context.getPollenUserService().deleteUser(userId);
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java 2014-05-02 12:06:45 UTC (rev 3898)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -25,7 +25,6 @@
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
import org.chorem.pollen.services.PollResult;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.debux.webmotion.server.WebMotionController;
/**
@@ -36,7 +35,7 @@
*/
public class VoteCountingService extends WebMotionController {
- public PollResult getResult(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException {
+ public PollResult getResult(PollenRestApiRequestContext context, String pollId) {
return context.getVoteCountingService().getResult(pollId);
}
}
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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -25,7 +25,7 @@
import org.chorem.pollen.persistence.entity.Vote;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
-import org.chorem.pollen.services.exception.InvalidVoteFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
import org.debux.webmotion.server.WebMotionController;
import java.util.List;
@@ -49,12 +49,12 @@
return context.getVoteService().getVote(pollId, voteId);
}
- public Vote addVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidVoteFormException {
+ public Vote addVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getVoteService().addVote(pollId, vote);
}
- public Vote editVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidVoteFormException {
+ public Vote editVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidFormException {
context.getSecurityService().prepareSubject(vote);
return context.getVoteService().editVote(pollId, vote);
}
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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -26,8 +26,7 @@
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.InvalidVoterListFormException;
-import org.chorem.pollen.services.exception.InvalidVoterListMemberFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
import org.debux.webmotion.server.WebMotionController;
import java.util.List;
@@ -56,12 +55,12 @@
return context.getVoterListService().getVoterList(pollId, voterListId);
}
- public VoterList createVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidVoterListFormException {
+ public VoterList createVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidFormException {
context.getSecurityService().prepareSubject(pollId);
return context.getVoterListService().addVoterList(pollId, voterList);
}
- public VoterList editVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidVoterListFormException {
+ public VoterList editVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidFormException {
context.getSecurityService().prepareSubject(voterList);
return context.getVoterListService().editVoterList(pollId, voterList);
}
@@ -82,12 +81,12 @@
return context.getVoterListService().getVoterListMember(pollId, voterListId, memberId);
}
- public VoterListMember addMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidVoterListMemberFormException {
+ public VoterListMember addMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidFormException {
context.getSecurityService().prepareSubject(member);
return context.getVoterListService().addVoterListMember(pollId, voterListId, member);
}
- public VoterListMember editMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidVoterListMemberFormException {
+ public VoterListMember editMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidFormException {
context.getSecurityService().prepareSubject(member);
return context.getVoterListService().editVoterListMember(pollId, voterListId, member);
}
Modified: trunk/pollen-rest-api/src/main/resources/mapping
===================================================================
--- trunk/pollen-rest-api/src/main/resources/mapping 2014-05-02 12:06:45 UTC (rev 3898)
+++ trunk/pollen-rest-api/src/main/resources/mapping 2014-05-02 12:07:13 UTC (rev 3899)
@@ -8,8 +8,6 @@
[filters]
* /* PollenRestApiRequestFilter.inject
-#- une fois un object lié à PollenUser, c'est immuable.
-
[errors]
org.chorem.pollen.services.exception.EntityNotFoundException ErrorAction.on404
@@ -17,15 +15,6 @@
org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException ErrorAction.on500
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
@@ -76,6 +65,7 @@
GET /v1/polls/invited PollService.getInvitedPolls
GET /v1/polls/participated PollService.getParticipatedPolls
POST /v1/polls PollService.createPoll
+GET /v1/polls/create PollService.createPoll
PUT /v1/polls/{pollId} PollService.editPoll
GET /v1/polls/{pollId} PollService.getPoll
DELETE /v1/polls/{pollId} PollService.deletePoll
Deleted: 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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidChoiceFormException.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -1,43 +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 class InvalidChoiceFormException extends InvalidFormException {
-
- private static final long serialVersionUID = 1L;
-
-
- public InvalidChoiceFormException(Multimap<String, String> errors) {
- super(errors);
- }
-
-}
Deleted: 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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidCommentFormException.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -1,40 +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 class InvalidCommentFormException extends InvalidFormException {
- private static final long serialVersionUID = 1L;
-
- public InvalidCommentFormException(Multimap<String, String> errors) {
- super(errors);
- }
-}
Deleted: 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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListFormException.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -1,41 +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 class InvalidFavoriteListFormException extends InvalidFormException {
-
- private static final long serialVersionUID = 1L;
-
- public InvalidFavoriteListFormException(Multimap<String, String> errors) {
- super(errors);
- }
-}
Deleted: 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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListMemberFormException.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -1,41 +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 class InvalidFavoriteListMemberFormException extends InvalidFormException {
-
- private static final long serialVersionUID = 1L;
-
- public InvalidFavoriteListMemberFormException(Multimap<String, String> errors) {
- super(errors);
- }
-}
Deleted: 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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollFormException.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -1,42 +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 class InvalidPollFormException extends InvalidFormException {
-
- private static final long serialVersionUID = 1L;
-
- public InvalidPollFormException(Multimap<String, String> errors) {
- super(errors);
- }
-
-}
Deleted: 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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollenUserFormException.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -1,40 +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 class InvalidPollenUserFormException extends InvalidFormException {
- private static final long serialVersionUID = 1L;
-
- public InvalidPollenUserFormException(Multimap<String, String> errors) {
- super(errors);
- }
-}
Deleted: 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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoteFormException.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -1,40 +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 class InvalidVoteFormException extends InvalidFormException {
- private static final long serialVersionUID = 1L;
-
- public InvalidVoteFormException(Multimap<String, String> errors) {
- super(errors);
- }
-}
Deleted: 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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListFormException.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -1,41 +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 class InvalidVoterListFormException extends InvalidFormException {
-
- private static final long serialVersionUID = 1L;
-
- public InvalidVoterListFormException(Multimap<String, String> errors) {
- super(errors);
- }
-}
Deleted: 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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListMemberFormException.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -1,41 +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 class InvalidVoterListMemberFormException extends InvalidFormException {
-
- private static final long serialVersionUID = 1L;
-
- public InvalidVoterListMemberFormException(Multimap<String, String> errors) {
- super(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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -30,8 +30,7 @@
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.services.exception.EntityNotFoundException;
-import org.chorem.pollen.services.exception.InvalidCommentFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
import org.chorem.pollen.services.service.security.PermissionVerb;
import java.util.List;
@@ -44,13 +43,13 @@
*/
public class CommentService extends PollenServiceSupport {
- public List<Comment> getComments(String pollId) throws EntityNotFoundException {
+ public List<Comment> getComments(String pollId) {
Preconditions.checkNotNull(pollId);
Poll poll = getPollService().getPoll(pollId);
return poll.getComment();
}
- public Comment getComment(String pollId, String commentId) throws EntityNotFoundException {
+ public Comment getComment(String pollId, String commentId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(commentId);
@@ -61,7 +60,7 @@
return result;
}
- public Comment addComment(String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
+ public Comment addComment(String pollId, Comment comment) throws InvalidFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(comment);
checkIsNotPersisted(comment);
@@ -76,7 +75,7 @@
return result;
}
- public Comment editComment(String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException {
+ public Comment editComment(String pollId, Comment comment) throws InvalidFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(comment);
checkIsPersisted(comment);
@@ -93,7 +92,7 @@
return result;
}
- public void deleteComment(String pollId, String commentId) throws EntityNotFoundException {
+ public void deleteComment(String pollId, String commentId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(commentId);
@@ -109,14 +108,14 @@
commit();
}
- protected Comment getComment(Poll poll, String commentId) throws EntityNotFoundException {
+ protected Comment getComment(Poll poll, String commentId) {
Comment result = poll.getCommentByTopiaId(commentId);
checkEntityExists(Comment.class, result, commentId);
return result;
}
- protected void checkCommentForm(Poll poll, Comment comment) throws InvalidCommentFormException {
+ protected void checkCommentForm(Poll poll, Comment comment) throws InvalidFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
@@ -129,11 +128,11 @@
if (!errors.isEmpty()) {
- throw new InvalidCommentFormException(errors);
+ throw new InvalidFormException(errors);
}
}
- protected Comment saveComment(Poll poll, Comment comment) throws EntityNotFoundException {
+ protected Comment saveComment(Poll poll, Comment comment) {
boolean commentExists = comment.isPersisted();
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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -33,10 +33,8 @@
import org.chorem.pollen.persistence.entity.FavoriteListMember;
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.services.PollenTechnicalException;
-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.chorem.pollen.services.exception.InvalidFormException;
import org.nuiton.util.StringUtil;
import javax.naming.NamingEnumeration;
@@ -67,7 +65,7 @@
*/
public class FavoriteListService extends PollenServiceSupport {
- public List<FavoriteList> getFavoriteLists(String userId) throws EntityNotFoundException {
+ public List<FavoriteList> getFavoriteLists(String userId) {
Preconditions.checkNotNull(userId);
PollenUser user = getUserService().getUser(userId);
@@ -75,7 +73,7 @@
return result;
}
- public FavoriteList getFavoriteList(String userId, String favoriteListId) throws EntityNotFoundException {
+ public FavoriteList getFavoriteList(String userId, String favoriteListId) {
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteListId);
@@ -86,7 +84,7 @@
}
public FavoriteList createFavoriteList(String userId,
- FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
+ FavoriteList favoriteList) throws InvalidFormException {
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteList);
checkIsNotPersisted(favoriteList);
@@ -106,7 +104,7 @@
}
public FavoriteList editFavoriteList(String userId,
- FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException {
+ FavoriteList favoriteList) throws InvalidFormException {
Preconditions.checkNotNull(favoriteList);
checkIsPersisted(favoriteList);
@@ -126,7 +124,7 @@
return toSave;
}
- public void deleteFavoriteList(String userId, String favoriteListId) throws EntityNotFoundException {
+ public void deleteFavoriteList(String userId, String favoriteListId) {
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteListId);
@@ -140,7 +138,7 @@
commit();
}
- public LinkedHashSet<FavoriteListMember> getFavoriteListMembers(String userId, String favoriteListId) throws EntityNotFoundException {
+ public LinkedHashSet<FavoriteListMember> getFavoriteListMembers(String userId, String favoriteListId) {
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteListId);
@@ -151,7 +149,7 @@
return favoriteList.getMember();
}
- public FavoriteListMember getFavoriteListMember(String userId, String favoriteListId, String memberId) throws EntityNotFoundException {
+ public FavoriteListMember getFavoriteListMember(String userId, String favoriteListId, String memberId) {
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(memberId);
@@ -166,7 +164,7 @@
public FavoriteListMember addFavoriteListMember(String userId,
String favoriteListId,
- FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException {
+ FavoriteListMember member) throws InvalidFormException {
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(member);
@@ -191,7 +189,7 @@
public FavoriteListMember editFavoriteListMember(String userId,
String favoriteListId,
- FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException {
+ FavoriteListMember member) throws InvalidFormException {
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(member);
@@ -218,7 +216,7 @@
public void removeFavoriteListMember(String userId,
String favoriteListId,
- String memberId) throws EntityNotFoundException {
+ String memberId) {
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(memberId);
@@ -237,7 +235,7 @@
public int importFavoriteListMembersFromCsv(String userId,
String favoriteListId,
- File file) throws EntityNotFoundException, FavoriteListImportException {
+ File file) throws FavoriteListImportException {
Preconditions.checkNotNull(userId);
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(file);
@@ -336,7 +334,7 @@
public int importFavoriteListMembersFromLdap(String userId,
String favoriteListId,
- String ldap) throws EntityNotFoundException, FavoriteListImportException {
+ String ldap) throws FavoriteListImportException {
Preconditions.checkNotNull(favoriteListId);
Preconditions.checkNotNull(ldap);
@@ -421,7 +419,7 @@
return result;
}
- protected FavoriteList getFavoriteList(PollenUser user, String favoriteListId) throws EntityNotFoundException {
+ protected FavoriteList getFavoriteList(PollenUser user, String favoriteListId) {
Preconditions.checkNotNull(favoriteListId);
FavoriteList result = user.getFavoriteListByTopiaId(favoriteListId);
@@ -430,7 +428,7 @@
return result;
}
- protected FavoriteListMember getFavoriteListMember(FavoriteList favoriteList, String memberId) throws EntityNotFoundException {
+ protected FavoriteListMember getFavoriteListMember(FavoriteList favoriteList, String memberId) {
FavoriteListMember result = favoriteList.getMemberByTopiaId(memberId);
checkEntityExists(FavoriteListMember.class, result, memberId);
@@ -450,7 +448,7 @@
destination.setEmail(StringUtils.lowerCase(source.getEmail()));
}
- protected void checkFavoriteListForm(PollenUser user, FavoriteList favoriteList) throws InvalidFavoriteListFormException {
+ protected void checkFavoriteListForm(PollenUser user, FavoriteList favoriteList) throws InvalidFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
@@ -507,12 +505,12 @@
if (!errors.isEmpty()) {
- throw new InvalidFavoriteListFormException(errors);
+ throw new InvalidFormException(errors);
}
}
- protected void checkFavoriteListMemberForm(FavoriteList favoriteList, FavoriteListMember favoriteListMember) throws InvalidFavoriteListMemberFormException {
+ protected void checkFavoriteListMemberForm(FavoriteList favoriteList, FavoriteListMember favoriteListMember) throws InvalidFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
@@ -558,7 +556,7 @@
if (!errors.isEmpty()) {
- throw new InvalidFavoriteListMemberFormException(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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -245,6 +245,15 @@
}
}
+ protected <E extends TopiaEntity> void checkEntityExists(Class<E> type,
+ E entity,
+ String property,
+ String entityId) throws EntityNotFoundException {
+ if (entity == null) {
+ throw new EntityNotFoundException(type, property, entityId);
+ }
+ }
+
protected boolean check(Multimap<String, String> errors, String field, boolean condition, String error) {
boolean valid = condition;
if (!valid) {
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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -29,14 +29,13 @@
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.persistence.entity.PollenUserTopiaDao;
import org.chorem.pollen.services.PollenService;
-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.exception.UserInvalidPasswordException;
import org.chorem.pollen.services.service.security.SecurityRole;
-import org.nuiton.topia.persistence.TopiaNoResultException;
import java.util.List;
+import java.util.Objects;
/**
* TODO
@@ -54,28 +53,24 @@
}
- public PollenUser getUser(String userId) throws EntityNotFoundException {
+ public PollenUser getUser(String userId) {
checkNotNull(userId);
- try {
- PollenUser result = getPollenUserDao().findByTopiaId(userId);
- return result;
- } catch (TopiaNoResultException e) {
- throw new EntityNotFoundException(PollenUser.class, userId);
- }
+ PollenUser result = getPollenUserDao().forTopiaIdEquals(userId).findUniqueOrNull();
+ checkEntityExists(PollenUser.class, result, userId);
+ return result;
+
}
- public PollenUser getUserByLogin(String login) throws EntityNotFoundException {
+ public PollenUser getUserByLogin(String login) {
checkNotNull(login);
- try {
- PollenUser result = getPollenUserDao().forLoginEquals(login).findAny();
- return result;
- } catch (TopiaNoResultException e) {
- throw new EntityNotFoundException(PollenUser.class, PollenUser.PROPERTY_LOGIN, login);
- }
+
+ PollenUser result = getPollenUserDao().forLoginEquals(login).findUniqueOrNull();
+ checkEntityExists(PollenUser.class, result, PollenUser.PROPERTY_LOGIN, login);
+ return result;
}
- public PollenUser createUser(PollenUser user, boolean generatePassword) throws InvalidPollenUserFormException {
+ public PollenUser createUser(PollenUser user, boolean generatePassword) throws InvalidFormException {
checkNotNull(user);
checkIsNotPersisted(user);
checkPollenUserForm(user);
@@ -88,7 +83,7 @@
return result;
}
- public PollenUser editUser(PollenUser user) throws InvalidPollenUserFormException {
+ public PollenUser editUser(PollenUser user) throws InvalidFormException {
checkNotNull(user);
checkIsPersisted(user);
checkPollenUserForm(user);
@@ -141,7 +136,7 @@
PollenUser user = getUser(userId);
- boolean valid = ObjectUtils.equals(
+ boolean valid = Objects.equals(
user.getEmailActivationToken(), token);
if (!valid) {
@@ -155,7 +150,7 @@
commit();
}
- public void createDefaultUsers() throws InvalidPollenUserFormException {
+ public void createDefaultUsers() throws InvalidFormException {
if (getPollenUserDao().count() == 0) {
@@ -170,7 +165,7 @@
}
}
- protected void checkPollenUserForm(PollenUser user) throws InvalidPollenUserFormException {
+ protected void checkPollenUserForm(PollenUser user) throws InvalidFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
@@ -218,7 +213,7 @@
if (!errors.isEmpty()) {
- throw new InvalidPollenUserFormException(errors);
+ throw new InvalidFormException(errors);
}
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java 2014-05-02 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -37,7 +37,7 @@
public class VoteCountingService extends PollenServiceSupport {
//GET /poll/{pollId}/results
- public PollResult getResult(String pollId) throws EntityNotFoundException {
+ public PollResult getResult(String pollId) {
Preconditions.checkNotNull(pollId);
Poll poll = getPollService().getPoll(pollId);
//TODO
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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -29,8 +29,7 @@
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.Polls;
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.exception.InvalidFormException;
import org.chorem.pollen.services.service.security.PermissionVerb;
import java.util.Date;
@@ -44,7 +43,7 @@
*/
public class VoteService extends PollenServiceSupport {
- public List<Vote> getVotes(String pollId) throws EntityNotFoundException {
+ public List<Vote> getVotes(String pollId) {
Preconditions.checkNotNull(pollId);
Poll poll = getPollService().getPoll(pollId);
@@ -52,7 +51,7 @@
return result;
}
- public Vote getVote(String pollId, String voteId) throws EntityNotFoundException {
+ public Vote getVote(String pollId, String voteId) {
Preconditions.checkNotNull(voteId);
checkPermission(PermissionVerb.readVote, voteId);
@@ -63,7 +62,7 @@
}
- public Vote addVote(String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
+ public Vote addVote(String pollId, Vote vote) throws InvalidFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(vote);
checkIsNotPersisted(vote);
@@ -80,7 +79,7 @@
return result;
}
- public Vote editVote(String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException {
+ public Vote editVote(String pollId, Vote vote) throws InvalidFormException {
Preconditions.checkNotNull(vote);
checkIsPersisted(vote);
checkPermission(PermissionVerb.editVote, vote.getTopiaId());
@@ -96,7 +95,7 @@
return result;
}
- public void deleteVote(String pollId, String voteId) throws EntityNotFoundException {
+ public void deleteVote(String pollId, String voteId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voteId);
@@ -113,7 +112,7 @@
//TODO Notify vote deleted
}
- protected void checkVoteForm(Poll poll, Vote vote) throws InvalidVoteFormException {
+ protected void checkVoteForm(Poll poll, Vote vote) throws InvalidFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
@@ -132,11 +131,11 @@
if (!errors.isEmpty()) {
- throw new InvalidVoteFormException(errors);
+ throw new InvalidFormException(errors);
}
}
- protected Vote saveVote(Poll poll, Vote vote) throws EntityNotFoundException {
+ protected Vote saveVote(Poll poll, Vote vote) {
boolean voteExist = vote.isPersisted();
@@ -171,7 +170,7 @@
return toSave;
}
- protected Vote getVote(Poll poll, String voteId) throws EntityNotFoundException {
+ protected Vote getVote(Poll poll, String voteId) {
Preconditions.checkNotNull(voteId);
Vote result = poll.getVoteByTopiaId(voteId);
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 12:06:45 UTC (rev 3898)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java 2014-05-02 12:07:13 UTC (rev 3899)
@@ -35,9 +35,7 @@
import org.chorem.pollen.persistence.entity.VoterListMember;
import org.chorem.pollen.persistence.entity.VoterListMemberTopiaDao;
import org.chorem.pollen.persistence.entity.VoterListTopiaDao;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
-import org.chorem.pollen.services.exception.InvalidVoterListFormException;
-import org.chorem.pollen.services.exception.InvalidVoterListMemberFormException;
+import org.chorem.pollen.services.exception.InvalidFormException;
import java.util.List;
import java.util.Set;
@@ -51,7 +49,7 @@
public class VoterListService extends PollenServiceSupport {
public VoterList importFavoriteList(String userId, String pollId,
- String favoriteListId) throws EntityNotFoundException {
+ String favoriteListId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(favoriteListId);
@@ -83,7 +81,7 @@
return result;
}
- public List<VoterList> getVoterLists(String pollId) throws EntityNotFoundException {
+ public List<VoterList> getVoterLists(String pollId) {
Preconditions.checkNotNull(pollId);
Poll poll = getPollService().getPoll(pollId);
@@ -92,7 +90,7 @@
return result;
}
- public VoterList getVoterList(String pollId, String voterListId) throws EntityNotFoundException {
+ public VoterList getVoterList(String pollId, String voterListId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterListId);
@@ -102,7 +100,7 @@
return result;
}
- public VoterList addVoterList(String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
+ public VoterList addVoterList(String pollId, VoterList voterList) throws InvalidFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterList);
checkIsNotPersisted(voterList);
@@ -117,7 +115,7 @@
return result;
}
- public VoterList editVoterList(String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException {
+ public VoterList editVoterList(String pollId, VoterList voterList) throws InvalidFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterList);
checkIsPersisted(voterList);
@@ -132,7 +130,7 @@
return result;
}
- public void deleteVoterList(String pollId, String voterListId) throws EntityNotFoundException {
+ public void deleteVoterList(String pollId, String voterListId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterListId);
@@ -146,7 +144,7 @@
commit();
}
- public Set<VoterListMember> getVoterListMembers(String pollId, String voterListId) throws EntityNotFoundException {
+ public Set<VoterListMember> getVoterListMembers(String pollId, String voterListId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterListId);
@@ -156,7 +154,7 @@
return result;
}
- public VoterListMember getVoterListMember(String pollId, String voterListId, String memberId) throws EntityNotFoundException {
+ public VoterListMember getVoterListMember(String pollId, String voterListId, String memberId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterListId);
Preconditions.checkNotNull(memberId);
@@ -168,7 +166,7 @@
return result;
}
- public VoterListMember addVoterListMember(String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException {
+ public VoterListMember addVoterListMember(String pollId, String voterListId, VoterListMember member) throws InvalidFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterListId);
Preconditions.checkNotNull(member);
@@ -186,7 +184,7 @@
}
- public VoterListMember editVoterListMember(String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException {
+ public VoterListMember editVoterListMember(String pollId, String voterListId, VoterListMember member) throws InvalidFormException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterListId);
Preconditions.checkNotNull(member);
@@ -203,7 +201,7 @@
return result;
}
- public void deleteVoterListMember(String pollId, String voterListId, String memberId) throws EntityNotFoundException {
+ public void deleteVoterListMember(String pollId, String voterListId, String memberId) {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voterListId);
Preconditions.checkNotNull(memberId);
@@ -218,14 +216,14 @@
commit();
}
- protected VoterList getVoterList(Poll poll, String voterListId) throws EntityNotFoundException {
+ protected VoterList getVoterList(Poll poll, String voterListId) {
VoterList result = poll.getVoterListByTopiaId(voterListId);
checkEntityExists(VoterList.class, result, voterListId);
return result;
}
- protected VoterListMember getVoterListMember(VoterList voterList, String memberId) throws EntityNotFoundException {
+ protected VoterListMember getVoterListMember(VoterList voterList, String memberId) {
Preconditions.checkNotNull(memberId);
VoterListMember result = voterList.getMemberByTopiaId(memberId);
@@ -233,7 +231,7 @@
return result;
}
- protected VoterList saveVoterList(Poll poll, VoterList voterList) throws EntityNotFoundException {
+ protected VoterList saveVoterList(Poll poll, VoterList voterList) {
boolean voterListExists = voterList.isPersisted();
@@ -263,7 +261,7 @@
}
protected VoterListMember saveVoterListMember(VoterList voterList,
- VoterListMember voterListMember) throws EntityNotFoundException {
+ VoterListMember voterListMember) {
boolean voterListMemberExists = voterListMember.isPersisted();
@@ -289,7 +287,7 @@
return toSave;
}
- protected void checkVoterList(Poll poll, VoterList voterList) throws InvalidVoterListFormException {
+ protected void checkVoterList(Poll poll, VoterList voterList) throws InvalidFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
@@ -351,11 +349,11 @@
if (!errors.isEmpty()) {
- throw new InvalidVoterListFormException(errors);
+ throw new InvalidFormException(errors);
}
}
- protected void checkVoterListMember(VoterList voterList, VoterListMember voterListMember) throws InvalidVoterListMemberFormException {
+ protected void checkVoterListMember(VoterList voterList, VoterListMember voterListMember) throws InvalidFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
@@ -400,7 +398,7 @@
if (!errors.isEmpty()) {
- throw new InvalidVoterListMemberFormException(errors);
+ throw new InvalidFormException(errors);
}
}
}
1
0
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