Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 3196 discussions
r3908 - trunk/pollen-services/src/main/java/org/chorem/pollen/services/service
by tchemit@users.chorem.org 04 May '14
by tchemit@users.chorem.org 04 May '14
04 May '14
Author: tchemit
Date: 2014-05-05 00:01:05 +0200 (Mon, 05 May 2014)
New Revision: 3908
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3908
Log:
some dev fixes
Modified:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java
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-04 21:57:18 UTC (rev 3907)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-05-04 22:01:05 UTC (rev 3908)
@@ -46,8 +46,8 @@
public List<PollenUser> getUsers() {
- checkIsConnected();
- checkIsAdmin();
+// checkIsConnected();
+// checkIsAdmin();
List<PollenUser> pollenUsers = getPollenUserDao().findAll();
return pollenUsers;
1
0
r3907 - trunk/pollen-services/src/main/java/org/chorem/pollen/services/service
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 23:57:18 +0200 (Sun, 04 May 2014)
New Revision: 3907
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3907
Log:
some dev fixes
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/PollService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java
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-04 21:39:22 UTC (rev 3906)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-05-04 21:57:18 UTC (rev 3907)
@@ -81,6 +81,7 @@
getPollDao().update(poll);
commit();
+
//TODO Notify Choice added
return result;
@@ -100,6 +101,7 @@
getChoiceDao().update(choice);
commit();
+
//TODO Notify Choice edited
return result;
@@ -124,7 +126,7 @@
protected Choice getChoice(Poll poll, String choiceId) {
- Choice result = poll.getChoiceByTopiaId(choiceId);
+ Choice result = getChoiceDao().findByTopiaId(choiceId);
if (!poll.containsChoice(result)) {
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-04 21:39:22 UTC (rev 3906)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-05-04 21:57:18 UTC (rev 3907)
@@ -53,8 +53,9 @@
public ImmutableSet<Poll> getPolls() {
- checkIsConnected();
- checkIsAdmin();
+ //TODO Push this back when security will be ok
+// checkIsConnected();
+// checkIsAdmin();
List<Poll> polls = getPollDao().findAll();
return ImmutableSet.copyOf(polls);
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 21:39:22 UTC (rev 3906)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-05-04 21:57:18 UTC (rev 3907)
@@ -219,8 +219,7 @@
public void checkIsAdmin() {
- //FIXME Reput this
-// getSecurityService().checkIsAdmin();
+ getSecurityService().checkIsAdmin();
}
1
0
Author: tchemit
Date: 2014-05-04 23:39:22 +0200 (Sun, 04 May 2014)
New Revision: 3906
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3906
Log:
security + sumplify exceptions + ...
Added:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/SessionTokenTopiaDao.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListImportException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/InvalidEntityLinkException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/InvalidFormException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenAuthenticationException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidEmailActivationTokenException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidPasswordException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidSessionTokenException.java
Removed:
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/RoleRequired.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityRole.java
Modified:
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/PollenTopiaTransactionFilter.java
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/ErrorAction.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/VoterListApi.java
trunk/pollen-rest-api/src/main/resources/mapping
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/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/PollenSecurityRealm.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/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/AbstractPollenServiceTest.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java
Added: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/SessionTokenTopiaDao.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/SessionTokenTopiaDao.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/SessionTokenTopiaDao.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -0,0 +1,11 @@
+package org.chorem.pollen.persistence.entity;
+
+public class SessionTokenTopiaDao extends AbstractSessionTokenTopiaDao<SessionToken> {
+
+ public SessionToken findUniqueOrNullByToken(String token) {
+
+ SessionToken sessionToken = forEquals(SessionToken.PROPERTY_POLLEN_TOKEN + "." + PollenToken.PROPERTY_TOKEN, token).findUniqueOrNull();
+ return sessionToken;
+
+ }
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/SessionTokenTopiaDao.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -36,7 +36,7 @@
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.chorem.pollen.services.service.InvalidFormException;
import org.debux.webmotion.server.call.Call;
import org.debux.webmotion.server.call.HttpContext;
import org.debux.webmotion.server.mapping.Mapping;
@@ -126,7 +126,7 @@
});
PollenRestApiApplicationContext applicationContext =
- PollenRestApiRequestFilter.getApplicationContext(context.getServletContext());
+ PollenRestApiApplicationContext.getApplicationContext(context.getServletContext());
boolean devMode = applicationContext.getApplicationConfig().isDevMode();
if (devMode) {
gsonBuilder.setPrettyPrinting();
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -28,6 +28,8 @@
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.LogManager;
import org.apache.log4j.PropertyConfigurator;
+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;
@@ -37,18 +39,19 @@
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;
-import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.InvalidFormException;
import org.chorem.pollen.services.service.PollenUserService;
import org.chorem.pollen.services.service.security.DefaultPollenSecurityContext;
import org.chorem.pollen.services.service.security.PollenSecurityContext;
+import org.chorem.pollen.services.service.security.PollenSecurityRealm;
import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.DefaultI18nInitializer;
import org.nuiton.i18n.init.I18nInitializer;
-import java.io.Closeable;
+import javax.servlet.ServletContext;
import java.io.File;
import java.util.Locale;
+import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -57,20 +60,46 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class PollenRestApiApplicationContext implements Closeable, PollenApplicationContext {
+public class PollenRestApiApplicationContext implements PollenApplicationContext {
private static Log log = LogFactory.getLog(PollenRestApiApplicationContext.class);
+ protected static final String APPLICATION_CONTEXT_PARAMETER = "pollen_PollenApplicationContext";
+
protected static PollenRestApiApplicationContext applicationContext;
public static PollenRestApiApplicationContext getApplicationContext() {
+
+ if (applicationContext == null) {
+
+ PollenServiceConfig applicationConfig = new PollenServiceConfig("pollen-rest-api.properties");
+
+ Map<String, String> topiaProperties = applicationConfig.getTopiaProperties();
+
+ PollenTopiaApplicationContext pollenTopiaApplicationContext = new PollenTopiaApplicationContext(topiaProperties);
+
+ applicationContext = new PollenRestApiApplicationContext(applicationConfig, pollenTopiaApplicationContext);
+
+ applicationContext.init();
+ }
return applicationContext;
}
+ public static PollenRestApiApplicationContext getApplicationContext(ServletContext servletContext) {
+ PollenRestApiApplicationContext result = (PollenRestApiApplicationContext)
+ servletContext.getAttribute(APPLICATION_CONTEXT_PARAMETER);
+ return result;
+ }
+
public static void setApplicationContext(PollenRestApiApplicationContext applicationContext) {
PollenRestApiApplicationContext.applicationContext = applicationContext;
}
+ public static void setApplicationContext(ServletContext servletContext,
+ PollenRestApiApplicationContext applicationContext) {
+ servletContext.setAttribute(APPLICATION_CONTEXT_PARAMETER, applicationContext);
+ }
+
protected AtomicBoolean started;
protected AtomicBoolean closed;
@@ -79,13 +108,6 @@
protected PollenServiceConfig applicationConfig;
- public static PollenRestApiApplicationContext newApplicationContext() {
- PollenServiceConfig applicationConfig = new PollenServiceConfig("pollen-rest-api.properties");
- PollenTopiaApplicationContext pollenTopiaApplicationContext = new PollenTopiaApplicationContext(applicationConfig.getTopiaProperties());
- PollenRestApiApplicationContext result = new PollenRestApiApplicationContext(applicationConfig, pollenTopiaApplicationContext);
- return result;
- }
-
protected PollenRestApiApplicationContext(PollenServiceConfig applicationConfig, PollenTopiaApplicationContext topiaApplicationContext) {
Preconditions.checkNotNull(applicationConfig, "Configuration can not be null!");
@@ -153,7 +175,7 @@
return;
}
- if (topiaApplicationContext != null) {
+ if (topiaApplicationContext != null && !topiaApplicationContext.isClosed()) {
if (log.isInfoEnabled()) {
log.info("stopping Pollen, will close persistence context");
@@ -165,6 +187,7 @@
started.set(false);
}
+ @Override
public void init() {
if (started.get()) {
@@ -221,12 +244,17 @@
serviceContext.newService(PollenUserService.class).createDefaultUsers();
} catch (InvalidFormException e) {
//Can't happen
- } catch (EntityNotFoundException e) {
- //Can't happen
} finally {
persistenceContext.closeContext();
}
+ // -- init security realm -- //
+
+ PollenSecurityRealm realm = new PollenSecurityRealm(this);
+
+ DefaultSecurityManager securityManager = new DefaultSecurityManager(realm);
+ SecurityUtils.setSecurityManager(securityManager);
+
started.set(true);
}
}
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 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -24,8 +24,6 @@
*/
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.chorem.pollen.services.PollenService;
import org.debux.webmotion.server.WebMotionServerListener;
@@ -36,7 +34,6 @@
import org.debux.webmotion.server.mapping.Mapping;
import org.nuiton.topia.persistence.TopiaEntity;
-import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Type;
import java.util.Date;
@@ -48,9 +45,6 @@
*/
public class PollenRestApiApplicationListener implements WebMotionServerListener {
- /** Logger. */
- private static final Log log = LogFactory.getLog(PollenRestApiApplicationListener.class);
-
@Override
public void onStart(Mapping mapping, ServerContext serverContext) {
@@ -107,9 +101,8 @@
PollenRestApiRequestContext result = null;
if (PollenRestApiRequestContext.class.isAssignableFrom(type)) {
HttpContext httpContext = call.getContext();
- HttpServletRequest request = httpContext.getRequest();
- result = PollenRestApiRequestFilter.getRequestContext(request);
+ result = PollenRestApiRequestContext.getRequestContext(httpContext);
}
return result;
}
@@ -121,9 +114,9 @@
PollenService result = null;
if (PollenService.class.isAssignableFrom(type)) {
HttpContext httpContext = call.getContext();
- HttpServletRequest request = httpContext.getRequest();
- PollenRestApiRequestContext requestContext = PollenRestApiRequestFilter.getRequestContext(request);
+ PollenRestApiRequestContext requestContext =
+ PollenRestApiRequestContext.getRequestContext(httpContext);
result = requestContext.getServiceContext().newService(type);
}
return result;
@@ -135,16 +128,7 @@
PollenRestApiApplicationContext applicationContext =
PollenRestApiApplicationContext.getApplicationContext();
- if (applicationContext == null) {
-
- // create application context
- applicationContext = PollenRestApiApplicationContext.newApplicationContext();
- PollenRestApiApplicationContext.setApplicationContext(applicationContext);
- applicationContext.init();
- }
-
- // push it in context
- PollenRestApiRequestFilter.setApplicationContext(
+ PollenRestApiApplicationContext.setApplicationContext(
serverContext.getServletContext(), applicationContext);
}
@@ -153,7 +137,7 @@
// Get application context
PollenRestApiApplicationContext applicationContext =
- PollenRestApiRequestFilter.getApplicationContext(
+ PollenRestApiApplicationContext.getApplicationContext(
serverContext.getServletContext());
// close it (and all underlined resources)
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 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestContext.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -24,6 +24,7 @@
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.service.security.PollenSecurityContext;
import org.chorem.pollen.services.service.security.SecurityService;
+import org.debux.webmotion.server.call.HttpContext;
/**
* Created on 4/25/14.
@@ -33,6 +34,20 @@
*/
public class PollenRestApiRequestContext {
+ protected static final String REQUEST_POLLEN_REQUEST_CONTEXT = "pollen_PollenRequestContext";
+
+ public static PollenRestApiRequestContext getRequestContext(HttpContext httpContext) {
+
+ PollenRestApiRequestContext result = (PollenRestApiRequestContext)
+ httpContext.getRequest().getAttribute(REQUEST_POLLEN_REQUEST_CONTEXT);
+ return result;
+ }
+
+ public static void setRequestContext(HttpContext httpContext,
+ PollenRestApiRequestContext serviceContext) {
+ httpContext.getRequest().setAttribute(REQUEST_POLLEN_REQUEST_CONTEXT, serviceContext);
+ }
+
protected PollenServiceContext serviceContext;
public void setServiceContext(PollenServiceContext serviceContext) {
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -27,19 +27,14 @@
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.PollenInvalidSessionTokenException;
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.CookieManager;
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;
@@ -51,53 +46,24 @@
*/
public class PollenRestApiRequestFilter extends WebMotionFilter {
- protected static final String APPLICATION_CONTEXT_PARAMETER = "pollen_PollenApplicationContext";
-
- protected static final String REQUEST_POLLEN_REQUEST_CONTEXT = "pollen_PollenRequestContext";
-
- protected static final String REQUEST_POLLEN_CONNECTED_USER = "pollen_PollenConnectedUser";
-
- 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);
- return result;
- }
+ public static final String POLLEN_SESSION = "pollenSession";
- public static PollenRestApiRequestContext getRequestContext(HttpServletRequest request) {
- PollenRestApiRequestContext result = (PollenRestApiRequestContext)
- request.getAttribute(REQUEST_POLLEN_REQUEST_CONTEXT);
- return result;
- }
+ public void inject(HttpContext context) throws PollenInvalidSessionTokenException {
- public static SessionToken getSessionToken(HttpServletRequest request) {
- SessionToken result = (SessionToken)
- request.getAttribute(REQUEST_POLLEN_CONNECTED_USER);
- return result;
- }
+ PollenRestApiRequestContext requestContext = prepareRequestContext(context);
- public static void setApplicationContext(ServletContext servletContext,
- PollenRestApiApplicationContext applicationContext) {
- servletContext.setAttribute(APPLICATION_CONTEXT_PARAMETER, applicationContext);
- }
+ doProcess();
- public static void setRequestContext(HttpServletRequest request,
- PollenRestApiRequestContext serviceContext) {
- request.setAttribute(REQUEST_POLLEN_REQUEST_CONTEXT, serviceContext);
- }
+ prepareResponse(context, requestContext);
- public static void setSessionToken(HttpServletRequest request,
- SessionToken sessionToken) {
- request.setAttribute(REQUEST_POLLEN_CONNECTED_USER, sessionToken);
}
- public void inject(Call call, HttpContext context) throws InvalidSessionTokenException {
+ protected PollenRestApiRequestContext prepareRequestContext(HttpContext context) throws PollenInvalidSessionTokenException {
PollenRestApiApplicationContext applicationContext =
- getApplicationContext(context.getServletContext());
+ PollenRestApiApplicationContext.getApplicationContext(context.getServletContext());
PollenPersistenceContext persistenceContext =
PollenTopiaTransactionFilter.getPersistenceContext(context.getRequest());
@@ -109,86 +75,63 @@
PollenRestApiRequestContext requestContext = new PollenRestApiRequestContext();
requestContext.setServiceContext(serviceContext);
- prepareSecurityContext(call, context, applicationContext, requestContext);
+ PollenSecurityContext securityContext = createSecurityContext(context, applicationContext, requestContext);
+ requestContext.setSecurityContext(securityContext);
- setRequestContext(context.getRequest(), requestContext);
+ PollenRestApiRequestContext.setRequestContext(context, requestContext);
- doProcess();
+ return requestContext;
+ }
+
+ protected void prepareResponse(HttpContext context, PollenRestApiRequestContext requestContext) {
+
HttpServletResponse response = context.getResponse();
response.addHeader(HttpContext.HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "*");
response.addHeader(HttpContext.HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
- }
- @Override
- public void doProcess() {
- super.doProcess();
- }
+ CookieManager cookieManager = context.getCookieManager();
- @Override
- public void doProcess(Mapping mapping, Call call) {
- super.doProcess(mapping, call);
- }
+ PollenSecurityContext securityContext = requestContext.getSecurityContext();
+ SessionToken sessionToken = securityContext.getSessionToken();
+ if (sessionToken != null) {
- protected void prepareSecurityContext(Call call,
- HttpContext httpContext,
- PollenRestApiApplicationContext applicationContext,
- PollenRestApiRequestContext requestContext) throws InvalidSessionTokenException {
+ CookieManager.CookieEntity pollenSession = cookieManager.create(POLLEN_SESSION, sessionToken.getPollenToken().getToken());
+ cookieManager.add(pollenSession);
- // --- Create security context --- //
- PollenSecurityContext securityContext = createSecurityContext(
- httpContext,
- applicationContext,
- requestContext);
+ } else {
- requestContext.setSecurityContext(securityContext);
+ cookieManager.remove(POLLEN_SESSION);
- SecurityService securityService = requestContext.getSecurityService();
-
- 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,
+ protected PollenSecurityContext createSecurityContext(HttpContext httpContext,
PollenRestApiApplicationContext applicationContext,
- PollenRestApiRequestContext pollenRestApiRequestContext) throws InvalidSessionTokenException {
+ PollenRestApiRequestContext requestContext) throws PollenInvalidSessionTokenException {
- SecurityService securityService = pollenRestApiRequestContext.getSecurityService();
- Map<String, String[]> parameters = context.getParameters();
+ SecurityService securityService = requestContext.getSecurityService();
- // get session token
- SessionToken sessionToken;
- {
+ // --- get session token (from cookie) --- //
+ CookieManager.CookieEntity pollenSession = httpContext.getCookieManager().get(POLLEN_SESSION);
+ String authParam = pollenSession == null ? null : pollenSession.getValue();
+ SessionToken sessionToken = securityService.getSessionTokenByToken(authParam);
- 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;
- {
+ // --- get mainPrincipal (from request parameters) --- //
+ Map<String, String[]> parameters = httpContext.getParameters();
+ String[] strings = parameters.get(REQUEST_CREDENTIAL_PARAMETER);
+ String credentialParam = strings == null || strings.length < 1 ? null : strings[0];
+ PollenPrincipal mainPrincipal = securityService.getPollenPrincipalById(credentialParam);
- String[] strings = parameters.get(REQUEST_CREDENTIAL_PARAMETER);
- String credentialParam = strings == null || strings.length < 1 ? null : strings[0];
- mainPrincipal = securityService.getPollenPrincipalById(credentialParam);
- }
-
+ // --- create security context --- //
PollenSecurityContext securityContext =
applicationContext.newSecurityContext(sessionToken, mainPrincipal);
return securityContext;
+
}
}
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenTopiaTransactionFilter.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenTopiaTransactionFilter.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenTopiaTransactionFilter.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -36,8 +36,7 @@
public class PollenTopiaTransactionFilter extends TypedTopiaTransactionFilter<PollenPersistenceContext> {
- private static final Log log =
- LogFactory.getLog(PollenTopiaTransactionFilter.class);
+ private static final Log log = LogFactory.getLog(PollenTopiaTransactionFilter.class);
public PollenTopiaTransactionFilter() {
super(PollenPersistenceContext.class);
@@ -45,9 +44,14 @@
@Override
protected PollenPersistenceContext beginTransaction(ServletRequest request) throws TopiaException {
- PollenRestApiApplicationContext applicationContext = PollenRestApiRequestFilter.getApplicationContext(request.getServletContext());
+
+ PollenRestApiApplicationContext applicationContext =
+ PollenRestApiApplicationContext.getApplicationContext(request.getServletContext());
+
PollenTopiaPersistenceContext persistenceContext = applicationContext.newPersistenceContext();
+
return persistenceContext;
+
}
@Override
Deleted: 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 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/RoleRequired.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -1,43 +0,0 @@
-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;
-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();
-
-}
Modified: 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/AuthApi.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -24,8 +24,8 @@
*/
import org.chorem.pollen.persistence.entity.SessionToken;
-import org.chorem.pollen.services.exception.UserInvalidPasswordException;
import org.chorem.pollen.services.service.AuthService;
+import org.chorem.pollen.services.service.security.PollenAuthenticationException;
import org.debux.webmotion.server.WebMotionController;
/**
@@ -36,15 +36,15 @@
*/
public class AuthApi extends WebMotionController {
- public SessionToken login(AuthService authService, String login, String password) throws UserInvalidPasswordException {
- return authService.login(login, password);
+ public SessionToken login(AuthService authService, String login, String password, Boolean rememberMe) throws PollenAuthenticationException {
+ return authService.login(login, password, rememberMe);
}
+ public void logout(AuthService authService) {
+ authService.logout();
+ }
+
public void lostPassword(AuthService authService, String login) {
authService.lostPassword(login);
}
-
- public void logout(AuthService authService, String login, String token) {
- authService.logout(login, token);
- }
}
Modified: 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/ChoiceApi.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceApi.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.Choice;
-import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.InvalidFormException;
import org.chorem.pollen.services.service.ChoiceService;
import org.debux.webmotion.server.WebMotionController;
Modified: 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/CommentApi.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentApi.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.Comment;
-import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.InvalidFormException;
import org.chorem.pollen.services.service.CommentService;
import org.debux.webmotion.server.WebMotionController;
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ErrorAction.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ErrorAction.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ErrorAction.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -23,7 +23,7 @@
* #L%
*/
-import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.InvalidFormException;
import org.debux.webmotion.server.WebMotionController;
import org.debux.webmotion.server.render.Render;
@@ -46,6 +46,14 @@
return renderError(HttpServletResponse.SC_NOT_FOUND, e.getMessage());
}
+ public Render on401(Exception e) {
+ return renderError(HttpServletResponse.SC_UNAUTHORIZED, e.getMessage());
+ }
+
+ public Render on403(Exception e) {
+ return renderError(HttpServletResponse.SC_FORBIDDEN, e.getMessage());
+ }
+
public Render on500(Exception e) {
return renderError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
}
Modified: 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/FavoriteListApi.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListApi.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -25,11 +25,9 @@
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.FavoriteListImportException;
+import org.chorem.pollen.services.service.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;
@@ -44,72 +42,60 @@
*/
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);
}
Modified: 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/PollApi.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -24,10 +24,8 @@
*/
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.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;
@@ -46,25 +44,21 @@
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;
Modified: 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/PollenUserApi.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -24,12 +24,10 @@
*/
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.InvalidFormException;
import org.chorem.pollen.services.service.PollenUserService;
-import org.chorem.pollen.services.service.security.SecurityRole;
+import org.chorem.pollen.services.service.security.PollenInvalidEmailActivationTokenException;
+import org.chorem.pollen.services.service.security.PollenInvalidPasswordException;
import org.debux.webmotion.server.WebMotionController;
import java.util.List;
@@ -42,7 +40,6 @@
*/
public class PollenUserApi extends WebMotionController {
- @RoleRequired(SecurityRole.administrator)
public List<PollenUser> getUsers(PollenUserService pollenUserService) {
List<PollenUser> users = pollenUserService.getUsers();
return users;
@@ -73,14 +70,14 @@
public void validateUserEmail(PollenUserService pollenUserService,
String userId,
- String token) throws UserInvalidEmailActivationTokenException {
+ String token) throws PollenInvalidEmailActivationTokenException {
pollenUserService.validateUserEmail(userId, token);
}
public void changePassword(PollenUserService pollenUserService,
String userId,
String oldPassword,
- String newPassword) throws UserInvalidPasswordException {
+ String newPassword) throws PollenInvalidPasswordException {
pollenUserService.changePassword(userId, oldPassword, newPassword);
}
}
Modified: 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/VoteApi.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteApi.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -24,7 +24,7 @@
*/
import org.chorem.pollen.persistence.entity.Vote;
-import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.InvalidFormException;
import org.chorem.pollen.services.service.VoteService;
import org.debux.webmotion.server.WebMotionController;
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListApi.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListApi.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListApi.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -25,10 +25,8 @@
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.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;
@@ -42,7 +40,6 @@
*/
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;
Modified: trunk/pollen-rest-api/src/main/resources/mapping
===================================================================
--- trunk/pollen-rest-api/src/main/resources/mapping 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/main/resources/mapping 2014-05-04 21:39:22 UTC (rev 3906)
@@ -10,10 +10,14 @@
[errors]
-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
+org.chorem.pollen.services.service.security.PollenAuthenticationException ErrorAction.on401
+org.chorem.pollen.services.service.security.PollenUnauthorizedException ErrorAction.on403
+org.chorem.pollen.services.service.security.PollenInvalidPermissionException ErrorAction.on403
+org.chorem.pollen.services.service.security.PollenInvalidSessionTokenException ErrorAction.on403
+org.chorem.pollen.services.service.security.PollenInvalidEmailActivationTokenException ErrorAction.on403
+org.chorem.pollen.services.service.InvalidFormException ErrorAction.on400Form
+org.nuiton.topia.persistence.TopiaNoResultException ErrorAction.on404
+org.chorem.pollen.services.service.InvalidEntityLinkException ErrorAction.on404
[actions]
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -26,6 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.persistence.PollenPersistenceContext;
+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.PollenServiceContext;
@@ -63,16 +64,18 @@
protected void loadFixtures(String fixturesSetName) {
- PollenRestApiApplicationContext applicationContext = PollenRestApiApplicationContext.getApplicationContext();
+ PollenTopiaPersistenceContext persistenceContext = application.newPersistenceContext();
- PollenServiceContext serviceContext = applicationContext.newServiceContext(applicationContext.newPersistenceContext(), Locale.FRANCE);
+ PollenServiceContext serviceContext = application.newServiceContext(persistenceContext, Locale.FRANCE);
application.loadFixtures(serviceContext, fixturesSetName);
+
}
protected <E> E fixture(String id) {
return application.fixture(id);
+
}
@Before
@@ -91,51 +94,49 @@
application.getTopiaApplicationContext(),
application.newPersistenceContext());
return serviceContext;
+
}
@Override
public PollenSecurityContext newSecurityContext(SessionToken sessionToken, PollenPrincipal mainPrincipal) {
+
FakePollenSecurityContext securityContext = new FakePollenSecurityContext();
securityContext.setMainPrincipal(mainPrincipal);
securityContext.setSessionToken(sessionToken);
return securityContext;
+
}
};
+
applicationContext.init();
+
PollenRestApiApplicationContext.setApplicationContext(applicationContext);
super.startServer();
+
}
@After
public void stopServer() throws Exception {
- PollenRestApiApplicationContext applicationContext = PollenRestApiApplicationContext.getApplicationContext();
+ if (log.isTraceEnabled()) {
+ log.trace("closing application context " + application);
+ }
- if (applicationContext != null) {
-
- if (log.isTraceEnabled()) {
- log.trace("closing application context " + applicationContext);
- }
- applicationContext.close();
- }
+ application.close();
server.stop();
server.destroy();
+
}
protected void showTestResult(String content) throws IOException {
+
String testName = application.getMethodName();
+
if (log.isInfoEnabled()) {
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-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -28,11 +28,15 @@
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.crypto.RandomNumberGenerator;
+import org.apache.shiro.crypto.hash.DefaultHashService;
+import org.apache.shiro.crypto.hash.Hash;
+import org.apache.shiro.crypto.hash.HashRequest;
+import org.apache.shiro.util.ByteSource;
import org.chorem.pollen.persistence.PollenPersistenceContext;
import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
import org.chorem.pollen.services.service.security.PollenSecurityContext;
-import org.nuiton.util.StringUtil;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@@ -52,6 +56,11 @@
private PollenTopiaApplicationContext topiaApplicationContext;
+ /**
+ * To hash passwords.
+ */
+ protected DefaultHashService hashService;
+
public void setPollenServiceConfig(PollenServiceConfig pollenServiceConfig) {
this.pollenServiceConfig = pollenServiceConfig;
}
@@ -84,11 +93,6 @@
}
@Override
- public String generateToken() {
- return generateId();
- }
-
- @Override
public Date getNow() {
Date now = new Date();
return now;
@@ -96,22 +100,62 @@
@Override
public PollenSecurityContext getSecurityContext() {
+
return securityContext;
+
}
@Override
+ public String generateSalt() {
+
+ RandomNumberGenerator generator = getHashService().getRandomNumberGenerator();
+ ByteSource byteSource = generator.nextBytes();
+ String salt = byteSource.toBase64();
+ return salt;
+
+ }
+
+ @Override
+ public String generateToken() {
+
+ // generate uuid
+ String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+
+ // decode in hexa base
+ byte[] decode;
+ try {
+ decode = Hex.decodeHex(uuid.toCharArray());
+ } catch (DecoderException e) {
+ // can't happen!
+ throw new RuntimeException(e);
+ }
+
+ // encode it in base64 (url safe version)
+ String result = Base64.encodeBase64URLSafeString(decode);
+ return result;
+
+ }
+
+ @Override
public String generatePassword() {
+
return RandomStringUtils.randomAlphanumeric(8);
+
}
@Override
- public PollenPersistenceContext getPersistenceContext() {
- return persistenceContext;
+ public String encodePassword(String salt, String password) {
+
+ HashRequest hashRequest = new HashRequest.Builder().setSalt(salt).setSource(password).build();
+ Hash hash = getHashService().computeHash(hashRequest);
+ String encodedToken = hash.toBase64();
+ return encodedToken;
+
}
@Override
- public String encodePassword(String password) {
- return StringUtil.encodeMD5(password);
+ public PollenPersistenceContext getPersistenceContext() {
+ return persistenceContext;
}
@Override
@@ -141,17 +185,10 @@
throw new PollenTechnicalException("all services must provide a default public constructor", e);
- } catch (InvocationTargetException e) {
+ } catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
throw new PollenTechnicalException("unable to instantiate pollen service", e);
- } catch (InstantiationException e) {
-
- throw new PollenTechnicalException("unable to instantiate pollen service", e);
-
- } catch (IllegalAccessException e) {
-
- throw new PollenTechnicalException("unable to instantiate pollen service", e);
}
service.setServiceContext(this);
@@ -160,23 +197,18 @@
}
- protected String generateId() {
+ protected DefaultHashService getHashService() {
- // generate uuid
- String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+ if (hashService == null) {
- // decode in hexa base
- byte[] decode;
- try {
- decode = Hex.decodeHex(uuid.toCharArray());
- } catch (DecoderException e) {
- // can't happen!
- throw new RuntimeException(e);
+ hashService = new DefaultHashService();
+ String hashAlgorithmName = getPollenServiceConfig().getHashAlgorithmName();
+ hashService.setHashAlgorithmName(hashAlgorithmName);
+
}
- // encode it in base64 (url safe version)
- String result = Base64.encodeBase64URLSafeString(decode);
- return result;
+ return hashService;
+
}
}
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 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenApplicationContext.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -29,6 +29,7 @@
import org.chorem.pollen.services.config.PollenServiceConfig;
import org.chorem.pollen.services.service.security.PollenSecurityContext;
+import java.io.Closeable;
import java.util.Locale;
/**
@@ -37,7 +38,7 @@
* @author Tony Chemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public interface PollenApplicationContext {
+public interface PollenApplicationContext extends Closeable {
PollenTopiaApplicationContext getTopiaApplicationContext();
@@ -48,4 +49,6 @@
PollenServiceContext newServiceContext(PollenPersistenceContext persistenceContext, Locale locale);
PollenSecurityContext newSecurityContext(SessionToken sessionToken, PollenPrincipal mainPrincipal);
+
+ void init();
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -55,9 +55,11 @@
String generatePassword();
- String encodePassword(String password);
-
Locale getLocale();
String getCleanMail(String email);
+
+ String generateSalt();
+
+ String encodePassword(String salt, String password);
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -28,6 +28,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.shiro.crypto.hash.Sha512Hash;
import org.chorem.pollen.persistence.entity.CommentVisibility;
import org.chorem.pollen.persistence.entity.PollType;
import org.chorem.pollen.persistence.entity.VoteVisibility;
@@ -167,4 +168,8 @@
public String getSmtpFrom() {
return applicationConfig.getOption(PollenServiceConfigOption.SMTP_FROM.key);
}
+
+ public String getHashAlgorithmName() {
+ return Sha512Hash.ALGORITHM_NAME;
+ }
}
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -26,11 +26,10 @@
import com.google.common.base.Preconditions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.persistence.entity.PollenToken;
import org.chorem.pollen.persistence.entity.PollenUser;
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.UserInvalidPasswordException;
+import org.chorem.pollen.services.service.security.PollenAuthenticationException;
/**
* TODO
@@ -43,64 +42,49 @@
/** Logger. */
private static final Log log = LogFactory.getLog(AuthService.class);
- public SessionToken login(String login, String password) throws EntityNotFoundException, UserInvalidPasswordException {
- Preconditions.checkNotNull(login);
- Preconditions.checkNotNull(password);
+ public SessionToken login(String login, String password, Boolean rememberMe) throws PollenAuthenticationException {
- PollenUser user = getUserService().getUserByLogin(login);
+ // Log-in user
+ PollenUser user = getSecurityService().login(login, password, rememberMe);
- String encodedPassword = serviceContext.encodePassword(password);
- if (!encodedPassword.equals(user.getPassword())) {
- throw new UserInvalidPasswordException();
- }
+ // Generate a token
+ PollenToken pollenToken = getSecurityService().generateNewToken();
- // Create a new session Token
- SessionTokenTopiaDao dao = getSessionTokenDao();
+ // Create session Token
+ SessionToken sessionToken = getSessionTokenDao().create(
+ SessionToken.PROPERTY_POLLEN_TOKEN, pollenToken,
+ SessionToken.PROPERTY_POLLEN_USER, user);
+ commit();
+ return sessionToken;
- SessionToken sessionToken = dao.newInstance();
- String token = serviceContext.generateToken();
- String encodedToken = serviceContext.encodePassword(token);
- sessionToken.setPollenUser(user);
- sessionToken.setToken(encodedToken);
- sessionToken.setCreationDate(serviceContext.getNow());
+ }
- dao.create(sessionToken);
- commit();
+ public void logout() {
- return sessionToken;
+ SessionToken sessionToken = getSecurityService().logout();
+ if (sessionToken != null) {
+ getSessionTokenDao().delete(sessionToken);
+ commit();
+ }
+
}
- public void lostPassword(String login) throws EntityNotFoundException {
+ public void lostPassword(String login) {
+
Preconditions.checkNotNull(login);
PollenUser user = getUserService().getUserByLogin(login);
- // Generate a new password
String newPassword = serviceContext.generatePassword();
- String encodedPassword = serviceContext.encodePassword(newPassword);
- user.setPassword(encodedPassword);
-// dao.update(user);
+
+ getSecurityService().setUserPassword(user, newPassword);
commit();
- //TODO Notifiy Password changed
+ //TODO Notifiy Password changed to user
if (log.isDebugEnabled()) {
- log.debug("Notify Password Changed");
+ log.debug("Notify Password changed");
}
- }
- public void logout(String login, String token) throws EntityNotFoundException {
- Preconditions.checkNotNull(login);
- Preconditions.checkNotNull(token);
-
- getUserService().getUserByLogin(login);
-
- SessionTokenTopiaDao dao = getSessionTokenDao();
-
- SessionToken sessionToken = dao.findByTopiaId(token);
- checkEntityExists(SessionToken.class, sessionToken, token);
-
- dao.delete(sessionToken);
- commit();
}
}
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -23,7 +23,6 @@
* #L%
*/
-import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
@@ -31,7 +30,6 @@
import org.chorem.pollen.persistence.entity.ChoiceTopiaDao;
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.PollenPrincipal;
-import org.chorem.pollen.services.exception.InvalidFormException;
import org.chorem.pollen.services.service.security.PermissionVerb;
import java.util.List;
@@ -46,30 +44,36 @@
public class ChoiceService extends PollenServiceSupport {
public List<Choice> getChoices(String pollId) {
- Preconditions.checkNotNull(pollId);
+ checkNotNull(pollId);
+
Poll poll = getPollService().getPoll(pollId);
return poll.getChoice();
+
}
public Choice getChoice(String pollId, String choiceId) {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(choiceId);
+
+ checkNotNull(pollId);
+ checkNotNull(choiceId);
checkPermission(PermissionVerb.readChoice, choiceId);
+
Poll poll = getPollService().getPoll(pollId);
Choice result = getChoice(poll, choiceId);
return result;
+
}
public Choice addChoice(String pollId, Choice choice) throws InvalidFormException {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(choice);
+
+ checkNotNull(pollId);
+ checkNotNull(choice);
checkIsNotPersisted(choice);
+ checkPermission(PermissionVerb.editPoll, pollId);
Poll poll = getPollService().getPoll(pollId);
- checkPermission(PermissionVerb.editPoll, pollId);
checkChoiceForm(poll, choice);
@@ -79,10 +83,12 @@
commit();
//TODO Notify Choice added
return result;
+
}
public Choice editChoice(String pollId, Choice choice) throws InvalidFormException {
- Preconditions.checkNotNull(choice);
+
+ checkNotNull(choice);
checkIsPersisted(choice);
checkPermission(PermissionVerb.editChoice, choice.getTopiaId());
@@ -96,11 +102,13 @@
commit();
//TODO Notify Choice edited
return result;
+
}
public void deleteChoice(String pollId, String choiceId) {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(choiceId);
+
+ checkNotNull(pollId);
+ checkNotNull(choiceId);
checkPermission(PermissionVerb.deleteChoice, choiceId);
Poll poll = getPollService().getPoll(pollId);
@@ -111,13 +119,21 @@
getPollDao().update(poll);
commit();
//TODO Notify Choice deleted
+
}
protected Choice getChoice(Poll poll, String choiceId) {
Choice result = poll.getChoiceByTopiaId(choiceId);
- checkEntityExists(Choice.class, result, choiceId);
+
+ if (!poll.containsChoice(result)) {
+
+ throw new InvalidEntityLinkException(Poll.PROPERTY_CHOICE, poll, result);
+
+ }
+
return result;
+
}
protected Choice saveChoice(Poll poll, Choice choice) {
@@ -167,6 +183,7 @@
throw new IllegalStateException("Not implemented");
}
return choiceToPersist;
+
}
protected void checkChoiceForm(Poll poll, Choice choice) throws InvalidFormException {
@@ -190,6 +207,7 @@
continue;
}
choiceNames.add(choice1.getName());
+
}
}
@@ -210,15 +228,19 @@
break;
case DATE:
+
throw new IllegalStateException("Not implemented");
case IMAGE:
+
throw new IllegalStateException("Not implemented");
}
if (!errors.isEmpty()) {
throw new InvalidFormException(errors);
+
}
+
}
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -23,14 +23,12 @@
* #L%
*/
-import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import org.apache.commons.lang3.StringUtils;
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.InvalidFormException;
import org.chorem.pollen.services.service.security.PermissionVerb;
import java.util.List;
@@ -44,58 +42,71 @@
public class CommentService extends PollenServiceSupport {
public List<Comment> getComments(String pollId) {
- Preconditions.checkNotNull(pollId);
+
+ checkNotNull(pollId);
+
Poll poll = getPollService().getPoll(pollId);
return poll.getComment();
+
}
public Comment getComment(String pollId, String commentId) {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(commentId);
- Poll poll = getPollService().getPoll(pollId);
+ checkNotNull(pollId);
+ checkNotNull(commentId);
checkPermission(PermissionVerb.readComment, commentId);
+ Poll poll = getPollService().getPoll(pollId);
+
Comment result = getComment(poll, commentId);
return result;
+
}
public Comment addComment(String pollId, Comment comment) throws InvalidFormException {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(comment);
+
+ checkNotNull(pollId);
+ checkNotNull(comment);
checkIsNotPersisted(comment);
checkPermission(PermissionVerb.addComment, pollId);
+
Poll poll = getPollService().getPoll(pollId);
- checkCommentForm(poll, comment);
+ checkCommentForm(comment);
+
Comment result = saveComment(poll, comment);
getPollDao().update(poll);
commit();
+
return result;
+
}
public Comment editComment(String pollId, Comment comment) throws InvalidFormException {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(comment);
+
+ checkNotNull(pollId);
+ checkNotNull(comment);
checkIsPersisted(comment);
-
checkPermission(PermissionVerb.editComment, comment.getTopiaId());
Poll poll = getPollService().getPoll(pollId);
- checkCommentForm(poll, comment);
+ checkCommentForm(comment);
+
Comment result = saveComment(poll, comment);
getCommentDao().update(comment);
commit();
+
return result;
+
}
public void deleteComment(String pollId, String commentId) {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(commentId);
+ checkNotNull(pollId);
+ checkNotNull(commentId);
checkPermission(PermissionVerb.deleteComment, commentId);
Poll poll = getPollService().getPoll(pollId);
@@ -106,16 +117,24 @@
getPollDao().update(poll);
commit();
+
}
protected Comment getComment(Poll poll, String commentId) {
- Comment result = poll.getCommentByTopiaId(commentId);
- checkEntityExists(Comment.class, result, commentId);
+ Comment result = getCommentDao().findByTopiaId(commentId);
+
+ if (!poll.containsComment(result)) {
+
+ throw new InvalidEntityLinkException(Poll.PROPERTY_COMMENT, poll, result);
+
+ }
+
return result;
+
}
- protected void checkCommentForm(Poll poll, Comment comment) throws InvalidFormException {
+ protected void checkCommentForm(Comment comment) throws InvalidFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
@@ -123,13 +142,17 @@
checkNotBlank(errors, "text", comment.getText(), "textcan not be empty");
boolean authorNotNull = checkNotNull(errors, "author", comment.getAuthor(), "author can not be null");
if (authorNotNull) {
+
checkNotBlank(errors, "author.name", comment.getAuthor().getName(), "author name can not be empty");
+
}
if (!errors.isEmpty()) {
throw new InvalidFormException(errors);
+
}
+
}
protected Comment saveComment(Poll poll, Comment comment) {
@@ -140,7 +163,8 @@
if (commentExists) {
- toSave = getComment(poll, comment.getTopiaId());
+ toSave = getCommentDao().findByTopiaId(comment.getTopiaId());
+
} else {
toSave = getCommentDao().newInstance();
@@ -152,6 +176,7 @@
toSave.setAuthor(author);
poll.addComment(toSave);
+
}
toSave.setText(comment.getText());
@@ -160,10 +185,13 @@
toSave.getAuthor().setName(comment.getAuthor().getName());
if (StringUtils.isNotBlank(comment.getAuthor().getEmail())) {
+
toSave.getAuthor().setEmail(StringUtils.lowerCase(comment.getAuthor().getEmail()));
+
}
return toSave;
+
}
}
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListImportException.java (from rev 3905, trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/FavoriteListImportException.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListImportException.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListImportException.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -0,0 +1,52 @@
+package org.chorem.pollen.services.service;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class FavoriteListImportException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private String causeMessage;
+
+ public FavoriteListImportException(String causeMessage, Throwable cause) {
+ super(cause);
+ this.causeMessage = causeMessage;
+ }
+
+ public FavoriteListImportException(Throwable cause) {
+ this(cause.getMessage(), cause);
+ }
+
+ /** @return the error message source from import execution. */
+ public String getCauseMessage() {
+ return causeMessage;
+ }
+
+}
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -23,7 +23,6 @@
* #L%
*/
-import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
@@ -33,8 +32,6 @@
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.FavoriteListImportException;
-import org.chorem.pollen.services.exception.InvalidFormException;
import org.nuiton.util.StringUtil;
import javax.naming.NamingEnumeration;
@@ -66,6 +63,8 @@
public class FavoriteListService extends PollenServiceSupport {
public List<FavoriteList> getFavoriteLists() {
+
+ checkIsConnected();
PollenUser user = getConnectedUser();
List<FavoriteList> result = user.getFavoriteList();
@@ -74,7 +73,8 @@
public FavoriteList getFavoriteList(String favoriteListId) {
- Preconditions.checkNotNull(favoriteListId);
+ checkIsConnected();
+ checkNotNull(favoriteListId);
PollenUser user = getConnectedUser();
@@ -84,7 +84,8 @@
public FavoriteList createFavoriteList(FavoriteList favoriteList) throws InvalidFormException {
- Preconditions.checkNotNull(favoriteList);
+ checkIsConnected();
+ checkNotNull(favoriteList);
checkIsNotPersisted(favoriteList);
PollenUser user = getConnectedUser();
@@ -102,7 +103,9 @@
}
public FavoriteList editFavoriteList(FavoriteList favoriteList) throws InvalidFormException {
- Preconditions.checkNotNull(favoriteList);
+
+ checkIsConnected();
+ checkNotNull(favoriteList);
checkIsPersisted(favoriteList);
// get user
@@ -123,7 +126,8 @@
public void deleteFavoriteList(String favoriteListId) {
- Preconditions.checkNotNull(favoriteListId);
+ checkIsConnected();
+ checkNotNull(favoriteListId);
PollenUser user = getConnectedUser();
@@ -137,7 +141,8 @@
public LinkedHashSet<FavoriteListMember> getFavoriteListMembers(String favoriteListId) {
- Preconditions.checkNotNull(favoriteListId);
+ checkIsConnected();
+ checkNotNull(favoriteListId);
PollenUser user = getConnectedUser();
@@ -148,8 +153,9 @@
public FavoriteListMember getFavoriteListMember(String favoriteListId, String memberId) {
- Preconditions.checkNotNull(favoriteListId);
- Preconditions.checkNotNull(memberId);
+ checkIsConnected();
+ checkNotNull(favoriteListId);
+ checkNotNull(memberId);
PollenUser user = getConnectedUser();
@@ -162,8 +168,9 @@
public FavoriteListMember addFavoriteListMember(String favoriteListId,
FavoriteListMember member) throws InvalidFormException {
- Preconditions.checkNotNull(favoriteListId);
- Preconditions.checkNotNull(member);
+ checkIsConnected();
+ checkNotNull(favoriteListId);
+ checkNotNull(member);
checkIsNotPersisted(member);
PollenUser user = getConnectedUser();
@@ -186,11 +193,11 @@
public FavoriteListMember editFavoriteListMember(String favoriteListId,
FavoriteListMember member) throws InvalidFormException {
- Preconditions.checkNotNull(favoriteListId);
- Preconditions.checkNotNull(member);
+ checkIsConnected();
+ checkNotNull(favoriteListId);
+ checkNotNull(member);
checkIsPersisted(member);
-
PollenUser user = getConnectedUser();
FavoriteList favoriteList = getFavoriteList(user, favoriteListId);
@@ -212,8 +219,9 @@
public void removeFavoriteListMember(String favoriteListId,
String memberId) {
- Preconditions.checkNotNull(favoriteListId);
- Preconditions.checkNotNull(memberId);
+ checkIsConnected();
+ checkNotNull(favoriteListId);
+ checkNotNull(memberId);
PollenUser user = getConnectedUser();
@@ -230,8 +238,9 @@
public int importFavoriteListMembersFromCsv(String favoriteListId,
File file) throws FavoriteListImportException {
- Preconditions.checkNotNull(favoriteListId);
- Preconditions.checkNotNull(file);
+ checkIsConnected();
+ checkNotNull(favoriteListId);
+ checkNotNull(file);
PollenUser user = getConnectedUser();
@@ -327,9 +336,11 @@
public int importFavoriteListMembersFromLdap(String favoriteListId,
String ldap) throws FavoriteListImportException {
- Preconditions.checkNotNull(favoriteListId);
- Preconditions.checkNotNull(ldap);
+ checkIsConnected();
+ checkNotNull(favoriteListId);
+ checkNotNull(ldap);
+
PollenUser user = getConnectedUser();
FavoriteList favoriteList = getFavoriteList(user, favoriteListId);
@@ -412,19 +423,30 @@
}
protected FavoriteList getFavoriteList(PollenUser user, String favoriteListId) {
- Preconditions.checkNotNull(favoriteListId);
- FavoriteList result = user.getFavoriteListByTopiaId(favoriteListId);
- checkEntityExists(FavoriteList.class, result, favoriteListId);
+ FavoriteList result = getFavoriteListDao().findByTopiaId(favoriteListId);
+ if (!user.containsFavoriteList(result)) {
+ throw new InvalidEntityLinkException(PollenUser.PROPERTY_FAVORITE_LIST, user, result);
+
+ }
+
return result;
+
}
protected FavoriteListMember getFavoriteListMember(FavoriteList favoriteList, String memberId) {
- FavoriteListMember result = favoriteList.getMemberByTopiaId(memberId);
- checkEntityExists(FavoriteListMember.class, result, memberId);
+ FavoriteListMember result = getFavoriteListMemberDao().findByTopiaId(memberId);
+
+ if (!favoriteList.containsMember(result)) {
+
+ throw new InvalidEntityLinkException(FavoriteList.PROPERTY_MEMBER, favoriteList, result);
+
+ }
+
return result;
+
}
protected void copyFavoriteList(FavoriteList source,
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FixturesService.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -34,7 +34,7 @@
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 org.chorem.pollen.services.service.security.SecurityService;
import java.util.Collection;
import java.util.Map;
@@ -86,13 +86,15 @@
}
+ SecurityService securityService = getSecurityService();
+
PollenUserTopiaDao userDao = persistenceContext.getPollenUserDao();
Collection<PollenUser> users = fixtures.fixture("users");
for (PollenUser user : users) {
- user.setPassword(serviceContext.encodePassword(user.getPassword()));
+ securityService.setUserPassword(user, user.getPassword());
PollenUser createdUser = userDao.create(user);
user.setTopiaId(createdUser.getTopiaId());
}
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/InvalidEntityLinkException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/InvalidEntityLinkException.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/InvalidEntityLinkException.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -0,0 +1,38 @@
+package org.chorem.pollen.services.service;
+
+import org.chorem.pollen.services.PollenTechnicalException;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * Created on 5/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class InvalidEntityLinkException extends PollenTechnicalException {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final Class<? extends TopiaEntity> containerType;
+
+ protected final Class<? extends TopiaEntity> entityType;
+
+ protected final String containerId;
+
+ protected final String link;
+
+ protected final String entityId;
+
+ public InvalidEntityLinkException(String link, TopiaEntity container, TopiaEntity entity) {
+ this.containerType = container.getClass();
+ this.entityType = entity.getClass();
+ this.link = link;
+ this.containerId = container.getTopiaId();
+ this.entityId = entity.getTopiaId();
+ }
+
+ @Override
+ public String getMessage() {
+ return "Could not find a " + entityType + " of id " + entityId + " as a " + link + " of container " + containerType + ") of id: " + containerId;
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/InvalidEntityLinkException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/InvalidFormException.java (from rev 3895, trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFormException.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/InvalidFormException.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/InvalidFormException.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -0,0 +1,52 @@
+package org.chorem.pollen.services.service;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Multimap;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class InvalidFormException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final Multimap<String, String> errors;
+
+ public InvalidFormException(Multimap<String, String> errors) {
+ this.errors = errors;
+ }
+
+ public Multimap<String, String> getErrors() {
+ return errors;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " errors: " + errors;
+ }
+}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-05-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -31,13 +31,11 @@
import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.persistence.entity.Choice;
import org.chorem.pollen.persistence.entity.Poll;
-import org.chorem.pollen.persistence.entity.PollTopiaDao;
import org.chorem.pollen.persistence.entity.PollenPrincipal;
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.persistence.entity.Polls;
import org.chorem.pollen.persistence.entity.VoterList;
import org.chorem.pollen.persistence.entity.VoterListMember;
-import org.chorem.pollen.services.exception.InvalidFormException;
import org.chorem.pollen.services.service.security.PermissionVerb;
import java.io.File;
@@ -55,32 +53,44 @@
public ImmutableSet<Poll> getPolls() {
+ checkIsConnected();
+ checkIsAdmin();
+
List<Poll> polls = getPollDao().findAll();
- return ImmutableSet.<Poll>builder().addAll(polls).build();
+ return ImmutableSet.copyOf(polls);
}
public ImmutableSet<Poll> getCreatedPolls() {
+ checkIsConnected();
+
PollenUser connectedUser = getConnectedUser();
+
Set<Poll> polls = getPollDao().findAllCreated(connectedUser);
- return ImmutableSet.<Poll>builder().addAll(polls).build();
+ return ImmutableSet.copyOf(polls);
}
public ImmutableSet<Poll> getInvitedPolls() {
+ checkIsConnected();
+
PollenUser connectedUser = getConnectedUser();
+
Set<Poll> polls = getPollDao().findAllInvited(connectedUser);
- return ImmutableSet.<Poll>builder().addAll(polls).build();
+ return ImmutableSet.copyOf(polls);
}
public ImmutableSet<Poll> getParticipatedPolls() {
+ checkIsConnected();
+
PollenUser connectedUser = getConnectedUser();
+
Set<Poll> polls = getPollDao().findAllParticipated(connectedUser);
- return ImmutableSet.<Poll>builder().addAll(polls).build();
+ return ImmutableSet.copyOf(polls);
}
@@ -88,8 +98,8 @@
checkNotNull(pollId);
checkPermission(PermissionVerb.readPoll, pollId);
- Poll result = getPollDao().forTopiaIdEquals(pollId).findUniqueOrNull();
- checkEntityExists(Poll.class, result, pollId);
+
+ Poll result = getPollDao().findByTopiaId(pollId);
return result;
}
@@ -121,6 +131,7 @@
result.setChoice(Lists.<Choice>newArrayList());
result.setVoterList(Lists.<VoterList>newArrayList());
+
return result;
}
@@ -135,7 +146,9 @@
getPollDao().create(savedPoll);
commit();
+
getNotificationService().onPollCreated(poll);
+
return savedPoll;
}
@@ -151,7 +164,9 @@
getPollDao().update(savedPoll);
commit();
+
getNotificationService().onPollEdited(poll);
+
return savedPoll;
}
@@ -165,6 +180,7 @@
getPollDao().delete(poll);
commit();
+
getNotificationService().onPollDeleted(poll);
}
@@ -175,9 +191,12 @@
checkPermission(PermissionVerb.clonePoll, pollId);
Poll poll = getPoll(pollId);
+
//TODO
commit();
+
getNotificationService().onPollCreated(poll);
+
return poll;
}
@@ -188,8 +207,10 @@
checkPermission(PermissionVerb.closePoll, pollId);
Poll poll = getPoll(pollId);
+
//TODO
commit();
+
getNotificationService().onPollClosed(poll);
}
@@ -198,7 +219,9 @@
checkNotNull(pollId);
checkPermission(PermissionVerb.exportPoll, pollId);
+
Poll poll = getPoll(pollId);
+
//TODO
return null;
@@ -211,17 +234,18 @@
Poll toSave;
if (pollExists) {
+
toSave = getPoll(poll.getTopiaId());
} else {
- PollTopiaDao dao = getPollDao();
- toSave = dao.newInstance();
+ toSave = getPollDao().newInstance();
PollenPrincipal creatorToPersist =
getSecurityService().generatePollenPrincipal();
toSave.setCreator(creatorToPersist);
+
}
// -- creator -- //
@@ -232,12 +256,15 @@
// link to connected user
toSave.getCreator().setPollenUser(connectedUser);
+
}
PollenPrincipal creator = poll.getCreator();
if (creator != null) {
+
toSave.getCreator().setName(creator.getName());
toSave.getCreator().setEmail(creator.getEmail());
+
}
// -- simple properties -- //
@@ -265,6 +292,7 @@
for (Choice choice : poll.getChoice()) {
getChoiceService().saveChoice(toSave, choice);
+
}
// -- voting list -- //
@@ -274,6 +302,7 @@
for (VoterList voterList : poll.getVoterList()) {
getVoterListService().saveVoterList(toSave, voterList);
+
}
}
@@ -409,6 +438,7 @@
if (!errors.isEmpty()) {
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -44,9 +44,9 @@
import org.chorem.pollen.services.PollenService;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
-import org.chorem.pollen.services.exception.EntityNotFoundException;
import org.chorem.pollen.services.service.mail.EmailService;
import org.chorem.pollen.services.service.security.PermissionVerb;
+import org.chorem.pollen.services.service.security.PollenSecurityContext;
import org.chorem.pollen.services.service.security.SecurityService;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.util.StringUtil;
@@ -77,8 +77,8 @@
return serviceContext.getNow();
}
- protected String generateToken() {
- return serviceContext.generateToken();
+ protected PollenSecurityContext getSecurityContext() {
+ return serviceContext.getSecurityContext();
}
protected String getCleanMail(String email) {
@@ -211,6 +211,19 @@
return serviceContext.getSecurityContext().getPollenUser();
}
+ public void checkIsConnected() {
+
+ getSecurityService().checkIsConnected();
+
+ }
+
+ public void checkIsAdmin() {
+
+ //FIXME Reput this
+// getSecurityService().checkIsAdmin();
+
+ }
+
protected void checkPermission(PermissionVerb verb, String id) {
String permission = getSecurityService().createPermission(verb, id);
getSecurityService().checkPermission(permission);
@@ -228,23 +241,6 @@
Preconditions.checkState(!entity.isPersisted());
}
- protected <E extends TopiaEntity> void checkEntityExists(Class<E> type,
- E entity,
- String entityId) throws EntityNotFoundException {
- if (entity == null) {
- throw new EntityNotFoundException(type, entityId);
- }
- }
-
- 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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -26,12 +26,12 @@
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import org.apache.commons.lang3.ObjectUtils;
+import org.chorem.pollen.persistence.entity.PollenToken;
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.InvalidFormException;
-import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
-import org.chorem.pollen.services.exception.UserInvalidPasswordException;
+import org.chorem.pollen.services.service.security.PollenInvalidEmailActivationTokenException;
+import org.chorem.pollen.services.service.security.PollenInvalidPasswordException;
import java.util.List;
import java.util.Objects;
@@ -46,6 +46,9 @@
public List<PollenUser> getUsers() {
+ checkIsConnected();
+ checkIsAdmin();
+
List<PollenUser> pollenUsers = getPollenUserDao().findAll();
return pollenUsers;
@@ -55,8 +58,7 @@
checkNotNull(userId);
- PollenUser result = getPollenUserDao().forTopiaIdEquals(userId).findUniqueOrNull();
- checkEntityExists(PollenUser.class, result, userId);
+ PollenUser result = getPollenUserDao().findByTopiaId(userId);
return result;
}
@@ -65,9 +67,9 @@
checkNotNull(login);
- PollenUser result = getPollenUserDao().forLoginEquals(login).findUniqueOrNull();
- checkEntityExists(PollenUser.class, result, PollenUser.PROPERTY_LOGIN, login);
+ PollenUser result = getPollenUserDao().forLoginEquals(login).findUnique();
return result;
+
}
public PollenUser createUser(PollenUser user, boolean generatePassword) throws InvalidFormException {
@@ -80,6 +82,7 @@
getPollenUserDao().create(result);
commit();
+
//TODO Notify user created
return result;
@@ -95,6 +98,7 @@
getPollenUserDao().update(result);
commit();
+
//TODO Notify user edited
return result;
@@ -105,6 +109,7 @@
checkNotNull(userId);
PollenUser user = getUser(userId);
+
getPollenUserDao().delete(user);
commit();
@@ -112,7 +117,7 @@
public void changePassword(String userId,
String oldPassword,
- String newPassword) throws UserInvalidPasswordException {
+ String newPassword) throws PollenInvalidPasswordException {
checkNotNull(userId);
checkNotNull(oldPassword);
@@ -120,15 +125,11 @@
PollenUser user = getUser(userId);
- // check current password
- String encodedPassword = serviceContext.encodePassword(user.getPassword());
- if (!encodedPassword.equals(user.getPassword())) {
- throw new UserInvalidPasswordException();
- }
+ // check old password
+ getSecurityService().checkUserPassword(user, oldPassword);
- // encode new password and store it in user account
- String newEncodedPassword = serviceContext.encodePassword(newPassword);
- user.setPassword(newEncodedPassword);
+ // set new password
+ getSecurityService().setUserPassword(user, newPassword);
getPollenUserDao().update(user);
commit();
@@ -137,24 +138,18 @@
}
public void validateUserEmail(String userId,
- String token) throws UserInvalidEmailActivationTokenException {
+ String token) throws PollenInvalidEmailActivationTokenException {
checkNotNull(userId);
checkNotNull(token);
PollenUser user = getUser(userId);
- boolean valid = Objects.equals(
- user.getEmailActivationToken(), token);
+ getSecurityService().checkUserEmailValidation(user, token);
- if (!valid) {
- throw new UserInvalidEmailActivationTokenException();
- }
-
// reset token in database
user.setEmailActivationToken(null);
- getPollenUserDao().update(user);
commit();
}
@@ -171,6 +166,7 @@
user.setEmail("admin(a)pollen.org");
user.setPassword("admin");
createUser(user, false);
+
}
}
@@ -209,6 +205,7 @@
if (emailChanged) {
check(errors, "email", !dao.emailExists(userEmail), "email already exists");
}
+
} else {
check(errors, "email", !dao.emailExists(userEmail), "email already exists");
}
@@ -217,13 +214,18 @@
if (userExists) {
// check current password
- String encodedPassword = serviceContext.encodePassword(user.getPassword());
- check(errors, "password", encodedPassword.equals(persisted.getPassword()), "invalid password");
+ try {
+ getSecurityService().checkUserPassword(persisted, user.getPassword());
+ } catch (PollenInvalidPasswordException e) {
+ check(errors, "password", false, "invalid password");
+ }
+
}
if (!errors.isEmpty()) {
throw new InvalidFormException(errors);
+
}
}
@@ -232,58 +234,52 @@
boolean userExists = user.isPersisted();
+ String cleanMail = getCleanMail(user.getEmail());
+
PollenUser toSave;
- String userEmail = getCleanMail(user.getEmail());
-
- String emailValidationToken = null;
-
if (userExists) {
toSave = getUser(user.getTopiaId());
- boolean emailChanged = ObjectUtils.notEqual(toSave.getEmail(),
- userEmail);
+ boolean emailChanged = !Objects.equals(toSave.getEmail(), cleanMail);
if (emailChanged) {
- // add a new emailValidationtoken
- emailValidationToken = generateToken();
+ PollenToken emailActivation = getSecurityService().generateNewToken();
+ toSave.setEmailActivationToken(emailActivation);
- //TODO Notify email changed
}
+
} else {
- toSave = getPollenUserDao().newInstance();
-
- // add a emailValidationToken
- emailValidationToken = generateToken();
-
String password;
if (generatePassword) {
- // let's generate the new password
+
password = serviceContext.generatePassword();
+
} else {
+
password = user.getPassword();
+
}
- // encode the password
- String encodedPassword = serviceContext.encodePassword(password);
+ PollenToken emailActivation = getSecurityService().generateNewToken();
+ toSave = getPollenUserDao().newInstance();
toSave.setLogin(user.getLogin());
- toSave.setPassword(encodedPassword);
+ toSave.setEmailActivationToken(emailActivation);
+
+ getSecurityService().setUserPassword(toSave, password);
+
}
toSave.setAdministrator(user.isAdministrator());
toSave.setName(user.getName());
toSave.setLanguage(user.getLanguage());
- toSave.setEmail(userEmail);
+ toSave.setEmail(cleanMail);
- if (emailValidationToken != null) {
- toSave.setEmailActivationToken(emailValidationToken);
- }
-
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -23,13 +23,11 @@
* #L%
*/
-import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
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.InvalidFormException;
import org.chorem.pollen.services.service.security.PermissionVerb;
import java.util.Date;
@@ -44,61 +42,74 @@
public class VoteService extends PollenServiceSupport {
public List<Vote> getVotes(String pollId) {
- Preconditions.checkNotNull(pollId);
+ checkNotNull(pollId);
+
Poll poll = getPollService().getPoll(pollId);
+
List<Vote> result = poll.getVote();
return result;
+
}
public Vote getVote(String pollId, String voteId) {
- Preconditions.checkNotNull(voteId);
+ checkNotNull(voteId);
checkPermission(PermissionVerb.readVote, voteId);
+
Poll poll = getPollService().getPoll(pollId);
Vote result = getVote(poll, voteId);
return result;
+
}
public Vote addVote(String pollId, Vote vote) throws InvalidFormException {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(vote);
+
+ checkNotNull(pollId);
+ checkNotNull(vote);
checkIsNotPersisted(vote);
checkPermission(PermissionVerb.addVote, pollId);
Poll poll = getPollService().getPoll(pollId);
+
checkVoteForm(poll, vote);
Vote result = saveVote(poll, vote);
getPollDao().update(poll);
commit();
+
//TODO Notify vote added
return result;
+
}
public Vote editVote(String pollId, Vote vote) throws InvalidFormException {
- Preconditions.checkNotNull(vote);
+
+ checkNotNull(vote);
checkIsPersisted(vote);
checkPermission(PermissionVerb.editVote, vote.getTopiaId());
Poll poll = getPollService().getPoll(pollId);
+
checkVoteForm(poll, vote);
Vote result = saveVote(poll, vote);
getVoteDao().update(vote);
commit();
+
//TODO Notify vote edited
return result;
+
}
public void deleteVote(String pollId, String voteId) {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(voteId);
+ checkNotNull(pollId);
+ checkNotNull(voteId);
checkPermission(PermissionVerb.deleteVote, voteId);
Poll poll = getPollService().getPoll(pollId);
@@ -110,6 +121,7 @@
getPollDao().update(poll);
commit();
//TODO Notify vote deleted
+
}
protected void checkVoteForm(Poll poll, Vote vote) throws InvalidFormException {
@@ -132,7 +144,9 @@
if (!errors.isEmpty()) {
throw new InvalidFormException(errors);
+
}
+
}
protected Vote saveVote(Poll poll, Vote vote) {
@@ -168,13 +182,20 @@
// }
return toSave;
+
}
protected Vote getVote(Poll poll, String voteId) {
- Preconditions.checkNotNull(voteId);
- Vote result = poll.getVoteByTopiaId(voteId);
- checkEntityExists(Vote.class, result, voteId);
+ Vote result = getVoteDao().findByTopiaId(voteId);
+
+ if (!poll.containsVote(result)) {
+
+ throw new InvalidEntityLinkException(Poll.PROPERTY_VOTE, poll, result);
+
+ }
+
return result;
+
}
}
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -23,7 +23,6 @@
* #L%
*/
-import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
@@ -35,7 +34,6 @@
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.InvalidFormException;
import java.util.List;
import java.util.Set;
@@ -50,9 +48,11 @@
public VoterList importFavoriteList(String pollId,
String favoriteListId) {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(favoriteListId);
+ checkIsConnected();
+ checkNotNull(pollId);
+ checkNotNull(favoriteListId);
+
Poll poll = getPollService().getPoll(pollId);
FavoriteList favoriteList = getFavoriteListService().getFavoriteList(favoriteListId);
@@ -78,62 +78,77 @@
getPollDao().update(poll);
commit();
+
return result;
+
}
public List<VoterList> getVoterLists(String pollId) {
- Preconditions.checkNotNull(pollId);
+ checkNotNull(pollId);
+
Poll poll = getPollService().getPoll(pollId);
List<VoterList> result = Lists.newArrayList(poll.getVoterList());
return result;
+
}
public VoterList getVoterList(String pollId, String voterListId) {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(voterListId);
+ checkNotNull(pollId);
+ checkNotNull(voterListId);
+
Poll poll = getPollService().getPoll(pollId);
VoterList result = getVoterList(poll, voterListId);
return result;
+
}
public VoterList addVoterList(String pollId, VoterList voterList) throws InvalidFormException {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(voterList);
+
+ checkNotNull(pollId);
+ checkNotNull(voterList);
checkIsNotPersisted(voterList);
Poll poll = getPollService().getPoll(pollId);
- checkVoterList(poll, voterList);
+ checkVoterListForm(poll, voterList);
+
VoterList result = saveVoterList(poll, voterList);
getPollDao().update(poll);
commit();
+
return result;
+
}
public VoterList editVoterList(String pollId, VoterList voterList) throws InvalidFormException {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(voterList);
+
+ checkNotNull(pollId);
+ checkNotNull(voterList);
checkIsPersisted(voterList);
Poll poll = getPollService().getPoll(pollId);
- checkVoterList(poll, voterList);
+ checkVoterListForm(poll, voterList);
+
VoterList result = saveVoterList(poll, voterList);
getVoterListDao().update(voterList);
commit();
+
return result;
+
}
public void deleteVoterList(String pollId, String voterListId) {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(voterListId);
+ checkNotNull(pollId);
+ checkNotNull(voterListId);
+
Poll poll = getPollService().getPoll(pollId);
VoterList voterList = getVoterList(poll, voterListId);
@@ -142,98 +157,121 @@
getPollDao().update(poll);
commit();
+
}
public Set<VoterListMember> getVoterListMembers(String pollId, String voterListId) {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(voterListId);
+ checkNotNull(pollId);
+ checkNotNull(voterListId);
+
VoterList voterList = getVoterList(pollId, voterListId);
Set<VoterListMember> result = voterList.getMember();
return result;
+
}
public VoterListMember getVoterListMember(String pollId, String voterListId, String memberId) {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(voterListId);
- Preconditions.checkNotNull(memberId);
+ checkNotNull(pollId);
+ checkNotNull(voterListId);
+ checkNotNull(memberId);
+
VoterList voterList = getVoterList(pollId, voterListId);
VoterListMember result = getVoterListMember(voterList, memberId);
- checkEntityExists(VoterListMember.class, result, memberId);
+
return result;
+
}
public VoterListMember addVoterListMember(String pollId, String voterListId, VoterListMember member) throws InvalidFormException {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(voterListId);
- Preconditions.checkNotNull(member);
+
+ checkNotNull(pollId);
+ checkNotNull(voterListId);
+ checkNotNull(member);
checkIsNotPersisted(member);
VoterList voterList = getVoterList(pollId, voterListId);
- checkVoterListMember(voterList, member);
+ checkVoterListMemberForm(voterList, member);
VoterListMember result = saveVoterListMember(voterList, member);
getVoterListDao().update(voterList);
commit();
+
return result;
+
}
public VoterListMember editVoterListMember(String pollId, String voterListId, VoterListMember member) throws InvalidFormException {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(voterListId);
- Preconditions.checkNotNull(member);
+
+ checkNotNull(pollId);
+ checkNotNull(voterListId);
+ checkNotNull(member);
checkIsPersisted(member);
VoterList voterList = getVoterList(pollId, voterListId);
- checkVoterListMember(voterList, member);
+ checkVoterListMemberForm(voterList, member);
VoterListMember result = saveVoterListMember(voterList, member);
getVoterListMemberDao().update(member);
commit();
+
return result;
+
}
public void deleteVoterListMember(String pollId, String voterListId, String memberId) {
- Preconditions.checkNotNull(pollId);
- Preconditions.checkNotNull(voterListId);
- Preconditions.checkNotNull(memberId);
+ checkNotNull(pollId);
+ checkNotNull(voterListId);
+ checkNotNull(memberId);
+
VoterList voterList = getVoterList(pollId, voterListId);
VoterListMember member = getVoterListMember(voterList, memberId);
voterList.removeMember(member);
-// getVoterListDao().merge(voterList);
+ commit();
- commit();
}
protected VoterList getVoterList(Poll poll, String voterListId) {
- VoterList result = poll.getVoterListByTopiaId(voterListId);
- checkEntityExists(VoterList.class, result, voterListId);
+ VoterList result = getVoterListDao().findByTopiaId(voterListId);
+
+ if (!poll.containsVoterList(result)) {
+
+ throw new InvalidEntityLinkException(Poll.PROPERTY_VOTER_LIST, poll, result);
+
+ }
+
return result;
+
}
protected VoterListMember getVoterListMember(VoterList voterList, String memberId) {
- Preconditions.checkNotNull(memberId);
- VoterListMember result = voterList.getMemberByTopiaId(memberId);
- checkEntityExists(VoterListMember.class, result, memberId);
+ VoterListMember result = getVoterListMemberDao().findByTopiaId(memberId);
+
+ if (!voterList.containsMember(result)) {
+
+ throw new InvalidEntityLinkException(VoterList.PROPERTY_MEMBER, voterList, result);
+
+ }
+
return result;
+
}
protected VoterList saveVoterList(Poll poll, VoterList voterList) {
-
boolean voterListExists = voterList.isPersisted();
VoterList toSave;
@@ -241,12 +279,13 @@
if (voterListExists) {
toSave = getVoterList(poll, voterList.getTopiaId());
+
} else {
- VoterListTopiaDao voterListDao =
- getVoterListDao();
- toSave = voterListDao.newInstance();
+ toSave = getVoterListDao().newInstance();
+
poll.addVoterList(toSave);
+
}
toSave.setName(voterList.getName());
@@ -255,9 +294,11 @@
for (VoterListMember voterListMember : voterList.getMember()) {
saveVoterListMember(toSave, voterListMember);
+
}
return toSave;
+
}
protected VoterListMember saveVoterListMember(VoterList voterList,
@@ -270,14 +311,13 @@
if (voterListMemberExists) {
toSave = getVoterListMember(voterList, voterListMember.getTopiaId());
+
} else {
- VoterListMemberTopiaDao voterListMemberDao =
- getVoterListMemberDao();
+ toSave = getVoterListMemberDao().newInstance();
- toSave = voterListMemberDao.newInstance();
+ voterList.addMember(toSave);
- voterList.addMember(toSave);
}
toSave.setName(voterListMember.getName());
@@ -285,9 +325,10 @@
toSave.setWeight(voterListMember.getWeight());
return toSave;
+
}
- protected void checkVoterList(Poll poll, VoterList voterList) throws InvalidFormException {
+ protected void checkVoterListForm(Poll poll, VoterList voterList) throws InvalidFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
@@ -307,7 +348,9 @@
}
voterListNames.add(voterList.getName());
+
}
+
}
checkNotBlank(errors, "name", voterList.getName(), "voterList name can not be empty");
@@ -344,16 +387,19 @@
checkValidEmail(errors, voterListMemberField + "email", voterListMemberEmail, "member email is not valid");
boolean emailAdded = voterListMemberEmails.add(voterListMemberEmail);
check(errors, voterListMemberField + "email", emailAdded, "member email already used in this list");
+
}
}
if (!errors.isEmpty()) {
throw new InvalidFormException(errors);
+
}
+
}
- protected void checkVoterListMember(VoterList voterList, VoterListMember voterListMember) throws InvalidFormException {
+ protected void checkVoterListMemberForm(VoterList voterList, VoterListMember voterListMember) throws InvalidFormException {
//TODO use nuiton validator ?
Multimap<String, String> errors = ArrayListMultimap.create();
@@ -375,7 +421,9 @@
voterListMemberNames.add(voterListMember.getName());
voterListMemberEmails.add(voterListMember.getEmail());
+
}
+
}
String voterListMemberName = voterListMember.getName();
boolean nameNotblank = checkNotBlank(errors, "name", voterListMemberName, "member name can not be empty");
@@ -394,11 +442,14 @@
checkValidEmail(errors, "email", voterListMemberEmail, "member email is not valid");
boolean emailAdded = voterListMemberEmails.add(voterListMemberEmail);
check(errors, "email", emailAdded, "member email already used in this list");
+
}
if (!errors.isEmpty()) {
throw new InvalidFormException(errors);
+
}
+
}
}
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenAuthenticationException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenAuthenticationException.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenAuthenticationException.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -0,0 +1,16 @@
+package org.chorem.pollen.services.service.security;
+
+/**
+ * Created on 5/4/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenAuthenticationException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public PollenAuthenticationException(Exception e) {
+ super(e);
+ }
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenAuthenticationException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidEmailActivationTokenException.java (from rev 3895, trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/UserInvalidEmailActivationTokenException.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidEmailActivationTokenException.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidEmailActivationTokenException.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.services.service.security;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenInvalidEmailActivationTokenException extends Exception {
+ private static final long serialVersionUID = 1L;
+}
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidPasswordException.java (from rev 3895, trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/UserInvalidPasswordException.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidPasswordException.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidPasswordException.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.services.service.security;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenInvalidPasswordException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+}
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidSessionTokenException.java (from rev 3895, trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidSessionTokenException.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidSessionTokenException.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenInvalidSessionTokenException.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -0,0 +1,35 @@
+package org.chorem.pollen.services.service.security;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenInvalidSessionTokenException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+}
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/PollenSecurityRealm.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -28,19 +28,14 @@
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UsernamePasswordToken;
+import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
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.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/>
@@ -51,10 +46,19 @@
*/
public class PollenSecurityRealm extends AuthorizingRealm {
- protected PollenApplicationContext applicationContext;
+ public static final String REALM_NAME = "pollenRealm";
- public void setApplicationContext(PollenApplicationContext applicationContext) {
+ protected final PollenApplicationContext applicationContext;
+
+ public PollenSecurityRealm(PollenApplicationContext applicationContext) {
+
this.applicationContext = applicationContext;
+
+ String hashAlgorithmName = applicationContext.getApplicationConfig().getHashAlgorithmName();
+ HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(hashAlgorithmName);
+ matcher.setStoredCredentialsHexEncoded(false);
+ setCredentialsMatcher(matcher);
+
}
@Override
@@ -72,21 +76,20 @@
UsernamePasswordToken upToken = (UsernamePasswordToken) token;
String username = upToken.getUsername();
- char[] password = upToken.getPassword();
+
PollenTopiaPersistenceContext persistenceContext = applicationContext.newPersistenceContext();
try {
- 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);
+ boolean loginExists = persistenceContext.getPollenUserDao().loginExists(username);
+
+ if (!loginExists) {
+ throw new AuthenticationException();
}
+
+ char[] password = upToken.getPassword();
+
SimpleAuthenticationInfo result =
new SimpleAuthenticationInfo(username, password, getName());
return result;
Deleted: 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 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityRole.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -1,33 +0,0 @@
-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.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public enum SecurityRole {
- 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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -28,6 +28,8 @@
import com.google.common.collect.Sets;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.SimplePrincipalCollection;
import org.apache.shiro.subject.Subject;
import org.chorem.pollen.persistence.entity.Choice;
@@ -36,16 +38,17 @@
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.PollenToken;
+import org.chorem.pollen.persistence.entity.PollenTokenTopiaDao;
import org.chorem.pollen.persistence.entity.PollenUser;
import org.chorem.pollen.persistence.entity.SessionToken;
import org.chorem.pollen.persistence.entity.Vote;
-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.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
/**
@@ -59,23 +62,79 @@
/** Logger. */
private static final Log log = LogFactory.getLog(SecurityService.class);
+ public PollenUser login(String login, String password, Boolean rememberMe) throws PollenAuthenticationException {
+
+ Subject subject = getSubject();
+ UsernamePasswordToken token = new UsernamePasswordToken(login, password);
+ token.setRememberMe(rememberMe);
+
+ try {
+ subject.login(token);
+ } catch (AuthenticationException e) {
+ throw new PollenAuthenticationException(e);
+ }
+
+ PollenUser user = getUserService().getUserByLogin(login);
+ return user;
+
+ }
+
+ public SessionToken logout() {
+
+ SessionToken sessionToken = serviceContext.getSecurityContext().getSessionToken();
+
+ if (sessionToken != null) {
+ Subject subject = getSecurityService().getSubject();
+ subject.logout();
+ }
+
+ return sessionToken;
+
+ }
+
+ public PollenToken generateNewToken() {
+
+ PollenTokenTopiaDao dao = getPersistenceContext().getPollenTokenDao();
+
+ // Create instance
+ PollenToken pollenToken = dao.newInstance();
+ pollenToken.setCreationDate(serviceContext.getNow());
+
+ // Generate token
+ String token = serviceContext.generateToken();
+ pollenToken.setToken(token);
+
+ // Persist
+ pollenToken = dao.create(pollenToken);
+
+ return pollenToken;
+
+ }
+
public PollenPrincipal generatePollenPrincipal() {
- PollenPrincipalTopiaDao pollenPrincipalDao = getPersistenceContext().getPollenPrincipalDao();
- PollenPrincipal principal = pollenPrincipalDao.newInstance();
- principal.setCreationDate(serviceContext.getNow());
- pollenPrincipalDao.create(principal);
+ PollenPrincipalTopiaDao dao = getPersistenceContext().getPollenPrincipalDao();
+
+ // Create instance
+ PollenPrincipal principal = dao.newInstance();
+
+ // Generate token
+ PollenToken token = generateNewToken();
+ principal.setToken(token);
+
+ // Persist
+ dao.create(principal);
return principal;
}
- public SessionToken getSessionTokenByToken(String token) throws InvalidSessionTokenException {
+ public SessionToken getSessionTokenByToken(String token) throws PollenInvalidSessionTokenException {
SessionToken sessionToken = null;
if (token != null) {
- sessionToken = getSessionTokenDao().forTokenEquals(token).findUniqueOrNull();
+ sessionToken = getSessionTokenDao().findUniqueOrNullByToken(token);
if (sessionToken == null) {
- throw new InvalidSessionTokenException();
+ throw new PollenInvalidSessionTokenException();
}
}
return sessionToken;
@@ -86,44 +145,62 @@
PollenPrincipal principal = null;
if (principalId != null) {
- principal = getPollenPrincipalDao().forTopiaIdEquals(principalId).findUniqueOrNull();
- checkEntityExists(PollenPrincipal.class, principal, principalId);
+ principal = getPollenPrincipalDao().findByTopiaId(principalId);
}
return principal;
}
+ public void setUserPassword(PollenUser user, String newPassword) {
+
+ String salt = serviceContext.generateSalt();
+
+ String encodedPassword = serviceContext.encodePassword(salt, newPassword);
+
+ user.setSalt(salt);
+ user.setPassword(encodedPassword);
+ }
+
public String createPermission(PermissionVerb verb, String id) {
return ":" + verb.name() + ":" + id;
}
- public void checkRole(SecurityRole roleName) {
+ public void checkUserPassword(PollenUser user, String password) throws PollenInvalidPasswordException {
- checkNotNull(roleName);
+ String encodedPassword = serviceContext.encodePassword(user.getSalt(), password);
+ boolean valid = Objects.equals(encodedPassword, user.getPassword());
+ if (!valid) {
+ throw new PollenInvalidPasswordException();
+ }
- PollenSecurityContext securityContext = serviceContext.getSecurityContext();
- switch (roleName) {
+ }
- case connected:
+ public void checkUserEmailValidation(PollenUser user, String emailToken) throws PollenInvalidEmailActivationTokenException {
- if (!securityContext.isConnected()) {
- throw new PollenUnauthorizedException("connected");
- }
- break;
+ boolean valid = Objects.equals(user.getEmailActivationToken().getToken(), emailToken);
- case administrator:
+ if (!valid) {
+ throw new PollenInvalidEmailActivationTokenException();
+ }
- if (!securityContext.isAdmin()) {
- throw new PollenUnauthorizedException("administrator");
- }
- break;
+ }
- default:
+ public void checkIsConnected() {
- throw new PollenTechnicalException("can't handler security role: " + roleName);
+ PollenSecurityContext securityContext = getSecurityContext();
+ if (!securityContext.isConnected()) {
+ throw new PollenUnauthorizedException("connected");
+ }
+ }
+
+ public void checkIsAdmin() {
+
+ PollenSecurityContext securityContext = getSecurityContext();
+ if (!securityContext.isAdmin()) {
+ throw new PollenUnauthorizedException("administrator");
}
}
@@ -146,7 +223,7 @@
protected Subject getSubject() {
- PollenSecurityContext securityContext = serviceContext.getSecurityContext();
+ PollenSecurityContext securityContext = getSecurityContext();
Preconditions.checkNotNull(securityContext);
Subject subject = securityContext.getSubject();
@@ -162,7 +239,7 @@
// Create Subject
SimplePrincipalCollection principalCollection = new SimplePrincipalCollection();
- principalCollection.addAll(permissions, "pollenRealm");
+ principalCollection.addAll(permissions, PollenSecurityRealm.REALM_NAME);
subject = new Subject.
Builder().
authenticated(securityContext.isConnected()).
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 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenApplicationContext.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -61,41 +61,31 @@
/** Logger. */
private static final Log log = LogFactory.getLog(FakePollenApplicationContext.class);
- private File testBasedir;
+ protected static AtomicInteger portNumberCounter = new AtomicInteger(9999);
+ protected File testBasedir;
+
protected List<PollenTopiaPersistenceContext> openedTransactions = new LinkedList<>();
- private PollenTopiaApplicationContext applicationContext;
+ protected PollenTopiaApplicationContext applicationContext;
- private PollenServiceConfig configuration;
+ protected PollenServiceConfig configuration;
- private final String configurationPath;
-
protected PollenFixtures fixtures;
protected String methodName;
- protected static AtomicInteger portNumberCounter = new AtomicInteger(9999);
-
protected int currentPortNumber;
+ protected final String configurationPath;
+
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();
@@ -109,20 +99,42 @@
log.debug("testBasedir: " + testBasedir);
}
- // create configuration
+ init();
+ }
+
+ @Override
+ public void finished(Description description) {
+
+ close();
+ }
+
+ @Override
+ public void init() {
+
+ // --- create configuration --- //
+
Properties defaultvalues = new Properties();
defaultvalues.put(PollenServiceConfigOption.DATA_DIRECTORY.getKey(), testBasedir.getAbsolutePath());
configuration = new PollenServiceConfig(configurationPath, defaultvalues);
+ // --- create topia application context --- //
+
Map<String, String> topiaProperties = configuration.getTopiaProperties();
applicationContext = new PollenTopiaApplicationContext(topiaProperties);
+ // --- create security context --- //
+
+ PollenSecurityRealm realm = new PollenSecurityRealm(this);
+
+ DefaultSecurityManager securityManager = new DefaultSecurityManager(realm);
+ SecurityUtils.setSecurityManager(securityManager);
+
}
@Override
- public void finished(Description description) {
+ public void close() {
if (applicationContext != null && !applicationContext.isClosed()) {
@@ -145,10 +157,6 @@
}
}
- public File getTestBasedir() {
- return testBasedir;
- }
-
@Override
public PollenTopiaApplicationContext getTopiaApplicationContext() {
return applicationContext;
@@ -191,12 +199,22 @@
@Override
public FakePollenSecurityContext newSecurityContext(SessionToken sessionToken, PollenPrincipal mainPrincipal) {
+
FakePollenSecurityContext securityContext = new FakePollenSecurityContext();
securityContext.setMainPrincipal(mainPrincipal);
securityContext.setSessionToken(sessionToken);
return securityContext;
+
}
+ public File getTestBasedir() {
+ return testBasedir;
+ }
+
+ public int getPort() {
+ return currentPortNumber;
+ }
+
public String getMethodName() {
return methodName;
}
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 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenSecurityContext.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -21,7 +21,6 @@
* #L%
*/
-import org.apache.shiro.subject.Subject;
import org.chorem.pollen.services.service.security.DefaultPollenSecurityContext;
/**
@@ -44,9 +43,4 @@
return false;
}
- @Override
- public void setSubject(Subject subject) {
- this.subject = subject;
- }
-
}
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -25,7 +25,7 @@
import com.google.common.collect.Multimap;
import org.chorem.pollen.services.PollenService;
-import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.InvalidFormException;
import org.chorem.pollen.services.test.FakePollenApplicationContext;
import org.chorem.pollen.services.test.FakePollenServiceContext;
import org.junit.Assert;
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-04 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -29,7 +29,7 @@
import org.chorem.pollen.persistence.entity.PollType;
import org.chorem.pollen.persistence.entity.VoterList;
import org.chorem.pollen.persistence.entity.VoterListMember;
-import org.chorem.pollen.services.exception.InvalidFormException;
+import org.chorem.pollen.services.service.InvalidFormException;
import org.chorem.pollen.services.service.ChoiceService;
import org.chorem.pollen.services.service.PollService;
import org.chorem.pollen.services.service.VoterListService;
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 16:40:00 UTC (rev 3905)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java 2014-05-04 21:39:22 UTC (rev 3906)
@@ -26,13 +26,13 @@
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;
-import org.chorem.pollen.services.exception.InvalidFormException;
-import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException;
+import org.chorem.pollen.services.service.InvalidFormException;
+import org.chorem.pollen.services.service.security.PollenInvalidEmailActivationTokenException;
import org.chorem.pollen.services.service.PollenUserService;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.nuiton.topia.persistence.TopiaNoResultException;
import java.text.ParseException;
import java.util.Date;
@@ -77,7 +77,7 @@
try {
service.getUser("pollen_user_tony_" + System.nanoTime());
- } catch (EntityNotFoundException e) {
+ } catch (TopiaNoResultException e) {
Assert.assertTrue(true);
}
@@ -167,7 +167,7 @@
}
@Test
- public void testValidateEmail() throws UserInvalidEmailActivationTokenException, InvalidFormException {
+ public void testValidateEmail() throws PollenInvalidEmailActivationTokenException, InvalidFormException {
PollenUser user = service.getUser(this.user.getTopiaId());
Assert.assertNotNull(user);
@@ -188,13 +188,13 @@
try {
service.validateUserEmail(user.getTopiaId(), "fakeToken");
Assert.fail();
- } catch (UserInvalidEmailActivationTokenException e) {
+ } catch (PollenInvalidEmailActivationTokenException e) {
Assert.assertTrue(true);
}
Assert.assertFalse(PollenUsers.isEmailActivated(savedUser));
- service.validateUserEmail(user.getTopiaId(), savedUser.getEmailActivationToken());
+ service.validateUserEmail(user.getTopiaId(), savedUser.getEmailActivationToken().getToken());
PollenUser reloadedUser = service.getUser(this.user.getTopiaId());
Assert.assertTrue(PollenUsers.isEmailActivated(reloadedUser));
1
0
Author: tchemit
Date: 2014-05-04 18:40:00 +0200 (Sun, 04 May 2014)
New Revision: 3905
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3905
Log:
begin of site v2
Added:
trunk/src/site/rst/restApi.rst
Modified:
trunk/pom.xml
trunk/src/site/site_en.xml
trunk/src/site/site_fr.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-05-04 00:50:55 UTC (rev 3904)
+++ trunk/pom.xml 2014-05-04 16:40:00 UTC (rev 3905)
@@ -15,7 +15,7 @@
<name>Pollen</name>
<description>Application de vote Pollen</description>
- <url>http://maven-site.chorem.org/pollen</url>
+ <url>http://doc.chorem.org/pollen</url>
<inceptionYear>2009</inceptionYear>
<licenses>
<license>
@@ -149,7 +149,7 @@
<distributionManagement>
<site>
<id>doc.${platform}</id>
- <url>${our.site.repository}/${projectId}</url>
+ <url>${our.site.repository}/${projectId}/v2</url>
</site>
</distributionManagement>
Added: trunk/src/site/rst/restApi.rst
===================================================================
--- trunk/src/site/rst/restApi.rst (rev 0)
+++ trunk/src/site/rst/restApi.rst 2014-05-04 16:40:00 UTC (rev 3905)
@@ -0,0 +1,111 @@
+~~~~~~~~~~~~~~~
+Pollen Rest API
+~~~~~~~~~~~~~~~
+
+Abstract
+========
+
+- Describe the REST API offers since Pollen 2.0
+
+Doc
+===
+
+GET /v1/doc
+
+Auth
+====
+
+PUT /v1/login
+GET /v1/lostpassword/{token}
+GET /v1/logout
+
+Choice
+======
+
+GET /v1/polls/{pollId}/choices
+POST /v1/polls/{pollId}/choices
+GET /v1/polls/{pollId}/choices/{choiceId}
+PUT /v1/polls/{pollId}/choices/{choiceId}
+DELETE /v1/polls/{pollId}/choices/{choiceId}
+
+Comment
+=======
+
+GET /v1/polls/{pollId}/comments
+POST /v1/polls/{pollId}/comments
+GET /v1/polls/{pollId}/comments/{commentId}
+PUT /v1/polls/{pollId}/comments/{commentId}
+DELETE /v1/polls/{pollId}/comments/{commentId}
+
+FavoriteList
+============
+
+GET /v1/favoriteLists
+GET /v1/favoriteLists/{flId}
+POST /v1/favoriteLists/{flId}/importCsv
+POST /v1/favoriteLists/{flId}/importLdap
+POST /v1/favoriteLists
+PUT /v1/favoriteLists/{flId}
+DELETE /v1/favoriteLists/{flId}
+GET /v1/favoriteLists/{flId}/members
+GET /v1/favoriteLists/{flId}/members/{mId}
+POST /v1/favoriteLists/{flId}/members
+PUT /v1/favoriteLists/{flId}/members/{mId}
+DELETE /v1/favoriteLists/{flId}/members/{mId}
+
+Poll
+====
+
+GET /v1/polls/new
+GET /v1/polls
+GET /v1/polls/created
+GET /v1/polls/invited
+GET /v1/polls/participated
+POST /v1/polls
+GET /v1/polls/create
+PUT /v1/polls/{pollId}
+GET /v1/polls/{pollId}
+DELETE /v1/polls/{pollId}
+POST /v1/polls/{pollId}
+GET /v1/polls/{pollId}/export
+PUT /v1/polls/{pollId}/close
+
+PollenUser
+==========
+
+GET /v1/users
+GET /v1/users/{userId}
+POST /v1/users
+PUT /v1/users/{userId}
+DELETE /v1/users/{userId}
+PUT /v1/users/{userId}?token={}
+
+VoteCounting
+============
+
+GET /v1/polls/{pollId}/results
+
+VoterList
+=========
+
+PUT /v1/polls/{pollId}/favoriteLists/{flId}
+GET /v1/polls/{pollId}/voterLists
+GET /v1/polls/{pollId}/voterLists/{vlId}
+POST /v1/polls/{pollId}/voterLists
+PUT /v1/polls/{pollId}/voterLists/{vlId}
+DELETE /v1/polls/{pollId}/voterLists/{vlId}
+
+GET /v1/polls/{pollId}/voterLists/{vlId}/members
+GET /v1/polls/{pollId}/voterLists/{vlId}/members/{mId}
+POST /v1/polls/{pollId}/voterLists/{vlId}/members
+PUT /v1/polls/{pollId}/voterLists/{vlId}/members/{mId}
+DELETE /v1/polls/{pollId}/voterLists/{vlId}/members/{mId}
+
+Vote
+====
+
+GET /v1/polls/{pollId}/votes
+PUT /v1/polls/{pollId}/votes
+GET /v1/polls/{pollId}/votes/{voteId}
+PUT /v1/polls/{pollId}/votes/{voteId}
+DELETE /v1/polls/{pollId}/votes/{voteId}
Modified: trunk/src/site/site_en.xml
===================================================================
--- trunk/src/site/site_en.xml 2014-05-04 00:50:55 UTC (rev 3904)
+++ trunk/src/site/site_en.xml 2014-05-04 16:40:00 UTC (rev 3905)
@@ -38,7 +38,7 @@
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId>
- <version>1.3.0</version>
+ <version>${fluidoSkinVersion}</version>
</skin>
<custom>
@@ -56,34 +56,36 @@
<poweredBy>
<logo href="http://maven.apache.org" name="Maven"
- img="http://maven-site.nuiton.org/public/images/logos/logos/maven-feather.png"/>
+ img="${mavenpomSiteCommonResourcesUrl}/public/images/logos/maven-feather.png"/>
<logo href="http://struts.apache.org/" name="Struts 2"
- img="http://maven-site.nuiton.org/public/images/logos/struts2-logo.png"/>
+ img="${mavenpomSiteCommonResourcesUrl}/public/images/logos/struts2-logo.png"/>
<logo href="http://docutils.sourceforge.net/rst.html"
name="ReStructuredText"
- img="http://maven-site.nuiton.org/public/images/logos/restructuredtext-logo.png"/>
+ img="${mavenpomSiteCommonResourcesUrl}/public/images/logos/restructuredtext-logo.png"/>
- <logo href="http://maven-site.nuiton.org/jrst" name="JRst"
- img="http://maven-site.nuiton.org/public/images/logos/jrst-logo.png"/>
+ <logo href="http://doc.nuiton.org/jrst" name="JRst"
+ img="${mavenpomSiteCommonResourcesUrl}/public/images/logos/jrst-logo.png"/>
- <logo href="http://maven-site.nuiton.org/topia" name="ToPIA"
- img="http://maven-site.nuiton.org/public/images/logos/topia-logo.png"/>
+ <logo href="http://doc.nuiton.org/topia" name="ToPIA"
+ img="${mavenpomSiteCommonResourcesUrl}/public/images/logos/topia-logo.png"/>
+ <logo href="http://http://www.webmotion-framework.org/" name="WebMotion"/>
+
<logo href="http://argouml.tigris.org/" name="ArgoUML"
- img="http://maven-site.nuiton.org/public/images/logos/argouml-logo.png"/>
+ img="${mavenpomSiteCommonResourcesUrl}/public/images/logos/argouml-logo.png"/>
</poweredBy>
<body>
<head>
<script type="text/javascript"
- src="http://maven-site.chorem.org/public/js/mavenpom-site.js">
+ src="${mavenpomSiteCommonResourcesUrl}/public/js/mavenpom-site.js">
</script>
<link rel="stylesheet" type="text/css"
- href="http://maven-site.chorem.org/public/css/mavenpom-site.css"/>
+ href="${mavenpomSiteCommonResourcesUrl}/public/css/mavenpom-site.css"/>
</head>
<breadcrumbs>
@@ -109,7 +111,9 @@
<menu name="Public instances">
<item name="Official instance (Use last stable version of Pollen, No data loss)" href="http://pollen.chorem.org/"/>
- <item name="Test instance (Use last dev version of Pollen, Test purpose only)" href="http://demo.codelutin.com/pollen"/>
+ <item name="Test instance (stable) (utilise la dernière version stable, Test purpose only)" href="http://demo.codelutin.com/pollen-stable"/>
+ <item name="Test instance (staging) (utilise la prochaine version stable, Test purpose only)" href="http://demo.codelutin.com/pollen-staging"/>
+ <item name="Test instance (latest) (utilise la dernière version de dev, Test purpose only)" href="http://demo.codelutin.com/pollen-latest"/>
</menu>
<menu name="Language">
@@ -120,6 +124,7 @@
<menu name="Technical">
<item name="Security" href="./security.html"/>
<item name="UI Tests" href="./tests.html"/>
+ <item name="Rest API" href="./restApi.html"/>
</menu>
<menu ref="reports"/>
@@ -134,7 +139,9 @@
scmwebeditorurl='${project.scmwebeditorUrl}'
siteSourcesType='${project.siteSourcesType}'
piwikEnabled='${project.piwikEnabled}'
- piwikId='${project.piwikId}'>
+ piwikId='${project.piwikId}'
+ scmwebeditor_vmFiles=",install.html,"
+ scmwebeditor_skipDefaultFiles="true">
</div>
</footer>
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2014-05-04 00:50:55 UTC (rev 3904)
+++ trunk/src/site/site_fr.xml 2014-05-04 16:40:00 UTC (rev 3905)
@@ -38,7 +38,7 @@
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId>
- <version>1.3.0</version>
+ <version>${fluidoSkinVersion}</version>
</skin>
<custom>
@@ -56,34 +56,36 @@
<poweredBy>
<logo href="http://maven.apache.org" name="Maven"
- img="${project.url}/images/logos/maven-feather.png"/>
+ img="${mavenpomSiteCommonResourcesUrl}/public/images/logos/maven-feather.png"/>
<logo href="http://struts.apache.org/" name="Struts 2"
- img="http://maven-site.nuiton.org/public/images/logos/struts2-logo.png"/>
+ img="${mavenpomSiteCommonResourcesUrl}/public/images/logos//struts2-logo.png"/>
<logo href="http://docutils.sourceforge.net/rst.html"
name="ReStructuredText"
- img="http://maven-site.nuiton.org/public/images/logos/restructuredtext-logo.png"/>
+ img="${mavenpomSiteCommonResourcesUrl}/public/images/logos/restructuredtext-logo.png"/>
- <logo href="http://maven-site.nuiton.org/jrst" name="JRst"
- img="http://maven-site.nuiton.org/public/images/logos/jrst-logo.png"/>
+ <logo href="http://doc.nuiton.org/jrst" name="JRst"
+ img="${mavenpomSiteCommonResourcesUrl}/public/images/logos/jrst-logo.png"/>
- <logo href="http://maven-site.nuiton.org/topia" name="ToPIA"
- img="http://maven-site.nuiton.org/public/images/logos/topia-logo.png"/>
+ <logo href="http://doc.nuiton.org/topia" name="ToPIA"
+ img="${mavenpomSiteCommonResourcesUrl}/public/images/logos/topia-logo.png"/>
+ <logo href="http://http://www.webmotion-framework.org/" name="WebMotion"/>
+
<logo href="http://argouml.tigris.org/" name="ArgoUML"
- img="http://maven-site.nuiton.org/public/images/logos/argouml-logo.png"/>
+ img="${mavenpomSiteCommonResourcesUrl}/public/images/logos/argouml-logo.png"/>
</poweredBy>
<body>
<head>
<script type="text/javascript"
- src="http://maven-site.nuiton.org/public/js/mavenpom-site.js">
+ src="${mavenpomSiteCommonResourcesUrl}/public/js/mavenpom-site.js">
</script>
<link rel="stylesheet" type="text/css"
- href="http://maven-site.nuiton.org/public/css/mavenpom-site.css"/>
+ href="${mavenpomSiteCommonResourcesUrl}/public/css/mavenpom-site.css"/>
</head>
<breadcrumbs>
@@ -91,8 +93,8 @@
</breadcrumbs>
<links>
- <item name="nuiton.org" href="http://www.nuiton.org"/>
- <item name="chorem.org" href="http://www.chorem.org"/>
+ <item name="Nuiton.org" href="http://forge.nuiton.org"/>
+ <item name="Chorem.org" href="http://forge.chorem.org"/>
<item name="CodeLutin" href="http://codelutin.com"/>
<item name="Libre-Entreprise" href="http://www.libre-entreprise.org/"/>
</links>
@@ -107,9 +109,15 @@
<item name="Configurer Pollen" href="configure.html"/>
</menu>
+ <menu name="Technique">
+ <item name="API REST" href="restApi.html"/>
+ </menu>
+
<menu name="Instances publiques">
<item name="Instance officielle (utilise la dernière version stable, Pas de perte de données)" href="http://pollen.chorem.org/"/>
- <item name="Instance de tests (utilise la dernière version de dev, pour tests uniquement)" href="http://demo.codelutin.com/pollen"/>
+ <item name="Instance de tests (stable) (utilise la dernière version stable, Données non conversées)" href="http://demo.codelutin.com/pollen-stable"/>
+ <item name="Instance de tests (staging) (utilise la prochaine version stable, Données non conversées)" href="http://demo.codelutin.com/pollen-staging"/>
+ <item name="Instance de tests (latest) (utilise la dernière version de dev, Données non conversées)" href="http://demo.codelutin.com/pollen-latest"/>
</menu>
<menu name="Langue">
@@ -130,7 +138,9 @@
scmwebeditorurl='${project.scmwebeditorUrl}'
siteSourcesType='${project.siteSourcesType}'
piwikEnabled='${project.piwikEnabled}'
- piwikId='${project.piwikId}'>
+ piwikId='${project.piwikId}'
+ scmwebeditor_vmFiles=",install.html,"
+ scmwebeditor_skipDefaultFiles="true">
</div>
</footer>
1
0
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