Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 3196 discussions
r3215 - in branches/pollen-1.2.6-struts2: pollen-persistence/src/main/java/org/chorem/pollen/business/persistence pollen-services/src/main/java/org/chorem/pollen/services/impl pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/resources/config pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by fdesbois@users.chorem.org 28 Mar '12
by fdesbois@users.chorem.org 28 Mar '12
28 Mar '12
Author: fdesbois
Date: 2012-03-28 18:39:46 +0200 (Wed, 28 Mar 2012)
New Revision: 3215
Url: http://chorem.org/repositories/revision/pollen/3215
Log:
- improve binding pollAccount and userAccount
- use copy of bean for edition
- add validation
Modified:
branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java
branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -97,5 +97,38 @@
return pollAccountExists;
}
+
+ public PollAccount findByPollVoteUser(Poll poll,
+ UserAccount user) throws TopiaException {
+
+ Preconditions.checkNotNull(poll);
+ Preconditions.checkNotNull(user);
+
+ TopiaQuery query = createQuery("e")
+ .addFrom(Poll.class, "p")
+ .addFrom(Vote.class, "v")
+ .addInElements("v", "p." + Poll.PROPERTY_VOTE)
+ .addWhere("e = v." + Vote.PROPERTY_POLL_ACCOUNT)
+ .addEquals("e." + PollAccount.PROPERTY_USER_ACCOUNT, user);
+ PollAccount result = findByQuery(query);
+ return result;
+ }
+ public boolean existsByPollVoteAccountId(String pollId,
+ String accountId) throws TopiaException {
+
+ Preconditions.checkNotNull(pollId);
+ Preconditions.checkNotNull(accountId);
+
+ TopiaQuery query = createQuery("e")
+ .addFrom(Poll.class, "p")
+ .addFrom(Vote.class, "v")
+ .addEquals("p." + Poll.PROPERTY_POLL_ID, pollId)
+ .addInElements("v", "p." + Poll.PROPERTY_VOTE)
+ .addWhere("e = v." + Vote.PROPERTY_POLL_ACCOUNT)
+ .addEquals("e." + PollAccount.PROPERTY_ACCOUNT_ID, accountId);
+ boolean result = existByQuery(query);
+ return result;
+ }
+
} //PollAccountDAOImpl<E extends PollAccount>
Modified: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -112,4 +112,16 @@
// result = count > 0;
}
+
+ public Vote findByAccountId(String accountId) throws TopiaException {
+
+ String accountIdProperty =
+ TopiaQuery.getProperty("e", Vote.PROPERTY_POLL_ACCOUNT, PollAccount.PROPERTY_ACCOUNT_ID);
+
+ TopiaQuery query = createQuery("e").addEquals(accountIdProperty, accountId);
+ Vote result = findByQuery(query);
+ return result;
+ }
+
+
} //VoteDAOImpl<E extends Vote>
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -49,6 +49,7 @@
import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.entities.PollenBinderHelper;
import org.chorem.pollen.services.PollenServiceSupport;
import org.chorem.pollen.services.exceptions.PollAccountNotFound;
import org.chorem.pollen.services.exceptions.PollChoiceNotFoundException;
@@ -378,7 +379,7 @@
Poll result = dao.findByPollId(pollId);
return result;
} catch (TopiaException e) {
- throw new PollenTechnicalException("Could not find poll with pollId " + pollId);
+ throw new PollenTechnicalException("Could not find poll with pollId '" + pollId + "'", e);
}
}
@@ -386,23 +387,23 @@
* Retrieve a pollAccount with {@code accountId}. This pollAccount will be
* attached to the given {@code userAccount} (only if not already attached).
* If the {@code accountId} is undefined, a new instance of PollAccount will
- * be retrieved, otherwise the existing PollAccount is used. No create or
- * update is done here.
+ * be retrieved, otherwise a copy of the existing PollAccount is used. No
+ * create or update is done here. The {@code poll} is used to retrieve a potential
+ * existing vote with pollAccount linked to {@code userAccount}.
*
* @param accountId Id of the existing account (optional)
* @param userAccount UserAccount where account will be attached (optional)
+ * @param poll Poll where pollAccount will be added
* @return the existing PollAccount or a new instance
* @throws PollAccountNotFound if accountId is defined and doesn't match any
* existing PollAccount
*/
- public PollAccount getPollAccount(String accountId, UserAccount userAccount) throws PollAccountNotFound {
- PollAccount result;
+ public PollAccount getPollAccountEditable(String accountId, UserAccount userAccount, Poll poll) throws PollAccountNotFound {
+ PollAccount result = null;
if (StringUtils.isNotEmpty(accountId)) {
- result = getPollAccountByAccountId(accountId);
+ PollAccount pollAccountLoaded = getPollAccountByAccountId(accountId);
- // REMARQUES :
- // - pas le droit de modif si le pollAccount est rattaché a un userAccount et qu'on est pas loggé ?!?
- // - Ce serait plus simple que l'Admin ne puisse jamais voter, il ne peut que modérer les votes
+ result = copyPollAccount(pollAccountLoaded);
// Don't remove or update userAccount link if already set
if (userAccount != null && result.getUserAccount() == null) {
@@ -418,10 +419,47 @@
}
} else {
- result = getNewPollAccount(userAccount);
+
+ // Retrieve existing pollAccount from user
+ if (userAccount != null) {
+ PollAccountDAO pollAccountDAO = getDAO(PollAccount.class);
+ PollAccount pollAccountLoaded;
+ try {
+ pollAccountLoaded = pollAccountDAO.findByPollVoteUser(poll, userAccount);
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(e);
+ }
+
+ if (pollAccountLoaded != null) {
+ result = copyPollAccount(pollAccountLoaded);
+ }
+
+ if (log.isDebugEnabled()) {
+ String account = result == null
+ ? "null"
+ : result.getVotingId() + " [" + result.getAccountId() + "]";
+
+ log.debug(String.format(
+ "PollAccount found from user '%s' = %s",
+ userAccount.getDisplayName(), account
+ ));
+ }
+ }
+
+ if (result == null) {
+ result = getNewPollAccount(userAccount);
+ }
}
return result;
}
+
+ protected PollAccount copyPollAccount(PollAccount source) {
+ PollAccountDAO dao = getDAO(PollAccount.class);
+ PollAccount result = newInstance(dao);
+ PollenBinderHelper.copy("", source, result, true);
+ result.setUserAccount(source.getUserAccount());
+ return result;
+ }
public PollAccount getNewPollAccount(UserAccount userAccount) {
PollAccountDAO dao = getDAO(PollAccount.class);
@@ -557,6 +595,8 @@
if (poll == null) {
throw new PollNotFoundException();
}
+
+ PollAccountDAO dao = getDAO(PollAccount.class);
if (poll.getPollType() != PollType.FREE) {
@@ -564,7 +604,6 @@
// Use PersonToList association entity to find coherence between
// the poll and votingId
- PollAccountDAO dao = getDAO(PollAccount.class);
try {
PollAccount result =
@@ -577,6 +616,19 @@
throw new PollenTechnicalException(
"Could not obtain restricted pollAccount", e);
}
+
+ } else if (accountId != null) {
+
+ try {
+
+ if (!dao.existsByPollVoteAccountId(pollId, accountId)) {
+ throw new UnauthorizedPollAccessException();
+ }
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(
+ "Could not check pollAccount existence from poll '" +
+ pollId + "' and account '" + accountId + "'", e);
+ }
}
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -24,9 +24,7 @@
package org.chorem.pollen.services.impl;
import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -42,6 +40,7 @@
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.business.persistence.VoteToChoiceDAO;
import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.entities.PollenBinderHelper;
import org.chorem.pollen.entities.PollenDAOHelper;
import org.chorem.pollen.services.PollenServiceSupport;
import org.chorem.pollen.services.exceptions.VoteNotFoundException;
@@ -68,6 +67,8 @@
Vote result = newInstance(voteDAO);
result.setPollAccount(account);
+ // TODO weight ?
+ result.setWeight(1.);
// Prepare the List of VoteToChoice with Poll's choices
for (Choice choice : poll.getChoice()) {
@@ -75,53 +76,65 @@
element.setChoice(choice);
result.addChoiceVoteToChoice(element);
}
-
- // TODO weight ?
return result;
}
- public Vote getVote(Poll poll, List<Vote> votes, final PollAccount account) {
+ public Vote getVoteEditable(Poll poll, PollAccount accountEditable) {
Preconditions.checkNotNull(poll);
- Preconditions.checkNotNull(votes);
- Preconditions.checkNotNull(account);
+ Preconditions.checkNotNull(accountEditable);
- Vote result = Iterables.find(votes, new Predicate<Vote>() {
-
- @Override
- public boolean apply(Vote input) {
- return account.equals(input.getPollAccount());
- }
+ VoteDAO dao = getDAO(Vote.class);
+ Vote voteLoaded;
+ try {
+ voteLoaded = dao.findByAccountId(accountEditable.getAccountId());
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(e);
+ }
+
+ Vote result;
+ if (voteLoaded != null) {
+ result = copyVote(voteLoaded);
- }, getNewVote(poll, account));
+ // Attach the given accountEditable instead of the loaded one
+ result.setPollAccount(accountEditable);
-
- // For an existing Vote, ensure that there is as many voteToChoice as poll choices
- if (result.getTopiaId() != null) {
-
+ // For an existing Vote, ensure that there is as many voteToChoice as poll choices
VoteToChoiceDAO voteToChoiceDAO = getDAO(VoteToChoice.class);
+ List<VoteToChoice> voteToChoices = Lists.newArrayList();
- List<VoteToChoice> voteToChoices = result.getChoiceVoteToChoice();
-
// Add all VoteToChoice even they have empty value to match the size of Poll Choice List
List<Choice> choices = poll.getChoice();
for (int i = 0; i < choices.size(); i++) {
Choice choice = choices.get(i);
- VoteToChoice voteToChoice = voteToChoices.get(i);
- // Add new VoteToChoice if choice doesn't match (not exists)
- if (!voteToChoice.getChoice().equals(choice)) {
- VoteToChoice element = newInstance(voteToChoiceDAO);
- element.setChoice(choice);
- voteToChoices.add(i, element);
+ VoteToChoice voteToChoice = newInstance(voteToChoiceDAO);
+ voteToChoice.setChoice(choice);
+
+ // Retrieve existing value from loaded vote
+ VoteToChoice voteToChoiceLoaded = voteLoaded.getChoiceVoteToChoice(choice);
+ if (voteToChoiceLoaded != null) {
+ voteToChoice.setVoteValue(voteToChoiceLoaded.getVoteValue());
}
+
+ voteToChoices.add(i, voteToChoice);
}
+ result.setChoiceVoteToChoice(voteToChoices);
+ } else {
+ result = getNewVote(poll, accountEditable);
}
return result;
}
+
+ protected Vote copyVote(Vote source) {
+ VoteDAO dao = getDAO(Vote.class);
+ Vote result = newInstance(dao);
+ PollenBinderHelper.copy("", source, result, true);
+ return result;
+ }
/**
* Retrieve the URL to update a vote based on {@link PollUri}.
@@ -140,7 +153,6 @@
public Vote createVote(Vote vote) {
VoteDAO voteDAO = getDAO(Vote.class);
- VoteToChoiceDAO voteToChoiceDAO = getDAO(VoteToChoice.class);
Vote result = create(voteDAO);
result.setWeight(vote.getWeight());
@@ -183,17 +195,7 @@
Integer value = input.getVoteValue();
if (value != null) {
-
- VoteToChoice voteToChoiceCreated = create(voteToChoiceDAO);
- voteToChoiceCreated.setVoteValue(value);
-
- // Bind with existing Choice
- String choiceId = input.getChoice().getTopiaId();
- Choice choiceLoaded = getEntityById(Choice.class, choiceId);
- voteToChoiceCreated.setChoice(choiceLoaded);
- voteToChoiceCreated.setVote(result);
-
- result.addChoiceVoteToChoice(voteToChoiceCreated);
+ createVoteToChoice(result, input);
}
}
@@ -206,45 +208,82 @@
return result;
}
- public void updateVote(Vote vote) throws VoteNotFoundException {
+ public Vote updateVote(Vote vote) throws VoteNotFoundException {
- Vote entityToUpdate = getEntityById(Vote.class, vote.getTopiaId());
+ Vote result = getEntityById(Vote.class, vote.getTopiaId());
- if (entityToUpdate == null) {
+ if (result == null) {
throw new VoteNotFoundException();
}
- VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
+ // -- PollAccount -- //
+ PollAccount voteAccount = vote.getPollAccount();
+ PollAccount pollAccountEntity = result.getPollAccount();
+ if (vote.isAnonymous()) {
+ pollAccountEntity.setVotingId(null);
+ pollAccountEntity.setEmail(null);
+ pollAccountEntity.setUserAccount(null);
+ } else {
+ pollAccountEntity.setVotingId(voteAccount.getVotingId());
+ pollAccountEntity.setEmail(voteAccount.getEmail());
+ pollAccountEntity.setUserAccount(voteAccount.getUserAccount());
+ }
+ result.setAnonymous(vote.isAnonymous());
+
+ // -- List of VoteToChoice -- //
for (VoteToChoice input : vote.getChoiceVoteToChoice()) {
Integer value = input.getVoteValue();
- VoteToChoice voteToChoiceEntity = entityToUpdate.getChoiceVoteToChoice(input.getChoice());
+ VoteToChoice voteToChoiceEntity = result.getChoiceVoteToChoice(input.getChoice());
if (value != null) {
- if (voteToChoiceEntity == null) {
- voteToChoiceEntity = create(voteToChoiceDao);
- voteToChoiceEntity.setChoice(input.getChoice()); // very dangerous, bind with id
- entityToUpdate.addChoiceVoteToChoice(voteToChoiceEntity);
+ if (voteToChoiceEntity != null) {
+ voteToChoiceEntity.setVoteValue(value);
+
+ } else {
+ createVoteToChoice(result, input);
}
- voteToChoiceEntity.setVoteValue(value);
- // update needed ??
} else if (voteToChoiceEntity != null) {
-
- entityToUpdate.removeChoiceVoteToChoice(voteToChoiceEntity);
- delete(voteToChoiceDao, voteToChoiceEntity);
+ deleteVoteToChoice(result, voteToChoiceEntity);
}
}
if (log.isDebugEnabled()) {
- log.debug("Entity updated: " + vote.getTopiaId());
+ log.debug("Entity updated: " + result.getTopiaId());
}
commitTransaction("Could not update vote");
+
+ return result;
}
+
+ protected VoteToChoice createVoteToChoice(Vote vote, VoteToChoice source) {
+
+ VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
+ VoteToChoice result = create(voteToChoiceDao);
+
+ String choiceId = source.getChoice().getTopiaId();
+ Choice choiceLoaded = getEntityById(Choice.class, choiceId);
+ result.setChoice(choiceLoaded);
+
+ result.setVote(vote);
+ result.setVoteValue(source.getVoteValue());
+
+ vote.addChoiceVoteToChoice(result);
+
+ return result;
+ }
+
+ protected void deleteVoteToChoice(Vote vote, VoteToChoice entity) {
+ VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
+ vote.removeChoiceVoteToChoice(entity);
+ delete(voteToChoiceDao, entity);
+ }
+
/**
* Delete vote referenced by {@code voteId}. This will also delete all
* associated {@link VoteToChoice}. The {@link PollAccount} could also be
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -66,4 +66,8 @@
pollUri = PollUriConverter.convertFromString(values);
}
}
+
+ protected void preparePollUri(String pollId, String accountId) {
+ pollUri = PollUri.newPollUri(pollId, accountId);
+ }
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -192,7 +192,7 @@
}
public String getCreatorName() {
- return poll.getCreator().getAccountId();
+ return poll.getCreator().getVotingId();
}
public String getVoteSizeMessage() {
@@ -277,14 +277,14 @@
DateFormat.SHORT, getLocale()));
// Current poll account
- pollAccount = getPollService().getPollAccount(getAccountId(), getPollenUserAccount());
+ pollAccount = getPollService().getPollAccountEditable(getAccountId(), getPollenUserAccount(), poll);
// All votes
// TODO no pagination for the moment, need to retrieve the correct page depends on current pollAccount
votes = poll.getVote();
// Current vote
- vote = getVoteService().getVote(poll, votes, pollAccount);
+ vote = getVoteService().getVoteEditable(poll, pollAccount);
loadPollResults();
loadPollComments();
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -23,8 +23,6 @@
*/
package org.chorem.pollen.ui.actions.poll;
-import org.chorem.pollen.bean.PollUri;
-
/**
* EditVote is a redirection to vote page. This action will simply update the
* uri with {@code accountId} and {@code pollId}.
@@ -51,7 +49,7 @@
@Override
public String execute() throws Exception {
- setUriId(PollUri.newPollUri(pollId, accountId));
+ preparePollUri(pollId, accountId);
return SUCCESS;
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -23,11 +23,15 @@
*/
package org.chorem.pollen.ui.actions.poll;
+import com.google.common.base.Preconditions;
import com.opensymphony.xwork2.Preparable;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.Vote;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Votes to a poll.
@@ -38,7 +42,7 @@
*/
public class VoteForPoll extends AbstractVoteAction implements Preparable {
- private static final Logger log = LoggerFactory.getLogger(VoteForPoll.class);
+ private static final Log log = LogFactory.getLog(VoteForPoll.class);
private static final long serialVersionUID = 1L;
@@ -50,12 +54,36 @@
}
@Override
+ public void validate() {
+
+ Vote vote = getVote();
+ Preconditions.checkNotNull(vote);
+
+ PollAccount pollAccount = getVote().getPollAccount();
+ Preconditions.checkNotNull(pollAccount);
+
+ Poll poll = getPoll();
+
+ String name = pollAccount.getVotingId();
+ if (StringUtils.isBlank(name)) {
+ addFieldError("pollAccount.votingId", _("pollen.error.pollAccount.votingId.required"));
+ }
+
+ // check if the new pollAccount (topiaId = null) has already voted
+ if (pollAccount.getTopiaId() == null && getVoteService().hasAlreadyVoted(name, poll)) {
+ addFieldError("pollAccount.votingId", _("pollen.error.user.alreadyVoted"));
+ }
+ }
+
+ @Override
public String execute() throws Exception {
+ // REMARQUES :
+ // - pas le droit de modif si le pollAccount est rattaché a un userAccount et qu'on est pas loggé ?!?
+ // - Ce serait plus simple que l'Admin ne puisse jamais voter, il ne peut que modérer les votes
+
// VALIDATION ::
- // - votingId/name not empty
- // - account not exists (matching userAccount) > check on all votes (EXISTS userAccount FROM poll.votes)
- // - votingId/name is unique > check on all votes (EXISTS votingId FROM poll.votes)
+ // - account not exists (matching userAccount) > check on all votes (EXISTS userAccount FROM poll.votes) >>> secu ?
if (getVote().getTopiaId() != null) {
getVoteService().updateVote(getVote());
@@ -74,7 +102,9 @@
String updateUrl = getVoteService().getUpdateVoteUrl(pollUri);
- log.debug("UpdateURL for poll '{}' and account '{}' = {}", new Object[]{pollId, accountId, updateUrl});
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("UpdateURL for poll '%s' and account '%s' = %s", pollId, accountId, updateUrl));
+ }
addActionMessage(_("pollen.information.vote.createdWithUpdateUrl", updateUrl));
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 16:39:46 UTC (rev 3215)
@@ -98,8 +98,9 @@
</action>
<!-- vote poll -->
- <action name="vote" method="execute"
+ <action name="vote/*" method="execute"
class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
+ <param name="uriId">{1}</param>
<result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
<result type="redirectToVote"/>
</action>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-28 16:39:46 UTC (rev 3215)
@@ -160,7 +160,7 @@
title="%{getText('pollen.title.delete.pollChoice')}"
autoOpen="false" modal="true" width="800"/>
-<s:form id="voteForm">
+<s:form id="voteForm" validate="true">
<s:hidden key="uriId"/>
<table id="poll">
<thead>
@@ -401,6 +401,7 @@
</tbody>
</table>
<div id="voteError">
+ <s:fielderror fieldName="pollAccount.votingId"/>
<%--<t:errors/>--%>
</div>
@@ -411,7 +412,7 @@
<%--<t:label for="anonymousVote"/>--%>
<br/>
</s:if>
- <s:submit action="vote" key="pollen.action.pollVote"/>
+ <s:submit action="vote/%{uriId}" key="pollen.action.pollVote"/>
<%--<input id="submitVote" t:type="Submit" t:value="${message:submitVote}"/>--%>
</div>
</s:if>
1
0
r3214 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui java/org/chorem/pollen/ui/actions java/org/chorem/pollen/ui/results resources/config resources/org/chorem/pollen/business/persistence resources/org/chorem/pollen/ui/actions/poll webapp/js
by tchemit@users.chorem.org 28 Mar '12
by tchemit@users.chorem.org 28 Mar '12
28 Mar '12
Author: tchemit
Date: 2012-03-28 10:56:35 +0200 (Wed, 28 Mar 2012)
New Revision: 3214
Url: http://chorem.org/repositories/revision/pollen/3214
Log:
add result to avoid the : void mystery + add svn properties
Added:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java 2012-03-28 07:59:26 UTC (rev 3213)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java 2012-03-28 08:56:35 UTC (rev 3214)
@@ -1,3 +1,26 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
package org.chorem.pollen.ui.actions;
import org.apache.struts2.util.StrutsTypeConverter;
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java 2012-03-28 07:59:26 UTC (rev 3213)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java 2012-03-28 08:56:35 UTC (rev 3214)
@@ -1,3 +1,26 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
package org.chorem.pollen.ui.actions;
import com.google.common.base.Preconditions;
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java 2012-03-28 08:56:35 UTC (rev 3214)
@@ -0,0 +1,231 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.chorem.pollen.ui.results;
+
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.dispatcher.ServletActionRedirectResult;
+import org.apache.struts2.dispatcher.ServletRedirectResult;
+import org.apache.struts2.dispatcher.mapper.ActionMapper;
+import org.apache.struts2.dispatcher.mapper.ActionMapping;
+import org.apache.struts2.views.util.UrlHelper;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+
+/**
+ * <!-- START SNIPPET: description -->
+ * <p/>
+ * This result uses the {@link ActionMapper} provided by the
+ * {@link ActionMapperFactory} to redirect the browser to a URL that invokes the
+ * specified action and (optional) namespace. This is better than the
+ * {@link ServletRedirectResult} because it does not require you to encode the
+ * URL patterns processed by the {@link ActionMapper} in to your struts.xml
+ * configuration files. This means you can change your URL patterns at any point
+ * and your application will still work. It is strongly recommended that if you
+ * are redirecting to another action, you use this result rather than the
+ * standard redirect result.
+ * <p/>
+ * See examples below for an example of how request parameters could be passed
+ * in.
+ * <p/>
+ * <!-- END SNIPPET: description -->
+ * <p/>
+ * <b>This result type takes the following parameters:</b>
+ * <p/>
+ * <!-- START SNIPPET: params -->
+ * <p/>
+ * <ul>
+ * <p/>
+ * <li><b>actionName (default)</b> - The name of the action that will be
+ * redirected to.</li>
+ * <p/>
+ * <li><b>namespace</b> - Used to determine which namespace the action is in
+ * that we're redirecting to. If namespace is null, the default will be the
+ * current namespace.</li>
+ * <p/>
+ * <li><b>suppressEmptyParameters</b> - Optional boolean (defaults to false) that
+ * can prevent parameters with no values from being included in the redirect
+ * URL.</li>
+ * <p/>
+ * <li><b>parse</b> - Boolean, true by default. If set to false, the actionName
+ * param will not be parsed for Ognl expressions.</li>
+ * <p/>
+ * <li><b>anchor</b> - Optional. Also known as "fragment" or colloquially as
+ * "hash". You can specify an anchor for a result.</li>
+ * </ul>
+ * <p/>
+ * <!-- END SNIPPET: params -->
+ * <p/>
+ * <b>Example:</b>
+ * <p/>
+ * <pre>
+ * <!-- START SNIPPET: example -->
+ * <package name="public" extends="struts-default">
+ * <action name="login" class="...">
+ * <!-- Redirect to another namespace -->
+ * <result type="redirectAction">
+ * <param name="actionName">dashboard</param>
+ * <param name="namespace">/secure</param>
+ * </result>
+ * </action>
+ * </package>
+ *
+ * <package name="secure" extends="struts-default" namespace="/secure">
+ * <-- Redirect to an action in the same namespace -->
+ * <action name="dashboard" class="...">
+ * <result>dashboard.jsp</result>
+ * <result name="error" type="redirectAction">error</result>
+ * </action>
+ *
+ * <action name="error" class="...">
+ * <result>error.jsp</result>
+ * </action>
+ * </package>
+ *
+ * <package name="passingRequestParameters" extends="struts-default" namespace="/passingRequestParameters">
+ * <!-- Pass parameters (reportType, width and height) -->
+ * <!--
+ * The redirectAction url generated will be :
+ * /genReport/generateReport.action?reportType=pie&width=100&height=100#summary
+ * -->
+ * <action name="gatherReportInfo" class="...">
+ * <result name="showReportResult" type="redirectAction">
+ * <param name="actionName">generateReport</param>
+ * <param name="namespace">/genReport</param>
+ * <param name="reportType">pie</param>
+ * <param name="width">100</param>
+ * <param name="height">100</param>
+ * <param name="empty"></param>
+ * <param name="suppressEmptyParameters">true</param>
+ * <param name="anchor">summary</param>
+ * </result>
+ * </action>
+ * </package>
+ *
+ *
+ * <!-- END SNIPPET: example -->
+ * </pre>
+ *
+ * @see ActionMapper
+ */
+public class PollenServletActionRedirectResult extends ServletActionRedirectResult {
+
+ private static final long serialVersionUID = -9042425229314584066L;
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(ServletRedirectResult.class);
+
+ /**
+ * Redirects to the location specified by calling
+ * {@link HttpServletResponse#sendRedirect(String)}.
+ *
+ * @param finalLocation the location to redirect to.
+ * @param invocation an encapsulation of the action execution state.
+ * @throws Exception if an error occurs when redirecting.
+ */
+ protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
+ ActionContext ctx = invocation.getInvocationContext();
+ HttpServletRequest request = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
+ HttpServletResponse response = (HttpServletResponse) ctx.get(ServletActionContext.HTTP_RESPONSE);
+
+// if (isPathUrl(finalLocation)) {
+ if (!finalLocation.startsWith("/")) {
+ ActionMapping mapping = actionMapper.getMapping(request, Dispatcher.getInstance().getConfigurationManager());
+ String namespace = null;
+ if (mapping != null) {
+ namespace = mapping.getNamespace();
+ }
+
+ if ((namespace != null) && (namespace.length() > 0) && (!"/".equals(namespace))) {
+ finalLocation = namespace + "/" + finalLocation;
+ } else {
+ finalLocation = "/" + finalLocation;
+ }
+ }
+
+ // if the URL's are relative to the servlet context, append the servlet context path
+ if (prependServletContext && (request.getContextPath() != null) && (request.getContextPath().length() > 0)) {
+ finalLocation = request.getContextPath() + finalLocation;
+ }
+
+ ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(invocation.getResultCode());
+ if (resultConfig != null) {
+ Map<String, String> resultConfigParams = resultConfig.getParams();
+
+ for (Map.Entry<String, String> e : resultConfigParams.entrySet()) {
+ if (!getProhibitedResultParams().contains(e.getKey())) {
+ String potentialValue = e.getValue() == null ? "" : conditionalParse(e.getValue(), invocation);
+ if (!suppressEmptyParameters || ((potentialValue != null) && (potentialValue.length() > 0))) {
+ requestParameters.put(e.getKey(), potentialValue);
+ }
+ }
+ }
+ }
+
+ StringBuilder tmpLocation = new StringBuilder(finalLocation);
+ UrlHelper.buildParametersString(requestParameters, tmpLocation, "&");
+
+ // add the anchor
+ if (anchor != null) {
+ tmpLocation.append('#').append(anchor);
+ }
+
+ finalLocation = response.encodeRedirectURL(tmpLocation.toString());
+// }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Redirecting to finalLocation " + finalLocation);
+ }
+
+ sendRedirect(response, finalLocation);
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 07:59:26 UTC (rev 3213)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 08:56:35 UTC (rev 3214)
@@ -34,7 +34,7 @@
<result-types>
<result-type name="redirectToVote"
- class="org.apache.struts2.dispatcher.ServletActionRedirectResult">
+ class="org.chorem.pollen.ui.results.PollenServletActionRedirectResult">
<param name="namespace">/poll</param>
<param name="actionName">votefor/${uriId}</param>
</result-type>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties 2012-03-28 07:59:26 UTC (rev 3213)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties 2012-03-28 08:56:35 UTC (rev 3214)
@@ -1 +1,24 @@
+###
+# #%L
+# Pollen :: UI (strust2)
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2009 - 2012 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%
+###
voteValue=org.chorem.pollen.ui.actions.BooleanIntegerConverter
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties 2012-03-28 07:59:26 UTC (rev 3213)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties 2012-03-28 08:56:35 UTC (rev 3214)
@@ -1 +1,24 @@
+###
+# #%L
+# Pollen :: UI (strust2)
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2009 - 2012 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%
+###
uriId=org.chorem.pollen.ui.actions.PollUriConverter
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r3213 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: resources resources/config webapp/WEB-INF/decorators webapp/WEB-INF/jsp/poll webapp/WEB-INF/jsp/user
by tchemit@users.chorem.org 28 Mar '12
by tchemit@users.chorem.org 28 Mar '12
28 Mar '12
Author: tchemit
Date: 2012-03-28 09:59:26 +0200 (Wed, 28 Mar 2012)
New Revision: 3213
Url: http://chorem.org/repositories/revision/pollen/3213
Log:
move some actions to user namespace + pass into devmode
Added:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/DateChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/ImageChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/TextChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp
Removed:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createdList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/dateChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/imageChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/participatedList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/personToList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/textChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/votingList.jsp
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-03-28 07:59:26 UTC (rev 3213)
@@ -32,18 +32,25 @@
<package name="admin" extends="default" namespace="/admin">
- <default-interceptor-ref name="pollenBasicStack"/>
+ <default-interceptor-ref name="pollenParamsPrepareParamsStack"/>
<!-- manage users -->
<action name="usersList" method="input"
class="org.chorem.pollen.ui.actions.admin.ManageUsers">
+ <interceptor-ref name="pollenBasicStack"/>
<result name="input">/WEB-INF/jsp/admin/usersList.jsp</result>
</action>
+ <!-- manage polls -->
+ <action name="pollsList" method="input"
+ class="org.chorem.pollen.ui.actions.admin.ManagePolls">
+ <interceptor-ref name="pollenBasicStack"/>
+ <result name="input">/WEB-INF/jsp/admin/pollsList.jsp</result>
+ </action>
+
<!-- create user -->
<action name="create" method="create"
class="org.chorem.pollen.ui.actions.admin.ManageUsers">
- <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/admin/usersList.jsp</result>
<result>/WEB-INF/jsp/admin/usersList.jsp</result>
</action>
@@ -51,7 +58,6 @@
<!-- save user -->
<action name="edit" method="edit"
class="org.chorem.pollen.ui.actions.admin.ManageUsers">
- <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/admin/usersList.jsp</result>
<result>/WEB-INF/jsp/admin/usersList.jsp</result>
</action>
@@ -59,17 +65,10 @@
<!-- delete user -->
<action name="delete" method="delete"
class="org.chorem.pollen.ui.actions.admin.ManageUsers">
- <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/admin/usersList.jsp</result>
<result>/WEB-INF/jsp/admin/usersList.jsp</result>
</action>
- <!-- manage polls -->
- <action name="pollsList" method="input"
- class="org.chorem.pollen.ui.actions.admin.ManagePolls">
- <result name="input">/WEB-INF/jsp/admin/pollsList.jsp</result>
- </action>
-
</package>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-03-28 07:59:26 UTC (rev 3213)
@@ -31,79 +31,11 @@
<package name="json" extends="default" namespace="/json">
- <default-interceptor-ref name="pollenBasicStack"/>
-
- <action name="get*"
- class="org.chorem.pollen.ui.actions.json.Get{1}">
+ <action name="get*" class="org.chorem.pollen.ui.actions.json.Get{1}">
+ <interceptor-ref name="pollenBasicStack"/>
<result type="json"/>
</action>
- <!---->
- <!--<!– get pagined users –>-->
- <!--<action name="getUsers"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetUsers">-->
- <!--<result type="json"/>-->
- <!--</action>-->
- <!--<!– get user detail –>-->
- <!--<action name="getUser"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetUser">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined favorite lists of user –>-->
- <!--<action name="getFavoriteLists"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteLists">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get selected favorite list of user –>-->
- <!--<action name="getFavoriteList"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteList">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined poll accounts of a given favorite list –>-->
- <!--<action name="getFavoriteListPollAccounts"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteListPollAccounts">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get selected poll account of a given favorite list –>-->
- <!--<action name="getFavoriteListPollAccount"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteListPollAccount">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined polls –>-->
- <!--<action name="getPolls"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetPolls">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined created polls –>-->
- <!--<action name="getCreatedPolls"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetCreatedPolls">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined invited polls –>-->
- <!--<action name="getInvitedPolls"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetInvitedPolls">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined created polls –>-->
- <!--<action name="getParticipatedPolls"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetParticipatedPolls">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined poll comments –>-->
- <!--<action name="getPollComments"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetPollComments">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
</package>
</struts>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 07:59:26 UTC (rev 3213)
@@ -53,36 +53,42 @@
<result>/WEB-INF/jsp/poll/resume.jsp</result>
</action>
- <!-- display text choice -->
- <action name="displayTextChoice"
- class="org.chorem.pollen.ui.actions.poll.DisplayTextChoice">
- <result>/WEB-INF/jsp/poll/textChoice.jsp</result>
+ <!-- display * -->
+ <action name="display*"
+ class="org.chorem.pollen.ui.actions.poll.Display{1}">
+ <result>/WEB-INF/jsp/poll/{1}.jsp</result>
</action>
- <!-- display date choice -->
- <action name="displayDateChoice"
- class="org.chorem.pollen.ui.actions.poll.DisplayDateChoice">
- <result>/WEB-INF/jsp/poll/dateChoice.jsp</result>
- </action>
+ <!--<!– display text choice –>-->
+ <!--<action name="displayTextChoice"-->
+ <!--class="org.chorem.pollen.ui.actions.poll.DisplayTextChoice">-->
+ <!--<result>/WEB-INF/jsp/poll/TextChoice.jsp</result>-->
+ <!--</action>-->
- <!-- display image choice -->
- <action name="displayImageChoice"
- class="org.chorem.pollen.ui.actions.poll.DisplayImageChoice">
- <result>/WEB-INF/jsp/poll/imageChoice.jsp</result>
- </action>
+ <!--<!– display date choice –>-->
+ <!--<action name="displayDateChoice"-->
+ <!--class="org.chorem.pollen.ui.actions.poll.DisplayDateChoice">-->
+ <!--<result>/WEB-INF/jsp/poll/DateChoice.jsp</result>-->
+ <!--</action>-->
- <!-- display a votingList -->
- <action name="displayVotingList"
- class="org.chorem.pollen.ui.actions.poll.DisplayVotingList">
- <result>/WEB-INF/jsp/poll/votingList.jsp</result>
- </action>
+ <!--<!– display image choice –>-->
+ <!--<action name="displayImageChoice"-->
+ <!--class="org.chorem.pollen.ui.actions.poll.DisplayImageChoice">-->
+ <!--<result>/WEB-INF/jsp/poll/ImageChoice.jsp</result>-->
+ <!--</action>-->
- <!-- display a personToList -->
- <action name="displayPersonToList"
- class="org.chorem.pollen.ui.actions.poll.DisplayPersonToList">
- <result>/WEB-INF/jsp/poll/personToList.jsp</result>
- </action>
+ <!--<!– display a votingList –>-->
+ <!--<action name="displayVotingList"-->
+ <!--class="org.chorem.pollen.ui.actions.poll.DisplayVotingList">-->
+ <!--<result>/WEB-INF/jsp/poll/VotingList.jsp</result>-->
+ <!--</action>-->
+ <!--<!– display a personToList –>-->
+ <!--<action name="displayPersonToList"-->
+ <!--class="org.chorem.pollen.ui.actions.poll.DisplayPersonToList">-->
+ <!--<result>/WEB-INF/jsp/poll/PersonToList.jsp</result>-->
+ <!--</action>-->
+
<!-- edit poll -->
<action name="modification/*"
class="org.chorem.pollen.ui.actions.poll.EditPoll">
@@ -169,20 +175,6 @@
<result>/WEB-INF/jsp/poll/result.jsp</result>
</action>
- <!-- display createds polls -->
- <action name="createdList"
- class="org.chorem.pollen.ui.actions.poll.CreatedList">
- <interceptor-ref name="pollenBasicStack"/>
- <result>/WEB-INF/jsp/poll/createdList.jsp</result>
- </action>
-
- <!-- display participated polls -->
- <action name="participatedList"
- class="org.chorem.pollen.ui.actions.poll.ParticipatedList">
- <interceptor-ref name="pollenBasicStack"/>
- <result>/WEB-INF/jsp/poll/participatedList.jsp</result>
- </action>
-
<!-- confirm delete comment -->
<action name="confirmDeleteComment"
class="org.chorem.pollen.ui.actions.poll.ConfirmDeleteComment">
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-03-28 07:59:26 UTC (rev 3213)
@@ -118,6 +118,20 @@
<result>/WEB-INF/jsp/user/favoriteList.jsp</result>
</action>
+ <!-- display createds polls -->
+ <action name="createdList"
+ class="org.chorem.pollen.ui.actions.poll.CreatedList">
+ <interceptor-ref name="pollenBasicStack"/>
+ <result>/WEB-INF/jsp/user/createdList.jsp</result>
+ </action>
+
+ <!-- display participated polls -->
+ <action name="participatedList"
+ class="org.chorem.pollen.ui.actions.poll.ParticipatedList">
+ <interceptor-ref name="pollenBasicStack"/>
+ <result>/WEB-INF/jsp/user/participatedList.jsp</result>
+ </action>
+
</package>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini 2012-03-28 07:59:26 UTC (rev 3213)
@@ -17,15 +17,12 @@
[urls]
+# anon urls
+/user/login = anon
+/user/register** = anon
+
# connected urls
-/poll/createdList=connected
-/poll/participatedList=connected
-/user/favoriteLists=connected
-/user/createFavoriteList=connected
-/user/deleteFavoriteList=connected
-/user/show=connected
-/user/edit=connected
-/user/editFavoriteList=connected
+/user/**=connected
/json/getFavoriteLists=connected
/json/getFavoriteList=connected
/json/getFavoriteListPollAccounts=connected
@@ -36,16 +33,13 @@
# connected and admin urls
/admin/**=connected,admin
-/user/addPollAccount=connected,admin
-/user/editPollAccount=connected,admin
-/user/removePollAccount=connected,admin
/json/getUsers=connected,admin
/json/getUser=connected,admin
/json/getPolls=connected,admin
# is pollAccount (can vote and see result of a poll)
/poll/votefor/**=poll,pollAccess
-/poll/result/**=poll,pollAccess
+/poll/results/**=poll,pollAccess
# is pollCreator (can admin a poll)
/poll/modification/**=poll,pollCreator
\ No newline at end of file
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-03-28 07:59:26 UTC (rev 3213)
@@ -43,6 +43,7 @@
<constant name="struts.ui.theme" value="css_xhtml"/>
<constant name="struts.multipart.maxSize" value="209715200"/>
<constant name="struts.enable.SlashesInActionNames" value="true"/>
+ <constant name="struts.devMode" value="true"/>
<!--Performance tuning-->
<!--see http://struts.apache.org/2.2.3/docs/performance-tuning.html-->
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -153,7 +153,7 @@
<!-- Menu -->
<ul id="menu">
<li class="menu_elt">
- <s:a action="home">
+ <s:a action="home" namespace="/">
<s:text name="pollen.menu.home"/>
</s:a>
</li>
@@ -172,12 +172,12 @@
</li>
<s:if test="userExists">
<li>
- <s:a action="createdList" namespace="/poll">
+ <s:a action="createdList" namespace="/user">
<s:text name="pollen.menu.pollsCreatedList"/>
</s:a>
</li>
<li>
- <s:a action="participatedList" namespace="/poll">
+ <s:a action="participatedList" namespace="/user">
<s:text name="pollen.menu.pollsParticipatedList"/>
</s:a>
</li>
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/DateChoice.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/dateChoice.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/DateChoice.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/DateChoice.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,70 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 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%
+ --%>
+<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
+
+<s:set name="prefix">dateChoice_<s:property value="choiceNumber"/></s:set>
+<s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
+<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
+<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
+<div id='choicesDATE_<s:property value="choiceNumber"/>'>
+ <s:hidden key='%{#prefix}.topiaId' value='%{choice.topiaId}' label=''/>
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.name" id="choicesDATE_label_%{choiceNumber}"
+ theme="simple" value=''/>
+ <sj:datepicker id='%{#prefix}.name' key="%{#prefix}.name" changeMonth="true"
+ changeYear="true" labelSeparator="" theme="simple" label=""
+ timepicker="true" value="%{choice.date}" displayFormat="dd/mm/yy"/>
+ -
+ <s:label for="%{#prefix}.description" key="pollen.common.description"
+ theme="simple"/>
+ </div>
+ <div class="fleft">
+ <s:textarea cols="30" id="%{#prefix}.description"
+ key="%{#prefix}.description" label='' theme="simple"
+ value="%{choice.description}"/>
+ </div>
+ <div class="fright">
+ <s:a href='#' onclick="return deleteChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
+ <%--s:a id='choicesDATE_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesDATE_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a--%>
+ </div>
+ <div class="cleanBoth"></div>
+</div>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/DateChoice.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/ImageChoice.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/imageChoice.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/ImageChoice.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/ImageChoice.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,83 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 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%
+ --%>
+<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<s:set name="prefix">imageChoice_<s:property value="choiceNumber"/></s:set>
+<s:set name="prefix2">imageChoice[<s:property value="choiceNumber"/>]</s:set>
+<s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
+<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
+<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
+<div id='choicesIMAGE_<s:property value="choiceNumber"/>'>
+ <s:hidden key='%{#prefix}.topiaId' value='%{choice.topiaId}' label=''/>
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.name" id="choicesIMAGE_label_%{choiceNumber}"
+ theme="simple" value=''/>
+ <s:if test="choice.name != ''">
+
+ <%--Uploaded image--%>
+ <s:hidden id="%{#prefix}.name" name="%{#prefix}.name"
+ value="%{choice.name}" label='' theme="simple"/>
+
+ <s:hidden id="%{#prefix}.location" name="%{#prefix}.location"
+ value="%{choice.location}" label='' theme="simple"/>
+
+ <s:label label='' theme="simple" cssClass="nameField"
+ value="%{choice.name}" readonly="true"/>
+ </s:if>
+ <s:else>
+ <%--New image--%>
+ <s:file key='%{#prefix2}' label='' theme="simple" cssClass="nameField"/>
+ </s:else>
+ -
+ <s:label for="%{#prefix}.description" key="pollen.common.description"
+ theme="simple"/>
+ </div>
+ <div class="fleft">
+ <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
+ key="%{#prefix}.description" value="%{choice.description}"/>
+ </div>
+ <div class="fright">
+ <s:a href='#' onclick="return deleteChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
+ <%--s:a id='choicesIMAGE_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesIMAGE_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a--%>
+ </div>
+
+ <div class="cleanBoth"></div>
+</div>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/ImageChoice.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/personToList.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,62 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 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%
+ --%>
+<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<s:set name="prefix">personToList_<s:property
+ value="votingListNumber"/>_<s:property value="personToListNumber"/>
+</s:set>
+<s:set id='deleteTitle'>
+ <s:text name="pollen.action.pollPersonToListDelete"/>
+</s:set>
+<s:div id='%{#prefix}'>
+ <s:fielderror/>
+ <s:hidden key='%{#prefix}.topiaId' value='%{personToList.topiaId}' label=''/>
+ <s:hidden key='%{#prefix}.accountId' value='%{personToList.pollAccount.accountId}' label=''/>
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.votingId" id="%{#prefix}_label" theme="simple"
+ value=''/>
+ <s:textfield cssClass="nameField" id='%{#prefix}.votingId'
+ key="%{#prefix}.votingId" label='' theme="simple"
+ value="%{personToList.pollAccount.votingId}"/>
+ -
+ <s:label for="%{#prefix}.email" key="pollen.common.email" theme="simple"/>
+ <s:textfield cols="30" id="%{#prefix}.email" key="%{#prefix}.email"
+ label='' theme="simple" size="30"
+ value="%{personToList.pollAccount.email}"/>
+ -
+ <s:label for="%{#prefix}.weight" key="pollen.common.weight" theme="simple"/>
+ <s:textfield id="%{#prefix}.weight" key="%{#prefix}.weight" size="1"
+ label='' theme="simple" value="%{personToList.weight}"/>
+ </div>
+ <div class="fright">
+ <s:a href='#' onclick="return deletePersonToList('%{#prefix}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
+ </div>
+
+ <div class="cleanBoth"></div>
+</s:div>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/TextChoice.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/textChoice.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/TextChoice.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/TextChoice.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,67 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 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%
+ --%>
+<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<s:set name="prefix">textChoice_<s:property value="choiceNumber"/></s:set>
+<s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
+<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
+<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
+<div id='choicesTEXT_<s:property value="choiceNumber"/>'>
+ <s:hidden key='%{#prefix}.topiaId' value='%{choice.topiaId}' label=''/>
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.name" id="choicesTEXT_label_%{choiceNumber}"
+ theme="simple" value=''/>
+ <s:textfield cssClass="nameField" id='%{#prefix}.name' key="%{#prefix}.name"
+ label='' theme="simple" value="%{choice.name}"/>
+ -
+ <s:label for="%{#prefix}.description" key="pollen.common.description"
+ theme="simple"/>
+ <%--/div>
+ <div class="fleft"--%>
+ <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
+ key="%{#prefix}.description" value="%{choice.description}"/>
+ </div>
+ <div class="fright">
+ <s:a href='#' onclick="return deleteChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
+ <%--s:a id='choicesTEXT_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesTEXT_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a--%>
+ </div>
+ <div class="cleanBoth"></div>
+</div>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/TextChoice.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/votingList.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,90 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 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%
+ --%>
+<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<s:set name="prefix">votingList_<s:property value="votingListNumber"/></s:set>
+<s:set id='deleteTitle'>
+ <s:text name="pollen.action.pollVotingListDelete"/>
+</s:set>
+
+<script type="text/javascript">
+ jQuery(document).ready(function () {
+ // personToList loading
+ <s:iterator begin="1" end="nbPersonToLists" status="status">
+ addPersonToList(<s:property value="votingListNumber"/>, <s:property value='%{#status.index}'/>, <s:property value="nbPersonToLists - 1"/>, '<s:property value="personToListTokenId" />');
+ </s:iterator>
+ });
+</script>
+<s:div id='votingLists_%{votingListNumber}'>
+ <fieldset class="ui-widget-content ui-corner-all">
+
+ <s:fielderror/>
+ <div class="groupPoll">
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.name" theme="simple"
+ id="votingLists_%{votingListNumber}_label"/>
+ <s:textfield id='%{#prefix}.name' key="%{#prefix}.name" label=''
+ theme="simple" value="%{votingList.name}"/>
+ -
+ <s:label for="%{#prefix}.weight" key="pollen.common.weight"
+ theme="simple"/>
+ <s:textfield id="%{#prefix}.weight" key="%{#prefix}.weight"
+ value="%{votingList.weight}"
+ size="1" label='' theme="simple"/>
+ </div>
+ <div id='<s:property value="%{#prefix}"/>_actions' class="fright">
+ <s:a href='#'
+ onclick="return deleteVotingList('votingLists_%{votingListNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
+ </div>
+ <hr/>
+ </div>
+ <div class="cleanBoth"></div>
+ <s:hidden key='%{#prefix}.topiaId' value='%{votingList.topiaId}' label=''/>
+
+ <s:div id='personToList_%{votingListNumber}'>
+ <%--Where to load personToList--%>
+ </s:div>
+ <hr/>
+ <div class="cleanBoth" align="center">
+ <s:submit id='%{#prefix}_addPersonToList'
+ name='%{#prefix}_addPersonToList'
+ key="pollen.action.addPersonToList" theme="simple"
+ onclick='return addNewPersonToList("%{votingListNumber}");'/>
+ <s:if test="userLoggued">
+ <s:submit id='%{#prefix}_addPersonToList' theme="simple"
+ name='%{#prefix}_addPersonToList'
+ key="pollen.action.addPersonListFromVotingList"
+ onclick='return selectPersonListToAddToVotingList("%{votingListNumber}");'/>
+ </s:if>
+
+ </div>
+
+ </fieldset>
+ <br/>
+</s:div>
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createdList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createdList.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createdList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,59 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- %%
- 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%
- --%>
-<%@page contentType="text/html" pageEncoding="UTF-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
-
-<script type="text/javascript">
-var redirectUrl = '<s:url namespace="/poll" action="createdList"/>';
-</script>
-<%@include file="/WEB-INF/jsp/pollListHelper.jsp"%>
-
-<title><s:text name="pollen.title.pollsCreatedList"/></title>
-
-<h1 class="title${pageLogo}"><s:text name="pollen.title.pollsCreatedList"/></h1>
-
-<h4><s:text name="pollen.title.pollsCreatedList.legend"/></h4>
-
-<s:url id="loadUrl" action="getCreatedPolls" namespace="/json" escapeAmp="false"/>
-
-<sjg:grid id="polls" dataType="json" href="%{loadUrl}" gridModel="polls"
- sortable="true" pager="true" pagerButtons="true" pagerInput="true"
- navigator="true" rownumbers="false" autowidth="true"
- onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
- onCompleteTopics='users-cleanSelect'
- navigatorEdit="false" navigatorDelete="false"
- navigatorSearch="false" navigatorRefresh="false"
- navigatorAdd="false" viewrecords="true"
- rowList="10,15,20,50,100" rowNum="10">
- <sjg:gridColumn name="id" title="id" hidden="true"/>
-
- <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
- <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
- <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
- <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
- <sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
- <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
- formatter="pollFunctions" width="180" sortable="false"/>
-</sjg:grid>
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/dateChoice.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/dateChoice.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/dateChoice.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,70 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 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%
- --%>
-<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
-
-<s:set name="prefix">dateChoice_<s:property value="choiceNumber"/></s:set>
-<s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
-<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
-<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
-<div id='choicesDATE_<s:property value="choiceNumber"/>'>
- <s:hidden key='%{#prefix}.topiaId' value='%{choice.topiaId}' label=''/>
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.name" id="choicesDATE_label_%{choiceNumber}"
- theme="simple" value=''/>
- <sj:datepicker id='%{#prefix}.name' key="%{#prefix}.name" changeMonth="true"
- changeYear="true" labelSeparator="" theme="simple" label=""
- timepicker="true" value="%{choice.date}" displayFormat="dd/mm/yy"/>
- -
- <s:label for="%{#prefix}.description" key="pollen.common.description"
- theme="simple"/>
- </div>
- <div class="fleft">
- <s:textarea cols="30" id="%{#prefix}.description"
- key="%{#prefix}.description" label='' theme="simple"
- value="%{choice.description}"/>
- </div>
- <div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- <%--s:a id='choicesDATE_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
- </s:a>
- <s:a id='choicesDATE_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
- </div>
- <div class="cleanBoth"></div>
-</div>
\ No newline at end of file
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/imageChoice.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/imageChoice.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/imageChoice.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,83 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 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%
- --%>
-<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-
-<s:set name="prefix">imageChoice_<s:property value="choiceNumber"/></s:set>
-<s:set name="prefix2">imageChoice[<s:property value="choiceNumber"/>]</s:set>
-<s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
-<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
-<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
-<div id='choicesIMAGE_<s:property value="choiceNumber"/>'>
- <s:hidden key='%{#prefix}.topiaId' value='%{choice.topiaId}' label=''/>
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.name" id="choicesIMAGE_label_%{choiceNumber}"
- theme="simple" value=''/>
- <s:if test="choice.name != ''">
-
- <%--Uploaded image--%>
- <s:hidden id="%{#prefix}.name" name="%{#prefix}.name"
- value="%{choice.name}" label='' theme="simple"/>
-
- <s:hidden id="%{#prefix}.location" name="%{#prefix}.location"
- value="%{choice.location}" label='' theme="simple"/>
-
- <s:label label='' theme="simple" cssClass="nameField"
- value="%{choice.name}" readonly="true"/>
- </s:if>
- <s:else>
- <%--New image--%>
- <s:file key='%{#prefix2}' label='' theme="simple" cssClass="nameField"/>
- </s:else>
- -
- <s:label for="%{#prefix}.description" key="pollen.common.description"
- theme="simple"/>
- </div>
- <div class="fleft">
- <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
- key="%{#prefix}.description" value="%{choice.description}"/>
- </div>
- <div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- <%--s:a id='choicesIMAGE_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
- </s:a>
- <s:a id='choicesIMAGE_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
- </div>
-
- <div class="cleanBoth"></div>
-</div>
\ No newline at end of file
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/participatedList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/participatedList.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/participatedList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,85 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- %%
- 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%
- --%>
-<%@page contentType="text/html" pageEncoding="UTF-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
-<script type="text/javascript">
- var redirectUrl = '<s:url namespace="/poll" action="participatedList"/>';
-</script>
-<%@include file="/WEB-INF/jsp/pollListHelper.jsp"%>
-
-<title><s:text name="pollen.title.pollsParticipatedList"/></title>
-
-<h1 class="title${pageLogo}"><s:text name="pollen.title.pollsParticipatedList"/></h1>
-
-<h4><s:text name="pollen.title.pollsInvitedList.legend"/></h4>
-
-<s:url id="loadInvitedUrl" action="getInvitedPolls"
- namespace="/json" escapeAmp="false"/>
-
-<sjg:grid dataType="json" href="%{loadInvitedUrl}" gridModel="polls"
- sortable="true" pager="true" pagerButtons="true" pagerInput="true"
- navigator="true" rownumbers="false" autowidth="true"
- onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
- onCompleteTopics='users-cleanSelect'
- navigatorEdit="false" navigatorDelete="false"
- navigatorSearch="false" navigatorRefresh="false"
- navigatorAdd="false" viewrecords="true"
- rowList="10,15,20,50,100" rowNum="10">
- <sjg:gridColumn name="id" title="id" hidden="true"/>
-
- <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
- <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
- <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
- <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
- <sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
- <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
- formatter="pollFunctions" width="180" sortable="false"/>
-</sjg:grid>
-
-
-<h4><s:text name="pollen.title.pollsParticipatedList.legend"/></h4>
-
-<s:url id="loadParticipatedUrl" action="getParticipatedPolls"
- namespace="/json" escapeAmp="false"/>
-
-<sjg:grid dataType="json" href="%{loadParticipatedUrl}" gridModel="polls"
- sortable="true" pager="true" pagerButtons="true" pagerInput="true"
- navigator="true" rownumbers="false" autowidth="true"
- onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
- onCompleteTopics='users-cleanSelect'
- navigatorEdit="false" navigatorDelete="false"
- navigatorSearch="false" navigatorRefresh="false"
- navigatorAdd="false" viewrecords="true"
- rowList="10,15,20,50,100" rowNum="10">
- <sjg:gridColumn name="id" title="id" hidden="true"/>
-
- <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
- <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
- <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
- <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
- <sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
- <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
- formatter="pollFunctions" width="180" sortable="false"/>
-</sjg:grid>
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/personToList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/personToList.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/personToList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,62 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 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%
- --%>
-<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-
-<s:set name="prefix">personToList_<s:property
- value="votingListNumber"/>_<s:property value="personToListNumber"/>
-</s:set>
-<s:set id='deleteTitle'>
- <s:text name="pollen.action.pollPersonToListDelete"/>
-</s:set>
-<s:div id='%{#prefix}'>
- <s:fielderror/>
- <s:hidden key='%{#prefix}.topiaId' value='%{personToList.topiaId}' label=''/>
- <s:hidden key='%{#prefix}.accountId' value='%{personToList.pollAccount.accountId}' label=''/>
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.votingId" id="%{#prefix}_label" theme="simple"
- value=''/>
- <s:textfield cssClass="nameField" id='%{#prefix}.votingId'
- key="%{#prefix}.votingId" label='' theme="simple"
- value="%{personToList.pollAccount.votingId}"/>
- -
- <s:label for="%{#prefix}.email" key="pollen.common.email" theme="simple"/>
- <s:textfield cols="30" id="%{#prefix}.email" key="%{#prefix}.email"
- label='' theme="simple" size="30"
- value="%{personToList.pollAccount.email}"/>
- -
- <s:label for="%{#prefix}.weight" key="pollen.common.weight" theme="simple"/>
- <s:textfield id="%{#prefix}.weight" key="%{#prefix}.weight" size="1"
- label='' theme="simple" value="%{personToList.weight}"/>
- </div>
- <div class="fright">
- <s:a href='#' onclick="return deletePersonToList('%{#prefix}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- </div>
-
- <div class="cleanBoth"></div>
-</s:div>
\ No newline at end of file
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/textChoice.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/textChoice.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/textChoice.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,67 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 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%
- --%>
-<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-
-<s:set name="prefix">textChoice_<s:property value="choiceNumber"/></s:set>
-<s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
-<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
-<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
-<div id='choicesTEXT_<s:property value="choiceNumber"/>'>
- <s:hidden key='%{#prefix}.topiaId' value='%{choice.topiaId}' label=''/>
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.name" id="choicesTEXT_label_%{choiceNumber}"
- theme="simple" value=''/>
- <s:textfield cssClass="nameField" id='%{#prefix}.name' key="%{#prefix}.name"
- label='' theme="simple" value="%{choice.name}"/>
- -
- <s:label for="%{#prefix}.description" key="pollen.common.description"
- theme="simple"/>
- <%--/div>
- <div class="fleft"--%>
- <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
- key="%{#prefix}.description" value="%{choice.description}"/>
- </div>
- <div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- <%--s:a id='choicesTEXT_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
- </s:a>
- <s:a id='choicesTEXT_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
- </div>
- <div class="cleanBoth"></div>
-</div>
\ No newline at end of file
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/votingList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/votingList.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/votingList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,90 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 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%
- --%>
-<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-
-<s:set name="prefix">votingList_<s:property value="votingListNumber"/></s:set>
-<s:set id='deleteTitle'>
- <s:text name="pollen.action.pollVotingListDelete"/>
-</s:set>
-
-<script type="text/javascript">
- jQuery(document).ready(function () {
- // personToList loading
- <s:iterator begin="1" end="nbPersonToLists" status="status">
- addPersonToList(<s:property value="votingListNumber"/>, <s:property value='%{#status.index}'/>, <s:property value="nbPersonToLists - 1"/>, '<s:property value="personToListTokenId" />');
- </s:iterator>
- });
-</script>
-<s:div id='votingLists_%{votingListNumber}'>
- <fieldset class="ui-widget-content ui-corner-all">
-
- <s:fielderror/>
- <div class="groupPoll">
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.name" theme="simple"
- id="votingLists_%{votingListNumber}_label"/>
- <s:textfield id='%{#prefix}.name' key="%{#prefix}.name" label=''
- theme="simple" value="%{votingList.name}"/>
- -
- <s:label for="%{#prefix}.weight" key="pollen.common.weight"
- theme="simple"/>
- <s:textfield id="%{#prefix}.weight" key="%{#prefix}.weight"
- value="%{votingList.weight}"
- size="1" label='' theme="simple"/>
- </div>
- <div id='<s:property value="%{#prefix}"/>_actions' class="fright">
- <s:a href='#'
- onclick="return deleteVotingList('votingLists_%{votingListNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- </div>
- <hr/>
- </div>
- <div class="cleanBoth"></div>
- <s:hidden key='%{#prefix}.topiaId' value='%{votingList.topiaId}' label=''/>
-
- <s:div id='personToList_%{votingListNumber}'>
- <%--Where to load personToList--%>
- </s:div>
- <hr/>
- <div class="cleanBoth" align="center">
- <s:submit id='%{#prefix}_addPersonToList'
- name='%{#prefix}_addPersonToList'
- key="pollen.action.addPersonToList" theme="simple"
- onclick='return addNewPersonToList("%{votingListNumber}");'/>
- <s:if test="userLoggued">
- <s:submit id='%{#prefix}_addPersonToList' theme="simple"
- name='%{#prefix}_addPersonToList'
- key="pollen.action.addPersonListFromVotingList"
- onclick='return selectPersonListToAddToVotingList("%{votingListNumber}");'/>
- </s:if>
-
- </div>
-
- </fieldset>
- <br/>
-</s:div>
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createdList.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,59 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
+ %%
+ 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%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
+
+<script type="text/javascript">
+var redirectUrl = '<s:url namespace="/user" action="createdList"/>';
+</script>
+<%@include file="/WEB-INF/jsp/pollListHelper.jsp"%>
+
+<title><s:text name="pollen.title.pollsCreatedList"/></title>
+
+<h1 class="title${pageLogo}"><s:text name="pollen.title.pollsCreatedList"/></h1>
+
+<h4><s:text name="pollen.title.pollsCreatedList.legend"/></h4>
+
+<s:url id="loadUrl" action="getCreatedPolls" namespace="/json" escapeAmp="false"/>
+
+<sjg:grid id="polls" dataType="json" href="%{loadUrl}" gridModel="polls"
+ sortable="true" pager="true" pagerButtons="true" pagerInput="true"
+ navigator="true" rownumbers="false" autowidth="true"
+ onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
+ onCompleteTopics='users-cleanSelect'
+ navigatorEdit="false" navigatorDelete="false"
+ navigatorSearch="false" navigatorRefresh="false"
+ navigatorAdd="false" viewrecords="true"
+ rowList="10,15,20,50,100" rowNum="10">
+ <sjg:gridColumn name="id" title="id" hidden="true"/>
+
+ <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
+ <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
+ <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
+ <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
+ <sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
+ <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
+ formatter="pollFunctions" width="180" sortable="false"/>
+</sjg:grid>
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/participatedList.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,85 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
+ %%
+ 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%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
+<script type="text/javascript">
+ var redirectUrl = '<s:url namespace="/user" action="participatedList"/>';
+</script>
+<%@include file="/WEB-INF/jsp/pollListHelper.jsp"%>
+
+<title><s:text name="pollen.title.pollsParticipatedList"/></title>
+
+<h1 class="title${pageLogo}"><s:text name="pollen.title.pollsParticipatedList"/></h1>
+
+<h4><s:text name="pollen.title.pollsInvitedList.legend"/></h4>
+
+<s:url id="loadInvitedUrl" action="getInvitedPolls"
+ namespace="/json" escapeAmp="false"/>
+
+<sjg:grid dataType="json" href="%{loadInvitedUrl}" gridModel="polls"
+ sortable="true" pager="true" pagerButtons="true" pagerInput="true"
+ navigator="true" rownumbers="false" autowidth="true"
+ onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
+ onCompleteTopics='users-cleanSelect'
+ navigatorEdit="false" navigatorDelete="false"
+ navigatorSearch="false" navigatorRefresh="false"
+ navigatorAdd="false" viewrecords="true"
+ rowList="10,15,20,50,100" rowNum="10">
+ <sjg:gridColumn name="id" title="id" hidden="true"/>
+
+ <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
+ <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
+ <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
+ <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
+ <sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
+ <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
+ formatter="pollFunctions" width="180" sortable="false"/>
+</sjg:grid>
+
+
+<h4><s:text name="pollen.title.pollsParticipatedList.legend"/></h4>
+
+<s:url id="loadParticipatedUrl" action="getParticipatedPolls"
+ namespace="/json" escapeAmp="false"/>
+
+<sjg:grid dataType="json" href="%{loadParticipatedUrl}" gridModel="polls"
+ sortable="true" pager="true" pagerButtons="true" pagerInput="true"
+ navigator="true" rownumbers="false" autowidth="true"
+ onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
+ onCompleteTopics='users-cleanSelect'
+ navigatorEdit="false" navigatorDelete="false"
+ navigatorSearch="false" navigatorRefresh="false"
+ navigatorAdd="false" viewrecords="true"
+ rowList="10,15,20,50,100" rowNum="10">
+ <sjg:gridColumn name="id" title="id" hidden="true"/>
+
+ <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
+ <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
+ <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
+ <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
+ <sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
+ <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
+ formatter="pollFunctions" width="180" sortable="false"/>
+</sjg:grid>
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r3212 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions java/org/chorem/pollen/ui/actions/poll resources/org/chorem/pollen resources/org/chorem/pollen/business resources/org/chorem/pollen/business/persistence resources/org/chorem/pollen/ui/actions/poll
by fdesbois@users.chorem.org 27 Mar '12
by fdesbois@users.chorem.org 27 Mar '12
27 Mar '12
Author: fdesbois
Date: 2012-03-27 21:09:51 +0200 (Tue, 27 Mar 2012)
New Revision: 3212
Url: http://chorem.org/repositories/revision/pollen/3212
Log:
- add PollUriConverter for parameter uriId that becomes a PollUri
- add BooleanIntegerConverter for voteValue in case of NORMAL VoteCounting
Added:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java 2012-03-27 19:09:51 UTC (rev 3212)
@@ -0,0 +1,49 @@
+package org.chorem.pollen.ui.actions;
+
+import org.apache.struts2.util.StrutsTypeConverter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+/**
+ * Created: 26/03/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ * $Id$
+ */
+public class BooleanIntegerConverter extends StrutsTypeConverter {
+
+ private static final Logger log = LoggerFactory.getLogger(BooleanIntegerConverter.class);
+
+ @Override
+ public Integer convertFromString(Map context, String[] values, Class toClass) {
+ Integer result;
+ if (values.length == 1) {
+ result = parseValue(values[0]);
+
+ } else {
+ result = null;
+ }
+ return result;
+ }
+
+ protected Integer parseValue(String value) {
+ Integer result;
+ if ("true".equals(value)) {
+ result = 1;
+
+ } else if ("false".equals(value)) {
+ result = 0;
+
+ } else {
+ result = Integer.parseInt(value);
+ }
+ return result;
+ }
+
+ @Override
+ public String convertToString(Map context, Object object) {
+ return object == null ? "" : String.valueOf(object);
+ }
+}
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java 2012-03-27 19:09:51 UTC (rev 3212)
@@ -0,0 +1,55 @@
+package org.chorem.pollen.ui.actions;
+
+import com.google.common.base.Preconditions;
+import org.apache.struts2.util.StrutsTypeConverter;
+import org.chorem.pollen.bean.PollUri;
+
+import java.util.Map;
+
+/**
+ * Created: 27/03/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class PollUriConverter extends StrutsTypeConverter {
+
+ private static PollUriConverter instance;
+
+ public static PollUriConverter getInstance() {
+ if (instance == null) {
+ instance = new PollUriConverter();
+ }
+ return instance;
+ }
+
+ @Override
+ public PollUri convertFromString(Map context, String[] values, Class toClass) {
+ PollUri result;
+ if (values.length == 1) {
+ String value = values[0];
+ result = PollUri.newPollUri(value);
+
+ } else {
+ result = null;
+ }
+ return result;
+ }
+
+ @Override
+ public String convertToString(Map context, Object o) {
+ String result;
+ if (o != null) {
+ result = ((PollUri)o).getUri();
+
+ } else {
+ result = "";
+ }
+ return result;
+ }
+
+ public static PollUri convertFromString(String[] values) {
+ Preconditions.checkNotNull(values);
+ PollUri result = getInstance().convertFromString(null, values, PollUri.class);
+ return result;
+ }
+}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-03-27 11:28:43 UTC (rev 3211)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-03-27 19:09:51 UTC (rev 3212)
@@ -24,8 +24,11 @@
package org.chorem.pollen.ui.actions.poll;
import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.ui.actions.PollUriConverter;
import org.chorem.pollen.ui.actions.PollenActionSupport;
+import java.util.Map;
+
/**
* Abstract action for all actions with a poll uri id.
*
@@ -34,23 +37,21 @@
* @since 1.2.6
*/
public abstract class AbstractPollUriIdAction extends PollenActionSupport {
+
+ public static final String PARAM_POLL_URI = "uriId";
private static final long serialVersionUID = 1L;
private PollUri pollUri;
- public final String getUriId() {
- return pollUri != null ? pollUri.getUri() : null;
+ public final PollUri getUriId() {
+ return pollUri;
}
- public final void setUriId(String uriId) {
- pollUri = PollUri.newPollUri(uriId);
+ public final void setUriId(PollUri pollUri) {
+ this.pollUri = pollUri;
}
- public void prepareUriId(String pollId, String accountId) {
- pollUri = PollUri.newPollUri(pollId, accountId);
- }
-
public final String getPollId() {
return pollUri != null ? pollUri.getPollId() : null;
}
@@ -58,4 +59,11 @@
public final String getAccountId() {
return pollUri != null ? pollUri.getAccountId() : null;
}
+
+ protected void preparePollUri(Map<String, String[]> parameters) {
+ if (pollUri == null) {
+ String[] values = parameters.get(PARAM_POLL_URI);
+ pollUri = PollUriConverter.convertFromString(values);
+ }
+ }
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-27 11:28:43 UTC (rev 3211)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-27 19:09:51 UTC (rev 3212)
@@ -267,13 +267,8 @@
public void prepareVotePage() throws Exception {
- // Ensure pollId for loading
- if (getPollId() == null) {
- log.debug("parameters= " + parameters);
- String uriId = parameters.get("uriId")[0];
- log.debug("uriId= " + uriId);
- setUriId(uriId);
- }
+ // Ensure uri for poll and pollAccount loading
+ preparePollUri(parameters);
loadPoll();
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java 2012-03-27 11:28:43 UTC (rev 3211)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java 2012-03-27 19:09:51 UTC (rev 3212)
@@ -23,13 +23,14 @@
*/
package org.chorem.pollen.ui.actions.poll;
+import org.chorem.pollen.bean.PollUri;
+
/**
* EditVote is a redirection to vote page. This action will simply update the
* uri with {@code accountId} and {@code pollId}.
*
* @author fdesbois <fdesbois(a)codelutin.com>
* @since 1.2.6
- * @see #prepareUriId(String, String)
*/
public class EditVote extends AbstractPollUriIdAction {
@@ -50,7 +51,7 @@
@Override
public String execute() throws Exception {
- prepareUriId(pollId, accountId);
+ setUriId(PollUri.newPollUri(pollId, accountId));
return SUCCESS;
}
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties 2012-03-27 19:09:51 UTC (rev 3212)
@@ -0,0 +1 @@
+voteValue=org.chorem.pollen.ui.actions.BooleanIntegerConverter
\ No newline at end of file
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties 2012-03-27 19:09:51 UTC (rev 3212)
@@ -0,0 +1 @@
+uriId=org.chorem.pollen.ui.actions.PollUriConverter
\ No newline at end of file
1
0
r3211 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions/poll resources/config webapp/WEB-INF/jsp/poll
by fdesbois@users.chorem.org 27 Mar '12
by fdesbois@users.chorem.org 27 Mar '12
27 Mar '12
Author: fdesbois
Date: 2012-03-27 13:28:43 +0200 (Tue, 27 Mar 2012)
New Revision: 3211
Url: http://chorem.org/repositories/revision/pollen/3211
Log:
- use PollUri object in AbstractPollUriIdAction
- rename and implement EditVote action
Added:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java
Removed:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ModifyVote.java
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmPollAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeletePoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ExportPoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -23,48 +23,39 @@
*/
package org.chorem.pollen.ui.actions.poll;
-import org.apache.commons.lang3.StringUtils;
+import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.ui.actions.PollenActionSupport;
/**
* Abstract action for all actions with a poll uri id.
*
* @author tchemit <chemit(a)codelutin.com>
+ * @author fdesbois <fdesbois(a)codelutin.com>
* @since 1.2.6
*/
public abstract class AbstractPollUriIdAction extends PollenActionSupport {
private static final long serialVersionUID = 1L;
+
+ private PollUri pollUri;
- /** Poll id (not topiaId but uuid, perharps we should use directly topiaId transformed to something smaller ?). */
- protected String pollId;
-
- /** Account id (not topiaId but uuid, perharps we should use directly topiaId transformed to something smaller ?). */
- protected String accountId;
-
public final String getUriId() {
- String result = pollId;
- if (StringUtils.isNotEmpty(accountId)) {
- result += ":" + accountId;
- }
- return result;
+ return pollUri != null ? pollUri.getUri() : null;
}
public final void setUriId(String uriId) {
- String[] split = uriId.split(":", 2);
- if (split.length > 0) {
- pollId = split[0];
- if (split.length > 1) {
- accountId = split[1];
- }
- }
+ pollUri = PollUri.newPollUri(uriId);
}
+ public void prepareUriId(String pollId, String accountId) {
+ pollUri = PollUri.newPollUri(pollId, accountId);
+ }
+
public final String getPollId() {
- return pollId;
+ return pollUri != null ? pollUri.getPollId() : null;
}
public final String getAccountId() {
- return accountId;
+ return pollUri != null ? pollUri.getAccountId() : null;
}
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -34,7 +34,6 @@
import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
-import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.common.ChoiceType;
@@ -56,6 +55,7 @@
* Abstract action for actions on the vote poll page.
*
* @author tchemit <chemit(a)codelutin.com>
+ * @author fdesbois <fdesbois(a)codelutin.com>
* @since 1.2.6
*/
public abstract class AbstractVoteAction extends AbstractPollUriIdAction implements ParameterAware {
@@ -152,12 +152,6 @@
return vote;
}
- public boolean getVoteValueAsBoolean(int index) {
- VoteToChoice voteToChoice = getVote().getChoiceVoteToChoice().get(index);
- Integer value = voteToChoice.getVoteValue();
- return value == 1;
- }
-
public boolean isPollChoiceOrVoteStarted() {
Date now = serviceContext.getCurrentTime();
return poll.isAddChoiceStarted(now) || poll.isStarted(now);
@@ -287,8 +281,16 @@
DateFormat.SHORT,
DateFormat.SHORT, getLocale()));
- loadPollAccount();
- loadVotes();
+ // Current poll account
+ pollAccount = getPollService().getPollAccount(getAccountId(), getPollenUserAccount());
+
+ // All votes
+ // TODO no pagination for the moment, need to retrieve the correct page depends on current pollAccount
+ votes = poll.getVote();
+
+ // Current vote
+ vote = getVoteService().getVote(poll, votes, pollAccount);
+
loadPollResults();
loadPollComments();
@@ -365,31 +367,7 @@
}
public boolean isModifAllowed(String voteId) {
-
- boolean result = false;
-
- Vote vote = poll.getVoteByTopiaId(voteId);
-
- // can only modify a vote if poll is running.
- if (vote != null && isPollRunning()) {
- PollAccount votePollAccount = vote.getPollAccount();
-
- // si le votant du vote correspond au votant actuel (pollAccountId)
- if (accountId != null
- && accountId.equals(votePollAccount.getAccountId())) {
- result = true;
- }
-
- UserAccount userAccount = getPollenUserAccount();
-
-
- // si l'utilisateur du vote correspond à l'utilisateur actuel (user)
- if (userAccount != null) {
- UserAccount voteUserAccount = votePollAccount.getUserAccount();
- result = voteUserAccount != null && userAccount.getTopiaId().equals(voteUserAccount.getTopiaId());
- }
- }
- return result;
+ return getVoteService().isUpdateAllowed(getPoll(), voteId, getAccountId(), getPollenUserAccount());
}
public String escapeLineBreak(String text) {
@@ -402,6 +380,7 @@
protected void loadPoll() throws PollNotFoundException {
+ String pollId = getPollId();
if (StringUtils.isNotEmpty(pollId)) {
poll = getPollService().getPollByPollId(pollId);
}
@@ -421,76 +400,6 @@
}
}
- protected void loadPollAccount() throws PollNotFoundException {
-
- //// Contrôle et définition du votingId
-// alreadyVoted = false;
-// boolean modifAllowed = false;
-// boolean restrictedListsForbidden = false;
-
- // Suppression des espaces pouvant provoquer un double vote
- // TODO maybe it's better to keep current pollAccount instead of creating one each time
- pollAccount = getPollService().getNewPollAccount(getPollenUserAccount());
-// String votingId = pollAccount.getVotingId().trim();
-// pollAccount.setVotingId(votingId);
-//
-// // The calcul of alreadyVoted will be needed for no double votingId
-// // Carefull, not correct for an anonymous vote
-// alreadyVoted = getVoteService().hasAlreadyVoted(votingId, poll);
-//
-// // Check for restricted poll
-// if (!alreadyVoted && !isFreePoll()) {
-//
-// if (StringUtils.isNotEmpty(getAccountId())) {
-//
-// // The accountUId must be valid for the poll
-// PollAccount restrictedAccount =
-// getPollService().getRestrictedAccount(getPollId(), getAccountId());
-//
-// if (restrictedAccount != null) {
-// // PollAccount is replaced by the good account from db
-// pollAccount = restrictedAccount;
-//
-// // Refresh alreadyVoted value depends on pollAccount
-//// alreadyVoted = pollAccount.isHasVoted();
-//
-// } else {
-// // Existing account is null is forbidden for a restricted poll
-// restrictedListsForbidden = true;
-// }
-//
-// } else {
-// // Not allowed to vote without an accountUId
-// restrictedListsForbidden = true;
-// }
-//
-// if (restrictedListsForbidden) {
-// addActionError(_("pollen.error.user.restrictedListsForbidden"));
-// }
-// }
-//
-// // Génération d'un identifiant de vote (si le sondage est libre et anonyme)
-// if (poll.isAnonymous() && isFreePoll()) {
-// getPollAccount().setVotingId(
-// "anonymous" + serviceContext.createPollenUrlId());
-// }
-//
-// modifAllowed = isModifAllowed(getPollAccount().getVotingId());
-// if (alreadyVoted && !modifAllowed) {
-// addActionError(_("pollen.error.user.alreadyVoted",
-// getPollAccount().getVotingId()));
-// }
- }
-
- protected void loadVotes() {
-
- // TODO no pagination for the moment, need to retrieve the correct page depends on current pollAccount
- votes = getPoll().getVote();
-
- // Current vote
- vote = getVoteService().getVote(getPoll(), getVotes(), getPollAccount());
- }
-
protected void loadPollComments() {
PollCommentService service = newService(PollCommentService.class);
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -50,7 +50,7 @@
PollService service = newService(PollService.class);
- service.closePoll(pollId, getPollenUserAccount(), accountId);
+ service.closePoll(getPollId(), getPollenUserAccount(), getAccountId());
return SUCCESS;
}
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -53,6 +53,7 @@
@Override
public String execute() throws Exception {
+ String pollId = getPollId();
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choiceId);
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -55,6 +55,7 @@
@Override
public String execute() throws Exception {
+ String pollId = getPollId();
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(commentId);
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -53,6 +53,7 @@
@Override
public String execute() throws Exception {
+ String pollId = getPollId();
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voteId);
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmPollAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmPollAction.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmPollAction.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -55,6 +55,7 @@
@Override
public String execute() throws Exception {
+ String pollId = getPollId();
Preconditions.checkNotNull(pollId);
poll = newService(PollService.class).getPollByPollId(pollId);
return SUCCESS;
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -45,6 +45,7 @@
@Override
public String execute() throws Exception {
+ String pollId = getPollId();
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choiceId);
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeletePoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeletePoll.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeletePoll.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -50,7 +50,7 @@
PollService service = newService(PollService.class);
- service.deletePoll(pollId, getPollenUserAccount(), accountId);
+ service.deletePoll(getPollId(), getPollenUserAccount(), getAccountId());
return SUCCESS;
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -45,7 +45,6 @@
@Override
public String execute() throws Exception {
- Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voteId);
VoteService service = newService(VoteService.class);
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java (from rev 3210, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ModifyVote.java)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -0,0 +1,57 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
+package org.chorem.pollen.ui.actions.poll;
+
+/**
+ * EditVote is a redirection to vote page. This action will simply update the
+ * uri with {@code accountId} and {@code pollId}.
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @since 1.2.6
+ * @see #prepareUriId(String, String)
+ */
+public class EditVote extends AbstractPollUriIdAction {
+
+ private static final long serialVersionUID = 1L;
+
+ private String accountId;
+
+ private String pollId;
+
+ public void setAccountId(String accountId) {
+ this.accountId = accountId;
+ }
+
+ public void setPollId(String pollId) {
+ this.pollId = pollId;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ prepareUriId(pollId, accountId);
+
+ return SUCCESS;
+ }
+}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ExportPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ExportPoll.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ExportPoll.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -60,6 +60,7 @@
@Override
public String execute() throws Exception {
+ String pollId = getPollId();
Preconditions.checkNotNull(pollId);
PollResultsService service = newService(PollResultsService.class);
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ModifyVote.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ModifyVote.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ModifyVote.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -1,44 +0,0 @@
-/*
- * #%L
- * Pollen :: UI (strust2)
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2012 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%
- */
-package org.chorem.pollen.ui.actions.poll;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since TODO
- */
-public class ModifyVote extends AbstractVoteAction {
-
- private static final long serialVersionUID = 1L;
-
-
- @Override
- public String execute() throws Exception {
-
- loadPoll();
-
- return SUCCESS;
- }
-}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -151,6 +151,7 @@
@Override
public String execute() throws Exception {
+ String pollId = getPollId();
Preconditions.checkNotNull(pollId);
PollService service = newService(PollService.class);
@@ -171,6 +172,7 @@
DateFormat.SHORT,
DateFormat.SHORT, getLocale()));
+ String accountId = getAccountId();
if (poll.isPublicResults()) {
userAllowed = true;
} else if (StringUtils.isNotEmpty(accountId)) {
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-27 11:28:43 UTC (rev 3211)
@@ -26,23 +26,22 @@
import com.opensymphony.xwork2.Preparable;
import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Vote;
-import org.chorem.pollen.business.persistence.VoteToChoice;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Votes to a poll.
*
* @author tchemit <chemit(a)codelutin.com>
+ * @author fdesbois <fdesbois(a)codelutin.com>
* @since 1.2.6
*/
public class VoteForPoll extends AbstractVoteAction implements Preparable {
+
+ private static final Logger log = LoggerFactory.getLogger(VoteForPoll.class);
private static final long serialVersionUID = 1L;
- public void setVoteValueAsBoolean(int index, boolean value) {
- VoteToChoice voteToChoice = getVote().getChoiceVoteToChoice().get(index);
- voteToChoice.setVoteValue(value ? 1 : 0);
- }
-
@Override
public String input() throws Exception {
@@ -52,6 +51,11 @@
@Override
public String execute() throws Exception {
+
+ // VALIDATION ::
+ // - votingId/name not empty
+ // - account not exists (matching userAccount) > check on all votes (EXISTS userAccount FROM poll.votes)
+ // - votingId/name is unique > check on all votes (EXISTS votingId FROM poll.votes)
if (getVote().getTopiaId() != null) {
getVoteService().updateVote(getVote());
@@ -69,6 +73,9 @@
PollUri pollUri = PollUri.newPollUri(pollId, accountId);
String updateUrl = getVoteService().getUpdateVoteUrl(pollUri);
+
+ log.debug("UpdateURL for poll '{}' and account '{}' = {}", new Object[]{pollId, accountId, updateUrl});
+
addActionMessage(_("pollen.information.vote.createdWithUpdateUrl", updateUrl));
} else{
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-27 11:28:43 UTC (rev 3211)
@@ -225,9 +225,9 @@
<result type="redirectToVote"/>
</action>
- <!-- modify poll vote -->
- <action name="modifyVote"
- class="org.chorem.pollen.ui.actions.poll.ModifyVote">
+ <!-- edit poll vote -->
+ <action name="editVote"
+ class="org.chorem.pollen.ui.actions.poll.EditVote">
<result type="redirectToVote"/>
</action>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-27 11:28:36 UTC (rev 3210)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-27 11:28:43 UTC (rev 3211)
@@ -312,8 +312,8 @@
<s:if test="!poll.anonymous">
<s:if test="isModifAllowed(#vote.topiaId)">
<s:a action="editVote" namespace="/poll">
- <s:param name="uriId" value="%{uriId}"/>
- <s:param name="voteId" value="%{#vote.topiaId}"/>
+ <s:param name="pollId" value="%{pollId}"/>
+ <s:param name="accountId" value="%{#vote.pollAccount.accountId}"/>
<img src="<s:url value="/img/editSmall.png"/>"
title="<s:text name="pollen.action.editVote"/>"
alt="<s:text name="pollen.action.editVote"/>"/>
1
0
r3210 - branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl
by fdesbois@users.chorem.org 27 Mar '12
by fdesbois@users.chorem.org 27 Mar '12
27 Mar '12
Author: fdesbois
Date: 2012-03-27 13:28:36 +0200 (Tue, 27 Mar 2012)
New Revision: 3210
Url: http://chorem.org/repositories/revision/pollen/3210
Log:
- Move isUpdateVoteAllowed to VoteService
- Add getPollAccount method in PollService
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-26 17:02:58 UTC (rev 3209)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-27 11:28:36 UTC (rev 3210)
@@ -25,6 +25,7 @@
import com.google.common.base.Preconditions;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenConfiguration;
@@ -381,24 +382,66 @@
}
}
+ /**
+ * Retrieve a pollAccount with {@code accountId}. This pollAccount will be
+ * attached to the given {@code userAccount} (only if not already attached).
+ * If the {@code accountId} is undefined, a new instance of PollAccount will
+ * be retrieved, otherwise the existing PollAccount is used. No create or
+ * update is done here.
+ *
+ * @param accountId Id of the existing account (optional)
+ * @param userAccount UserAccount where account will be attached (optional)
+ * @return the existing PollAccount or a new instance
+ * @throws PollAccountNotFound if accountId is defined and doesn't match any
+ * existing PollAccount
+ */
+ public PollAccount getPollAccount(String accountId, UserAccount userAccount) throws PollAccountNotFound {
+ PollAccount result;
+ if (StringUtils.isNotEmpty(accountId)) {
+ result = getPollAccountByAccountId(accountId);
+
+ // REMARQUES :
+ // - pas le droit de modif si le pollAccount est rattaché a un userAccount et qu'on est pas loggé ?!?
+ // - Ce serait plus simple que l'Admin ne puisse jamais voter, il ne peut que modérer les votes
+
+ // Don't remove or update userAccount link if already set
+ if (userAccount != null && result.getUserAccount() == null) {
+ result.setUserAccount(userAccount);
+
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Attach User '%s' [%s] to the existing Account [%s]",
+ userAccount.getDisplayName(),
+ userAccount.getTopiaId(),
+ accountId
+ ));
+ }
+ }
+
+ } else {
+ result = getNewPollAccount(userAccount);
+ }
+ return result;
+ }
+
public PollAccount getNewPollAccount(UserAccount userAccount) {
PollAccountDAO dao = getDAO(PollAccount.class);
PollAccount result = newInstance(dao);
result.setAccountId(serviceContext.createPollenUrlId());
- if (userAccount != null) {
- String displayName = userAccount.getDisplayName();
- result.setVotingId(displayName);
- } else {
- result.setVotingId("");
- }
+ String votingId = userAccount != null ? userAccount.getDisplayName() : "";
+ result.setVotingId(votingId);
result.setUserAccount(userAccount);
return result;
}
- public PollAccount getPollAccountByAccountId(String accountId) {
+ public PollAccount getPollAccountByAccountId(String accountId) throws PollAccountNotFound {
try {
PollAccountDAO dao = getDAO(PollAccount.class);
PollAccount result = dao.findByAccountId(accountId);
+
+ if (result == null) {
+ throw new PollAccountNotFound();
+ }
+
return result;
} catch (TopiaException e) {
throw new PollenTechnicalException("Could not botain account with this id", e);
@@ -424,10 +467,6 @@
PollAccount account = getPollAccountByAccountId(accountId);
- if (account == null) {
- throw new PollAccountNotFound();
- }
-
if (!account.getAccountId().equals(poll.getCreator().getAccountId())) {
throw new UnauthorizedPollAccessException();
}
@@ -458,10 +497,6 @@
PollAccount account = getPollAccountByAccountId(accountId);
- if (account == null) {
- throw new PollAccountNotFound();
- }
-
if (!account.getAccountId().equals(poll.getCreator().getAccountId())) {
throw new UnauthorizedPollAccessException();
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-26 17:02:58 UTC (rev 3209)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-27 11:28:36 UTC (rev 3210)
@@ -50,6 +50,7 @@
import org.nuiton.topia.persistence.TopiaFilterPagerUtil;
import java.net.URL;
+import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -303,7 +304,34 @@
throw new PollenTechnicalException("Could not obtain votes", e);
}
}
+
+ public boolean isUpdateAllowed(Poll poll, String voteId, String accountId, UserAccount userConnected) {
+
+ Date now = serviceContext.getCurrentTime();
+
+ boolean result = false;
+ Vote vote = poll.getVoteByTopiaId(voteId);
+
+ // can only modify a vote if poll is running.
+ if (vote != null && poll.isRunning(now)) {
+ PollAccount votePollAccount = vote.getPollAccount();
+
+ // si le votant du vote correspond au votant actuel (pollAccountId)
+ if (accountId != null
+ && accountId.equals(votePollAccount.getAccountId())) {
+ result = true;
+ }
+
+ // si l'utilisateur du vote correspond à l'utilisateur actuel (user)
+ if (userConnected != null) {
+ UserAccount voteUserAccount = votePollAccount.getUserAccount();
+ result = userConnected.equals(voteUserAccount);
+ }
+ }
+ return result;
+ }
+
public boolean hasAlreadyVoted(String votingId, Poll poll) {
try {
VoteDAO dao = getDAO(Vote.class);
1
0
r3209 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui java/org/chorem/pollen/ui/actions java/org/chorem/pollen/ui/actions/poll resources resources/i18n webapp/WEB-INF/jsp/poll
by fdesbois@users.chorem.org 26 Mar '12
by fdesbois@users.chorem.org 26 Mar '12
26 Mar '12
Author: fdesbois
Date: 2012-03-26 19:02:58 +0200 (Mon, 26 Mar 2012)
New Revision: 3209
Url: http://chorem.org/repositories/revision/pollen/3209
Log:
- Resolve issue with VoteToChoice save
- Add message support in session (not working yet)
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java 2012-03-26 17:02:51 UTC (rev 3208)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java 2012-03-26 17:02:58 UTC (rev 3209)
@@ -48,6 +48,10 @@
/** Key to store the {@link PollenSession} instance in the session's map. */
protected static final String SESSION_PARAMETER = "pollenSession";
+ public static final String SESSION_TOKEN_MESSAGES = "messages";
+
+ public static final String SESSION_TOKEN_ERRORS = "errors";
+
public static PollenSession get(ServletRequest servletRequest) {
HttpSession httpSession = ((HttpServletRequest) servletRequest).getSession(true);
PollenSession pollenSession = (PollenSession) httpSession.getAttribute(SESSION_PARAMETER);
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-03-26 17:02:51 UTC (rev 3208)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-03-26 17:02:58 UTC (rev 3209)
@@ -44,6 +44,8 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -229,4 +231,48 @@
String result = getDateTimeFormat().format(date);
return result;
}
+
+ @Override
+ public void addActionMessage(String message) {
+ List<String> messages = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
+ if (messages == null) {
+ messages = Lists.newArrayList(message);
+ getPollenSession().putDynamicData(PollenSession.SESSION_TOKEN_MESSAGES, messages);
+ } else {
+ messages.add(message);
+ }
+ }
+
+ @Override
+ public void addActionError(String message) {
+ List<String> messages = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
+ if (messages == null) {
+ messages = Lists.newArrayList(message);
+ getPollenSession().putDynamicData(PollenSession.SESSION_TOKEN_ERRORS, messages);
+ } else {
+ messages.add(message);
+ }
+ }
+
+ @Override
+ public Collection<String> getActionErrors() {
+ List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
+ if (result != null) {
+ getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
+ } else {
+ result = Collections.emptyList();
+ }
+ return result;
+ }
+
+ @Override
+ public Collection<String> getActionMessages() {
+ List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
+ if (result != null) {
+ getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
+ } else {
+ result = Collections.emptyList();
+ }
+ return result;
+ }
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-26 17:02:51 UTC (rev 3208)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-26 17:02:58 UTC (rev 3209)
@@ -152,12 +152,9 @@
return vote;
}
- public VoteToChoice getVoteToChoice(int index) {
- return getVote().getChoiceVoteToChoice().get(index);
- }
-
public boolean getVoteValueAsBoolean(int index) {
- Integer value = getVoteToChoice(index).getVoteValue();
+ VoteToChoice voteToChoice = getVote().getChoiceVoteToChoice().get(index);
+ Integer value = voteToChoice.getVoteValue();
return value == 1;
}
@@ -488,7 +485,7 @@
protected void loadVotes() {
// TODO no pagination for the moment, need to retrieve the correct page depends on current pollAccount
- votes = getPoll().getVote();
+ votes = getPoll().getVote();
// Current vote
vote = getVoteService().getVote(getPoll(), getVotes(), getPollAccount());
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-26 17:02:51 UTC (rev 3208)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-26 17:02:58 UTC (rev 3209)
@@ -24,7 +24,9 @@
package org.chorem.pollen.ui.actions.poll;
import com.opensymphony.xwork2.Preparable;
+import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Vote;
+import org.chorem.pollen.business.persistence.VoteToChoice;
/**
* Votes to a poll.
@@ -37,7 +39,8 @@
private static final long serialVersionUID = 1L;
public void setVoteValueAsBoolean(int index, boolean value) {
- getVoteToChoice(index).setVoteValue(value ? 1 : 0);
+ VoteToChoice voteToChoice = getVote().getChoiceVoteToChoice().get(index);
+ voteToChoice.setVoteValue(value ? 1 : 0);
}
@Override
@@ -58,6 +61,20 @@
getPollService().addVoteToPoll(getPoll(), voteCreated);
}
+ // Display updateUrl if user is not logged
+ if (!isUserLoggued()) {
+
+ String pollId = getPoll().getPollId();
+ String accountId = getPollAccount().getAccountId();
+ PollUri pollUri = PollUri.newPollUri(pollId, accountId);
+
+ String updateUrl = getVoteService().getUpdateVoteUrl(pollUri);
+ addActionMessage(_("pollen.information.vote.createdWithUpdateUrl", updateUrl));
+
+ } else{
+
+ addActionMessage(_("pollen.information.vote.created"));
+ }
return SUCCESS;
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-03-26 17:02:51 UTC (rev 3208)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-03-26 17:02:58 UTC (rev 3209)
@@ -193,6 +193,8 @@
pollen.information.user.created=User %s created.
pollen.information.user.deleted=User %s deleted.
pollen.information.user.updated=User %s updated.
+pollen.information.vote.created=
+pollen.information.vote.createdWithUpdateUrl=
pollen.information.your.are.loggued=You are logged.
pollen.label.contact.administrator=Send an email to an administrator
pollen.label.pollEditPage=The link below leads to the page to modify your poll. Save it to be able to modify your poll later if you need it or to close it \:
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-03-26 17:02:51 UTC (rev 3208)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-03-26 17:02:58 UTC (rev 3209)
@@ -200,6 +200,8 @@
pollen.information.user.created=L'utilisateur %s a été créé.
pollen.information.user.deleted=L'utilisateur %s a été supprimé.
pollen.information.user.updated=L'utilisateur %s a été mis à jour.
+pollen.information.vote.created=Vote enregistré
+pollen.information.vote.createdWithUpdateUrl=Vote enregistré, vous pourrez le modifier à l'adresse suivante <a href\="%1$s">%1$s</a>
pollen.information.your.are.loggued=Vous êtes connecté.
pollen.label.contact.administrator=Contacter un administrateur
pollen.label.pollEditPage=Le lien ci-dessous mène à la page de modification du sondage. Enregistrez-le pour pouvoir modifier votre sondage au besoin ou le clore \:
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-03-26 17:02:51 UTC (rev 3208)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-03-26 17:02:58 UTC (rev 3209)
@@ -39,7 +39,7 @@
<constant name="struts.action.extension" value=",,"/>
<constant name="struts.locale" value="fr_FR"/>
<constant name="struts.i18n.reload" value="false"/>
- <constant name="struts.configuration.xml.reload" value="false"/>
+ <constant name="struts.configuration.xml.reload" value="true"/>
<constant name="struts.ui.theme" value="css_xhtml"/>
<constant name="struts.multipart.maxSize" value="209715200"/>
<constant name="struts.enable.SlashesInActionNames" value="true"/>
@@ -71,9 +71,9 @@
<interceptor-stack name="pollenBasicStack">
<interceptor-ref name="i18n"/>
<interceptor-ref name="basicStack"/>
- <interceptor-ref name="store">
+<!-- <interceptor-ref name="store">
<param name="operationMode">STORE</param>
- </interceptor-ref>
+ </interceptor-ref>-->
</interceptor-stack>
<!-- params stack with params-->
@@ -107,9 +107,9 @@
<interceptor-ref name="workflow">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
- <interceptor-ref name="store">
+<!-- <interceptor-ref name="store">
<param name="operationMode">STORE</param>
- </interceptor-ref>
+ </interceptor-ref>-->
</interceptor-stack>
</interceptors>
@@ -137,9 +137,9 @@
<result>/WEB-INF/jsp/home.jsp</result>
<interceptor-ref name="i18n"/>
<interceptor-ref name="basicStack"/>
- <interceptor-ref name="store">
+<!-- <interceptor-ref name="store">
<param name="operationMode">RETRIEVE</param>
- </interceptor-ref>
+ </interceptor-ref>-->
</action>
<!-- change lang-->
@@ -153,9 +153,9 @@
<interceptor-ref name="paramRemover">
<param name="paramNames">request_locale</param>
</interceptor-ref>
- <interceptor-ref name="store">
+<!-- <interceptor-ref name="store">
<param name="operationMode">STORE</param>
- </interceptor-ref>
+ </interceptor-ref>-->
</action>
</package>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-26 17:02:51 UTC (rev 3208)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-26 17:02:58 UTC (rev 3209)
@@ -270,24 +270,24 @@
<s:if test="!isChoiceHidden(#choice)">
<th>
<s:if test="normalVoteCounting">
- <s:checkbox name="voteValueAsBoolean[%{#status.index}]"
- value="%{voteValueAsBoolean[#status.index]}" theme="simple"/>
+ <s:checkbox name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
+ value="%{vote.choiceVoteToChoice[#status.index].voteValue}" theme="simple"/>
</s:if>
<s:if test="percentageVoteCounting">
- <s:textfield name="voteToChoice[%{#status.index}].voteValue"
- value="%{voteToChoice[#status.index].voteValue}"
+ <s:textfield name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
+ value="%{vote.choiceVoteToChoice[#status.index].voteValue}"
required="true" size="3" theme="simple"/>
<%--t:validate="required, min=0, max=100"/>%--%>
</s:if>
<s:if test="condorcetVoteCounting">
- <s:textfield name="voteToChoice[%{#status.index}].voteValue"
- value="%{voteToChoice[#status.index].voteValue}"
+ <s:textfield name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
+ value="%{vote.choiceVoteToChoice[#status.index].voteValue}"
id="condorcetInput" size="3" theme="simple"/>
<%--t:nulls="zero" t:validate="min=0, max=99"/>--%>
</s:if>
<s:if test="numberVoteCounting">
- <s:textfield name="voteToChoice[%{#status.index}].voteValue"
- value="%{voteToChoice[#status.index].voteValue}"
+ <s:textfield name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
+ value="%{vote.choiceVoteToChoice[#status.index].voteValue}"
size="3" theme="simple"/>
</s:if>
</th>
1
0
r3208 - in branches/pollen-1.2.6-struts2: pollen-services/src/main/java/org/chorem/pollen/bean pollen-services/src/main/java/org/chorem/pollen/services/impl pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by fdesbois@users.chorem.org 26 Mar '12
by fdesbois@users.chorem.org 26 Mar '12
26 Mar '12
Author: fdesbois
Date: 2012-03-26 19:02:51 +0200 (Mon, 26 Mar 2012)
New Revision: 3208
Url: http://chorem.org/repositories/revision/pollen/3208
Log:
- Delete vote
- Add method for updateVoteUrl
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java 2012-03-23 21:32:36 UTC (rev 3207)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java 2012-03-26 17:02:51 UTC (rev 3208)
@@ -23,6 +23,7 @@
*/
package org.chorem.pollen.bean;
+import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
/**
@@ -47,10 +48,22 @@
return result;
}
+ public static PollUri newPollUri(String pollId, String accountId) {
+ Preconditions.checkNotNull(pollId);
+
+ PollUri result = new PollUri();
+
+ result.pollId = pollId;
+ result.accountId = accountId;
+ return result;
+ }
+
protected String pollId;
protected String accountId;
+ private PollUri() { }
+
public String getPollId() {
return pollId;
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-23 21:32:36 UTC (rev 3207)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-26 17:02:51 UTC (rev 3208)
@@ -44,7 +44,6 @@
import org.chorem.pollen.business.persistence.PreventRuleDAO;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.Vote;
-import org.chorem.pollen.business.persistence.VoteDAO;
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.common.ChoiceType;
@@ -53,7 +52,6 @@
import org.chorem.pollen.services.exceptions.PollAccountNotFound;
import org.chorem.pollen.services.exceptions.PollChoiceNotFoundException;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import org.chorem.pollen.services.exceptions.PollVoteNotFoundException;
import org.chorem.pollen.services.exceptions.UnauthorizedPollAccessException;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaFilterPagerUtil;
@@ -483,26 +481,6 @@
commitTransaction("Could not close poll " + poll.getTitle());
}
- public void deleteVote(String pollId, String voteId)
- throws PollNotFoundException, PollVoteNotFoundException {
-
- Poll poll = getPollByPollId(pollId);
-
- if (poll == null) {
- throw new PollNotFoundException();
- }
- Vote vote = poll.getVoteByTopiaId(voteId);
-
- if (vote == null) {
- throw new PollVoteNotFoundException();
- }
-
- VoteDAO dao = getDAO(Vote.class);
- delete(dao, vote);
-
- commitTransaction("Could not delete vote " + vote);
- }
-
public void deleteChoice(String pollId, String choiceId)
throws PollNotFoundException, PollChoiceNotFoundException {
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-23 21:32:36 UTC (rev 3207)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-26 17:02:51 UTC (rev 3208)
@@ -25,11 +25,13 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenTechnicalException;
+import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
@@ -39,6 +41,7 @@
import org.chorem.pollen.business.persistence.VoteDAO;
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.business.persistence.VoteToChoiceDAO;
+import org.chorem.pollen.common.PollType;
import org.chorem.pollen.entities.PollenDAOHelper;
import org.chorem.pollen.services.PollenServiceSupport;
import org.chorem.pollen.services.exceptions.VoteNotFoundException;
@@ -46,6 +49,7 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaFilterPagerUtil;
+import java.net.URL;
import java.util.List;
import java.util.Map;
@@ -117,6 +121,20 @@
}
return result;
}
+
+ /**
+ * Retrieve the URL to update a vote based on {@link PollUri}.
+ *
+ * @param pollUri Uri with pollId and accountId
+ * @return the URL that allow the voting person to update his vote
+ */
+ public String getUpdateVoteUrl(PollUri pollUri) {
+ Preconditions.checkNotNull(pollUri.getAccountId());
+ URL baseUrl = serviceContext.getApplicationURL();
+ String result =
+ String.format("%s/poll/votefor/%s", baseUrl, pollUri.getUri());
+ return result;
+ }
public Vote createVote(Vote vote) {
@@ -172,6 +190,7 @@
String choiceId = input.getChoice().getTopiaId();
Choice choiceLoaded = getEntityById(Choice.class, choiceId);
voteToChoiceCreated.setChoice(choiceLoaded);
+ voteToChoiceCreated.setVote(result);
result.addChoiceVoteToChoice(voteToChoiceCreated);
}
@@ -225,6 +244,16 @@
commitTransaction("Could not update vote");
}
+ /**
+ * Delete vote referenced by {@code voteId}. This will also delete all
+ * associated {@link VoteToChoice}. The {@link PollAccount} could also be
+ * deleted for a {@link PollType#FREE} poll where vote will be removed. This
+ * remove implied an new execution of poll vote counting if continuous results
+ * is activated.
+ *
+ * @param voteId TopiaId of the vote
+ * @throws VoteNotFoundException if vote doesn't exist
+ */
public void deleteVote(String voteId) throws VoteNotFoundException {
Vote entityToDelete = getEntityById(Vote.class, voteId);
@@ -234,8 +263,28 @@
}
VoteDAO dao = getDAO(Vote.class);
+ VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
+
+ // Delete all VoteToChoice
+ List<VoteToChoice> voteToChoices = ImmutableList.copyOf(entityToDelete.getChoiceVoteToChoice());
+ for (VoteToChoice voteToChoice : voteToChoices) {
+ entityToDelete.removeChoiceVoteToChoice(voteToChoice);
+ delete(voteToChoiceDao, voteToChoice);
+ }
+
+ // Delete vote PollAccount if the Poll is free and account is not the creator
+ Poll poll = entityToDelete.getPoll();
+ PollAccount voteAccount = entityToDelete.getPollAccount();
+ if (PollType.FREE.equals(poll.getPollType()) && !voteAccount.equals(poll.getCreator())) {
+ PollAccountDAO accountDAO = getDAO(PollAccount.class);
+ delete(accountDAO, voteAccount);
+ }
+
+ poll.removeVote(entityToDelete);
delete(dao, entityToDelete);
+ // TODO calculate results if continuous
+
if (log.isDebugEnabled()) {
log.debug("Entity deleted: " + voteId);
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-03-23 21:32:36 UTC (rev 3207)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-03-26 17:02:51 UTC (rev 3208)
@@ -24,7 +24,7 @@
package org.chorem.pollen.ui.actions.poll;
import com.google.common.base.Preconditions;
-import org.chorem.pollen.services.impl.PollService;
+import org.chorem.pollen.services.impl.VoteService;
/**
* To delete a poll vote.
@@ -48,9 +48,9 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voteId);
- PollService service = newService(PollService.class);
+ VoteService service = newService(VoteService.class);
- service.deleteVote(pollId, voteId);
+ service.deleteVote(voteId);
return SUCCESS;
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp 2012-03-23 21:32:36 UTC (rev 3207)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp 2012-03-26 17:02:51 UTC (rev 3208)
@@ -27,7 +27,7 @@
<s:form method="POST" namespace="/poll" action="deleteVote">
<s:hidden key="uriId" label=''/>
- <s:hidden key="voteId" label=''/>
+ <s:hidden key="voteId" value="%{vote.topiaId}" label=''/>
<s:text name="pollen.information.confirmDeletePollVote">
<s:param>
1
0
23 Mar '12
Author: tchemit
Date: 2012-03-23 22:32:36 +0100 (Fri, 23 Mar 2012)
New Revision: 3207
Url: http://chorem.org/repositories/revision/pollen/3207
Log:
- add shiro filters
- improve access to application context and user session
- usage of javascript files to clean pages
- clean interceptor stacks
Added:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AdminUserRequired.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/ConnectedUserRequired.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollRequired.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/admin_required.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/connected_required.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_access_required.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_creator_required.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_required.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js
Removed:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenShiroFilter.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationContext.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/PollenFileUploadInterceptor.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/log4j.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClonePoll.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationContext.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationContext.java 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationContext.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -23,22 +23,48 @@
*/
package org.chorem.pollen.ui;
+import com.opensymphony.xwork2.ActionContext;
import org.chorem.pollen.PollenConfiguration;
import org.chorem.pollen.services.PollenNotifierWorker;
import org.nuiton.topia.TopiaContext;
+import javax.servlet.ServletContext;
+import java.util.Map;
+
/**
* @author tchemit <chemit(a)codelutin.com>
* @since 1.2.6
*/
public class PollenApplicationContext {
+ /** Key to store the single instance of the application context */
+ public static final String APPLICATION_CONTEXT_PARAMETER =
+ "pollenApplicationContext";
+
protected PollenConfiguration configuration;
protected TopiaContext rootContext;
protected PollenNotifierWorker pollenNotifierWorker;
+ public static PollenApplicationContext get(ActionContext actionContext) {
+ Map<String, Object> application = actionContext.getApplication();
+ PollenApplicationContext applicationContext =
+ (PollenApplicationContext) application.get(APPLICATION_CONTEXT_PARAMETER);
+ return applicationContext;
+ }
+
+ public static PollenApplicationContext get(ServletContext servletContext) {
+ PollenApplicationContext applicationContext =
+ (PollenApplicationContext) servletContext.getAttribute(APPLICATION_CONTEXT_PARAMETER);
+ return applicationContext;
+ }
+
+ public static void set(ServletContext servletContext,
+ PollenApplicationContext context) {
+ servletContext.setAttribute(APPLICATION_CONTEXT_PARAMETER, context);
+ }
+
public PollenConfiguration getConfiguration() {
return configuration;
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -34,13 +34,13 @@
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.PollenServiceFactory;
import org.chorem.pollen.services.impl.UserService;
-import org.chorem.pollen.ui.actions.PollenActionSupport;
import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.DefaultI18nInitializer;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaUtil;
+import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.io.IOException;
@@ -77,8 +77,10 @@
i18nInitializer.setMissingKeyReturnNull(true);
I18n.init(i18nInitializer, Locale.getDefault());
- PollenApplicationContext applicationContext = new PollenApplicationContext();
- sce.getServletContext().setAttribute(PollenActionSupport.APPLICATION_CONTEXT_PARAMETER, applicationContext);
+ PollenApplicationContext applicationContext =
+ new PollenApplicationContext();
+ PollenApplicationContext.set(sce.getServletContext(),
+ applicationContext);
// initialize configuration
PollenConfiguration configuration = new PollenConfiguration();
@@ -112,8 +114,9 @@
log.info("Application is ending at " + new Date() + "...");
}
+ ServletContext servletContext = sce.getServletContext();
PollenApplicationContext applicationContext =
- (PollenApplicationContext) sce.getServletContext().getAttribute(PollenActionSupport.APPLICATION_CONTEXT_PARAMETER);
+ PollenApplicationContext.get(servletContext);
if (applicationContext != null) {
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -24,10 +24,14 @@
package org.chorem.pollen.ui;
import com.google.common.collect.Maps;
+import com.opensymphony.xwork2.ActionContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.business.persistence.UserAccount;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
import java.util.Map;
/**
@@ -41,6 +45,39 @@
/** Logger. */
private static final Log log = LogFactory.getLog(PollenSession.class);
+ /** Key to store the {@link PollenSession} instance in the session's map. */
+ protected static final String SESSION_PARAMETER = "pollenSession";
+
+ public static PollenSession get(ServletRequest servletRequest) {
+ HttpSession httpSession = ((HttpServletRequest) servletRequest).getSession(true);
+ PollenSession pollenSession = (PollenSession) httpSession.getAttribute(SESSION_PARAMETER);
+ if (pollenSession == null) {
+ pollenSession = new PollenSession();
+ httpSession.setAttribute(SESSION_PARAMETER, pollenSession);
+ }
+ return pollenSession;
+ }
+
+ public static PollenSession get(ActionContext actionContext) {
+
+ // load it from session
+ Map<String, Object> strutsSession =
+ actionContext.getSession();
+ PollenSession session = (PollenSession)
+ strutsSession.get(SESSION_PARAMETER);
+
+ if (session == null) {
+
+ // create an empty session
+ session = new PollenSession();
+
+ // and store it in the struts session
+ strutsSession.put(SESSION_PARAMETER, session);
+ }
+ return session;
+ }
+
+
/** User loggued account (if anonymous, then userAccount is null). */
private UserAccount userAccount;
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenShiroFilter.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenShiroFilter.java 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenShiroFilter.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -1,37 +0,0 @@
-package org.chorem.pollen.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.shiro.web.filter.authz.AuthorizationFilter;
-import org.chorem.pollen.business.persistence.UserAccount;
-import org.chorem.pollen.ui.actions.PollenActionSupport;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-public class PollenShiroFilter extends AuthorizationFilter {
-
- private static final Log log = LogFactory.getLog(PollenShiroFilter.class);
-
- @Override
- protected boolean isAccessAllowed(ServletRequest servletRequest, ServletResponse servletResponse, Object mappedValue) {
-
- PollenSession pollenSession = PollenActionSupport.getPollenSession(servletRequest);
-
- UserAccount userAccount = pollenSession.getUserAccount();
-
- boolean isAccessAllowed = userAccount != null && userAccount.isAdministrator();
-
- if (log.isDebugEnabled()) {
- if (isAccessAllowed) {
- log.debug("granting access to an admin-reserved page");
- } else {
- log.debug("illegal access to an admin-reserved page, user will be sent to " + getUnauthorizedUrl());
- }
- }
-
- return isAccessAllowed;
-
- }
-
-}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -25,7 +25,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.ui.actions.PollenActionSupport;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaRuntimeException;
@@ -48,7 +47,7 @@
@Override
protected TopiaContext beginTransaction(ServletRequest request) throws TopiaRuntimeException {
PollenApplicationContext applicationContext =
- PollenActionSupport.getPollenApplicationContext();
+ PollenApplicationContext.get(request.getServletContext());
TopiaContext rootContext = applicationContext.getRootContext();
try {
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -25,8 +25,6 @@
import com.google.common.collect.Lists;
import com.opensymphony.xwork2.ActionContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.struts2.StrutsStatics;
import org.chorem.pollen.PollenConfiguration;
import org.chorem.pollen.business.persistence.UserAccount;
@@ -41,16 +39,13 @@
import org.nuiton.web.filter.TopiaTransactionFilter;
import org.nuiton.web.struts2.BaseAction;
-import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
import java.net.URL;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
-import java.util.Map;
/**
* Pollen action support.
@@ -67,24 +62,13 @@
private static final long serialVersionUID = 1L;
- /** Key to store the {@link PollenSession} instance in the session's map. */
- protected static final String SESSION_PARAMETER = "pollenSession";
-
- /** Key to store the single instance of the application context */
- public static final String APPLICATION_CONTEXT_PARAMETER = "pollenApplicationContext";
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(PollenActionSupport.class);
-
private static DateFormat dateTimeFormat;
private DateFormat dateFormat;
public static PollenApplicationContext getPollenApplicationContext() {
- Map<String, Object> application = getActionContext().getApplication();
PollenApplicationContext applicationContext =
- (PollenApplicationContext) application.get(APPLICATION_CONTEXT_PARAMETER);
+ PollenApplicationContext.get(getActionContext());
return applicationContext;
}
@@ -111,34 +95,9 @@
return "Index";
}
- public static PollenSession getPollenSession(ServletRequest servletRequest) {
- HttpSession httpSession = ((HttpServletRequest) servletRequest).getSession(true);
- PollenSession pollenSession = (PollenSession) httpSession.getAttribute(SESSION_PARAMETER);
- if (pollenSession == null) {
- pollenSession = new PollenSession();
- httpSession.setAttribute(SESSION_PARAMETER, pollenSession);
- }
- return pollenSession;
- }
-
public PollenSession getPollenSession() {
if (pollenSession == null) {
-
- // load it from session
- Map<String, Object> strutsSession =
- getActionContext().getSession();
- PollenSession session = (PollenSession)
- strutsSession.get(SESSION_PARAMETER);
-
- if (session == null) {
-
- // create an empty session
- session = new PollenSession();
-
- // and store it in the struts session
- strutsSession.put(SESSION_PARAMETER, session);
- }
- pollenSession = session;
+ pollenSession = PollenSession.get(getActionContext());
}
return pollenSession;
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -25,6 +25,7 @@
import com.google.common.base.Preconditions;
import com.opensymphony.xwork2.Preparable;
+import org.apache.struts2.interceptor.ParameterAware;
import org.chorem.pollen.business.persistence.PersonList;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.services.exceptions.FavoriteListNotFoundException;
@@ -33,16 +34,20 @@
import org.chorem.pollen.services.impl.FavoriteService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
+import java.util.Map;
+
/**
* Manage a selected favorite lists of a connected user.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.2.6
*/
-public class ManageFavoriteList extends PollenActionSupport implements Preparable {
+public class ManageFavoriteList extends PollenActionSupport implements Preparable, ParameterAware {
private static final long serialVersionUID = 1L;
+ private Map<String, String[]> parameters;
+
@Override
public String getPageLogo() {
return "Creation";
@@ -50,7 +55,7 @@
protected String action;
- protected String favoriteListId;
+// protected String favoriteListId;
protected PersonList favoriteList;
@@ -73,26 +78,26 @@
}
public String getFavoriteListId() {
- return favoriteListId;
+ return favoriteList.getTopiaId();
}
- public void setFavoriteListId(String favoriteListId) {
- this.favoriteListId = favoriteListId;
- }
-
public String getAction() {
return action;
}
- public void setAction(String action) {
- this.action = action;
- }
-
@Override
public void prepare() throws Exception {
- Preconditions.checkNotNull(favoriteListId);
+ String[] favoriteListIds = parameters.get("favoriteListId");
+ Preconditions.checkNotNull(favoriteListIds);
+ Preconditions.checkArgument(favoriteListIds.length == 1);
+ String favoriteListId = favoriteListIds[0];
+ String[] actions = parameters.get("action");
+ if (actions != null && actions.length == 1) {
+ action = actions[0];
+ }
+
FavoriteService service = newService(FavoriteService.class);
try {
@@ -190,4 +195,8 @@
return pollAccount;
}
+ @Override
+ public void setParameters(Map<String, String[]> parameters) {
+ this.parameters = parameters;
+ }
}
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -1,84 +0,0 @@
-/*
- * #%L
- * Pollen :: UI (strust2)
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- * %%
- * 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%
- */
-package org.chorem.pollen.ui.interceptors;
-
-import com.google.common.base.Preconditions;
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.persistence.UserAccount;
-import org.chorem.pollen.ui.PollenSession;
-import org.chorem.pollen.ui.PollenUIUtils;
-import org.chorem.pollen.ui.actions.PollenActionSupport;
-
-/**
- * To check if logged user is admin.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2.6
- */
-public class CheckUserIsAdmin extends AbstractInterceptor {
-
- private static final long serialVersionUID = 1L;
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(CheckUserIsAdmin.class);
-
- /** Where to redirect where user is loggued */
- protected String redirectAction;
-
- public void setRedirectAction(String redirectAction) {
- this.redirectAction = redirectAction;
- }
-
- @Override
- public String intercept(ActionInvocation invocation) throws Exception {
-
- PollenActionSupport action = (PollenActionSupport) invocation.getAction();
-
- UserAccount user = action.getPollenUserAccount();
- Preconditions.checkNotNull(user, "No user found is session");
-
- boolean check = user.isAdministrator();
-
- String result = null;
-
- if (!check) {
-
- if (log.isInfoEnabled()) {
- log.info("User not admin try to acces admin section...");
- }
-
- if (log.isInfoEnabled()) {
- log.info("Will redirect to " + redirectAction);
- }
- PollenUIUtils.redirect(redirectAction);
-
- } else {
- result = invocation.invoke();
- }
- return result;
- }
-}
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -1,99 +0,0 @@
-/*
- * #%L
- * Pollen :: UI (strust2)
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- * %%
- * 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%
- */
-package org.chorem.pollen.ui.interceptors;
-
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.ui.PollenSession;
-import org.chorem.pollen.ui.PollenUIUtils;
-import org.chorem.pollen.ui.actions.PollenActionSupport;
-
-/**
- * To check user is loggued. If not, then redirect to the {@link #loginAction}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2.6
- */
-public class CheckUserIsLogguedInterceptor extends AbstractInterceptor {
-
- private static final long serialVersionUID = 1L;
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(CheckUserIsLogguedInterceptor.class);
-
- /** Where to redirect if user is not authenticated. */
- protected String loginAction;
-
- /** Where to redirect where user is loggued */
- protected String redirectAction;
-
- public void setLoginAction(String loginAction) {
- this.loginAction = loginAction;
- }
-
- public void setRedirectAction(String redirectAction) {
- this.redirectAction = redirectAction;
- }
-
- protected static final String URL_PATTERN = "%s?redirectAction=%s";
-
- @Override
- public String intercept(ActionInvocation invocation) throws Exception {
-
- PollenActionSupport action = (PollenActionSupport) invocation.getAction();
-
- boolean userLoggued = action.getPollenUserAccount() != null;
-
- if (!userLoggued && log.isInfoEnabled()) {
- log.info("No user loggued!");
- }
-
- String result = null;
-
- if (!userLoggued) {
-
- // redirect to login
-
- String url = String.format(URL_PATTERN,
- loginAction,
- redirectAction
- );
- if (log.isInfoEnabled()) {
- log.info("Will redirect to " + url);
- }
- PollenUIUtils.redirect(url);
-
- } else {
-
- result = invocation.invoke();
- }
-
- return result;
- }
-
-
-}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/PollenFileUploadInterceptor.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/PollenFileUploadInterceptor.java 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/PollenFileUploadInterceptor.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -58,7 +58,6 @@
public class PollenFileUploadInterceptor extends FileUploadInterceptor {
private static final long serialVersionUID = 1L;
-
protected final Pattern FILENAME_PATTERN = Pattern.compile("(.+)\\[(.+)\\]");
@Override
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,115 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
+package org.chorem.pollen.ui.security;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shiro.util.StringUtils;
+import org.apache.shiro.web.filter.authz.AuthorizationFilter;
+import org.apache.shiro.web.util.WebUtils;
+import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.business.persistence.UserAccount;
+import org.chorem.pollen.services.DefaultPollenServiceContext;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.PollenServiceFactory;
+import org.chorem.pollen.ui.PollenApplicationContext;
+import org.chorem.pollen.ui.PollenSession;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.web.filter.TopiaTransactionFilter;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public abstract class AbstractPollenAuthorization extends AuthorizationFilter {
+
+ public static final Pattern URI_PATTERN =
+ Pattern.compile("/.*/(.[^/]+)/(.+)");
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(AbstractPollenAuthorization.class);
+
+ protected AbstractPollenAuthorization() {
+ if (log.isInfoEnabled()) {
+ log.info("Init - "+this);
+ }
+ }
+
+ protected PollUri getPollUri(ServletRequest request) {
+ String servletPath = ((HttpServletRequest) request).getServletPath();
+ Matcher m = URI_PATTERN.matcher(servletPath);
+
+ PollUri result = null;
+ if (m.find()) {
+
+ String uriId = m.group(2);
+ result = PollUri.newPollUri(uriId);
+
+ }
+ return result;
+ }
+
+ protected UserAccount getPollenUSerAccount(ServletRequest request) {
+ PollenSession pollenSession = PollenSession.get(request);
+
+ return pollenSession.getUserAccount();
+ }
+
+ protected PollenServiceContext getServiceContext(ServletRequest request) {
+ PollenApplicationContext applicationContext =
+ PollenApplicationContext.get(request.getServletContext());
+
+ PollenServiceFactory serviceFactory = new PollenServiceFactory();
+
+ TopiaContext transaction =
+ TopiaTransactionFilter.getTransaction(request);
+
+ Locale locale = Locale.getDefault();
+ return DefaultPollenServiceContext.newContext(
+ locale,
+ transaction,
+ applicationContext.getConfiguration(),
+ serviceFactory
+ );
+ }
+
+ @Override
+ protected final boolean onAccessDenied(ServletRequest request,
+ ServletResponse response) throws IOException {
+ String unauthorizedUrl = getUnauthorizedUrl();
+ //SHIRO-142 - ensure that redirect _or_ error code occurs - both cannot happen due to response commit:
+ if (StringUtils.hasText(unauthorizedUrl)) {
+ WebUtils.issueRedirect(request, response, unauthorizedUrl);
+ } else {
+ WebUtils.toHttp(response).sendError(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+ return false;
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AdminUserRequired.java (from rev 3202, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenShiroFilter.java)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AdminUserRequired.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AdminUserRequired.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,59 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
+package org.chorem.pollen.ui.security;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.persistence.UserAccount;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class AdminUserRequired extends AbstractPollenAuthorization {
+
+ private static final Log log =
+ LogFactory.getLog(AdminUserRequired.class);
+
+ @Override
+ protected boolean isAccessAllowed(ServletRequest request,
+ ServletResponse response,
+ Object mappedValue) {
+
+ UserAccount userAccount = getPollenUSerAccount(request);
+
+ boolean isAccessAllowed = userAccount != null &&
+ userAccount.isAdministrator();
+
+ if (log.isDebugEnabled()) {
+ if (isAccessAllowed) {
+ log.debug("granting access to an admin-reserved page");
+ } else {
+ log.debug("illegal access to an admin-reserved page, user will be sent to " + getUnauthorizedUrl());
+ }
+ }
+
+ return isAccessAllowed;
+ }
+
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AdminUserRequired.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/ConnectedUserRequired.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/ConnectedUserRequired.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/ConnectedUserRequired.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,48 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
+package org.chorem.pollen.ui.security;
+
+import org.apache.shiro.web.filter.authc.UserFilter;
+import org.chorem.pollen.business.persistence.UserAccount;
+import org.chorem.pollen.ui.PollenSession;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class ConnectedUserRequired extends UserFilter {
+
+ @Override
+ protected boolean isAccessAllowed(ServletRequest request,
+ ServletResponse response,
+ Object mappedValue) {
+ PollenSession pollenSession =
+ PollenSession.get(request);
+
+ UserAccount userAccount = pollenSession.getUserAccount();
+
+ boolean isAccessAllowed = userAccount != null;
+ return isAccessAllowed;
+ }
+
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/ConnectedUserRequired.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,102 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
+package org.chorem.pollen.ui.security;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.exceptions.PollNotFoundException;
+import org.chorem.pollen.services.exceptions.UnauthorizedPollAccessException;
+import org.chorem.pollen.services.impl.PollService;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class PollAccessRequired extends AbstractPollenAuthorization {
+
+ private static final Log log =
+ LogFactory.getLog(PollAccessRequired.class);
+
+ protected final AdminUserRequired adminFilter;
+
+ public PollAccessRequired() {
+ adminFilter = new AdminUserRequired();
+ }
+
+ @Override
+ protected boolean isAccessAllowed(ServletRequest request,
+ ServletResponse response,
+ Object mappedValue) {
+
+ boolean isAccessAllowed;
+
+ if (adminFilter.isAccessAllowed(request, response, mappedValue)) {
+
+ // user is connected ans admin, so
+ isAccessAllowed = true;
+
+ } else {
+
+ PollUri pollUri = getPollUri(request);
+
+ if (pollUri == null) {
+
+ // no uriId given
+ isAccessAllowed = false;
+
+
+ } else {
+ PollenServiceContext serviceContext =
+ getServiceContext(request);
+
+ PollService pollService =
+ serviceContext.newService(PollService.class);
+
+ try {
+ pollService.checkPollAccount(pollUri);
+ isAccessAllowed = true;
+
+ if (log.isDebugEnabled()) {
+ log.debug("Can access to this poll " + pollUri.getPollId());
+ }
+ } catch (PollNotFoundException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Poll not found!");
+ }
+ isAccessAllowed = false;
+ } catch (UnauthorizedPollAccessException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("User can not access page");
+ }
+ isAccessAllowed = false;
+ }
+
+ }
+ }
+
+ return isAccessAllowed;
+ }
+
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,103 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
+package org.chorem.pollen.ui.security;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.exceptions.PollNotFoundException;
+import org.chorem.pollen.services.exceptions.UnauthorizedPollAccessException;
+import org.chorem.pollen.services.impl.PollService;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class PollCreatorRequired extends AbstractPollenAuthorization {
+
+ private static final Log log = LogFactory.getLog(PollCreatorRequired.class);
+
+ protected final AdminUserRequired adminFilter;
+
+ public PollCreatorRequired() {
+ adminFilter = new AdminUserRequired();
+ }
+
+
+ @Override
+ protected boolean isAccessAllowed(ServletRequest request,
+ ServletResponse response,
+ Object mappedValue) {
+
+ boolean isAccessAllowed;
+
+ if (adminFilter.isAccessAllowed(request, response, mappedValue)) {
+
+ // user is connected ans admin, so
+ isAccessAllowed = true;
+
+ } else {
+
+ PollUri pollUri = getPollUri(request);
+
+ if (pollUri == null) {
+
+ // no uriId given
+ isAccessAllowed = false;
+
+
+ } else {
+ PollenServiceContext serviceContext =
+ getServiceContext(request);
+
+ PollService pollService =
+ serviceContext.newService(PollService.class);
+
+ try {
+ pollService.checkPollCreator(pollUri);
+ isAccessAllowed = true;
+
+ if (log.isDebugEnabled()) {
+ log.debug("Can access to this poll " +
+ pollUri.getPollId());
+ }
+ } catch (PollNotFoundException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Poll not found!");
+ }
+ isAccessAllowed = false;
+ } catch (UnauthorizedPollAccessException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("User can not access page");
+ }
+ isAccessAllowed = false;
+ }
+
+ }
+ }
+
+ return isAccessAllowed;
+ }
+
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollRequired.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollRequired.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollRequired.java 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,80 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
+package org.chorem.pollen.ui.security;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.exceptions.PollNotFoundException;
+import org.chorem.pollen.services.impl.PollService;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class PollRequired extends AbstractPollenAuthorization {
+
+ private static final Log log =
+ LogFactory.getLog(PollRequired.class);
+
+ @Override
+ protected boolean isAccessAllowed(ServletRequest request,
+ ServletResponse response,
+ Object mappedValue) {
+
+ boolean isAccessAllowed;
+
+ PollUri pollUri = getPollUri(request);
+
+ if (pollUri == null) {
+
+ // no uriId given
+ isAccessAllowed = false;
+
+ } else {
+
+ PollenServiceContext serviceContext = getServiceContext(request);
+
+ PollService pollService =
+ serviceContext.newService(PollService.class);
+
+ try {
+ pollService.checkPoll(pollUri);
+ isAccessAllowed = true;
+
+ if (log.isDebugEnabled()) {
+ log.debug("Can access to this poll " + pollUri.getPollId());
+ }
+ } catch (PollNotFoundException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Poll not found!");
+ }
+ isAccessAllowed = false;
+ }
+ }
+
+ return isAccessAllowed;
+ }
+
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollRequired.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-03-23 21:32:36 UTC (rev 3207)
@@ -32,7 +32,7 @@
<package name="admin" extends="default" namespace="/admin">
- <default-interceptor-ref name="pollenBasicAdminStack"/>
+ <default-interceptor-ref name="pollenBasicStack"/>
<!-- manage users -->
<action name="usersList" method="input"
@@ -43,7 +43,7 @@
<!-- create user -->
<action name="create" method="create"
class="org.chorem.pollen.ui.actions.admin.ManageUsers">
- <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/>
+ <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/admin/usersList.jsp</result>
<result>/WEB-INF/jsp/admin/usersList.jsp</result>
</action>
@@ -51,7 +51,7 @@
<!-- save user -->
<action name="edit" method="edit"
class="org.chorem.pollen.ui.actions.admin.ManageUsers">
- <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/>
+ <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/admin/usersList.jsp</result>
<result>/WEB-INF/jsp/admin/usersList.jsp</result>
</action>
@@ -59,7 +59,7 @@
<!-- delete user -->
<action name="delete" method="delete"
class="org.chorem.pollen.ui.actions.admin.ManageUsers">
- <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/>
+ <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/admin/usersList.jsp</result>
<result>/WEB-INF/jsp/admin/usersList.jsp</result>
</action>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-03-23 21:32:36 UTC (rev 3207)
@@ -31,83 +31,79 @@
<package name="json" extends="default" namespace="/json">
- <!-- get pagined users -->
- <action name="getUsers"
- class="org.chorem.pollen.ui.actions.json.GetUsers">
- <interceptor-ref name="pollenBasicAdminStack"/>
- <result type="json"/>
- </action>
+ <default-interceptor-ref name="pollenBasicStack"/>
- <!-- get user detail -->
- <action name="getUser"
- class="org.chorem.pollen.ui.actions.json.GetUser">
- <interceptor-ref name="pollenBasicAdminStack"/>
+ <action name="get*"
+ class="org.chorem.pollen.ui.actions.json.Get{1}">
<result type="json"/>
</action>
+ <!---->
+ <!--<!– get pagined users –>-->
+ <!--<action name="getUsers"-->
+ <!--class="org.chorem.pollen.ui.actions.json.GetUsers">-->
+ <!--<result type="json"/>-->
+ <!--</action>-->
- <!-- get pagined favorite lists of user -->
- <action name="getFavoriteLists"
- class="org.chorem.pollen.ui.actions.json.GetFavoriteLists">
- <interceptor-ref name="pollenBasicLogguedStack"/>
- <result type="json"/>
- </action>
+ <!--<!– get user detail –>-->
+ <!--<action name="getUser"-->
+ <!--class="org.chorem.pollen.ui.actions.json.GetUser">-->
+ <!--<result type="json"/>-->
+ <!--</action>-->
- <!-- get selected favorite list of user -->
- <action name="getFavoriteList"
- class="org.chorem.pollen.ui.actions.json.GetFavoriteList">
- <interceptor-ref name="pollenBasicLogguedStack"/>
- <result type="json"/>
- </action>
+ <!--<!– get pagined favorite lists of user –>-->
+ <!--<action name="getFavoriteLists"-->
+ <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteLists">-->
+ <!--<result type="json"/>-->
+ <!--</action>-->
- <!-- get pagined poll accounts of a given favorite list -->
- <action name="getFavoriteListPollAccounts"
- class="org.chorem.pollen.ui.actions.json.GetFavoriteListPollAccounts">
- <interceptor-ref name="pollenBasicLogguedStack"/>
- <result type="json"/>
- </action>
+ <!--<!– get selected favorite list of user –>-->
+ <!--<action name="getFavoriteList"-->
+ <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteList">-->
+ <!--<result type="json"/>-->
+ <!--</action>-->
- <!-- get selected poll account of a given favorite list -->
- <action name="getFavoriteListPollAccount"
- class="org.chorem.pollen.ui.actions.json.GetFavoriteListPollAccount">
- <interceptor-ref name="pollenBasicLogguedStack"/>
- <result type="json"/>
- </action>
+ <!--<!– get pagined poll accounts of a given favorite list –>-->
+ <!--<action name="getFavoriteListPollAccounts"-->
+ <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteListPollAccounts">-->
+ <!--<result type="json"/>-->
+ <!--</action>-->
- <!-- get pagined polls -->
- <action name="getPolls"
- class="org.chorem.pollen.ui.actions.json.GetPolls">
- <interceptor-ref name="pollenBasicAdminStack"/>
- <result type="json"/>
- </action>
+ <!--<!– get selected poll account of a given favorite list –>-->
+ <!--<action name="getFavoriteListPollAccount"-->
+ <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteListPollAccount">-->
+ <!--<result type="json"/>-->
+ <!--</action>-->
- <!-- get pagined created polls -->
- <action name="getCreatedPolls"
- class="org.chorem.pollen.ui.actions.json.GetCreatedPolls">
- <interceptor-ref name="pollenBasicLogguedStack"/>
- <result type="json"/>
- </action>
+ <!--<!– get pagined polls –>-->
+ <!--<action name="getPolls"-->
+ <!--class="org.chorem.pollen.ui.actions.json.GetPolls">-->
+ <!--<result type="json"/>-->
+ <!--</action>-->
- <!-- get pagined invited polls -->
- <action name="getInvitedPolls"
- class="org.chorem.pollen.ui.actions.json.GetInvitedPolls">
- <interceptor-ref name="pollenBasicLogguedStack"/>
- <result type="json"/>
- </action>
+ <!--<!– get pagined created polls –>-->
+ <!--<action name="getCreatedPolls"-->
+ <!--class="org.chorem.pollen.ui.actions.json.GetCreatedPolls">-->
+ <!--<result type="json"/>-->
+ <!--</action>-->
- <!-- get pagined created polls -->
- <action name="getParticipatedPolls"
- class="org.chorem.pollen.ui.actions.json.GetParticipatedPolls">
- <interceptor-ref name="pollenBasicLogguedStack"/>
- <result type="json"/>
- </action>
+ <!--<!– get pagined invited polls –>-->
+ <!--<action name="getInvitedPolls"-->
+ <!--class="org.chorem.pollen.ui.actions.json.GetInvitedPolls">-->
+ <!--<result type="json"/>-->
+ <!--</action>-->
- <!-- get pagined poll comments -->
- <action name="getPollComments"
- class="org.chorem.pollen.ui.actions.json.GetPollComments">
- <interceptor-ref name="pollenBasicStack"/>
- <result type="json"/>
- </action>
+ <!--<!– get pagined created polls –>-->
+ <!--<action name="getParticipatedPolls"-->
+ <!--class="org.chorem.pollen.ui.actions.json.GetParticipatedPolls">-->
+ <!--<result type="json"/>-->
+ <!--</action>-->
+ <!--<!– get pagined poll comments –>-->
+ <!--<action name="getPollComments"-->
+ <!--class="org.chorem.pollen.ui.actions.json.GetPollComments">-->
+ <!--<result type="json"/>-->
+ <!--</action>-->
+
</package>
</struts>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-23 21:32:36 UTC (rev 3207)
@@ -38,6 +38,12 @@
<param name="namespace">/poll</param>
<param name="actionName">votefor/${uriId}</param>
</result-type>
+
+ <result-type name="redirect2"
+ class="org.apache.struts2.dispatcher.ServletRedirectResult">
+ <param name="location">${redirectUrl}</param>
+ <param name="prependServletContext">false</param>
+ </result-type>
</result-types>
<!-- create poll -->
@@ -110,10 +116,7 @@
<action name="clone/*"
class="org.chorem.pollen.ui.actions.poll.ClonePoll">
<param name="uriId">{1}</param>
- <result type="redirect">
- <param name="location">${redirectUrl}</param>
- <param name="prependServletContext">false</param>
- </result>
+ <result type="redirect2"/>
</action>
<!-- export poll -->
@@ -123,7 +126,8 @@
<result type="stream">
<param name="contentCharSet">UTF-8</param>
<param name="contentType">application/xml</param>
- <param name="contentDisposition">attachment;filename="${filename}"
+ <param name="contentDisposition">
+ attachment;filename="${filename}"
</param>
<param name="encode">true</param>
<param name="bufferSize">4096</param>
@@ -141,10 +145,7 @@
<action name="close/*"
class="org.chorem.pollen.ui.actions.poll.ClosePoll">
<param name="uriId">{1}</param>
- <result type="redirect">
- <param name="location">${redirectUrl}</param>
- <param name="prependServletContext">false</param>
- </result>
+ <result type="redirect2"/>
</action>
<!-- confirm delete poll -->
@@ -158,10 +159,7 @@
<action name="delete/*"
class="org.chorem.pollen.ui.actions.poll.DeletePoll">
<param name="uriId">{1}</param>
- <result type="redirect">
- <param name="location">${redirectUrl}</param>
- <param name="prependServletContext">false</param>
- </result>
+ <result type="redirect2"/>
</action>
<!-- display poll result -->
@@ -174,14 +172,14 @@
<!-- display createds polls -->
<action name="createdList"
class="org.chorem.pollen.ui.actions.poll.CreatedList">
- <interceptor-ref name="pollenBasicLogguedStack"/>
+ <interceptor-ref name="pollenBasicStack"/>
<result>/WEB-INF/jsp/poll/createdList.jsp</result>
</action>
<!-- display participated polls -->
<action name="participatedList"
class="org.chorem.pollen.ui.actions.poll.ParticipatedList">
- <interceptor-ref name="pollenBasicLogguedStack"/>
+ <interceptor-ref name="pollenBasicStack"/>
<result>/WEB-INF/jsp/poll/participatedList.jsp</result>
</action>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-03-23 21:32:36 UTC (rev 3207)
@@ -66,7 +66,7 @@
<!-- show favorite lists -->
<action name="favoriteLists" method="input"
class="org.chorem.pollen.ui.actions.user.ManageFavoriteLists">
- <interceptor-ref name="pollenBasicLogguedStack"/>
+ <interceptor-ref name="pollenBasicStack"/>
<result name="input">/WEB-INF/jsp/user/favoriteLists.jsp</result>
<result>/WEB-INF/jsp/user/favoriteLists.jsp</result>
</action>
@@ -74,7 +74,7 @@
<!-- create favorite list -->
<action name="createFavoriteList" method="create"
class="org.chorem.pollen.ui.actions.user.ManageFavoriteLists">
- <interceptor-ref name="pollenParamsPrepareParamsLogguedStack"/>
+ <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/user/favoriteLists.jsp</result>
<result>/WEB-INF/jsp/user/favoriteLists.jsp</result>
</action>
@@ -82,7 +82,7 @@
<!-- delete favorite list -->
<action name="deleteFavoriteList" method="delete"
class="org.chorem.pollen.ui.actions.user.ManageFavoriteLists">
- <interceptor-ref name="pollenParamsPrepareParamsLogguedStack"/>
+ <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/user/favoriteLists.jsp</result>
<result>/WEB-INF/jsp/user/favoriteLists.jsp</result>
</action>
@@ -90,14 +90,14 @@
<!-- edit favorite list -->
<action name="editFavoriteList" method="input"
class="org.chorem.pollen.ui.actions.user.ManageFavoriteList">
- <interceptor-ref name="pollenParamsPrepareParamsLogguedStack"/>
+ <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result>
</action>
<!-- add poll account to favorite list -->
<action name="addPollAccount" method="create"
class="org.chorem.pollen.ui.actions.user.ManageFavoriteList">
- <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/>
+ <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result>
<result>/WEB-INF/jsp/user/favoriteList.jsp</result>
</action>
@@ -105,7 +105,7 @@
<!-- edit poll account to favorite list -->
<action name="editPollAccount" method="edit"
class="org.chorem.pollen.ui.actions.user.ManageFavoriteList">
- <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/>
+ <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result>
<result>/WEB-INF/jsp/user/favoriteList.jsp</result>
</action>
@@ -113,7 +113,7 @@
<!-- remove poll account from a favorite list -->
<action name="removePollAccount" method="delete"
class="org.chorem.pollen.ui.actions.user.ManageFavoriteList">
- <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/>
+ <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result>
<result>/WEB-INF/jsp/user/favoriteList.jsp</result>
</action>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/log4j.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/log4j.properties 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/log4j.properties 2012-03-23 21:32:36 UTC (rev 3207)
@@ -28,5 +28,5 @@
log4j.appender.console.layout.ConversionPattern=%d [%p] %c %m%n
log4j.logger.org.chorem.pollen=INFO
-log4j.logger.org.chorem.pollen.ui.PollenShiroFilter=DEBUG
+log4j.logger.org.chorem.pollen.ui.PollenShiroIsAdministratorFilter=DEBUG
log4j.logger.org.nuiton=INFO
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini 2012-03-23 21:32:36 UTC (rev 3207)
@@ -1,8 +1,51 @@
[main]
-pollenFilter=org.chorem.pollen.ui.PollenShiroFilter
-pollenFilter.unauthorizedUrl=bordel.jsp
+connected=org.chorem.pollen.ui.security.ConnectedUserRequired
+connected.loginUrl=/security/connected_required
+admin=org.chorem.pollen.ui.security.AdminUserRequired
+admin.unauthorizedUrl=/security/admin_required
+
+poll=org.chorem.pollen.ui.security.PollRequired
+poll.unauthorizedUrl=/security/poll_required
+
+pollAccess=org.chorem.pollen.ui.security.PollAccessRequired
+pollAccess.unauthorizedUrl=/security/poll_access_required
+
+pollCreator=org.chorem.pollen.ui.security.PollCreatorRequired
+pollCreator.unauthorizedUrl=/security/poll_creator_required
+
[urls]
-/admin/**=pollenFilter
+# connected urls
+/poll/createdList=connected
+/poll/participatedList=connected
+/user/favoriteLists=connected
+/user/createFavoriteList=connected
+/user/deleteFavoriteList=connected
+/user/show=connected
+/user/edit=connected
+/user/editFavoriteList=connected
+/json/getFavoriteLists=connected
+/json/getFavoriteList=connected
+/json/getFavoriteListPollAccounts=connected
+/json/getFavoriteListPollAccount=connected
+/json/getCreatedPolls=connected
+/json/getInvitedPolls=connected
+/json/getParticipatedPolls=connected
+
+# connected and admin urls
+/admin/**=connected,admin
+/user/addPollAccount=connected,admin
+/user/editPollAccount=connected,admin
+/user/removePollAccount=connected,admin
+/json/getUsers=connected,admin
+/json/getUser=connected,admin
+/json/getPolls=connected,admin
+
+# is pollAccount (can vote and see result of a poll)
+/poll/votefor/**=poll,pollAccess
+/poll/result/**=poll,pollAccess
+
+# is pollCreator (can admin a poll)
+/poll/modification/**=poll,pollCreator
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-03-23 21:32:36 UTC (rev 3207)
@@ -67,17 +67,6 @@
<interceptor name="pollenFileUpload"
class="org.chorem.pollen.ui.interceptors.PollenFileUploadInterceptor"/>
- <!--<interceptor name="checkUserLoggued"-->
- <!--class="org.chorem.pollen.ui.interceptors.CheckUserIsLogguedInterceptor">-->
- <!--<param name="loginAction">/notLoggued</param>-->
- <!--<param name="redirectAction">/home</param>-->
- <!--</interceptor>-->
-
- <!--<interceptor name="checkUserAdmin"-->
- <!--class="org.chorem.pollen.ui.interceptors.CheckUserIsAdmin">-->
- <!--<param name="redirectAction">/notAdmin</param>-->
- <!--</interceptor>-->
-
<!-- basic stack -->
<interceptor-stack name="pollenBasicStack">
<interceptor-ref name="i18n"/>
@@ -87,17 +76,6 @@
</interceptor-ref>
</interceptor-stack>
- <interceptor-stack name="pollenBasicLogguedStack">
- <!--<interceptor-ref name="checkUserLoggued"/>-->
- <interceptor-ref name="pollenBasicStack"/>
- </interceptor-stack>
-
- <interceptor-stack name="pollenBasicAdminStack">
- <!-- interceptor-ref name="checkUserLoggued" />
- <interceptor-ref name="checkUserAdmin"/ -->
- <interceptor-ref name="pollenBasicStack"/>
- </interceptor-stack>
-
<!-- params stack with params-->
<interceptor-stack name="pollenParamsPrepareParamsStack">
<interceptor-ref name="i18n"/>
@@ -134,17 +112,6 @@
</interceptor-ref>
</interceptor-stack>
- <interceptor-stack name="pollenParamsPrepareParamsLogguedStack">
- <!--<interceptor-ref name="checkUserLoggued"/>-->
- <interceptor-ref name="pollenParamsPrepareParamsStack"/>
- </interceptor-stack>
-
- <interceptor-stack name="pollenParamsPrepareParamsAdminStack">
- <!--<interceptor-ref name="checkUserLoggued"/>-->
- <!--<interceptor-ref name="checkUserAdmin"/>-->
- <interceptor-ref name="pollenParamsPrepareParamsStack"/>
- </interceptor-stack>
-
</interceptors>
<!-- must be authenticated to perform any actions -->
@@ -193,6 +160,16 @@
</package>
+ <package name="security" extends="default" namespace="/security">
+
+ <default-interceptor-ref name="pollenBasicStack"/>
+
+ <action name="*">
+ <result>/WEB-INF/jsp/security/{1}.jsp</result>
+ </action>
+
+ </package>
+
<include file="config/struts-json.xml"/>
<include file="config/struts-admin.xml"/>
<include file="config/struts-poll.xml"/>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp 2012-03-23 21:32:36 UTC (rev 3207)
@@ -27,118 +27,23 @@
<script type="text/javascript"
src="<s:url value='/js/gridHelper.js' />"></script>
+<script type="text/javascript"
+ src="<s:url value='/js/usersList.js' />"></script>
+
<title><s:text name="pollen.title.usersList"/></title>
<h1 class="title${pageLogo}"><s:text name="pollen.title.usersList"/></h1>
<s:url id="loadUsers" action="getUsers" namespace="/json" escapeAmp="false"/>
-<s:url id="loadUser" action="getUser" namespace="/json"/>
-
<s:set var="user" value="%{#session.pollenSession.userAccount}"/>
<script type="text/javascript">
-
jQuery(document).ready(function () {
-
- var action='${action}';
-
- if ('${action}' == 'create') {
- $('#createForm').show();
- }
- if ('${action}' == 'edit') {
- $('#editForm').show();
- }
- if ('${action}' == 'delete') {
- $('#deleteForm').show();
- }
-
- // listen row selection
- $.addRowSelectTopic('users');
-
- $.addClearSelectTopic('users', function(){
- if (action !='') {
- // come back from action
- action='';
- return;
- }
- $(".userForm").hide();
- });
-
- // to create a new row
- $.listenRowTopic('users-addRow', function(event) {
-
- $('#createForm .errorMessage').hide();
- $('#createForm [name="createUser.login"]').val("");
- $('#createForm [name="createUser.email"]').val("");
- $('#createForm [name="createUser.firstName"]').val("");
- $('#createForm [name="createUser.lastName"]').val("");
- $('#createForm [name="createUser.administrator"]').prop('checked',false);
- $('#editForm').hide();
- $('#deleteForm').hide();
- $('#createForm').show();
- });
-
- // to edit a selected row
- $.listenRowTopic('users-editRow', function (event) {
- var id = $.getSelectedId('users');
- if(!id) {
-
- // no user selected
- return;
- }
- $('#editForm .errorMessage').hide();
- jQuery.getJSON("${loadUser}", { "userId":id }, function (result) {
-
- var user = result.user;
- $('#editForm [name="editUser.topiaId"]').val(user.id);
- $('#editForm [name="editUser.login"]').val(user.login);
- $('#editForm [name="editUser.email"]').val(user.email);
- $('#editForm [name="editUser.firstName"]').val(user.firstName);
- $('#editForm [name="editUser.lastName"]').val(user.lastName);
- $('#editForm [name="editUser.administrator"]').prop('checked',false);
- $('#editForm [name="editUser.administrator"]').prop('checked',user.administrator);
- $('#editForm').show();
- $('#createForm').hide();
- $('#deleteForm').hide();
- }
- );
- });
-
- // to delete the selected row
- $.listenRowTopic('users-deleteRow', function(event) {
- var id = $.getSelectedId('users');
- if(!id) {
-
- // no user selected
- return;
- }
-
- var userId = '${user.topiaId}';
-
- if (id == userId) {
-
- // can not delete connected user
- return;
- }
- $('#deleteForm .errorMessage').hide();
-
- jQuery.getJSON("${loadUser}", { "userId":id }, function (result) {
-
- var user = result.user;
- $('#deleteForm [name="deleteUser.topiaId"]').val(user.id);
- $('#deleteForm [name="deleteUser.login"]').val(user.login);
- $('#deleteForm [name="deleteUser.email"]').val(user.email);
- $('#deleteForm [name="deleteUser.firstName"]').val(user.firstName);
- $('#deleteForm [name="deleteUser.lastName"]').val(user.lastName);
- $('#deleteForm [name="deleteUser.administrator"]').prop('checked',false);
- $('#deleteForm [name="deleteUser.administrator"]').prop('checked',user.administrator);
- $('#editForm').hide();
- $('#createForm').hide();
- $('#deleteForm').show();
- }
- );
- });
+ initUsersPage(
+ '${action}',
+ '<s:url action="getUser" namespace="/json"/>'
+ );
});
</script>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClonePoll.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClonePoll.jsp 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClonePoll.jsp 2012-03-23 21:32:36 UTC (rev 3207)
@@ -2,8 +2,8 @@
#%L
Pollen :: UI (strust2)
- $Id: confirmDeletePoll.jsp 3185 2012-03-14 14:43:26Z tchemit $
- $HeadURL: http://svn.chorem.org/svn/pollen/branches/pollen-1.2.6-struts2/pollen-ui-st… $
+ $Id$
+ $HeadURL$
%%
Copyright (C) 2009 - 2012 CodeLutin
%%
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmClonePoll.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/admin_required.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/admin_required.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/admin_required.jsp 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,28 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 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%
+ --%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head><title></title></head>
+<body>Vous devez être connecter en administrateur pour accéder à cette page.</body>
+</html>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/admin_required.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/connected_required.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/connected_required.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/connected_required.jsp 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,28 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 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%
+ --%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head><title></title></head>
+<body>Vous devez être connecter pour accéder à cette page.</body>
+</html>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/connected_required.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_access_required.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_access_required.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_access_required.jsp 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,28 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 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%
+ --%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head><title></title></head>
+<body>Vous n'êtes pas autorisé à accéder à cette page de sondage.</body>
+</html>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_access_required.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_creator_required.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_creator_required.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_creator_required.jsp 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,28 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 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%
+ --%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head><title></title></head>
+<body>Seul le créateur du sondage ou un administratuer peut accéder à cette page.</body>
+</html>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_creator_required.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_required.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_required.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_required.jsp 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,28 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 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%
+ --%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head><title></title></head>
+<body>Aucun sondage à l'url donné.</body>
+</html>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/security/poll_required.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp 2012-03-23 21:32:36 UTC (rev 3207)
@@ -27,103 +27,33 @@
<script type="text/javascript"
src="<s:url value='/js/gridHelper.js' />"></script>
+<script type="text/javascript"
+ src="<s:url value='/js/favoriteList.js' />"></script>
+
<s:url id="loadPollAccounts" action="getFavoriteListPollAccounts"
namespace="/json" escapeAmp="false">
- <s:param name="favoriteListId" value="%{favoriteListId}"/>
+ <s:param name="favoriteListId" value="%{favoriteList.topiaId}"/>
</s:url>
-<s:url id="loadPollAccount" action="getFavoriteListPollAccount"
- namespace="/json"/>
-
<script type="text/javascript">
jQuery(document).ready(function () {
- var action = '${action}';
-
- if ('${action}' == 'create') {
- $('#createForm').show();
- } else if ('${action}' == 'edit') {
- $('#editForm').show();
- } else if ('${action}' == 'delete') {
- $('#deleteForm').show();
- }
-
- // listen row selection
- $.addRowSelectTopic('pollAccounts');
-
- $.addClearSelectTopic('pollAccounts', function () {
- if (action != '') {
- // come back from action
- action = '';
- return;
- }
- $(".pollAccountForm").hide();
- });
-
- // to create a new row
- $.listenRowTopic('pollAccounts-addRow', function (event) {
- $('#createForm [name="createPollAccount.votingId"]').val("");
- $('#createForm [name="createPollAccount.email"]').val("");
- $('#deleteForm').hide();
- $('#editForm').hide();
- $('#createForm').show();
- });
-
- // to edit the selected row
- $.listenRowTopic('pollAccounts-editRow', function (event) {
- var id = $.getSelectedId('pollAccounts');
- if (!id) {
-
- // no row selected
- return;
- }
-
- jQuery.getJSON("${loadPollAccount}", { "pollAccountId":id },
- function (result) {
-
- var pollAccount = result.pollAccount;
- $('#editForm [name="editPollAccount.topiaId"]').val(pollAccount.id);
- $('#editForm [name="editPollAccount.votingId"]').val(pollAccount.votingId);
- $('#editForm [name="editPollAccount.email"]').val(pollAccount.email);
- $('#deleteForm').hide();
- $('#createForm').hide();
- $('#editForm').show();
- }
- );
- });
-
- // to delete the selected row
- $.listenRowTopic('pollAccounts-deleteRow', function (event) {
- var id = $.getSelectedId('pollAccounts');
- if (!id) {
-
- // no row selected
- return;
- }
-
- jQuery.getJSON("${loadPollAccount}", { "pollAccountId":id },
- function (result) {
-
- var pollAccount = result.pollAccount;
- $('#deleteForm [name="deletePollAccount.topiaId"]').val(pollAccount.id);
- $('#deleteForm [name="deletePollAccount.votingId"]').val(pollAccount.votingId);
- $('#deleteForm [name="deletePollAccount.email"]').val(pollAccount.email);
- $('#editForm').hide();
- $('#createForm').hide();
- $('#deleteForm').show();
- }
- );
- });
+ initFavoritePage(
+ '${action}',
+ '<s:url action="getFavoriteListPollAccount" namespace="/json"/>'
+ );
});
</script>
<title>
- <s:text name="pollen.title.editFavoriteList"/> ${favoriteList.name}
+ <s:text name="pollen.title.editFavoriteList"/> <s:property
+ value="favoriteList.name"/>
</title>
<h1 class="title${pageLogo}">
- <s:text name="pollen.title.editFavoriteList"/> ${favoriteList.name}
+ <s:text name="pollen.title.editFavoriteList"/> <s:property
+ value="favoriteList.name"/>
</h1>
<sjg:grid id="pollAccounts" dataType="json" href="%{loadPollAccounts}"
@@ -207,7 +137,8 @@
</fieldset>
<br/>
- <s:submit action="removePollAccount" key="pollen.action.delete" align="center"/>
+ <s:submit action="removePollAccount" key="pollen.action.delete"
+ align="center"/>
</s:form>
<br/>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp 2012-03-23 21:30:45 UTC (rev 3206)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp 2012-03-23 21:32:36 UTC (rev 3207)
@@ -27,81 +27,27 @@
<script type="text/javascript"
src="<s:url value='/js/gridHelper.js' />"></script>
+<script type="text/javascript"
+ src="<s:url value='/js/favoriteLists.js' />"></script>
+
<title><s:text name="pollen.title.favoriteLists"/></title>
<h1 class="title${pageLogo}"><s:text name="pollen.title.favoriteLists"/></h1>
<s:url id="loadFavoriteLists" action="getFavoriteLists" namespace="/json"/>
-<s:url id="loadFavoriteList" action="getFavoriteList" namespace="/json"/>
<script type="text/javascript">
jQuery(document).ready(function () {
- var action = '${action}';
-
- if ('${action}' == 'create') {
- $('#createForm').show();
- } else if ('${action}' == 'delete') {
- $('#deleteForm').show();
- }
-
- // listen row selection
- $.addRowSelectTopic('favoriteLists');
-
- $.addClearSelectTopic('favoriteLists', function () {
- if (action != '') {
- // come back from action
- action = '';
- return;
- }
- $(".userForm").hide();
- });
-
- // to create a new row
- $.listenRowTopic('favoriteLists-addRow', function (event) {
-
- $('#createForm .errorMessage').hide();
- $('#createForm [name="favoriteList.name"]').val("");
- $('#createForm [name="csvImport"]').val("");
- $('#createForm [name="ldapImport"]').val("");
- $('#deleteForm').hide();
- $('#createForm').show();
- });
-
- // to edit a selected row
- $.listenRowTopic('favoriteLists-editRow', function (event) {
- var id = $.getSelectedId('favoriteLists');
- if (!id) {
- // no row selected
- return;
- }
-
- $('#editForm [name="favoriteListId"]').val(id);
- $('#editForm').submit();
- });
-
- // to delete the selected row
- $.listenRowTopic('favoriteLists-deleteRow', function (event) {
- var id = $.getSelectedId('favoriteLists');
- if (!id) {
- // no row selected
- return;
- }
- jQuery.getJSON("${loadFavoriteList}", { favoriteListId:id },
- function (result) {
- var user = result.favoriteList;
- $('#deleteForm [name="deleteFavoriteList.topiaId"]').val(user.id);
- $('#deleteForm [name="deleteFavoriteList.name"]').val(user.name);
- $('#createForm').hide();
- $('#deleteForm').show();
- }
- );
- });
+ initFavoritesPage(
+ '${action}',
+ '<s:url action="getFavoriteList" namespace="/json"/>'
+ );
});
</script>
-<sjg:grid id="favoriteLists" dataType="json" href="%{loadFavoriteLists}"
+<sjg:grid id="favoriteLists" dataType="json" href='%{loadFavoriteLists}'
gridModel="favoriteLists" sortable="true" pager="true"
pagerButtons="true" pagerInput="true" navigator="true"
rownumbers="false" autowidth="true" viewrecords="true"
@@ -153,7 +99,6 @@
</legend>
<s:textfield key="deleteFavoriteList.name" required="true" readonly="true"
size="40" label="%{getText('pollen.common.name')}"/>
-
</fieldset>
<br/>
<s:submit action="deleteFavoriteList" key="pollen.action.delete"
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,99 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
+function initFavoritePage(action, loadPollActionUrl) {
+ if (action == 'create') {
+ $('#createForm').show();
+ } else if (action == 'edit') {
+ $('#editForm').show();
+ } else if (action == 'delete') {
+ $('#deleteForm').show();
+ }
+
+ // listen row selection
+ $.addRowSelectTopic('pollAccounts');
+
+ $.addClearSelectTopic('pollAccounts', function () {
+ if (action != '') {
+ // come back from action
+ action = '';
+ return;
+ }
+ $(".pollAccountForm").hide();
+ });
+
+ // to create a new row
+ $.listenRowTopic('pollAccounts-addRow', function (event) {
+ $('#createForm [name="createPollAccount.votingId"]').val("");
+ $('#createForm [name="createPollAccount.email"]').val("");
+ $('#deleteForm').hide();
+ $('#editForm').hide();
+ $('#createForm').show();
+ });
+
+ // to edit the selected row
+ $.listenRowTopic('pollAccounts-editRow', function (event) {
+ var id = $.getSelectedId('pollAccounts');
+ if (!id) {
+
+ // no row selected
+ return;
+ }
+
+ jQuery.getJSON(loadPollActionUrl, { "pollAccountId":id },
+ function (result) {
+
+ var pollAccount = result.pollAccount;
+ $('#editForm [name="editPollAccount.topiaId"]').val(pollAccount.id);
+ $('#editForm [name="editPollAccount.votingId"]').val(pollAccount.votingId);
+ $('#editForm [name="editPollAccount.email"]').val(pollAccount.email);
+ $('#deleteForm').hide();
+ $('#createForm').hide();
+ $('#editForm').show();
+ }
+ );
+ });
+
+ // to delete the selected row
+ $.listenRowTopic('pollAccounts-deleteRow', function (event) {
+ var id = $.getSelectedId('pollAccounts');
+ if (!id) {
+
+ // no row selected
+ return;
+ }
+
+ jQuery.getJSON(loadPollActionUrl, { "pollAccountId":id },
+ function (result) {
+
+ var pollAccount = result.pollAccount;
+ $('#deleteForm [name="deletePollAccount.topiaId"]').val(pollAccount.id);
+ $('#deleteForm [name="deletePollAccount.votingId"]').val(pollAccount.votingId);
+ $('#deleteForm [name="deletePollAccount.email"]').val(pollAccount.email);
+ $('#editForm').hide();
+ $('#createForm').hide();
+ $('#deleteForm').show();
+ }
+ );
+ });
+}
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,84 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
+function initFavoritesPage(action, loadFavoriteList) {
+
+ if (action == 'create') {
+ $('#createForm').show();
+ } else if (action == 'delete') {
+ $('#deleteForm').show();
+ }
+
+ // listen row selection
+ $.addRowSelectTopic('favoriteLists');
+
+ $.addClearSelectTopic('favoriteLists', function () {
+ if (action != '') {
+ // come back from action
+ action = '';
+ return;
+ }
+ $(".userForm").hide();
+ });
+
+ // to create a new row
+ $.listenRowTopic('favoriteLists-addRow', function (event) {
+
+ $('#createForm .errorMessage').hide();
+ $('#createForm [name="favoriteList.name"]').val("");
+ $('#createForm [name="csvImport"]').val("");
+ $('#createForm [name="ldapImport"]').val("");
+ $('#deleteForm').hide();
+ $('#createForm').show();
+ });
+
+ // to edit a selected row
+ $.listenRowTopic('favoriteLists-editRow', function (event) {
+ var id = $.getSelectedId('favoriteLists');
+ if (!id) {
+ // no row selected
+ return;
+ }
+
+ $('#editForm [name="favoriteListId"]').val(id);
+ $('#editForm').submit();
+ });
+
+ // to delete the selected row
+ $.listenRowTopic('favoriteLists-deleteRow', function (event) {
+ var id = $.getSelectedId('favoriteLists');
+ if (!id) {
+ // no row selected
+ return;
+ }
+ jQuery.getJSON(loadFavoriteList, { favoriteListId:id },
+ function (result) {
+ var user = result.favoriteList;
+ $('#deleteForm [name="deleteFavoriteList.topiaId"]').val(user.id);
+ $('#deleteForm [name="deleteFavoriteList.name"]').val(user.name);
+ $('#createForm').hide();
+ $('#deleteForm').show();
+ }
+ );
+ });
+}
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js 2012-03-23 21:32:36 UTC (rev 3207)
@@ -0,0 +1,122 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
+function initUsersPage(action, loadUserUrl) {
+
+ if (action == 'create') {
+ $('#createForm').show();
+ }
+ if (action == 'edit') {
+ $('#editForm').show();
+ }
+ if (action == 'delete') {
+ $('#deleteForm').show();
+ }
+
+ // listen row selection
+ $.addRowSelectTopic('users');
+
+ $.addClearSelectTopic('users', function () {
+ if (action != '') {
+ // come back from action
+ action = '';
+ return;
+ }
+ $(".userForm").hide();
+ });
+
+ // to create a new row
+ $.listenRowTopic('users-addRow', function (event) {
+
+ $('#createForm .errorMessage').hide();
+ $('#createForm [name="createUser.login"]').val("");
+ $('#createForm [name="createUser.email"]').val("");
+ $('#createForm [name="createUser.firstName"]').val("");
+ $('#createForm [name="createUser.lastName"]').val("");
+ $('#createForm [name="createUser.administrator"]').prop('checked', false);
+ $('#editForm').hide();
+ $('#deleteForm').hide();
+ $('#createForm').show();
+ });
+
+ // to edit a selected row
+ $.listenRowTopic('users-editRow', function (event) {
+ var id = $.getSelectedId('users');
+ if (!id) {
+
+ // no user selected
+ return;
+ }
+ $('#editForm .errorMessage').hide();
+ jQuery.getJSON(loadUserUrl, { "userId":id }, function (result) {
+
+ var user = result.user;
+ $('#editForm [name="editUser.topiaId"]').val(user.id);
+ $('#editForm [name="editUser.login"]').val(user.login);
+ $('#editForm [name="editUser.email"]').val(user.email);
+ $('#editForm [name="editUser.firstName"]').val(user.firstName);
+ $('#editForm [name="editUser.lastName"]').val(user.lastName);
+ $('#editForm [name="editUser.administrator"]').prop('checked', false);
+ $('#editForm [name="editUser.administrator"]').prop('checked', user.administrator);
+ $('#editForm').show();
+ $('#createForm').hide();
+ $('#deleteForm').hide();
+ }
+ );
+ });
+
+ // to delete the selected row
+ $.listenRowTopic('users-deleteRow', function (event) {
+ var id = $.getSelectedId('users');
+ if (!id) {
+
+ // no user selected
+ return;
+ }
+
+ var userId = '${user.topiaId}';
+
+ if (id == userId) {
+
+ // can not delete connected user
+ return;
+ }
+ $('#deleteForm .errorMessage').hide();
+
+ jQuery.getJSON(loadUserUrl, { "userId":id }, function (result) {
+
+ var user = result.user;
+ $('#deleteForm [name="deleteUser.topiaId"]').val(user.id);
+ $('#deleteForm [name="deleteUser.login"]').val(user.login);
+ $('#deleteForm [name="deleteUser.email"]').val(user.email);
+ $('#deleteForm [name="deleteUser.firstName"]').val(user.firstName);
+ $('#deleteForm [name="deleteUser.lastName"]').val(user.lastName);
+ $('#deleteForm [name="deleteUser.administrator"]').prop('checked', false);
+ $('#deleteForm [name="deleteUser.administrator"]').prop('checked', user.administrator);
+ $('#editForm').hide();
+ $('#createForm').hide();
+ $('#deleteForm').show();
+ }
+ );
+ });
+}
\ No newline at end of file
1
0
r3206 - in branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen: bean services/impl
by tchemit@users.chorem.org 23 Mar '12
by tchemit@users.chorem.org 23 Mar '12
23 Mar '12
Author: tchemit
Date: 2012-03-23 22:30:45 +0100 (Fri, 23 Mar 2012)
New Revision: 3206
Url: http://chorem.org/repositories/revision/pollen/3206
Log:
add PollUri object + security method in PollService
Added:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
Added: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java 2012-03-23 21:30:45 UTC (rev 3206)
@@ -0,0 +1,77 @@
+/*
+ * #%L
+ * Pollen :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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%
+ */
+package org.chorem.pollen.bean;
+
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class PollUri {
+
+ public static PollUri newPollUri(String uri) {
+
+ PollUri result = new PollUri();
+
+ String[] split = uri.split(":", 2);
+ if (split.length > 0) {
+ result.setPollId(split[0]);
+ if (split.length > 1) {
+ result.setAccountId(split[1]);
+ }
+ }
+ return result;
+ }
+
+ protected String pollId;
+
+ protected String accountId;
+
+ public String getPollId() {
+ return pollId;
+ }
+
+ public String getAccountId() {
+ return accountId;
+ }
+
+ public void setPollId(String pollId) {
+ this.pollId = pollId;
+ }
+
+ public void setAccountId(String accountId) {
+ this.accountId = accountId;
+ }
+
+ public String getUri() {
+ String result = pollId;
+ if (StringUtils.isNotEmpty(accountId)) {
+ result += ":" + accountId;
+ }
+ return result;
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-23 17:15:58 UTC (rev 3205)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-23 21:30:45 UTC (rev 3206)
@@ -31,6 +31,7 @@
import org.chorem.pollen.PollenTechnicalException;
import org.chorem.pollen.bean.PollDateChoice;
import org.chorem.pollen.bean.PollImageChoice;
+import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.ChoiceDAO;
import org.chorem.pollen.business.persistence.PersonToList;
@@ -47,6 +48,7 @@
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.common.ChoiceType;
+import org.chorem.pollen.common.PollType;
import org.chorem.pollen.services.PollenServiceSupport;
import org.chorem.pollen.services.exceptions.PollAccountNotFound;
import org.chorem.pollen.services.exceptions.PollChoiceNotFoundException;
@@ -153,7 +155,6 @@
PreventRuleDAO preventRuleDAO = getDAO(PreventRule.class);
for (PreventRule preventRule : poll.getPreventRule()) {
-
PreventRule preventRuleCreated = create(preventRuleDAO);
preventRuleCreated.setActive(preventRule.isActive());
preventRuleCreated.setMethod(preventRule.getMethod());
@@ -522,32 +523,68 @@
commitTransaction("Could not delete choice " + choice.getName());
}
- public PollAccount getRestrictedAccount(String pollId,
- String accountId) throws PollNotFoundException {
+ public void checkPoll(PollUri uri) throws PollNotFoundException {
+
+ String pollId = uri.getPollId();
+
Poll poll = getPollByPollId(pollId);
if (poll == null) {
throw new PollNotFoundException();
}
+ }
- if (log.isInfoEnabled()) {
- log.info("getRestrictedAccount : accountId = " + accountId +
- " _ pollId = " + poll.getPollId());
+ public void checkPollAccount(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
+
+ String pollId = uri.getPollId();
+ String accountId = uri.getAccountId();
+
+ Poll poll = getPollByPollId(pollId);
+
+ if (poll == null) {
+ throw new PollNotFoundException();
}
- // Use PersonToList association entity to find coherence between
- // the poll and votingId
- PollAccountDAO dao = getDAO(PollAccount.class);
+ if (poll.getPollType() != PollType.FREE) {
- try {
- PollAccount result = dao.getRestrictedPollAccount(pollId, accountId);
- return result;
- } catch (TopiaException e) {
- throw new PollenTechnicalException(
- "Could not obtain restricted pollAccount", e);
+ // check that uri contains a correct poll account for this
+
+ // Use PersonToList association entity to find coherence between
+ // the poll and votingId
+ PollAccountDAO dao = getDAO(PollAccount.class);
+
+ try {
+ PollAccount result =
+ dao.getRestrictedPollAccount(pollId, accountId);
+
+ if (result == null) {
+ throw new UnauthorizedPollAccessException();
+ }
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(
+ "Could not obtain restricted pollAccount", e);
+ }
}
}
+ public void checkPollCreator(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
+
+ String pollId = uri.getPollId();
+ String accountId = uri.getAccountId();
+
+ Poll poll = getPollByPollId(pollId);
+
+ if (poll == null) {
+ throw new PollNotFoundException();
+ }
+
+ String creatorId = poll.getCreator().getAccountId();
+
+ if (!creatorId.equals(accountId)) {
+ throw new UnauthorizedPollAccessException();
+ }
+ }
+
public File getPollChoiceImageFile(String pollId,
String choiceId,
boolean thumb) {
@@ -613,8 +650,8 @@
pollToUpdate.addVote(voteToAdd);
commitTransaction("Can't add the vote [" + voteId + "] to the poll [" + pollId + "]");
-
-
+
+
// TopiaContext transaction = null;
// try {
// transaction = rootContext.beginTransaction();
1
0