r3899 - in trunk: pollen-rest-api/src/main/java/org/chorem/pollen/rest/api pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1 pollen-rest-api/src/main/resources pollen-services/src/main/java/org/chorem/pollen/services/exception pollen-services/src/main/java/org/chorem/pollen/services/service
Author: tchemit Date: 2014-05-02 14:07:13 +0200 (Fri, 02 May 2014) New Revision: 3899 Url: http://forge.chorem.org/projects/pollen/repository/revisions/3899 Log: simplify form exception (keep only one) Removed: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidChoiceFormException.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidCommentFormException.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListFormException.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListMemberFormException.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollFormException.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollenUserFormException.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoteFormException.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListFormException.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListMemberFormException.java Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java trunk/pollen-rest-api/src/main/resources/mapping trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -36,7 +36,7 @@ import org.chorem.pollen.services.PollenServiceContext; import org.chorem.pollen.services.config.PollenServiceConfig; import org.chorem.pollen.services.exception.EntityNotFoundException; -import org.chorem.pollen.services.exception.InvalidPollenUserFormException; +import org.chorem.pollen.services.exception.InvalidFormException; import org.chorem.pollen.services.service.PollenUserService; import org.chorem.pollen.services.service.security.DefaultPollenSecurityContext; import org.chorem.pollen.services.service.security.PollenSecurityContext; @@ -212,7 +212,7 @@ try { PollenServiceContext serviceContext = newServiceContext(persistenceContext, Locale.FRANCE); serviceContext.newService(PollenUserService.class).createDefaultUsers(); - } catch (InvalidPollenUserFormException e) { + } catch (InvalidFormException e) { //Can't happen } catch (EntityNotFoundException e) { //Can't happen Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -25,7 +25,7 @@ import org.chorem.pollen.persistence.entity.Comment; import org.chorem.pollen.rest.api.PollenRestApiRequestContext; -import org.chorem.pollen.services.exception.InvalidCommentFormException; +import org.chorem.pollen.services.exception.InvalidFormException; import org.debux.webmotion.server.WebMotionController; import java.util.List; @@ -49,12 +49,12 @@ return context.getCommentService().getComment(pollId, commentId); } - public Comment addComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidCommentFormException { + public Comment addComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidFormException { context.getSecurityService().prepareSubject(pollId); return context.getCommentService().addComment(pollId, comment); } - public Comment editComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidCommentFormException { + public Comment editComment(PollenRestApiRequestContext context, String pollId, Comment comment) throws InvalidFormException { context.getSecurityService().prepareSubject(comment); return context.getCommentService().editComment(pollId, comment); } Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/FavoriteListService.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -27,8 +27,7 @@ import org.chorem.pollen.persistence.entity.FavoriteListMember; import org.chorem.pollen.rest.api.PollenRestApiRequestContext; import org.chorem.pollen.services.exception.FavoriteListImportException; -import org.chorem.pollen.services.exception.InvalidFavoriteListFormException; -import org.chorem.pollen.services.exception.InvalidFavoriteListMemberFormException; +import org.chorem.pollen.services.exception.InvalidFormException; import org.debux.webmotion.server.WebMotionController; import java.io.File; @@ -52,11 +51,11 @@ return context.getFavoriteListService().getFavoriteList(userId, favoriteListId); } - public FavoriteList createFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws InvalidFavoriteListFormException { + public FavoriteList createFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws InvalidFormException { return context.getFavoriteListService().createFavoriteList(userId, favoriteList); } - public FavoriteList editFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws InvalidFavoriteListFormException { + public FavoriteList editFavoriteList(PollenRestApiRequestContext context, String userId, FavoriteList favoriteList) throws InvalidFormException { return context.getFavoriteListService().editFavoriteList(userId, favoriteList); } @@ -81,11 +80,11 @@ return context.getFavoriteListService().getFavoriteListMember(userId, favoriteListId, memberId); } - public FavoriteListMember addMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws InvalidFavoriteListMemberFormException { + public FavoriteListMember addMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws InvalidFormException { return context.getFavoriteListService().addFavoriteListMember(userId, favoriteListId, member); } - public FavoriteListMember editMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws InvalidFavoriteListMemberFormException { + public FavoriteListMember editMember(PollenRestApiRequestContext context, String userId, String favoriteListId, FavoriteListMember member) throws InvalidFormException { return context.getFavoriteListService().editFavoriteListMember(userId, favoriteListId, member); } Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -25,7 +25,7 @@ import org.chorem.pollen.persistence.entity.PollenUser; import org.chorem.pollen.rest.api.PollenRestApiRequestContext; -import org.chorem.pollen.services.exception.InvalidPollenUserFormException; +import org.chorem.pollen.services.exception.InvalidFormException; import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException; import org.chorem.pollen.services.exception.UserInvalidPasswordException; import org.debux.webmotion.server.WebMotionController; @@ -51,17 +51,17 @@ public PollenUser createUser(PollenRestApiRequestContext context, PollenUser user, - boolean generatePassword) throws InvalidPollenUserFormException { + boolean generatePassword) throws InvalidFormException { return context.getPollenUserService().createUser(user, generatePassword); } public PollenUser editUser(PollenRestApiRequestContext context, - PollenUser user) throws InvalidPollenUserFormException { + PollenUser user) throws InvalidFormException { return context.getPollenUserService().editUser(user); } - public void deleteUser(PollenRestApiRequestContext context, String userId) throws InvalidPollenUserFormException { + public void deleteUser(PollenRestApiRequestContext context, String userId) throws InvalidFormException { context.getPollenUserService().deleteUser(userId); } Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteCountingService.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -25,7 +25,6 @@ import org.chorem.pollen.rest.api.PollenRestApiRequestContext; import org.chorem.pollen.services.PollResult; -import org.chorem.pollen.services.exception.EntityNotFoundException; import org.debux.webmotion.server.WebMotionController; /** @@ -36,7 +35,7 @@ */ public class VoteCountingService extends WebMotionController { - public PollResult getResult(PollenRestApiRequestContext context, String pollId) throws EntityNotFoundException { + public PollResult getResult(PollenRestApiRequestContext context, String pollId) { return context.getVoteCountingService().getResult(pollId); } } Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -25,7 +25,7 @@ import org.chorem.pollen.persistence.entity.Vote; import org.chorem.pollen.rest.api.PollenRestApiRequestContext; -import org.chorem.pollen.services.exception.InvalidVoteFormException; +import org.chorem.pollen.services.exception.InvalidFormException; import org.debux.webmotion.server.WebMotionController; import java.util.List; @@ -49,12 +49,12 @@ return context.getVoteService().getVote(pollId, voteId); } - public Vote addVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidVoteFormException { + public Vote addVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidFormException { context.getSecurityService().prepareSubject(pollId); return context.getVoteService().addVote(pollId, vote); } - public Vote editVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidVoteFormException { + public Vote editVote(PollenRestApiRequestContext context, String pollId, Vote vote) throws InvalidFormException { context.getSecurityService().prepareSubject(vote); return context.getVoteService().editVote(pollId, vote); } Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -26,8 +26,7 @@ import org.chorem.pollen.persistence.entity.VoterList; import org.chorem.pollen.persistence.entity.VoterListMember; import org.chorem.pollen.rest.api.PollenRestApiRequestContext; -import org.chorem.pollen.services.exception.InvalidVoterListFormException; -import org.chorem.pollen.services.exception.InvalidVoterListMemberFormException; +import org.chorem.pollen.services.exception.InvalidFormException; import org.debux.webmotion.server.WebMotionController; import java.util.List; @@ -56,12 +55,12 @@ return context.getVoterListService().getVoterList(pollId, voterListId); } - public VoterList createVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidVoterListFormException { + public VoterList createVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidFormException { context.getSecurityService().prepareSubject(pollId); return context.getVoterListService().addVoterList(pollId, voterList); } - public VoterList editVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidVoterListFormException { + public VoterList editVoterList(PollenRestApiRequestContext context, String pollId, VoterList voterList) throws InvalidFormException { context.getSecurityService().prepareSubject(voterList); return context.getVoterListService().editVoterList(pollId, voterList); } @@ -82,12 +81,12 @@ return context.getVoterListService().getVoterListMember(pollId, voterListId, memberId); } - public VoterListMember addMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidVoterListMemberFormException { + public VoterListMember addMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidFormException { context.getSecurityService().prepareSubject(member); return context.getVoterListService().addVoterListMember(pollId, voterListId, member); } - public VoterListMember editMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidVoterListMemberFormException { + public VoterListMember editMember(PollenRestApiRequestContext context, String pollId, String voterListId, VoterListMember member) throws InvalidFormException { context.getSecurityService().prepareSubject(member); return context.getVoterListService().editVoterListMember(pollId, voterListId, member); } Modified: trunk/pollen-rest-api/src/main/resources/mapping =================================================================== --- trunk/pollen-rest-api/src/main/resources/mapping 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-rest-api/src/main/resources/mapping 2014-05-02 12:07:13 UTC (rev 3899) @@ -8,8 +8,6 @@ [filters] * /* PollenRestApiRequestFilter.inject -#- une fois un object lié à PollenUser, c'est immuable. - [errors] org.chorem.pollen.services.exception.EntityNotFoundException ErrorAction.on404 @@ -17,15 +15,6 @@ org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException ErrorAction.on500 org.chorem.pollen.services.exception.InvalidFormException ErrorAction.on400Form -#org.chorem.pollen.services.exception.InvalidChoiceFormException ErrorAction.on500Form -#org.chorem.pollen.services.exception.InvalidPollenUserFormException ErrorAction.on500Form -#org.chorem.pollen.services.exception.InvalidFavoriteListFormException ErrorAction.on500Form -#org.chorem.pollen.services.exception.InvalidFavoriteListMemberFormException ErrorAction.on500Form -#org.chorem.pollen.services.exception.InvalidVoterListFormException ErrorAction.on500Form -#org.chorem.pollen.services.exception.InvalidVoterListMemberFormException ErrorAction.on500Form -#org.chorem.pollen.services.exception.InvalidVoteFormException ErrorAction.on500Form -#org.chorem.pollen.services.exception.InvalidPollFormException ErrorAction.on500Form - [actions] # Doc @@ -76,6 +65,7 @@ GET /v1/polls/invited PollService.getInvitedPolls GET /v1/polls/participated PollService.getParticipatedPolls POST /v1/polls PollService.createPoll +GET /v1/polls/create PollService.createPoll PUT /v1/polls/{pollId} PollService.editPoll GET /v1/polls/{pollId} PollService.getPoll DELETE /v1/polls/{pollId} PollService.deletePoll Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidChoiceFormException.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidChoiceFormException.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidChoiceFormException.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -1,43 +0,0 @@ -package org.chorem.pollen.services.exception; - -/* - * #%L - * Pollen :: Service - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.google.common.collect.Multimap; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class InvalidChoiceFormException extends InvalidFormException { - - private static final long serialVersionUID = 1L; - - - public InvalidChoiceFormException(Multimap<String, String> errors) { - super(errors); - } - -} Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidCommentFormException.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidCommentFormException.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidCommentFormException.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -1,40 +0,0 @@ -package org.chorem.pollen.services.exception; - -/* - * #%L - * Pollen :: Service - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.google.common.collect.Multimap; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class InvalidCommentFormException extends InvalidFormException { - private static final long serialVersionUID = 1L; - - public InvalidCommentFormException(Multimap<String, String> errors) { - super(errors); - } -} Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListFormException.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListFormException.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListFormException.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -1,41 +0,0 @@ -package org.chorem.pollen.services.exception; - -/* - * #%L - * Pollen :: Service - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.google.common.collect.Multimap; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class InvalidFavoriteListFormException extends InvalidFormException { - - private static final long serialVersionUID = 1L; - - public InvalidFavoriteListFormException(Multimap<String, String> errors) { - super(errors); - } -} Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListMemberFormException.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListMemberFormException.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidFavoriteListMemberFormException.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -1,41 +0,0 @@ -package org.chorem.pollen.services.exception; - -/* - * #%L - * Pollen :: Service - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.google.common.collect.Multimap; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class InvalidFavoriteListMemberFormException extends InvalidFormException { - - private static final long serialVersionUID = 1L; - - public InvalidFavoriteListMemberFormException(Multimap<String, String> errors) { - super(errors); - } -} Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollFormException.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollFormException.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollFormException.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -1,42 +0,0 @@ -package org.chorem.pollen.services.exception; - -/* - * #%L - * Pollen :: Service - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.google.common.collect.Multimap; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class InvalidPollFormException extends InvalidFormException { - - private static final long serialVersionUID = 1L; - - public InvalidPollFormException(Multimap<String, String> errors) { - super(errors); - } - -} Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollenUserFormException.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollenUserFormException.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidPollenUserFormException.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -1,40 +0,0 @@ -package org.chorem.pollen.services.exception; - -/* - * #%L - * Pollen :: Service - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.google.common.collect.Multimap; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class InvalidPollenUserFormException extends InvalidFormException { - private static final long serialVersionUID = 1L; - - public InvalidPollenUserFormException(Multimap<String, String> errors) { - super(errors); - } -} Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoteFormException.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoteFormException.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoteFormException.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -1,40 +0,0 @@ -package org.chorem.pollen.services.exception; - -/* - * #%L - * Pollen :: Service - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.google.common.collect.Multimap; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class InvalidVoteFormException extends InvalidFormException { - private static final long serialVersionUID = 1L; - - public InvalidVoteFormException(Multimap<String, String> errors) { - super(errors); - } -} Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListFormException.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListFormException.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListFormException.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -1,41 +0,0 @@ -package org.chorem.pollen.services.exception; - -/* - * #%L - * Pollen :: Service - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.google.common.collect.Multimap; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class InvalidVoterListFormException extends InvalidFormException { - - private static final long serialVersionUID = 1L; - - public InvalidVoterListFormException(Multimap<String, String> errors) { - super(errors); - } -} Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListMemberFormException.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListMemberFormException.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exception/InvalidVoterListMemberFormException.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -1,41 +0,0 @@ -package org.chorem.pollen.services.exception; - -/* - * #%L - * Pollen :: Service - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2013 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.google.common.collect.Multimap; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class InvalidVoterListMemberFormException extends InvalidFormException { - - private static final long serialVersionUID = 1L; - - public InvalidVoterListMemberFormException(Multimap<String, String> errors) { - super(errors); - } -} Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -30,8 +30,7 @@ import org.chorem.pollen.persistence.entity.Comment; import org.chorem.pollen.persistence.entity.Poll; import org.chorem.pollen.persistence.entity.PollenPrincipal; -import org.chorem.pollen.services.exception.EntityNotFoundException; -import org.chorem.pollen.services.exception.InvalidCommentFormException; +import org.chorem.pollen.services.exception.InvalidFormException; import org.chorem.pollen.services.service.security.PermissionVerb; import java.util.List; @@ -44,13 +43,13 @@ */ public class CommentService extends PollenServiceSupport { - public List<Comment> getComments(String pollId) throws EntityNotFoundException { + public List<Comment> getComments(String pollId) { Preconditions.checkNotNull(pollId); Poll poll = getPollService().getPoll(pollId); return poll.getComment(); } - public Comment getComment(String pollId, String commentId) throws EntityNotFoundException { + public Comment getComment(String pollId, String commentId) { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(commentId); @@ -61,7 +60,7 @@ return result; } - public Comment addComment(String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException { + public Comment addComment(String pollId, Comment comment) throws InvalidFormException { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(comment); checkIsNotPersisted(comment); @@ -76,7 +75,7 @@ return result; } - public Comment editComment(String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException { + public Comment editComment(String pollId, Comment comment) throws InvalidFormException { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(comment); checkIsPersisted(comment); @@ -93,7 +92,7 @@ return result; } - public void deleteComment(String pollId, String commentId) throws EntityNotFoundException { + public void deleteComment(String pollId, String commentId) { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(commentId); @@ -109,14 +108,14 @@ commit(); } - protected Comment getComment(Poll poll, String commentId) throws EntityNotFoundException { + protected Comment getComment(Poll poll, String commentId) { Comment result = poll.getCommentByTopiaId(commentId); checkEntityExists(Comment.class, result, commentId); return result; } - protected void checkCommentForm(Poll poll, Comment comment) throws InvalidCommentFormException { + protected void checkCommentForm(Poll poll, Comment comment) throws InvalidFormException { //TODO use nuiton validator ? Multimap<String, String> errors = ArrayListMultimap.create(); @@ -129,11 +128,11 @@ if (!errors.isEmpty()) { - throw new InvalidCommentFormException(errors); + throw new InvalidFormException(errors); } } - protected Comment saveComment(Poll poll, Comment comment) throws EntityNotFoundException { + protected Comment saveComment(Poll poll, Comment comment) { boolean commentExists = comment.isPersisted(); Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -33,10 +33,8 @@ import org.chorem.pollen.persistence.entity.FavoriteListMember; import org.chorem.pollen.persistence.entity.PollenUser; import org.chorem.pollen.services.PollenTechnicalException; -import org.chorem.pollen.services.exception.EntityNotFoundException; import org.chorem.pollen.services.exception.FavoriteListImportException; -import org.chorem.pollen.services.exception.InvalidFavoriteListFormException; -import org.chorem.pollen.services.exception.InvalidFavoriteListMemberFormException; +import org.chorem.pollen.services.exception.InvalidFormException; import org.nuiton.util.StringUtil; import javax.naming.NamingEnumeration; @@ -67,7 +65,7 @@ */ public class FavoriteListService extends PollenServiceSupport { - public List<FavoriteList> getFavoriteLists(String userId) throws EntityNotFoundException { + public List<FavoriteList> getFavoriteLists(String userId) { Preconditions.checkNotNull(userId); PollenUser user = getUserService().getUser(userId); @@ -75,7 +73,7 @@ return result; } - public FavoriteList getFavoriteList(String userId, String favoriteListId) throws EntityNotFoundException { + public FavoriteList getFavoriteList(String userId, String favoriteListId) { Preconditions.checkNotNull(userId); Preconditions.checkNotNull(favoriteListId); @@ -86,7 +84,7 @@ } public FavoriteList createFavoriteList(String userId, - FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException { + FavoriteList favoriteList) throws InvalidFormException { Preconditions.checkNotNull(userId); Preconditions.checkNotNull(favoriteList); checkIsNotPersisted(favoriteList); @@ -106,7 +104,7 @@ } public FavoriteList editFavoriteList(String userId, - FavoriteList favoriteList) throws EntityNotFoundException, InvalidFavoriteListFormException { + FavoriteList favoriteList) throws InvalidFormException { Preconditions.checkNotNull(favoriteList); checkIsPersisted(favoriteList); @@ -126,7 +124,7 @@ return toSave; } - public void deleteFavoriteList(String userId, String favoriteListId) throws EntityNotFoundException { + public void deleteFavoriteList(String userId, String favoriteListId) { Preconditions.checkNotNull(userId); Preconditions.checkNotNull(favoriteListId); @@ -140,7 +138,7 @@ commit(); } - public LinkedHashSet<FavoriteListMember> getFavoriteListMembers(String userId, String favoriteListId) throws EntityNotFoundException { + public LinkedHashSet<FavoriteListMember> getFavoriteListMembers(String userId, String favoriteListId) { Preconditions.checkNotNull(userId); Preconditions.checkNotNull(favoriteListId); @@ -151,7 +149,7 @@ return favoriteList.getMember(); } - public FavoriteListMember getFavoriteListMember(String userId, String favoriteListId, String memberId) throws EntityNotFoundException { + public FavoriteListMember getFavoriteListMember(String userId, String favoriteListId, String memberId) { Preconditions.checkNotNull(userId); Preconditions.checkNotNull(favoriteListId); Preconditions.checkNotNull(memberId); @@ -166,7 +164,7 @@ public FavoriteListMember addFavoriteListMember(String userId, String favoriteListId, - FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException { + FavoriteListMember member) throws InvalidFormException { Preconditions.checkNotNull(userId); Preconditions.checkNotNull(favoriteListId); Preconditions.checkNotNull(member); @@ -191,7 +189,7 @@ public FavoriteListMember editFavoriteListMember(String userId, String favoriteListId, - FavoriteListMember member) throws EntityNotFoundException, InvalidFavoriteListMemberFormException { + FavoriteListMember member) throws InvalidFormException { Preconditions.checkNotNull(userId); Preconditions.checkNotNull(favoriteListId); Preconditions.checkNotNull(member); @@ -218,7 +216,7 @@ public void removeFavoriteListMember(String userId, String favoriteListId, - String memberId) throws EntityNotFoundException { + String memberId) { Preconditions.checkNotNull(userId); Preconditions.checkNotNull(favoriteListId); Preconditions.checkNotNull(memberId); @@ -237,7 +235,7 @@ public int importFavoriteListMembersFromCsv(String userId, String favoriteListId, - File file) throws EntityNotFoundException, FavoriteListImportException { + File file) throws FavoriteListImportException { Preconditions.checkNotNull(userId); Preconditions.checkNotNull(favoriteListId); Preconditions.checkNotNull(file); @@ -336,7 +334,7 @@ public int importFavoriteListMembersFromLdap(String userId, String favoriteListId, - String ldap) throws EntityNotFoundException, FavoriteListImportException { + String ldap) throws FavoriteListImportException { Preconditions.checkNotNull(favoriteListId); Preconditions.checkNotNull(ldap); @@ -421,7 +419,7 @@ return result; } - protected FavoriteList getFavoriteList(PollenUser user, String favoriteListId) throws EntityNotFoundException { + protected FavoriteList getFavoriteList(PollenUser user, String favoriteListId) { Preconditions.checkNotNull(favoriteListId); FavoriteList result = user.getFavoriteListByTopiaId(favoriteListId); @@ -430,7 +428,7 @@ return result; } - protected FavoriteListMember getFavoriteListMember(FavoriteList favoriteList, String memberId) throws EntityNotFoundException { + protected FavoriteListMember getFavoriteListMember(FavoriteList favoriteList, String memberId) { FavoriteListMember result = favoriteList.getMemberByTopiaId(memberId); checkEntityExists(FavoriteListMember.class, result, memberId); @@ -450,7 +448,7 @@ destination.setEmail(StringUtils.lowerCase(source.getEmail())); } - protected void checkFavoriteListForm(PollenUser user, FavoriteList favoriteList) throws InvalidFavoriteListFormException { + protected void checkFavoriteListForm(PollenUser user, FavoriteList favoriteList) throws InvalidFormException { //TODO use nuiton validator ? Multimap<String, String> errors = ArrayListMultimap.create(); @@ -507,12 +505,12 @@ if (!errors.isEmpty()) { - throw new InvalidFavoriteListFormException(errors); + throw new InvalidFormException(errors); } } - protected void checkFavoriteListMemberForm(FavoriteList favoriteList, FavoriteListMember favoriteListMember) throws InvalidFavoriteListMemberFormException { + protected void checkFavoriteListMemberForm(FavoriteList favoriteList, FavoriteListMember favoriteListMember) throws InvalidFormException { //TODO use nuiton validator ? Multimap<String, String> errors = ArrayListMultimap.create(); @@ -558,7 +556,7 @@ if (!errors.isEmpty()) { - throw new InvalidFavoriteListMemberFormException(errors); + throw new InvalidFormException(errors); } } } Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -245,6 +245,15 @@ } } + protected <E extends TopiaEntity> void checkEntityExists(Class<E> type, + E entity, + String property, + String entityId) throws EntityNotFoundException { + if (entity == null) { + throw new EntityNotFoundException(type, property, entityId); + } + } + protected boolean check(Multimap<String, String> errors, String field, boolean condition, String error) { boolean valid = condition; if (!valid) { Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -29,14 +29,13 @@ import org.chorem.pollen.persistence.entity.PollenUser; import org.chorem.pollen.persistence.entity.PollenUserTopiaDao; import org.chorem.pollen.services.PollenService; -import org.chorem.pollen.services.exception.EntityNotFoundException; -import org.chorem.pollen.services.exception.InvalidPollenUserFormException; +import org.chorem.pollen.services.exception.InvalidFormException; import org.chorem.pollen.services.exception.UserInvalidEmailActivationTokenException; import org.chorem.pollen.services.exception.UserInvalidPasswordException; import org.chorem.pollen.services.service.security.SecurityRole; -import org.nuiton.topia.persistence.TopiaNoResultException; import java.util.List; +import java.util.Objects; /** * TODO @@ -54,28 +53,24 @@ } - public PollenUser getUser(String userId) throws EntityNotFoundException { + public PollenUser getUser(String userId) { checkNotNull(userId); - try { - PollenUser result = getPollenUserDao().findByTopiaId(userId); - return result; - } catch (TopiaNoResultException e) { - throw new EntityNotFoundException(PollenUser.class, userId); - } + PollenUser result = getPollenUserDao().forTopiaIdEquals(userId).findUniqueOrNull(); + checkEntityExists(PollenUser.class, result, userId); + return result; + } - public PollenUser getUserByLogin(String login) throws EntityNotFoundException { + public PollenUser getUserByLogin(String login) { checkNotNull(login); - try { - PollenUser result = getPollenUserDao().forLoginEquals(login).findAny(); - return result; - } catch (TopiaNoResultException e) { - throw new EntityNotFoundException(PollenUser.class, PollenUser.PROPERTY_LOGIN, login); - } + + PollenUser result = getPollenUserDao().forLoginEquals(login).findUniqueOrNull(); + checkEntityExists(PollenUser.class, result, PollenUser.PROPERTY_LOGIN, login); + return result; } - public PollenUser createUser(PollenUser user, boolean generatePassword) throws InvalidPollenUserFormException { + public PollenUser createUser(PollenUser user, boolean generatePassword) throws InvalidFormException { checkNotNull(user); checkIsNotPersisted(user); checkPollenUserForm(user); @@ -88,7 +83,7 @@ return result; } - public PollenUser editUser(PollenUser user) throws InvalidPollenUserFormException { + public PollenUser editUser(PollenUser user) throws InvalidFormException { checkNotNull(user); checkIsPersisted(user); checkPollenUserForm(user); @@ -141,7 +136,7 @@ PollenUser user = getUser(userId); - boolean valid = ObjectUtils.equals( + boolean valid = Objects.equals( user.getEmailActivationToken(), token); if (!valid) { @@ -155,7 +150,7 @@ commit(); } - public void createDefaultUsers() throws InvalidPollenUserFormException { + public void createDefaultUsers() throws InvalidFormException { if (getPollenUserDao().count() == 0) { @@ -170,7 +165,7 @@ } } - protected void checkPollenUserForm(PollenUser user) throws InvalidPollenUserFormException { + protected void checkPollenUserForm(PollenUser user) throws InvalidFormException { //TODO use nuiton validator ? Multimap<String, String> errors = ArrayListMultimap.create(); @@ -218,7 +213,7 @@ if (!errors.isEmpty()) { - throw new InvalidPollenUserFormException(errors); + throw new InvalidFormException(errors); } } Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -37,7 +37,7 @@ public class VoteCountingService extends PollenServiceSupport { //GET /poll/{pollId}/results - public PollResult getResult(String pollId) throws EntityNotFoundException { + public PollResult getResult(String pollId) { Preconditions.checkNotNull(pollId); Poll poll = getPollService().getPoll(pollId); //TODO Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -29,8 +29,7 @@ import org.chorem.pollen.persistence.entity.Poll; import org.chorem.pollen.persistence.entity.Polls; import org.chorem.pollen.persistence.entity.Vote; -import org.chorem.pollen.services.exception.EntityNotFoundException; -import org.chorem.pollen.services.exception.InvalidVoteFormException; +import org.chorem.pollen.services.exception.InvalidFormException; import org.chorem.pollen.services.service.security.PermissionVerb; import java.util.Date; @@ -44,7 +43,7 @@ */ public class VoteService extends PollenServiceSupport { - public List<Vote> getVotes(String pollId) throws EntityNotFoundException { + public List<Vote> getVotes(String pollId) { Preconditions.checkNotNull(pollId); Poll poll = getPollService().getPoll(pollId); @@ -52,7 +51,7 @@ return result; } - public Vote getVote(String pollId, String voteId) throws EntityNotFoundException { + public Vote getVote(String pollId, String voteId) { Preconditions.checkNotNull(voteId); checkPermission(PermissionVerb.readVote, voteId); @@ -63,7 +62,7 @@ } - public Vote addVote(String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException { + public Vote addVote(String pollId, Vote vote) throws InvalidFormException { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(vote); checkIsNotPersisted(vote); @@ -80,7 +79,7 @@ return result; } - public Vote editVote(String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException { + public Vote editVote(String pollId, Vote vote) throws InvalidFormException { Preconditions.checkNotNull(vote); checkIsPersisted(vote); checkPermission(PermissionVerb.editVote, vote.getTopiaId()); @@ -96,7 +95,7 @@ return result; } - public void deleteVote(String pollId, String voteId) throws EntityNotFoundException { + public void deleteVote(String pollId, String voteId) { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(voteId); @@ -113,7 +112,7 @@ //TODO Notify vote deleted } - protected void checkVoteForm(Poll poll, Vote vote) throws InvalidVoteFormException { + protected void checkVoteForm(Poll poll, Vote vote) throws InvalidFormException { //TODO use nuiton validator ? Multimap<String, String> errors = ArrayListMultimap.create(); @@ -132,11 +131,11 @@ if (!errors.isEmpty()) { - throw new InvalidVoteFormException(errors); + throw new InvalidFormException(errors); } } - protected Vote saveVote(Poll poll, Vote vote) throws EntityNotFoundException { + protected Vote saveVote(Poll poll, Vote vote) { boolean voteExist = vote.isPersisted(); @@ -171,7 +170,7 @@ return toSave; } - protected Vote getVote(Poll poll, String voteId) throws EntityNotFoundException { + protected Vote getVote(Poll poll, String voteId) { Preconditions.checkNotNull(voteId); Vote result = poll.getVoteByTopiaId(voteId); Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java 2014-05-02 12:06:45 UTC (rev 3898) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java 2014-05-02 12:07:13 UTC (rev 3899) @@ -35,9 +35,7 @@ import org.chorem.pollen.persistence.entity.VoterListMember; import org.chorem.pollen.persistence.entity.VoterListMemberTopiaDao; import org.chorem.pollen.persistence.entity.VoterListTopiaDao; -import org.chorem.pollen.services.exception.EntityNotFoundException; -import org.chorem.pollen.services.exception.InvalidVoterListFormException; -import org.chorem.pollen.services.exception.InvalidVoterListMemberFormException; +import org.chorem.pollen.services.exception.InvalidFormException; import java.util.List; import java.util.Set; @@ -51,7 +49,7 @@ public class VoterListService extends PollenServiceSupport { public VoterList importFavoriteList(String userId, String pollId, - String favoriteListId) throws EntityNotFoundException { + String favoriteListId) { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(favoriteListId); @@ -83,7 +81,7 @@ return result; } - public List<VoterList> getVoterLists(String pollId) throws EntityNotFoundException { + public List<VoterList> getVoterLists(String pollId) { Preconditions.checkNotNull(pollId); Poll poll = getPollService().getPoll(pollId); @@ -92,7 +90,7 @@ return result; } - public VoterList getVoterList(String pollId, String voterListId) throws EntityNotFoundException { + public VoterList getVoterList(String pollId, String voterListId) { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(voterListId); @@ -102,7 +100,7 @@ return result; } - public VoterList addVoterList(String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException { + public VoterList addVoterList(String pollId, VoterList voterList) throws InvalidFormException { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(voterList); checkIsNotPersisted(voterList); @@ -117,7 +115,7 @@ return result; } - public VoterList editVoterList(String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException { + public VoterList editVoterList(String pollId, VoterList voterList) throws InvalidFormException { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(voterList); checkIsPersisted(voterList); @@ -132,7 +130,7 @@ return result; } - public void deleteVoterList(String pollId, String voterListId) throws EntityNotFoundException { + public void deleteVoterList(String pollId, String voterListId) { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(voterListId); @@ -146,7 +144,7 @@ commit(); } - public Set<VoterListMember> getVoterListMembers(String pollId, String voterListId) throws EntityNotFoundException { + public Set<VoterListMember> getVoterListMembers(String pollId, String voterListId) { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(voterListId); @@ -156,7 +154,7 @@ return result; } - public VoterListMember getVoterListMember(String pollId, String voterListId, String memberId) throws EntityNotFoundException { + public VoterListMember getVoterListMember(String pollId, String voterListId, String memberId) { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(voterListId); Preconditions.checkNotNull(memberId); @@ -168,7 +166,7 @@ return result; } - public VoterListMember addVoterListMember(String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException { + public VoterListMember addVoterListMember(String pollId, String voterListId, VoterListMember member) throws InvalidFormException { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(voterListId); Preconditions.checkNotNull(member); @@ -186,7 +184,7 @@ } - public VoterListMember editVoterListMember(String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException { + public VoterListMember editVoterListMember(String pollId, String voterListId, VoterListMember member) throws InvalidFormException { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(voterListId); Preconditions.checkNotNull(member); @@ -203,7 +201,7 @@ return result; } - public void deleteVoterListMember(String pollId, String voterListId, String memberId) throws EntityNotFoundException { + public void deleteVoterListMember(String pollId, String voterListId, String memberId) { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(voterListId); Preconditions.checkNotNull(memberId); @@ -218,14 +216,14 @@ commit(); } - protected VoterList getVoterList(Poll poll, String voterListId) throws EntityNotFoundException { + protected VoterList getVoterList(Poll poll, String voterListId) { VoterList result = poll.getVoterListByTopiaId(voterListId); checkEntityExists(VoterList.class, result, voterListId); return result; } - protected VoterListMember getVoterListMember(VoterList voterList, String memberId) throws EntityNotFoundException { + protected VoterListMember getVoterListMember(VoterList voterList, String memberId) { Preconditions.checkNotNull(memberId); VoterListMember result = voterList.getMemberByTopiaId(memberId); @@ -233,7 +231,7 @@ return result; } - protected VoterList saveVoterList(Poll poll, VoterList voterList) throws EntityNotFoundException { + protected VoterList saveVoterList(Poll poll, VoterList voterList) { boolean voterListExists = voterList.isPersisted(); @@ -263,7 +261,7 @@ } protected VoterListMember saveVoterListMember(VoterList voterList, - VoterListMember voterListMember) throws EntityNotFoundException { + VoterListMember voterListMember) { boolean voterListMemberExists = voterListMember.isPersisted(); @@ -289,7 +287,7 @@ return toSave; } - protected void checkVoterList(Poll poll, VoterList voterList) throws InvalidVoterListFormException { + protected void checkVoterList(Poll poll, VoterList voterList) throws InvalidFormException { //TODO use nuiton validator ? Multimap<String, String> errors = ArrayListMultimap.create(); @@ -351,11 +349,11 @@ if (!errors.isEmpty()) { - throw new InvalidVoterListFormException(errors); + throw new InvalidFormException(errors); } } - protected void checkVoterListMember(VoterList voterList, VoterListMember voterListMember) throws InvalidVoterListMemberFormException { + protected void checkVoterListMember(VoterList voterList, VoterListMember voterListMember) throws InvalidFormException { //TODO use nuiton validator ? Multimap<String, String> errors = ArrayListMultimap.create(); @@ -400,7 +398,7 @@ if (!errors.isEmpty()) { - throw new InvalidVoterListMemberFormException(errors); + throw new InvalidFormException(errors); } } }
participants (1)
-
tchemit@users.chorem.org