Author: tchemit Date: 2013-06-20 09:55:10 +0200 (Thu, 20 Jun 2013) New Revision: 3838 Url: http://chorem.org/projects/pollen/repository/revisions/3838 Log: - continue security - add svn properties - make rest service works again Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PermissionVerb.java Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Poll.java trunk/pollen-persistence/src/main/xmi/pollen.properties trunk/pollen-persistence/src/main/xmi/pollen.zargo trunk/pollen-rest-api/pom.xml trunk/pollen-rest-api/src/jetty/jetty-context.xml trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java trunk/pollen-rest-api/src/main/resources/mapping trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityContext.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AbstractPollenService.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.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/SecurityService.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java trunk/pollen-ui-js/src/main/resources/nuiton-js/wro.properties trunk/pollen-ui-js/src/main/resources/nuiton-js/wro.xml trunk/pollen-ui-js/src/main/webapp/bundle/Messages.properties trunk/pollen-ui-js/src/main/webapp/css/style.css trunk/pollen-ui-js/src/main/webapp/index.html trunk/pollen-ui-js/src/main/webapp/js/controls/menu.js trunk/pollen-ui-js/src/main/webapp/js/controls/poll_form.js trunk/pollen-ui-js/src/main/webapp/js/controls/poll_list.js trunk/pollen-ui-js/src/main/webapp/js/controls/poll_summary.js trunk/pollen-ui-js/src/main/webapp/js/controls/user_form.js trunk/pollen-ui-js/src/main/webapp/js/controls/vote.js trunk/pollen-ui-js/src/main/webapp/js/libs/jquery.scrollto.js trunk/pollen-ui-js/src/main/webapp/js/models/comments.js trunk/pollen-ui-js/src/main/webapp/js/models/polls.js trunk/pollen-ui-js/src/main/webapp/js/models/users.js trunk/pollen-ui-js/src/main/webapp/js/models/votes.js trunk/pollen-ui-js/src/main/webapp/js/route.js trunk/pollen-ui-js/src/main/webapp/views/poll_list.ejs trunk/pollen-ui-js/src/main/webapp/views/user_form.ejs Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Poll.java =================================================================== --- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Poll.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Poll.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -23,8 +23,11 @@ * #L% */ +import com.google.common.collect.Sets; + import javax.persistence.Entity; import java.util.Date; +import java.util.Set; /** * TODO @@ -81,4 +84,16 @@ (endChoiceDate != null && endChoiceDate.before(currentDate)); } + public Set<VoterListMember> getAllVoters() { + Set<VoterListMember> result = Sets.newHashSet(); + if (!isVoterListEmpty()) { + for (VoterList list : getVoterList()) { + + if (!list.isVoterListMemberEmpty()) { + result.addAll(list.getVoterListMember()); + } + } + } + return result; + } } //Poll Modified: trunk/pollen-persistence/src/main/xmi/pollen.properties =================================================================== --- trunk/pollen-persistence/src/main/xmi/pollen.properties 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-persistence/src/main/xmi/pollen.properties 2013-06-20 07:55:10 UTC (rev 3838) @@ -20,10 +20,10 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # #L% ###m +model.tagvalue.version=2.0 model.tagValue.idFactory=true model.tagValue.generateVisitors=true -model.tagvalue.version=2.0 -#model.tagvalue.entitySuperClass=org.chorem.pollen.persistence.entity.AbstractJpaPollenEntity +model.tagValue.generateExtraTechnicalFields=true org.chorem.pollen.persistence.entity.Poll.attribute.choice.stereotype=ordered org.chorem.pollen.persistence.entity.Poll.attribute.voterList.stereotype=ordered Modified: trunk/pollen-persistence/src/main/xmi/pollen.zargo =================================================================== (Binary files differ) Modified: trunk/pollen-rest-api/pom.xml =================================================================== --- trunk/pollen-rest-api/pom.xml 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-rest-api/pom.xml 2013-06-20 07:55:10 UTC (rev 3838) @@ -147,6 +147,16 @@ <defaultDbDir>${basedir}/target</defaultDbDir> </properties> <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <includes> + <include>**/mapping</include> + </includes> + <filtering>true</filtering> + </resource> + </resources> + <pluginManagement> <plugins> <plugin> Modified: trunk/pollen-rest-api/src/jetty/jetty-context.xml =================================================================== --- trunk/pollen-rest-api/src/jetty/jetty-context.xml 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-rest-api/src/jetty/jetty-context.xml 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,11 +1,11 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> +<?xml version="1.0" encoding="UTF-8"?> <!-- #%L - Pollen :: UI (struts2) + Pollen :: Rest Api $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + 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 @@ -27,6 +27,6 @@ <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <Call name="setAttribute"> <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg> - <Arg>.*/.*jsp-api-[^/]\.jar$|./.*jsp-[^/]\.jar$|./.*taglibs[^/]*\.jar$</Arg> + <Arg>.*/.*webmotion.*[^/]\.jar$</Arg> </Call> </Configure> \ No newline at end of file Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceContextFilter.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -75,10 +75,8 @@ sessionToken = serviceContext.getAuthService().getUserByAuth(authParam); } - PollenSecurityContext securityContext; - securityContext = PollenSecurityContext.newContext( - sessionToken == null ? null : sessionToken.getPollenUser() - ); + PollenSecurityContext securityContext = + PollenSecurityContext.newContext(sessionToken); serviceContext.setSecurityContext(securityContext); } } Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenServiceListener.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -55,7 +55,6 @@ public void onStart(Mapping mapping, ServerContext serverContext) { serverContext.addInjector(new PollenServiceContextInjector()); - serverContext.addInjector(new SessionTokenInjector()); // Create application context PollenApplicationContext applicationContext = @@ -70,7 +69,7 @@ try { PollenServiceContext serviceContext = applicationContext.newServiceContext(entityManager); - serviceContext.getUserService().createDefaultUsers(); + serviceContext.getPollenUserService().createDefaultUsers(); } catch (InvalidPollenUserFormException e) { //Can't happen } catch (EntityNotFoundException e) { @@ -108,17 +107,5 @@ } } - protected static class SessionTokenInjector implements ExecutorParametersInjectorHandler.Injector { - @Override - public Object getValue(Mapping mapping, Call call, String name, Class<?> type, Type generic) { - PollenServiceContext result = null; - if (PollenServiceContext.class.isAssignableFrom(type)) { - HttpContext httpContext = call.getContext(); - HttpServletRequest request = httpContext.getRequest(); - result = PollenServices.getServiceContext(request); - } - return result; - } - } } Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -23,6 +23,7 @@ * #L% */ +import org.chorem.pollen.persistence.entity.SessionToken; import org.chorem.pollen.services.PollenServiceContext; import org.chorem.pollen.services.exception.EntityNotFoundException; import org.chorem.pollen.services.exception.UserInvalidPasswordException; @@ -36,7 +37,7 @@ */ public class AuthService extends WebMotionController { - public String login(PollenServiceContext context, String login, String password) throws UserInvalidPasswordException, EntityNotFoundException { + public SessionToken login(PollenServiceContext context, String login, String password) throws UserInvalidPasswordException, EntityNotFoundException { return context.getAuthService().login(login, password); } Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/ChoiceService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -40,23 +40,28 @@ public class ChoiceService extends WebMotionController { public List<Choice> getChoices(PollenServiceContext context, String pollId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(pollId); List<Choice> choices = context.getChoiceService().getChoices(pollId); return choices; } public Choice getChoice(PollenServiceContext context, String pollId, String choiceId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(choiceId); return context.getChoiceService().getChoice(pollId, choiceId); } public Choice addChoice(PollenServiceContext context, String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException { + context.getSecurityService().prepareSubject(pollId); return context.getChoiceService().addChoice(pollId, choice); } public Choice editChoice(PollenServiceContext context, String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException { + context.getSecurityService().prepareSubject(choice); return context.getChoiceService().editChoice(pollId, choice); } public void deleteChoice(PollenServiceContext context, String pollId, String choiceId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(choiceId); context.getChoiceService().deleteChoice(pollId, choiceId); } } \ No newline at end of file Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/CommentService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -40,23 +40,28 @@ public class CommentService extends WebMotionController { public List<Comment> getComments(PollenServiceContext context, String pollId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(pollId); List<Comment> comments = context.getCommentService().getComments(pollId); return comments; } public Comment getComment(PollenServiceContext context, String pollId, String commentId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(commentId); return context.getCommentService().getComment(pollId, commentId); } public Comment addComment(PollenServiceContext context, String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException { + context.getSecurityService().prepareSubject(pollId); return context.getCommentService().addComment(pollId, comment); } public Comment editComment(PollenServiceContext context, String pollId, Comment comment) throws EntityNotFoundException, InvalidCommentFormException { + context.getSecurityService().prepareSubject(comment); return context.getCommentService().editComment(pollId, comment); } public void deleteComment(PollenServiceContext context, String pollId, String commentId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(commentId); context.getCommentService().deleteComment(pollId, commentId); } } Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -66,6 +66,7 @@ } public Poll getPoll(PollenServiceContext context, String pollId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(pollId); return context.getPollService().getPoll(pollId); } @@ -74,22 +75,27 @@ } public Poll editPoll(PollenServiceContext context, Poll poll) throws EntityNotFoundException, InvalidPollFormException { + context.getSecurityService().prepareSubject(poll); return context.getPollService().editPoll(poll); } public void deletePoll(PollenServiceContext context, String pollId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(pollId); context.getPollService().deletePoll(pollId); } public Poll clonePoll(PollenServiceContext context, String pollId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(pollId); return context.getPollService().clonePoll(pollId); } public File closePoll(PollenServiceContext context, String pollId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(pollId); return context.getPollService().closePoll(pollId); } public File exportPoll(PollenServiceContext context, String pollId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(pollId); return context.getPollService().exportPoll(pollId); } } Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -42,36 +42,36 @@ public class PollenUserService extends WebMotionController { public List<PollenUser> getUsers(PollenServiceContext context) { - List<PollenUser> users = context.getUserService().getUsers(); + List<PollenUser> users = context.getPollenUserService().getUsers(); return users; } public PollenUser getUser(PollenServiceContext context, String userId) throws EntityNotFoundException { - return context.getUserService().getUser(userId); + return context.getPollenUserService().getUser(userId); } public PollenUser createUser(PollenServiceContext context, PollenUser user, boolean generatePassword) throws EntityNotFoundException, InvalidPollenUserFormException { - return context.getUserService().createUser(user, generatePassword); + return context.getPollenUserService().createUser(user, generatePassword); } public PollenUser editUser(PollenServiceContext context, PollenUser user) throws EntityNotFoundException, InvalidPollenUserFormException { - return context.getUserService().editUser(user); + return context.getPollenUserService().editUser(user); } public void validateUserEmail(PollenServiceContext context, String userId, String token) throws EntityNotFoundException, UserInvalidEmailActivationTokenException { - context.getUserService().validateUserEmail(userId, token); + context.getPollenUserService().validateUserEmail(userId, token); } public void changePassword(PollenServiceContext context, String userId, String oldPassword, String newPassword) throws EntityNotFoundException, UserInvalidPasswordException { - context.getUserService().changePassword(userId, oldPassword, newPassword); + context.getPollenUserService().changePassword(userId, oldPassword, newPassword); } } Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -40,23 +40,28 @@ public class VoteService extends WebMotionController { public List<Vote> getVotes(PollenServiceContext context, String pollId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(pollId); List<Vote> votes = context.getVoteService().getVotes(pollId); return votes; } public Vote getVote(PollenServiceContext context, String pollId, String voteId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(voteId); return context.getVoteService().getVote(pollId, voteId); } public Vote addVote(PollenServiceContext context, String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException { + context.getSecurityService().prepareSubject(pollId); return context.getVoteService().addVote(pollId, vote); } public Vote editVote(PollenServiceContext context, String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException { + context.getSecurityService().prepareSubject(vote); return context.getVoteService().editVote(pollId, vote); } public void deleteVote(PollenServiceContext context, String pollId, String voteId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(voteId); context.getVoteService().deleteVote(pollId, voteId); } } Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java =================================================================== --- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoterListService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -47,44 +47,54 @@ } public List<VoterList> getVoterLists(PollenServiceContext context, String pollId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(pollId); List<VoterList> voterLists = context.getVoterListService().getVoterLists(pollId); return voterLists; } public VoterList getVoterList(PollenServiceContext context, String pollId, String voterListId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(voterListId); return context.getVoterListService().getVoterList(pollId, voterListId); } public VoterList addVoterList(PollenServiceContext context, String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException { + context.getSecurityService().prepareSubject(pollId); return context.getVoterListService().addVoterList(pollId, voterList); } public VoterList editVoterList(PollenServiceContext context, String pollId, VoterList voterList) throws EntityNotFoundException, InvalidVoterListFormException { + context.getSecurityService().prepareSubject(voterList); return context.getVoterListService().editVoterList(pollId, voterList); } public void deleteVoterList(PollenServiceContext context, String pollId, String voterListId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(voterListId); context.getVoterListService().deleteVoterList(pollId, voterListId); } public Set<VoterListMember> getMembers(PollenServiceContext context, String pollId, String voterListId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(voterListId); Set<VoterListMember> members = context.getVoterListService().getVoterListMembers(pollId, voterListId); return members; } public VoterListMember getMember(PollenServiceContext context, String pollId, String voterListId, String memberId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(memberId); return context.getVoterListService().getVoterListMember(pollId, voterListId, memberId); } public VoterListMember addMember(PollenServiceContext context, String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException { + context.getSecurityService().prepareSubject(member); return context.getVoterListService().addVoterListMember(pollId, voterListId, member); } public VoterListMember editMember(PollenServiceContext context, String pollId, String voterListId, VoterListMember member) throws EntityNotFoundException, InvalidVoterListMemberFormException { + context.getSecurityService().prepareSubject(member); return context.getVoterListService().editVoterListMember(pollId, voterListId, member); } public void deleteMember(PollenServiceContext context, String pollId, String voterListId, String memberId) throws EntityNotFoundException { + context.getSecurityService().prepareSubject(memberId); context.getVoterListService().deleteVoterListMember(pollId, voterListId, memberId); } } Modified: trunk/pollen-rest-api/src/main/resources/mapping =================================================================== --- trunk/pollen-rest-api/src/main/resources/mapping 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-rest-api/src/main/resources/mapping 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,9 +1,9 @@ [config] -package.filters=org.chorem.pollen.rest -package.actions=org.chorem.pollen.rest.api -package.errors=org.chorem.pollen.rest.api -server.listener.class=org.chorem.pollen.rest.PollenServiceListener -default.render=org.chorem.pollen.rest.PollenRender +package.filters=org.chorem.pollen.rest.api +package.actions=org.chorem.pollen.rest.api.v1 +package.errors=org.chorem.pollen.rest.api.v1 +server.listener.class=org.chorem.pollen.rest.api.PollenServiceListener +default.render=org.chorem.pollen.rest.api.PollenRender [filters] * /* PollenServiceContextFilter.inject @@ -12,12 +12,12 @@ [errors] -org.chorem.pollen.service.exception.EntityNotFoundException ErrorAction.on404 -org.chorem.pollen.service.exception.UserEmailAlreadyUsedException ErrorAction.on500 -org.chorem.pollen.service.exception.UserLoginAlreadyUsedException ErrorAction.on500 -org.chorem.pollen.service.exception.UserInvalidPasswordException ErrorAction.on500 -org.chorem.pollen.service.exception.UserInvalidEmailActiviationTokenException ErrorAction.on500 -org.chorem.pollen.service.exception.AbstractInvalidFormException ErrorAction.on500Form +org.chorem.pollen.services.exception.EntityNotFoundException ErrorAction.on404 +org.chorem.pollen.services.exception.UserEmailAlreadyUsedException ErrorAction.on500 +org.chorem.pollen.services.exception.UserLoginAlreadyUsedException ErrorAction.on500 +org.chorem.pollen.services.exception.UserInvalidPasswordException ErrorAction.on500 +org.chorem.pollen.services.exception.UserInvalidEmailActiviationTokenException ErrorAction.on500 +org.chorem.pollen.services.exception.AbstractInvalidFormException ErrorAction.on500Form [actions] @@ -73,13 +73,13 @@ GET /v1/polls/{pollId}/export PollService.exportPoll PUT /v1/polls/{pollId}/close PollService.closePoll -# UserService +# PollenUserService -GET /v1/users UserService.getUsers -GET /v1/users/{userId} UserService.getUser -POST /v1/users UserService.createUser -PUT /v1/users/{userId} UserService.editUser -PUT /v1/users/{userId}?token={} UserService.validateUserEmail +GET /v1/users PollenUserService.getUsers +GET /v1/users/{userId} PollenUserService.getUser +POST /v1/users PollenUserService.createUser +PUT /v1/users/{userId} PollenUserService.editUser +PUT /v1/users/{userId}?token={} PollenUserService.validateUserEmail # VoteCountingService Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -128,7 +128,7 @@ } @Override - public PollenUserService getUserService() { + public PollenUserService getPollenUserService() { return newService(PollenUserService.class); } Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityContext.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityContext.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenSecurityContext.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -23,14 +23,11 @@ * #L% */ -import com.google.common.collect.ImmutableSet; -import org.apache.commons.collections.CollectionUtils; +import org.apache.shiro.subject.Subject; import org.chorem.pollen.persistence.entity.PollenUser; -import org.nuiton.jpa.api.JpaEntity; +import org.chorem.pollen.persistence.entity.SessionToken; import java.io.Serializable; -import java.util.Collections; -import java.util.Set; /** * TODO @@ -40,8 +37,10 @@ */ public class PollenSecurityContext implements Serializable { - private static final long serialVersionUID = 5348851531764083245L; + private static final long serialVersionUID = 1L; + protected Subject subject; + /** * Connected user account. * <p/> @@ -49,130 +48,35 @@ * * @since 2.0 */ - protected final PollenUser connectedUser; + protected final SessionToken sessionToken; - /** - * Resource to edit/delete (can be null for some creation contexts). - * - * @since 2.0 - */ - protected ObjectSecurityContext<?> resource; - - /** - * User roles on the poll. - * - * @since 2.0 - */ - protected Set<PollenUserSecurityRole> userRoles; - - public static PollenSecurityContext newContext(PollenUser userAccount) { + public static PollenSecurityContext newContext(SessionToken sessionToken) { PollenSecurityContext result = new PollenSecurityContext( - userAccount); + sessionToken); return result; } - public static <E extends JpaEntity> ObjectSecurityContext<E> ObjectSecurityContext(Class<E> type, - String id, - String token) { - return new ObjectSecurityContext<E>(type, id, token); + public Subject getSubject() { + return subject; } - public void setResource(ObjectSecurityContext<?> resource) { - this.resource = resource; + public SessionToken getSessionToken() { + return sessionToken; } - public void setUserRoles(Set<PollenUserSecurityRole> userRoles) { - this.userRoles = userRoles == null ? null : ImmutableSet.copyOf(userRoles); - } - - public boolean isAdministrator() { - return userRoles != null && userRoles.contains(PollenUserSecurityRole.ADMINISTRATOR); - } - - public boolean isCreator() { - return userRoles != null && userRoles.contains(PollenUserSecurityRole.CREATOR); - } - - public boolean isVoter() { - return userRoles != null && userRoles.contains(PollenUserSecurityRole.VOTER); - } - - public boolean isRestrictedVoter() { - return userRoles != null && userRoles.contains(PollenUserSecurityRole.RESTRICTED_VOTER); - } - - public boolean hasNoRole() { - return CollectionUtils.isEmpty(userRoles); - } - - public Set<PollenUserSecurityRole> getUserRoles() { - return userRoles == null ? - Collections.<PollenUserSecurityRole>emptySet() : - userRoles; - } - public PollenUser getPollenUser() { - return connectedUser; + return isConnected() ? sessionToken.getPollenUser() : null; } - protected PollenSecurityContext(PollenUser connectedUser) { - this.connectedUser = connectedUser; - } - public boolean isConnected() { - return connectedUser != null; + return sessionToken != null; } - /** - * To define a security role for a given pollen user which can be - * identified by his user account or a accountId. - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ - public enum PollenUserSecurityRole { - - /** - * Connected user with administration rights. - * <p/> - * This role can access to everything, but can not vote. - */ - ADMINISTRATOR, - - /** - * Creator of the poll. - * <p/> - * This role can access to everything, but can not vote. - */ - CREATOR, - - /** A user that has voted on a poll. */ - VOTER, - /** - * A user that was invited to a restricted poll. - * <p/> - * It might have alreay voted or not. - */ - RESTRICTED_VOTER - + public void setSubject(Subject subject) { + this.subject = subject; } - public static class ObjectSecurityContext<E extends JpaEntity> implements Serializable { - - private static final long serialVersionUID = 8554648867841712974L; - - protected final Class<E> type; - - protected final String id; - - protected final String token; - - public ObjectSecurityContext(Class<E> type, - String id, - String token) { - this.type = type; - this.id = id; - this.token = token; - } + protected PollenSecurityContext(SessionToken sessionToken) { + this.sessionToken = sessionToken; } } Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -68,7 +68,7 @@ PollService getPollService(); - PollenUserService getUserService(); + PollenUserService getPollenUserService(); VoteCountingService getVoteCountingService(); Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AbstractPollenService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AbstractPollenService.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AbstractPollenService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -51,6 +51,10 @@ protected PollenServiceContext serviceContext; + public String createPermission(PermissionVerb verb, String id) { + return ":" + verb.name() + ":" + id; + } + @Override public void setServiceContext(PollenServiceContext serviceContext) { this.serviceContext = serviceContext; @@ -103,7 +107,7 @@ } protected PollenUserService getUserService() { - return serviceContext.getUserService(); + return serviceContext.getPollenUserService(); } protected VoteCountingService getVoteCountingService() { @@ -120,6 +124,11 @@ // -- check method -- // + protected void checkPermission(PermissionVerb verb, String id) { + String permission = createPermission(verb, id); +// serviceContext.getSecurityContext().getSubject().checkPermission(permission); + } + protected void checkHasId(JpaEntity entity) { Preconditions.checkState(JpaEntities.isEntityHasId(entity)); } Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/AuthService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -40,14 +40,11 @@ */ public class AuthService extends AbstractPollenService { - public String login(String login, String password) throws EntityNotFoundException, UserInvalidPasswordException { + public SessionToken login(String login, String password) throws EntityNotFoundException, UserInvalidPasswordException { Preconditions.checkNotNull(login); Preconditions.checkNotNull(password); - PollenUser user = getPersistenceContext().getPollenUserDao().findByLogin(login); - if (user == null) { - throw new EntityNotFoundException(PollenUser.class, login); - } + PollenUser user = getUserService().getUserByLogin(login); String encodedPassword = serviceContext.encodePassword(password); if (!encodedPassword.equals(user.getPassword())) { @@ -67,7 +64,7 @@ dao.persist(sessionToken); getPersistenceContext().commit(); - return token; + return sessionToken; } public void lostPassword(String login) throws EntityNotFoundException { @@ -75,10 +72,7 @@ PollenUserJpaDao dao = getPersistenceContext().getPollenUserDao(); - PollenUser user = dao.findByLogin(login); - if (user == null) { - throw new EntityNotFoundException(PollenUser.class, login); - } + PollenUser user = getUserService().getUserByLogin(login); // Generate a new password String newPassword = serviceContext.generatePassword(); @@ -87,25 +81,21 @@ dao.merge(user); getPersistenceContext().commit(); - notifyPasswordChanged(user, newPassword); + //TODO Notifiy Password changed } public void logout(String login, String token) throws EntityNotFoundException { Preconditions.checkNotNull(login); Preconditions.checkNotNull(token); - PollenUser user = getPersistenceContext().getPollenUserDao().findByLogin(login); - if (user == null) { - throw new EntityNotFoundException(PollenUser.class, login); - } + getUserService().getUserByLogin(login); + String encodedToken = serviceContext.encodePassword(token); SessionTokenJpaDao dao = getPersistenceContext().getSessionTokenDao(); SessionToken sessionToken = dao.findByToken(encodedToken); - if (sessionToken == null) { - throw new EntityNotFoundException(SessionToken.class, token); - } + checkEntityExists(SessionToken.class, sessionToken, token); dao.remove(sessionToken); getPersistenceContext().commit(); @@ -121,7 +111,4 @@ return sessionToken; } - protected void notifyPasswordChanged(PollenUser user, String newPassword) { - //TODO - } } Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -57,6 +57,7 @@ public Choice getChoice(String pollId, String choiceId) throws EntityNotFoundException { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(choiceId); + checkPermission(PermissionVerb.editChoice, choiceId); Poll poll = getPollService().getPoll(pollId); Choice result = getChoice(poll, choiceId); @@ -69,10 +70,11 @@ checkHasNoId(choice); Poll poll = getPollService().getPoll(pollId); + checkPermission(PermissionVerb.addChoice, pollId); checkChoiceForm(poll, choice); - Choice result = saveChoice(poll, choice, null); + Choice result = saveChoice(poll, choice); getPersistenceContext().getPollDao().merge(poll); getPersistenceContext().commit(); @@ -83,12 +85,13 @@ public Choice editChoice(String pollId, Choice choice) throws EntityNotFoundException, InvalidChoiceFormException { Preconditions.checkNotNull(choice); checkHasId(choice); + checkPermission(PermissionVerb.editChoice, choice.getId()); Poll poll = getPollService().getPoll(pollId); checkChoiceForm(poll, choice); - Choice result = saveChoice(poll, choice, null); + Choice result = saveChoice(poll, choice); getPersistenceContext().getChoiceDao().merge(choice); getPersistenceContext().commit(); @@ -99,6 +102,7 @@ public void deleteChoice(String pollId, String choiceId) throws EntityNotFoundException { Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(choiceId); + checkPermission(PermissionVerb.deleteChoice, choiceId); Poll poll = getPollService().getPoll(pollId); Choice choice = getChoice(poll, choiceId); @@ -118,8 +122,7 @@ } protected Choice saveChoice(Poll poll, - Choice choice, - PollenPrincipal principal) throws EntityNotFoundException { + Choice choice) throws EntityNotFoundException { ChoiceJpaDao choiceDao = getPersistenceContext().getChoiceDao(); @@ -136,22 +139,15 @@ // create a new choice choiceToPersist = choiceDao.newInstance(); - if (principal == null) { + // create a new principal + PollenPrincipal principal = getSecurityService().generatePrincipal(); - // create a new principal - - principal = getSecurityService().generatePrincipal(); - - if (choice.getCreator() == null) { - - //TODO Should we use the poll creator ? - - } else { - - principal.setName(choice.getCreator().getName()); - principal.setEmail(choice.getCreator().getEmail()); - } + PollenPrincipal creator = choice.getCreator(); + if (creator != null) { + principal.setName(creator.getName()); + principal.setEmail(creator.getEmail()); } + choiceToPersist.setCreator(principal); poll.addChoice(choiceToPersist); } 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 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/CommentService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -55,6 +55,7 @@ Preconditions.checkNotNull(commentId); Poll poll = getPollService().getPoll(pollId); + checkPermission(PermissionVerb.readComment, commentId); Comment result = getComment(poll, commentId); return result; @@ -64,7 +65,7 @@ Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(comment); checkHasNoId(comment); - + checkPermission(PermissionVerb.addComment, pollId); Poll poll = getPollService().getPoll(pollId); checkCommentForm(poll, comment); @@ -80,6 +81,8 @@ Preconditions.checkNotNull(comment); checkHasId(comment); + checkPermission(PermissionVerb.editComment, comment.getId()); + Poll poll = getPollService().getPoll(pollId); checkCommentForm(poll, comment); @@ -94,6 +97,8 @@ Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(commentId); + checkPermission(PermissionVerb.deleteComment, commentId); + Poll poll = getPollService().getPoll(pollId); Comment comment = getComment(poll, commentId); Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PermissionVerb.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PermissionVerb.java (rev 0) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PermissionVerb.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -0,0 +1,57 @@ +package org.chorem.pollen.services.service; + +/* + * #%L + * Pollen :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public enum PermissionVerb { + readPoll, + readChoice, + readComment, + readVote, + + addPoll, + addChoice, + addComment, + addVote, + + editPoll, + editChoice, + editComment, + editVote, + + deletePoll, + deleteChoice, + deleteComment, + deleteVote, + + closePoll, + clonePoll, + exportPoll, + +} Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PermissionVerb.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -82,6 +82,7 @@ public Poll getPoll(String pollId) throws EntityNotFoundException { Preconditions.checkNotNull(pollId); + checkPermission(PermissionVerb.readPoll, pollId); Poll result = getPersistenceContext().getPollDao().findById(pollId); checkEntityExists(Poll.class, result, pollId); return result; @@ -136,6 +137,8 @@ Preconditions.checkNotNull(poll); checkHasId(poll); + checkPermission(PermissionVerb.editPoll, poll.getId()); + checkPollForm(poll); Poll toSave = savePoll(null, poll); @@ -150,6 +153,8 @@ public void deletePoll(String pollId) throws EntityNotFoundException { Preconditions.checkNotNull(pollId); + checkPermission(PermissionVerb.deletePoll, pollId); + Poll poll = getPoll(pollId); getPersistenceContext().getPollDao().remove(poll); @@ -164,6 +169,8 @@ public Poll clonePoll(String pollId) throws EntityNotFoundException { Preconditions.checkNotNull(pollId); + checkPermission(PermissionVerb.clonePoll, pollId); + Poll poll = getPoll(pollId); //TODO getPersistenceContext().commit(); @@ -172,6 +179,7 @@ public File closePoll(String pollId) throws EntityNotFoundException { Preconditions.checkNotNull(pollId); + checkPermission(PermissionVerb.closePoll, pollId); Poll poll = getPoll(pollId); //TODO @@ -181,6 +189,7 @@ public File exportPoll(String pollId) throws EntityNotFoundException { Preconditions.checkNotNull(pollId); + checkPermission(PermissionVerb.exportPoll, pollId); Poll poll = getPoll(pollId); //TODO return null; @@ -242,7 +251,7 @@ for (Choice choice : poll.getChoice()) { - getChoiceService().saveChoice(toSave, choice, toSave.getCreator()); + getChoiceService().saveChoice(toSave, choice); } // -- voting list -- // 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 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -58,6 +58,14 @@ return result; } + public PollenUser getUserByLogin(String login) throws EntityNotFoundException { + Preconditions.checkNotNull(login); + + PollenUser result = getPersistenceContext().getPollenUserDao().findByLogin(login); + checkEntityExists(PollenUser.class, result, login); + return result; + } + public PollenUser createUser(PollenUser user, boolean generatePassword) throws InvalidPollenUserFormException, EntityNotFoundException { Preconditions.checkNotNull(user); checkHasNoId(user); Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/SecurityService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -23,9 +23,32 @@ * #L% */ +import com.google.common.base.Preconditions; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.apache.shiro.subject.SimplePrincipalCollection; +import org.apache.shiro.subject.Subject; +import org.chorem.pollen.persistence.dao.ChoiceJpaDao; +import org.chorem.pollen.persistence.dao.CommentJpaDao; +import org.chorem.pollen.persistence.dao.PollJpaDao; import org.chorem.pollen.persistence.dao.PollenPrincipalJpaDao; +import org.chorem.pollen.persistence.dao.VoteJpaDao; +import org.chorem.pollen.persistence.entity.Choice; +import org.chorem.pollen.persistence.entity.Comment; +import org.chorem.pollen.persistence.entity.CommentVisibility; +import org.chorem.pollen.persistence.entity.Poll; import org.chorem.pollen.persistence.entity.PollenPrincipal; +import org.chorem.pollen.persistence.entity.PollenUser; +import org.chorem.pollen.persistence.entity.Vote; +import org.chorem.pollen.persistence.entity.VoterListMember; +import org.chorem.pollen.services.PollenSecurityContext; +import org.nuiton.jpa.api.JpaEntity; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * TODO * @@ -37,10 +60,230 @@ public PollenPrincipal generatePrincipal() { PollenPrincipalJpaDao pollenPrincipalDao = getPersistenceContext().getPollenPrincipalDao(); PollenPrincipal principal = pollenPrincipalDao.newInstance(); - principal.setToken(serviceContext.generateToken()); principal.setCreationDate(serviceContext.getNow()); pollenPrincipalDao.persist(principal); return principal; + } + public void prepareSubject(JpaEntity entity) { + Preconditions.checkNotNull(entity); + prepareSubject(entity.getId()); } + + public void prepareSubject(String principalId) { + PollenSecurityContext securityContext = serviceContext.getSecurityContext(); + Preconditions.checkNotNull(securityContext); + PollenUser pollenUser = securityContext.getPollenUser(); + Subject subject = getSubject(principalId, pollenUser); + securityContext.setSubject(subject); + } + + protected Subject getSubject(String principalId, PollenUser user) { + Set<String> permissions = Sets.newHashSet(); + + boolean userConnected = user != null; + boolean userIsAdmin = userConnected && user.isAdministrator(); + + if (userIsAdmin) { + permissions.add("*:*:*"); + } else { + + Set<PollenPrincipal> principals = Sets.newHashSet(); + + PollenPrincipalJpaDao pollenPrincipalDao = + getPersistenceContext().getPollenPrincipalDao(); + + if (principalId != null) { + PollenPrincipal pollenPrincipal = + pollenPrincipalDao.findById(principalId); + principals.add(pollenPrincipal); + } + + if (userConnected) { + + // find all principals + List<PollenPrincipal> allByPollenUser = + pollenPrincipalDao.findAllByPollenUser(user); + principals.addAll(allByPollenUser); + } + + Map<PollenPrincipal, JpaEntity> principalJpaEntityMap = Maps.newHashMap(); + + for (PollenPrincipal principal : principals) { + + // find out which entity is using this principal + JpaEntity entity = getPrincipalEntity(principal); + principalJpaEntityMap.put(principal, entity); + + if (entity instanceof Poll) { + + // add all poll entities + Poll poll = (Poll) entity; + + if (!poll.isChoiceEmpty()) { + for (Choice choice : poll.getChoice()) { + principalJpaEntityMap.put(choice.getCreator(), choice); + } + } + + if (!poll.isCommentEmpty()) { + for (Comment comment : poll.getComment()) { + principalJpaEntityMap.put(comment.getAuthor(), comment); + } + } + + if (!poll.isVoteEmpty()) { + for (Vote vote : poll.getVote()) { + principalJpaEntityMap.put(vote.getVoter(), vote); + } + } + } + } + + Date now = serviceContext.getNow(); + for (Map.Entry<PollenPrincipal, JpaEntity> entry : principalJpaEntityMap.entrySet()) { + JpaEntity entity = entry.getValue(); + + if (entity instanceof Choice) { + permissions.add(createWildcardSubjectPermission(entity)); + continue; + } + if (entity instanceof Comment) { + permissions.add(createWildcardSubjectPermission(entity)); + continue; + } + if (entity instanceof Vote) { + permissions.add(createWildcardSubjectPermission(entity)); + continue; + } + if (entity instanceof Poll) { + //TODO Get alls possible permissions on poll + + Poll poll = (Poll) entity; + + Set<VoterListMember> members = poll.getAllVoters(); + + boolean freePoll = poll.isFreePoll(); + + if (freePoll) { + + // everybody can read poll ? + permissions.add(createSubjectPermission(PermissionVerb.readPoll, entity)); + } else { + + // only his creator / participants / voters can read it + + for (VoterListMember member : members) { + permissions.add(createSubjectPermission(member.getId(), PermissionVerb.readPoll, entity)); + } + } + + if (poll.isAddChoiceRunning(now)) { + + permissions.add(createSubjectPermission(PermissionVerb.addChoice, entity)); + } + + if (poll.getCommentVisibility() != CommentVisibility.NOBODY) { + //FIXME Should see with voter ? + permissions.add(createSubjectPermission(PermissionVerb.addComment, entity)); + } + + if (poll.isRunning(now)) { + permissions.add(createSubjectPermission(PermissionVerb.addVote, entity)); + } + + //TODO Do for editVote,... + } + } + } + +// SimplePrincipalCollection principalCollection = new SimplePrincipalCollection(); +// principalCollection.addAll(permissions, "pollenRealm"); +// Subject subject = new Subject.Builder().principals(principalCollection).buildSubject(); +// return subject; + return null; + } + + protected JpaEntity getPrincipalEntity(PollenPrincipal principal) { + + JpaEntity result = null; + + // try a poll + Poll poll = getPollDao().findByCreator(principal); + if (poll == null) { + + // try a choice + Choice choice = getChoiceDao().findByCreator(principal); + if (choice == null) { + + // try a vote + Vote vote = getVoteDao().findByVoter(principal); + if (vote == null) { + + // try a comment + Comment comment = getCommentDao().findByAuthor(principal); + if (comment != null) { + result = comment; + } + } else { + result = vote; + } + } else { + result = choice; + } + } else { + result = poll; + } + + Preconditions.checkNotNull(result); + return result; + } + + protected CommentJpaDao commentDao; + + protected VoteJpaDao voteDao; + + protected ChoiceJpaDao choiceDao; + + protected PollJpaDao pollDao; + + protected CommentJpaDao getCommentDao() { + if (commentDao == null) { + commentDao = getPersistenceContext().getCommentDao(); + } + return commentDao; + } + + protected VoteJpaDao getVoteDao() { + if (voteDao == null) { + voteDao = getPersistenceContext().getVoteDao(); + } + return voteDao; + } + + protected ChoiceJpaDao getChoiceDao() { + if (choiceDao == null) { + choiceDao = getPersistenceContext().getChoiceDao(); + } + return choiceDao; + } + + protected PollJpaDao getPollDao() { + if (pollDao == null) { + pollDao = getPersistenceContext().getPollDao(); + } + return pollDao; + } + + protected String createSubjectPermission(String people, PermissionVerb verb, JpaEntity entity) { + return people + ":" + verb.name() + ":" + entity.getId(); + } + + protected String createSubjectPermission(PermissionVerb verb, JpaEntity entity) { + return createSubjectPermission("*", verb, entity); + } + + protected String createWildcardSubjectPermission(JpaEntity entity) { + return "*:*:" + entity.getId(); + } } 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 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -54,6 +54,7 @@ public Vote getVote(String pollId, String voteId) throws EntityNotFoundException { Preconditions.checkNotNull(voteId); + checkPermission(PermissionVerb.readVote, voteId); Poll poll = getPollService().getPoll(pollId); Vote result = getVote(poll, voteId); @@ -65,6 +66,7 @@ Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(vote); checkHasNoId(vote); + checkPermission(PermissionVerb.addVote, pollId); Poll poll = getPollService().getPoll(pollId); checkVoteForm(poll, vote); @@ -80,6 +82,7 @@ public Vote editVote(String pollId, Vote vote) throws EntityNotFoundException, InvalidVoteFormException { Preconditions.checkNotNull(vote); checkHasId(vote); + checkPermission(PermissionVerb.editVote, vote.getId()); Poll poll = getPollService().getPoll(pollId); checkVoteForm(poll, vote); @@ -96,6 +99,8 @@ Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(voteId); + checkPermission(PermissionVerb.deleteVote, voteId); + Poll poll = getPollService().getPoll(pollId); Vote vote = getVote(poll, voteId); @@ -136,6 +141,7 @@ Vote toSave; + //TODO Finish save if (commentExists) { toSave = getVote(poll, vote.getId()); Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java =================================================================== --- trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -29,6 +29,7 @@ import org.chorem.pollen.persistence.entity.PollType; import org.chorem.pollen.persistence.entity.VoterList; import org.chorem.pollen.persistence.entity.VoterListMember; +import org.chorem.pollen.services.PollenSecurityContext; import org.chorem.pollen.services.exception.EntityNotFoundException; import org.chorem.pollen.services.exception.InvalidPollFormException; import org.chorem.pollen.services.service.PollService; @@ -57,6 +58,8 @@ service = serviceContext.getPollService(); serviceContext.setDate(new Date(1363948427576l)); + + serviceContext.setSecurityContext(PollenSecurityContext.newContext(null)); } @Test @@ -109,6 +112,8 @@ Assert.assertNotNull(createdPoll); Assert.assertNotNull(createdPoll.getId()); + serviceContext.getSecurityService().prepareSubject(createdPoll.getCreator().getId()); + Poll reloadedPoll = service.getPoll(createdPoll.getId()); Assert.assertEquals(createdPoll, reloadedPoll); @@ -116,7 +121,6 @@ Assert.assertNotNull(createdPoll.getCreator()); Assert.assertNotNull(createdPoll.getCreator().getId()); - Assert.assertNotNull(createdPoll.getCreator().getToken()); Assert.assertNull(createdPoll.getCreator().getName()); Assert.assertNull(createdPoll.getCreator().getEmail()); Assert.assertNull(createdPoll.getComment()); @@ -236,7 +240,6 @@ voterListMember2.setName("voter2"); voterListMember2.setEmail("voter2@pollen.org"); - Poll createdPoll = service.createPoll(null, poll); Assert.assertNotNull(createdPoll); Assert.assertNotNull(createdPoll.getId()); @@ -248,7 +251,6 @@ Assert.assertNotNull(createdPoll.getCreator()); Assert.assertNotNull(createdPoll.getCreator().getId()); - Assert.assertNotNull(createdPoll.getCreator().getToken()); Assert.assertNull(createdPoll.getCreator().getName()); Assert.assertNull(createdPoll.getCreator().getEmail()); Assert.assertNull(createdPoll.getComment()); Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java =================================================================== --- trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java 2013-06-20 07:55:10 UTC (rev 3838) @@ -54,7 +54,7 @@ loadFixtures("fixtures"); - service = serviceContext.getUserService(); + service = serviceContext.getPollenUserService(); serviceContext.setDate(new Date(1363948427576l)); Modified: trunk/pollen-ui-js/src/main/resources/nuiton-js/wro.properties =================================================================== --- trunk/pollen-ui-js/src/main/resources/nuiton-js/wro.properties 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/resources/nuiton-js/wro.properties 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +### +# #%L +# Pollen :: UI (JS) +# $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% +### debug=false preProcessors=forceCssDataUri,cssUrlRewriting,cssImport,semicolonAppender,cssMinJawr postProcessors=cssVariables,jsMin Modified: trunk/pollen-ui-js/src/main/resources/nuiton-js/wro.xml =================================================================== --- trunk/pollen-ui-js/src/main/resources/nuiton-js/wro.xml 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/resources/nuiton-js/wro.xml 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +<!-- + #%L + Pollen :: UI (JS) + $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% + --> <groups xmlns="http://www.isdc.ro/wro"> <group name='pollen-ui-js'> Modified: trunk/pollen-ui-js/src/main/webapp/bundle/Messages.properties =================================================================== --- trunk/pollen-ui-js/src/main/webapp/bundle/Messages.properties 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/bundle/Messages.properties 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +### +# #%L +# Pollen :: UI (JS) +# $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% +### pollen.app.title=Pollen #common Modified: trunk/pollen-ui-js/src/main/webapp/css/style.css =================================================================== --- trunk/pollen-ui-js/src/main/webapp/css/style.css 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/css/style.css 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ .dropdown-menu.form { padding: 0; padding-top: 15px; Modified: trunk/pollen-ui-js/src/main/webapp/index.html =================================================================== --- trunk/pollen-ui-js/src/main/webapp/index.html 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/index.html 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +<!-- + #%L + Pollen :: UI (JS) + $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% + --> <!DOCTYPE html> <html lang="fr" xmlns="http://www.w3.org/1999/xhtml"> <head> Modified: trunk/pollen-ui-js/src/main/webapp/js/controls/menu.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/controls/menu.js 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/js/controls/menu.js 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ var Menu = can.Control({ init: function() { this.element.html(can.view('views/menu.ejs', {currentUser: currentUser})); Modified: trunk/pollen-ui-js/src/main/webapp/js/controls/poll_form.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/controls/poll_form.js 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/js/controls/poll_form.js 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ var PollForm = can.Control({ defaults: { Modified: trunk/pollen-ui-js/src/main/webapp/js/controls/poll_list.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/controls/poll_list.js 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/js/controls/poll_list.js 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ var PollList = can.Control({ defaults: { Property changes on: trunk/pollen-ui-js/src/main/webapp/js/controls/poll_list.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/pollen-ui-js/src/main/webapp/js/controls/poll_summary.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/controls/poll_summary.js 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/js/controls/poll_summary.js 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ var PollSummary = can.Control({ defaults: { Modified: trunk/pollen-ui-js/src/main/webapp/js/controls/user_form.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/controls/user_form.js 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/js/controls/user_form.js 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ var UserForm = can.Control({ defaults: { Modified: trunk/pollen-ui-js/src/main/webapp/js/controls/vote.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/controls/vote.js 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/js/controls/vote.js 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ var PollVote = can.Control({ // route Modified: trunk/pollen-ui-js/src/main/webapp/js/libs/jquery.scrollto.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/libs/jquery.scrollto.js 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/js/libs/jquery.scrollto.js 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ /*! * jquery.scrollto.js 0.0.1 - https://github.com/yckart/jquery.scrollto.js * Scroll smooth to any element in your DOM. Modified: trunk/pollen-ui-js/src/main/webapp/js/models/comments.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/models/comments.js 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/js/models/comments.js 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ var Comment = can.Model({ findAll : "GET " + backendUrl + "/polls/{pollId}/comments", findOne : "GET " + backendUrl + "/polls/{pollId}/comments/{id}", Modified: trunk/pollen-ui-js/src/main/webapp/js/models/polls.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/models/polls.js 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/js/models/polls.js 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ var Poll = can.Model({ findAll : "GET " + backendUrl + "/polls", findOne : "GET " + backendUrl + "/polls/{id}", Modified: trunk/pollen-ui-js/src/main/webapp/js/models/users.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/models/users.js 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/js/models/users.js 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ var User = can.Model({ findAll : "GET " + backendUrl + "/users", findOne : "GET " + backendUrl + "/users/{id}", Property changes on: trunk/pollen-ui-js/src/main/webapp/js/models/users.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/pollen-ui-js/src/main/webapp/js/models/votes.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/models/votes.js 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/js/models/votes.js 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ var Vote = can.Model({ findAll : "GET " + backendUrl + "/polls/{pollId}/votes", findOne : "GET " + backendUrl + "/polls/{pollId}/votes/{id}", Modified: trunk/pollen-ui-js/src/main/webapp/js/route.js =================================================================== --- trunk/pollen-ui-js/src/main/webapp/js/route.js 2013-06-19 17:50:01 UTC (rev 3837) +++ trunk/pollen-ui-js/src/main/webapp/js/route.js 2013-06-20 07:55:10 UTC (rev 3838) @@ -1,3 +1,25 @@ +/* + * #%L + * Pollen :: UI (JS) + * $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% + */ var Routing = can.Control({ 'route': function() { // Matches every routing change, but gets passed no data. Property changes on: trunk/pollen-ui-js/src/main/webapp/views/poll_list.ejs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/pollen-ui-js/src/main/webapp/views/user_form.ejs ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native