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
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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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!")); - } -}
participants (1)
-
tchemit@users.chorem.org