Author: tchemit Date: 2012-07-31 18:21:30 +0200 (Tue, 31 Jul 2012) New Revision: 3579 Url: http://chorem.org/repositories/revision/pollen/3579 Log: fixes #715: Import voting users list doesn't work remove bad action as CRUD prefer to have one class per action (avoid introduce bad state design) Added: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/CreateFavoriteList.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/CreateFavoriteListVoter.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteListVoter.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/EditFavoriteList.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/EditFavoriteListVoter.java Removed: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java trunk/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/ trunk/pollen-ui-struts2/src/main/resources/validators.xml Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Edit.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java trunk/pollen-ui-struts2/src/main/resources/config/struts-user.xml trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/edit.jsp trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/register.jsp trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/show.jsp trunk/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java 2012-07-31 16:21:30 UTC (rev 3579) @@ -24,7 +24,6 @@ import com.google.common.base.Preconditions; import org.apache.commons.lang3.StringUtils; -import org.chorem.pollen.business.persistence.PollAccount; import org.chorem.pollen.business.persistence.UserAccount; import org.chorem.pollen.services.exceptions.UserEmailAlreadyUsedException; import org.chorem.pollen.services.exceptions.UserInvalidPasswordException; Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-07-31 16:21:30 UTC (rev 3579) @@ -63,8 +63,7 @@ import org.chorem.pollen.services.impl.PollService; import org.chorem.pollen.services.impl.PreventRuleService; import org.chorem.pollen.ui.actions.FileUploadAware; -import org.chorem.pollen.ui.actions.PageSkin; -import org.chorem.pollen.ui.actions.PollenActionSupport; +import org.chorem.pollen.ui.actions.PollenActionSupportForEdition; import org.chorem.pollen.ui.converters.DateConverter; import org.chorem.pollen.votecounting.strategy.VoteCountingStrategy; import org.chorem.pollen.votecounting.strategy.VoteCountingStrategyProvider; @@ -90,7 +89,7 @@ * @author fdesbois <desbois@codelutin.com> * $Id$ */ -public abstract class AbstractPollForm extends PollenActionSupport implements Preparable, ParameterAware, FileUploadAware, ServletRequestAware { +public abstract class AbstractPollForm extends PollenActionSupportForEdition implements Preparable, ParameterAware, FileUploadAware, ServletRequestAware { private static final long serialVersionUID = 1L; @@ -575,11 +574,6 @@ this.parameters.putAll(parameters); } - @Override - public PageSkin getSkin() { - return PageSkin.EDITION; - } - public boolean isInformationsError() { return informationsError; } Added: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/CreateFavoriteList.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/CreateFavoriteList.java (rev 0) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/CreateFavoriteList.java 2012-07-31 16:21:30 UTC (rev 3579) @@ -0,0 +1,207 @@ +package org.chorem.pollen.ui.actions.user; +/* + * #%L + * Pollen :: UI (struts2) + * $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% + */ + +import com.google.common.base.Preconditions; +import org.apache.commons.lang3.StringUtils; +import org.chorem.pollen.business.persistence.PersonList; +import org.chorem.pollen.business.persistence.PollAccount; +import org.chorem.pollen.services.exceptions.FavoriteListAlreadyExistException; +import org.chorem.pollen.services.exceptions.FavoriteListImportException; +import org.chorem.pollen.services.exceptions.FavoriteListNotFoundException; +import org.chorem.pollen.services.exceptions.ParticipantAlreadyFoundInListException; +import org.chorem.pollen.services.impl.FavoriteService; +import org.chorem.pollen.ui.actions.FileUploadAware; +import org.chorem.pollen.ui.actions.PollenActionSupportForEdition; + +import java.io.File; +import java.util.List; + +/** + * To create a new favorite list. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.5 + */ +public class CreateFavoriteList extends PollenActionSupportForEdition implements FileUploadAware { + + private static final long serialVersionUID = 1L; + + protected PersonList createFavoriteList; + + protected File csvImport; + + protected String csvImportContentType; + + protected String csvImportFileName; + + protected String ldapImport; + + @Override + public void addFile(int index, File file) { + csvImport = file; + } + + @Override + public void addFileContentType(int index, String contentType) { + csvImportContentType = contentType; + } + + @Override + public void addFileName(int index, String fileName) { + csvImportFileName = fileName; + } + + public void setLdapImport(String ldapImport) { + this.ldapImport = ldapImport; + } + + public PersonList getCreateFavoriteList() { + if (createFavoriteList == null) { + createFavoriteList = getFavoriteService().newFavoriteList(); + } + return createFavoriteList; + } + + public String getLdapImport() { + return ldapImport; + } + + public String getAction() { + return "create"; + } + + @Override + public void validate() { + + if (StringUtils.isBlank(getCreateFavoriteList().getName())) { + addFieldError("createFavoriteList.name", + _("pollen.error.favoriteListName.required")); + } + + } + + @Override + public String execute() throws Exception { + + Preconditions.checkNotNull(createFavoriteList); + Preconditions.checkNotNull(createFavoriteList.getName()); + + int nbImports = 0; + try { + PersonList personList = + getFavoriteService().createFavoriteList(getPollenUserAccount(), + createFavoriteList.getName()); + + if (csvImportFileName != null) { + + nbImports = addImportFromCsv(personList); + } + + if (StringUtils.isNotBlank(ldapImport)) { + + nbImports = addImportFromLDAP(personList); + } + + } catch (FavoriteListAlreadyExistException ex) { + addFieldError("createFavoriteList.name", + _("pollen.error.favoriteList.already.used")); + } + + String result; + if (hasAnyErrors()) { + result = INPUT; + + } else { + getTransaction().commitTransaction(); + + if (nbImports > 0) { + addFlashMessage(_("pollen.information.favoriteList.imported", + createFavoriteList.getName(), nbImports)); + } else { + + addFlashMessage(_("pollen.information.favoriteList.created", + createFavoriteList.getName())); + } + createFavoriteList = null; + result = SUCCESS; + } + return result; + } + + protected int addImportFromCsv(PersonList personList) throws FavoriteListNotFoundException { + + int nbImports = 0; + + try { + List<PollAccount> importedAccounts = getFavoriteService().importFromCsvfile( + csvImportFileName, csvImport); + + nbImports = addImport(importedAccounts, personList); + + } catch (FavoriteListImportException ex) { + String message = ex.getLocalizedMessage(getLocale()); + addFlashError(message); + } + return nbImports; + } + + protected int addImportFromLDAP(PersonList personList) throws FavoriteListNotFoundException { + + int nbImports = 0; + + try { + List<PollAccount> importedAccounts = getFavoriteService().importFromLDAP( + ldapImport); + + nbImports = addImport(importedAccounts, personList); + + } catch (FavoriteListImportException ex) { + String message = ex.getLocalizedMessage(getLocale()); + addFlashError(message); + } + return nbImports; + } + + protected int addImport(List<PollAccount> importedAccounts, + PersonList list) + throws FavoriteListNotFoundException { + + FavoriteService favoriteService = getFavoriteService(); + + for (PollAccount importedAccount : importedAccounts) { + try { + favoriteService.addPollAccountToFavoriteList(list, importedAccount); + + } catch (ParticipantAlreadyFoundInListException ex) { + // WARNING ? + addFlashError( + _("pollen.error.favoriteList.import.participantExists" + , importedAccount.getEmail()) + ); + } + } + + return importedAccounts.size(); + } +} \ No newline at end of file Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/CreateFavoriteList.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/CreateFavoriteListVoter.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/CreateFavoriteListVoter.java (rev 0) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/CreateFavoriteListVoter.java 2012-07-31 16:21:30 UTC (rev 3579) @@ -0,0 +1,124 @@ +package org.chorem.pollen.ui.actions.user; + +import com.google.common.base.Preconditions; +import com.opensymphony.xwork2.Preparable; +import org.apache.commons.lang3.StringUtils; +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; +import org.chorem.pollen.services.exceptions.FavoriteListNotOwnedByUserException; +import org.chorem.pollen.services.exceptions.ParticipantAlreadyFoundInListException; +import org.chorem.pollen.ui.actions.PollenActionSupportForEdition; +import org.nuiton.util.StringUtil; + +import java.util.Map; + +/** + * Creates a new {@link PollAccount} inside a selected {@link PersonList}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.5 + */ +public class CreateFavoriteListVoter extends PollenActionSupportForEdition implements Preparable, ParameterAware { + + private static final long serialVersionUID = 1L; + + private Map<String, String[]> parameters; + + protected PersonList favoriteList; + + protected PollAccount pollAccount; + + public PollAccount getCreatePollAccount() { + return getPollAccount(); + } + + public PersonList getFavoriteList() { + return favoriteList; + } + + public String getFavoriteListId() { + return favoriteList.getTopiaId(); + } + + public String getAction() { + return "create"; + } + + @Override + public void prepare() throws Exception { + + String[] favoriteListIds = parameters.get("favoriteListId"); + Preconditions.checkNotNull(favoriteListIds); + Preconditions.checkArgument(favoriteListIds.length == 1); + String favoriteListId = favoriteListIds[0]; + + try { + favoriteList = getFavoriteService().getFavoriteList( + getPollenUserAccount(), favoriteListId); + } catch (FavoriteListNotFoundException e) { + addFlashError(_("pollen.error.favoriteList.not.found")); + } catch (FavoriteListNotOwnedByUserException e) { + addFlashError(_("pollen.error.favoriteList.not.owned.by.user")); + } + } + + @Override + public void validate() { + + PollAccount account = getCreatePollAccount(); + + if (StringUtils.isBlank(account.getVotingId())) { + addFieldError("createPollAccount.votingId", + _("pollen.error.pollAccount.votingId.required")); + } + + if (StringUtils.isBlank(account.getEmail())) { + addFieldError("createPollAccount.email", + _("pollen.error.email.required")); + } else if (!StringUtil.isEmail(account.getEmail())) { + addFieldError("createPollAccount.email", + _("pollen.error.email.invalid")); + } + + } + + @Override + public String execute() throws Exception { + + Preconditions.checkNotNull(favoriteList); + Preconditions.checkNotNull(pollAccount); + + String result = INPUT; + + try { + + getFavoriteService().addPollAccountToFavoriteList( + favoriteList, pollAccount); + + addFlashMessage( + _("pollen.information.pollAccount.addedTofavoriteList", + pollAccount.getVotingId())); + + pollAccount = null; + result = SUCCESS; + } catch (ParticipantAlreadyFoundInListException e) { + addFieldError("createPollAccount.email", + _("pollen.error.favoriteList.participant.already.found.in.list")); + } + return result; + } + + protected PollAccount getPollAccount() { + if (pollAccount == null) { + pollAccount = getFavoriteService().newPollAccountForFavoriteList(); + } + return pollAccount; + } + + @Override + public void setParameters(Map<String, String[]> parameters) { + this.parameters = parameters; + } +} \ No newline at end of file Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/CreateFavoriteListVoter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Copied: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteListVoter.java (from rev 3573, trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java) =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteListVoter.java (rev 0) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteListVoter.java 2012-07-31 16:21:30 UTC (rev 3579) @@ -0,0 +1,83 @@ +/* + * #%L + * Pollen :: UI (struts2) + * $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.actions.user; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.business.persistence.PersonList; +import org.chorem.pollen.business.persistence.PollAccount; +import org.chorem.pollen.services.impl.FavoriteService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * Delete a selected favorite list for the connected user. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.3 + */ +public class DeleteFavoriteListVoter extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + protected String favoriteListId; + + protected String pollAccountId; + + protected String redirectUrl; + + public void setRedirectUrl(String redirectUrl) { + this.redirectUrl = redirectUrl; + } + + public void setFavoriteListId(String favoriteListId) { + this.favoriteListId = favoriteListId; + } + + public void setPollAccountId(String pollAccountId) { + this.pollAccountId = pollAccountId; + } + + public String getRedirectUrl() { + return redirectUrl; + } + + public String execute() throws Exception { + + Preconditions.checkNotNull(pollAccountId); + + FavoriteService service = getFavoriteService(); + + PersonList favoriteList = service.getEntityById(PersonList.class, + favoriteListId); + + PollAccount pollAccount = service.getEntityById(PollAccount.class, + pollAccountId); + + service.removePollAccountToFavoriteList(favoriteList, pollAccount); + + addFlashMessage( + _("pollen.information.pollAccount.removedFromFavoriteList", + pollAccount.getVotingId())); + + return SUCCESS; + } +} Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteListVoter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java 2012-07-31 16:21:30 UTC (rev 3579) @@ -1,83 +0,0 @@ -/* - * #%L - * Pollen :: UI (struts2) - * $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.actions.user; - -import com.google.common.base.Preconditions; -import org.chorem.pollen.business.persistence.PersonList; -import org.chorem.pollen.business.persistence.PollAccount; -import org.chorem.pollen.services.impl.FavoriteService; -import org.chorem.pollen.ui.actions.PollenActionSupport; - -/** - * Delete a selected favorite list for the connected user. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.3 - */ -public class DeletePollAccount extends PollenActionSupport { - - private static final long serialVersionUID = 1L; - - protected String favoriteListId; - - protected String pollAccountId; - - protected String redirectUrl; - - public void setRedirectUrl(String redirectUrl) { - this.redirectUrl = redirectUrl; - } - - public void setFavoriteListId(String favoriteListId) { - this.favoriteListId = favoriteListId; - } - - public void setPollAccountId(String pollAccountId) { - this.pollAccountId = pollAccountId; - } - - public String getRedirectUrl() { - return redirectUrl; - } - - public String execute() throws Exception { - - Preconditions.checkNotNull(pollAccountId); - - FavoriteService service = getFavoriteService(); - - PersonList favoriteList = service.getEntityById(PersonList.class, - favoriteListId); - - PollAccount pollAccount = service.getEntityById(PollAccount.class, - pollAccountId); - - service.removePollAccountToFavoriteList(favoriteList, pollAccount); - - addFlashMessage( - _("pollen.information.pollAccount.removedFromFavoriteList", - pollAccount.getVotingId())); - - return SUCCESS; - } -} Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Edit.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Edit.java 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Edit.java 2012-07-31 16:21:30 UTC (rev 3579) @@ -27,8 +27,7 @@ import org.chorem.pollen.business.persistence.UserAccount; import org.chorem.pollen.services.exceptions.UserEmailAlreadyUsedException; import org.chorem.pollen.services.exceptions.UserInvalidPasswordException; -import org.chorem.pollen.ui.actions.PageSkin; -import org.chorem.pollen.ui.actions.PollenActionSupport; +import org.chorem.pollen.ui.actions.PollenActionSupportForEdition; import org.nuiton.util.StringUtil; /** @@ -37,26 +36,21 @@ * @author tchemit <chemit@codelutin.com> * @since 1.3 */ -public class Edit extends PollenActionSupport { +public class Edit extends PollenActionSupportForEdition { private static final long serialVersionUID = 1L; - protected UserAccount user; + protected UserAccount pollenUserAccount; protected String newPassword; protected String newPassword2; - @Override - public PageSkin getSkin() { - return PageSkin.EDITION; - } - - public UserAccount getUser() { - if (user == null) { - user = getUserService().getNewUser(); + public UserAccount getPollenUserAccount() { + if (pollenUserAccount == null) { + pollenUserAccount = getUserService().getNewUser(); } - return user; + return pollenUserAccount; } public String getNewPassword() { @@ -75,10 +69,12 @@ this.newPassword2 = newPassword2; } + @Override public String input() throws Exception { - UserAccount userAccount = getPollenUserAccount(); - user = getUserService().getEntityById(UserAccount.class, - userAccount.getTopiaId()); + UserAccount userAccount = super.getPollenUserAccount(); + pollenUserAccount = getUserService().getEntityById( + UserAccount.class, + userAccount.getTopiaId()); return INPUT; } @@ -86,24 +82,29 @@ @Override public void validate() { - if (StringUtils.isBlank(user.getLogin())) { - addFieldError("user.login", _("pollen.error.login.required")); + if (StringUtils.isBlank(pollenUserAccount.getLogin())) { + addFieldError("pollenUserAccount.login", + _("pollen.error.login.required")); } - if (StringUtils.isBlank(user.getPassword())) { - addFieldError("user.password", _("pollen.error.password.required")); + if (StringUtils.isBlank(pollenUserAccount.getPassword())) { + addFieldError("pollenUserAccount.password", + _("pollen.error.password.required")); } if (StringUtils.isNotBlank(getNewPassword())) { if (ObjectUtils.notEqual(getNewPassword(), getNewPassword2())) { - addFieldError("newPassword", _("pollen.error.passwords.not.equals")); + addFieldError("newPassword", + _("pollen.error.passwords.not.equals")); } } - if (StringUtils.isBlank(user.getEmail())) { - addFieldError("user.email", _("pollen.error.email.required")); - } else if (!StringUtil.isEmail(user.getEmail())) { - addFieldError("user.email", _("pollen.error.email.invalid")); + if (StringUtils.isBlank(pollenUserAccount.getEmail())) { + addFieldError("pollenUserAccount.email", + _("pollen.error.email.required")); + } else if (!StringUtil.isEmail(pollenUserAccount.getEmail())) { + addFieldError("pollenUserAccount.email", + _("pollen.error.email.invalid")); } } @@ -111,25 +112,30 @@ public String execute() throws Exception { // let's push back admin property to user to save - user.setAdministrator( - getPollenUserAccount().isAdministrator()); + pollenUserAccount.setAdministrator( + super.getPollenUserAccount().isAdministrator()); String result = INPUT; try { UserAccount updatedUser = - getUserService().updateUser(user, newPassword, false); + getUserService().updateUser(pollenUserAccount, + newPassword, false); // push back user to session getPollenSession().setUserAccount(updatedUser); + + addFlashMessage(_("pollen.information.pollAccount.updated")); result = SUCCESS; } catch (UserEmailAlreadyUsedException e) { - addFieldError("user.email", _("pollen.error.user.email.already.used")); + addFieldError("pollenUserAccount.email", + _("pollen.error.user.email.already.used")); } catch (UserInvalidPasswordException e) { - addFieldError("user.password", _("pollen.error.user.invalid.password")); + addFieldError("pollenUserAccount.password", + _("pollen.error.user.invalid.password")); } // reset password - user.setPassword(null); + pollenUserAccount.setPassword(null); newPassword = newPassword2 = null; return result; Added: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/EditFavoriteList.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/EditFavoriteList.java (rev 0) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/EditFavoriteList.java 2012-07-31 16:21:30 UTC (rev 3579) @@ -0,0 +1,48 @@ +package org.chorem.pollen.ui.actions.user; + +import org.chorem.pollen.business.persistence.PersonList; +import org.chorem.pollen.services.exceptions.FavoriteListNotFoundException; +import org.chorem.pollen.services.exceptions.FavoriteListNotOwnedByUserException; +import org.chorem.pollen.ui.actions.PollenActionSupportForEdition; + +/** + * Edit a given {@link PersonList}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.5 + */ +public class EditFavoriteList extends PollenActionSupportForEdition { + + private static final long serialVersionUID = 1L; + + protected String favoriteListId; + + protected PersonList favoriteList; + + public void setFavoriteListId(String favoriteListId) { + this.favoriteListId = favoriteListId; + } + + public PersonList getFavoriteList() { + return favoriteList; + } + + public String getFavoriteListId() { + return favoriteList.getTopiaId(); + } + + @Override + public String execute() throws Exception { + + try { + favoriteList = getFavoriteService().getFavoriteList( + getPollenUserAccount(), favoriteListId); + } catch (FavoriteListNotFoundException e) { + addFlashError(_("pollen.error.favoriteList.not.found")); + } catch (FavoriteListNotOwnedByUserException e) { + addFlashError(_("pollen.error.favoriteList.not.owned.by.user")); + } + return SUCCESS; + } + +} \ No newline at end of file Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/EditFavoriteList.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/EditFavoriteListVoter.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/EditFavoriteListVoter.java (rev 0) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/EditFavoriteListVoter.java 2012-07-31 16:21:30 UTC (rev 3579) @@ -0,0 +1,120 @@ +package org.chorem.pollen.ui.actions.user; + +import com.google.common.base.Preconditions; +import com.opensymphony.xwork2.Preparable; +import org.apache.commons.lang3.StringUtils; +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; +import org.chorem.pollen.services.exceptions.FavoriteListNotOwnedByUserException; +import org.chorem.pollen.services.exceptions.ParticipantAlreadyFoundInListException; +import org.chorem.pollen.ui.actions.PollenActionSupportForEdition; +import org.nuiton.util.StringUtil; + +import java.util.Map; + +/** + * Edits a {@link PollAccount} inside a selected {@link PersonList}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.5 + */ +public class EditFavoriteListVoter extends PollenActionSupportForEdition implements Preparable, ParameterAware { + + private static final long serialVersionUID = 1L; + + private Map<String, String[]> parameters; + + protected PersonList favoriteList; + + protected PollAccount editPollAccount; + + public PollAccount getEditPollAccount() { + if (editPollAccount == null) { + editPollAccount = getFavoriteService().newPollAccountForFavoriteList(); + } + return editPollAccount; + } + + public PersonList getFavoriteList() { + return favoriteList; + } + + public String getFavoriteListId() { + return favoriteList.getTopiaId(); + } + + public String getAction() { + return "edit"; + } + + @Override + public void prepare() throws Exception { + + String[] favoriteListIds = parameters.get("favoriteListId"); + Preconditions.checkNotNull(favoriteListIds); + Preconditions.checkArgument(favoriteListIds.length == 1); + String favoriteListId = favoriteListIds[0]; + + try { + favoriteList = getFavoriteService().getFavoriteList( + getPollenUserAccount(), favoriteListId); + } catch (FavoriteListNotFoundException e) { + addFlashError(_("pollen.error.favoriteList.not.found")); + } catch (FavoriteListNotOwnedByUserException e) { + addFlashError(_("pollen.error.favoriteList.not.owned.by.user")); + } + } + + @Override + public void validate() { + + PollAccount account = getEditPollAccount(); + + if (StringUtils.isBlank(account.getVotingId())) { + addFieldError("editPollAccount.votingId", + _("pollen.error.pollAccount.votingId.required")); + } + + if (StringUtils.isBlank(account.getEmail())) { + addFieldError("editPollAccount.email", + _("pollen.error.email.required")); + } else if (!StringUtil.isEmail(account.getEmail())) { + addFieldError("editPollAccount.email", + _("pollen.error.email.invalid")); + } + + } + + @Override + public String execute() throws Exception { + + Preconditions.checkNotNull(favoriteList); + Preconditions.checkNotNull(editPollAccount); + + String result = INPUT; + + try { + + getFavoriteService().editPollAccountToFavoriteList( + favoriteList, editPollAccount); + + addFlashMessage( + _("pollen.information.pollAccount.updatedTofavoriteList", + editPollAccount.getVotingId())); + + editPollAccount = null; + result = SUCCESS; + } catch (ParticipantAlreadyFoundInListException e) { + addFieldError("editPollAccount.email", + _("pollen.error.favoriteList.participant.already.found.in.list")); + } + return result; + } + + @Override + public void setParameters(Map<String, String[]> parameters) { + this.parameters = parameters; + } +} \ No newline at end of file Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/EditFavoriteListVoter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java 2012-07-31 16:21:30 UTC (rev 3579) @@ -31,8 +31,7 @@ import org.chorem.pollen.services.exceptions.FavoriteListNotFoundException; import org.chorem.pollen.services.exceptions.FavoriteListNotOwnedByUserException; import org.chorem.pollen.services.exceptions.ParticipantAlreadyFoundInListException; -import org.chorem.pollen.ui.actions.PageSkin; -import org.chorem.pollen.ui.actions.PollenActionSupport; +import org.chorem.pollen.ui.actions.PollenActionSupportForEdition; import org.nuiton.util.StringUtil; import java.util.Map; @@ -43,17 +42,12 @@ * @author tchemit <chemit@codelutin.com> * @since 1.3 */ -public class ManageFavoriteList extends PollenActionSupport implements Preparable, ParameterAware { +public class ManageFavoriteList extends PollenActionSupportForEdition implements Preparable, ParameterAware { private static final long serialVersionUID = 1L; private Map<String, String[]> parameters; - @Override - public PageSkin getSkin() { - return PageSkin.EDITION; - } - protected String action; // protected String favoriteListId; Deleted: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java 2012-07-31 16:21:30 UTC (rev 3579) @@ -1,210 +0,0 @@ -/* - * #%L - * Pollen :: UI (struts2) - * $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.actions.user; - -import com.google.common.base.Preconditions; -import org.apache.commons.lang3.StringUtils; -import org.chorem.pollen.business.persistence.PersonList; -import org.chorem.pollen.business.persistence.PollAccount; -import org.chorem.pollen.services.FavoriteListImport; -import org.chorem.pollen.services.exceptions.FavoriteListAlreadyExistException; -import org.chorem.pollen.services.exceptions.FavoriteListImportException; -import org.chorem.pollen.services.exceptions.FavoriteListNotFoundException; -import org.chorem.pollen.services.exceptions.ParticipantAlreadyFoundInListException; -import org.chorem.pollen.services.impl.FavoriteListImportCSV; -import org.chorem.pollen.services.impl.FavoriteListImportLDAP; -import org.chorem.pollen.ui.actions.PageSkin; -import org.chorem.pollen.ui.actions.PollenActionSupport; - -import java.io.File; -import java.util.List; - -/** - * Manage favorite lists of a connected user. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.3 - */ -public class ManageFavoriteLists extends PollenActionSupport { - - private static final long serialVersionUID = 1L; - - protected PersonList favoriteList; - - protected File csvImport; - - protected String csvImportContentType; - - protected String csvImportFileName; - - protected String ldapImport; - - protected String action; - - public void setCsvImport(File csvImport) { - this.csvImport = csvImport; - } - - public void setCsvImportContentType(String csvImportContentType) { - this.csvImportContentType = csvImportContentType; - } - - public void setCsvImportFileName(String csvImportFileName) { - this.csvImportFileName = csvImportFileName; - } - - public String getLdapImport() { - return ldapImport; - } - - public void setLdapImport(String ldapImport) { - this.ldapImport = ldapImport; - } - - public PersonList getCreateFavoriteList() { - return getFavoriteList(); - } - - public PersonList getDeleteFavoriteList() { - return getFavoriteList(); - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - @Override - public PageSkin getSkin() { - return PageSkin.EDITION; - } - - @Override - public void validate() { - - if ("create".equals(action)) { - - if( StringUtils.isBlank(getCreateFavoriteList().getName())) { - addFieldError("createFavoriteList.name", - _("pollen.error.favoriteListName.required")); - } - } - } - - public String create() throws Exception { - - Preconditions.checkNotNull(favoriteList); - Preconditions.checkNotNull(favoriteList.getName()); - - try { - PersonList personList = - getFavoriteService().createFavoriteList(getPollenUserAccount(), - favoriteList.getName()); - - if (csvImportFileName != null) { - - FavoriteListImport importService = newService(FavoriteListImportCSV.class); - - addImport(importService, csvImport.getAbsolutePath(), personList); - } - - if (StringUtils.isNotBlank(ldapImport)) { - - FavoriteListImport importService = newService(FavoriteListImportLDAP.class); - - addImport(importService, ldapImport, personList); - } - - } catch (FavoriteListAlreadyExistException ex) { - addFieldError("createFavoriteList.name", - _("pollen.error.favoriteList.already.used")); - } - - String result; - if (hasAnyErrors()) { - result = INPUT; - - } else { - getTransaction().commitTransaction(); - - addFlashMessage(_("pollen.information.favoriteList.created", - favoriteList.getName())); - action = null; - favoriteList = null; - result = SUCCESS; - } - return result; - } - - public String delete() throws Exception { - - Preconditions.checkNotNull(favoriteList); - - PersonList deletedFavoritedList = - getFavoriteService().deleteFavoriteList(getPollenUserAccount(), - favoriteList); - getTransaction().commitTransaction(); - - addFlashMessage(_("pollen.information.favoriteList.deleted", - deletedFavoritedList.getName())); - action = null; - favoriteList = null; - return SUCCESS; - } - - protected PersonList getFavoriteList() { - if (favoriteList == null) { - favoriteList = getFavoriteService().newFavoriteList(); - } - return favoriteList; - } - - protected void addImport(FavoriteListImport service, String url, PersonList list) - throws FavoriteListNotFoundException { - - List<PollAccount> importedAccounts; - try { - importedAccounts = service.execute(url); - - for (PollAccount importedAccount : importedAccounts) { - try { - getFavoriteService().addPollAccountToFavoriteList(list, importedAccount); - - } catch (ParticipantAlreadyFoundInListException ex) { - // WARNING ? - addFlashError( - _("pollen.error.favoriteList.import.participantExists" - , importedAccount.getEmail()) - ); - } - } - - } catch (FavoriteListImportException ex) { - String message = ex.getLocalizedMessage(getLocale()); - addFlashError(message); - } - } -} Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java 2012-07-31 16:21:30 UTC (rev 3579) @@ -27,8 +27,7 @@ import org.chorem.pollen.business.persistence.UserAccount; import org.chorem.pollen.services.exceptions.UserEmailAlreadyUsedException; import org.chorem.pollen.services.exceptions.UserLoginAlreadyUsedException; -import org.chorem.pollen.ui.actions.PageSkin; -import org.chorem.pollen.ui.actions.PollenActionSupport; +import org.chorem.pollen.ui.actions.PollenActionSupportForEdition; import org.nuiton.util.StringUtil; /** @@ -37,19 +36,19 @@ * @author tchemit <chemit@codelutin.com> * @since 1.3 */ -public class Register extends PollenActionSupport { +public class Register extends PollenActionSupportForEdition { private static final long serialVersionUID = 1L; - protected UserAccount user; + protected UserAccount pollenUserAccount; protected String password2; - public UserAccount getUser() { - if (user == null) { - user = getUserService().getNewUser(); + public UserAccount getPollenUserAccount() { + if (pollenUserAccount == null) { + pollenUserAccount = getUserService().getNewUser(); } - return user; + return pollenUserAccount; } public String getPassword2() { @@ -61,33 +60,28 @@ } @Override - public PageSkin getSkin() { - return PageSkin.EDITION; - } - - @Override public void validate() { - if (StringUtils.isBlank(user.getLogin())) { - addFieldError("user.login", _("pollen.error.login.required")); + if (StringUtils.isBlank(pollenUserAccount.getLogin())) { + addFieldError("pollenUserAccount.login", _("pollen.error.login.required")); } - if (StringUtils.isBlank(user.getPassword())) { - addFieldError("user.password", _("pollen.error.password.required")); + if (StringUtils.isBlank(pollenUserAccount.getPassword())) { + addFieldError("pollenUserAccount.password", _("pollen.error.password.required")); } if (StringUtils.isBlank(getPassword2())) { addFieldError("password2", _("pollen.error.password2.required")); } - if (ObjectUtils.notEqual(getPassword2(), user.getPassword())) { + if (ObjectUtils.notEqual(getPassword2(), pollenUserAccount.getPassword())) { addFieldError("password2", _("pollen.error.passwords.not.equals")); } - if (StringUtils.isBlank(user.getEmail())) { - addFieldError("user.email", _("pollen.error.email.required")); - } else if (!StringUtil.isEmail(user.getEmail())) { - addFieldError("user.email", _("pollen.error.email.invalid")); + if (StringUtils.isBlank(pollenUserAccount.getEmail())) { + addFieldError("pollenUserAccount.email", _("pollen.error.email.required")); + } else if (!StringUtil.isEmail(pollenUserAccount.getEmail())) { + addFieldError("pollenUserAccount.email", _("pollen.error.email.invalid")); } } @@ -96,21 +90,21 @@ String result = INPUT; try { - UserAccount createdUser = getUserService().createUser(user, false); + UserAccount createdUser = getUserService().createUser(pollenUserAccount, false); getPollenSession().setUserAccount(createdUser); addFlashMessage(_("pollen.information.your.are.loggued")); result = SUCCESS; } catch (UserLoginAlreadyUsedException e) { - addFieldError("user.login", _("pollen.error.user.login.already.used")); + addFieldError("pollenUserAccount.login", _("pollen.error.user.login.already.used")); } catch (UserEmailAlreadyUsedException e) { - addFieldError("user.email", _("pollen.error.user.email.already.used")); + addFieldError("pollenUserAccount.email", _("pollen.error.user.email.already.used")); } // if error go back to input // reset password - user.setPassword(null); + pollenUserAccount.setPassword(null); password2 = null; return result; Modified: trunk/pollen-ui-struts2/src/main/resources/config/struts-user.xml =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-07-31 16:21:30 UTC (rev 3579) @@ -56,7 +56,7 @@ </action> <!-- show user account --> - <action name="show" class="org.chorem.pollen.ui.actions.user.Show"> + <action name="show" class="org.chorem.pollen.ui.actions.PollenActionSupportForEdition"> <result>/WEB-INF/jsp/user/show.jsp</result> </action> @@ -82,15 +82,15 @@ <!-- show favorite lists --> <action name="favoriteLists" method="input" - class="org.chorem.pollen.ui.actions.user.ManageFavoriteLists"> + class="org.chorem.pollen.ui.actions.PollenActionSupportForEdition"> <interceptor-ref name="pollenBasicStack"/> <result name="input">/WEB-INF/jsp/user/favoriteLists.jsp</result> <result>/WEB-INF/jsp/user/favoriteLists.jsp</result> </action> <!-- create favorite list --> - <action name="createFavoriteList" method="create" - class="org.chorem.pollen.ui.actions.user.ManageFavoriteLists"> + <action name="createFavoriteList" + class="org.chorem.pollen.ui.actions.user.CreateFavoriteList"> <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result name="input">/WEB-INF/jsp/user/favoriteLists.jsp</result> <result>/WEB-INF/jsp/user/favoriteLists.jsp</result> @@ -110,23 +110,23 @@ </action> <!-- edit favorite list --> - <action name="editFavoriteList" method="input" - class="org.chorem.pollen.ui.actions.user.ManageFavoriteList"> + <action name="editFavoriteList" + class="org.chorem.pollen.ui.actions.user.EditFavoriteList"> <interceptor-ref name="pollenParamsPrepareParamsStack"/> - <result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result> + <result>/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"> + <action name="addPollAccount" + class="org.chorem.pollen.ui.actions.user.CreateFavoriteListVoter"> <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result> <result>/WEB-INF/jsp/user/favoriteList.jsp</result> </action> <!-- edit poll account to favorite list --> - <action name="editPollAccount" method="edit" - class="org.chorem.pollen.ui.actions.user.ManageFavoriteList"> + <action name="editPollAccount" + class="org.chorem.pollen.ui.actions.user.EditFavoriteListVoter"> <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result> <result>/WEB-INF/jsp/user/favoriteList.jsp</result> @@ -140,7 +140,7 @@ <!-- remove poll account from a favorite list --> <action name="deletePollAccount" - class="org.chorem.pollen.ui.actions.user.DeletePollAccount"> + class="org.chorem.pollen.ui.actions.user.DeleteFavoriteListVoter"> <interceptor-ref name="pollenParamsPrepareParamsStack"/> <result type="redirect2"/> </action> @@ -157,21 +157,21 @@ <!-- display createds polls --> <action name="createdList" - class="org.chorem.pollen.ui.actions.poll.CreatedList"> + class="org.chorem.pollen.ui.actions.PollenActionSupportForEdition"> <interceptor-ref name="pollenBasicStack"/> <result>/WEB-INF/jsp/user/createdList.jsp</result> </action> <!-- display invited polls --> <action name="invitedList" - class="org.chorem.pollen.ui.actions.poll.InvitedList"> + class="org.chorem.pollen.ui.actions.PollenActionSupportForVote"> <interceptor-ref name="pollenBasicStack"/> <result>/WEB-INF/jsp/user/invitedList.jsp</result> </action> <!-- display participated polls --> <action name="participatedList" - class="org.chorem.pollen.ui.actions.poll.ParticipatedList"> + class="org.chorem.pollen.ui.actions.PollenActionSupportForVote"> <interceptor-ref name="pollenBasicStack"/> <result>/WEB-INF/jsp/user/participatedList.jsp</result> </action> Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-07-31 16:21:30 UTC (rev 3579) @@ -92,7 +92,7 @@ pollen.common.email=Em@il pollen.common.endChoiceDate=End choice date pollen.common.endDate=End date -pollen.common.favoriteList.csvImport.help=The file to upload is a text file that contains one row per participant.<br/><br/>The first line must be <strong>votingId,email</strong>, then each next ones will define the participant's name and his email separated by a comma.<br/><br/>Here is an example \:<br/> +pollen.common.favoriteList.csvImport.help=The file to upload is a text file that contains one row per participant.<br/><br/>Each line must begin by the email of voter.<br/><br/>It can be followed by the voter Id (precede by a space).<br/><br/>If no voterId is given, then the email will be used.<br/><br/>Here is an example\: pollen.common.firstName=First name pollen.common.functions=Functions pollen.common.group=group @@ -165,7 +165,7 @@ pollen.error.email.invalid=The email doesn't have the good format pollen.error.email.required=You must provide an email pollen.error.favoriteList.already.used=List name already used -pollen.error.favoriteList.import.participantExists=The email '%1$s' is already used in the list +pollen.error.favoriteList.import.participantExists=The email '<strong>%s</strong>' is already used in the list pollen.error.favoriteList.not.found=Favorite list not found pollen.error.favoriteList.not.owned.by.user=You are not owner of this favorite list pollen.error.favoriteList.participant.already.found.in.list=Member with same email already exists in favorite list @@ -213,7 +213,7 @@ pollen.error.pollId.empty=Poll id is mandatory pollen.error.pollNotFound=The poll with given id does not exist. pollen.error.pollTabErrorFound=Some errors were found on this tab, please fix them to finalize the poll creation. -pollen.error.user.alreadyVoted=Someone has already used the name %s to vote. +pollen.error.user.alreadyVoted=Someone has already used the name '<strong>%s</strong>' to vote. pollen.error.user.bad.login.or.password=Login or password invalid. pollen.error.user.email.already.used=This email is already used pollen.error.user.invalid.email=Invalid e-mail @@ -263,29 +263,31 @@ pollen.information.confirmDeletePollChoice=Confir to delete choice %s pollen.information.confirmDeletePollVote=Confirm delete of vote of %s pollen.information.confirmDeleteUser=Confirm delete of user\: -pollen.information.favoriteList.created=Favorite list %s created. -pollen.information.favoriteList.deleted=Favorite list %s deleted. +pollen.information.favoriteList.created=Favorite list '<strong>%s</strong>' created. +pollen.information.favoriteList.deleted=Favorite list '<strong>%s</strong>' deleted. +pollen.information.favoriteList.imported=Favorite list '<strong>%s</strong>' created and %s voter were imported into it. pollen.information.irreversible.operation=Be ware, this operation is irreversible. pollen.information.lostPassword=You will receive a new password to the given email pollen.information.lostPassword.success=An e-mail was sent with your new password. You can change it on your user account page. pollen.information.moderate.page=From this page you can moderate votes and comments, but not vote. pollen.information.need.login=You must be logged to access this page. Please fill the form below. -pollen.information.poll.attached=Poll '%s' attached to your user account. -pollen.information.poll.closed=Poll '%s' closed. -pollen.information.poll.created=Poll '%s' created. +pollen.information.poll.attached=Poll '<strong>%s</strong>' attached to your user account. +pollen.information.poll.closed=Poll '<strong>%s</strong>' closed. +pollen.information.poll.created=Poll '<strong>%s</strong>' created. pollen.information.poll.form.voteStarted=Votes are started, some options can't be updated. -pollen.information.poll.updated=Poll '%s' modified. -pollen.information.pollAccount.addedTofavoriteList=Member '%s' was added to favorite list. -pollen.information.pollAccount.removedFromFavoriteList=Member '%s' was removed from favorite list. -pollen.information.pollAccount.updatedTofavoriteList=Member '%s' was updated in favorite list. +pollen.information.poll.updated=Poll '<strong>%s</strong>' modified. +pollen.information.pollAccount.addedTofavoriteList=Member '<strong>%s</strong>' added to favorite list. +pollen.information.pollAccount.removedFromFavoriteList=Member '<strong>%s</strong>' removed from favorite list. +pollen.information.pollAccount.updated=Your account was updated. +pollen.information.pollAccount.updatedTofavoriteList=Member '<strong>%s</strong>' updated in favorite list. pollen.information.pollChoiceRunning=Adding choices is allowed. pollen.information.pollClosed=This poll is closed. You can not vote anymore. pollen.information.pollFinished=This poll is finished. You can not vote anymore. pollen.information.pollNotStarted=This poll has not started yet. pollen.information.pollRunning=The poll is not finished. Results may change. -pollen.information.user.created=User %s created. -pollen.information.user.deleted=User %s deleted. -pollen.information.user.updated=User %s updated. +pollen.information.user.created=User'<strong>%s</strong>' created. +pollen.information.user.deleted=User '<strong>%s</strong>' deleted. +pollen.information.user.updated=User '<strong>%s</strong>' updated. pollen.information.vote.created=Vote saved pollen.information.vote.createdWithUpdateUrl=Vote saved, you can modify it using this address\: <br/> <a href\="%1$s">%1$s</a> pollen.information.vote.creatorUser=You are identified as the poll's creator. You can't vote with this URL. Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-07-31 16:21:30 UTC (rev 3579) @@ -92,7 +92,7 @@ pollen.common.email=Em@il pollen.common.endChoiceDate=Date de fin des choix pollen.common.endDate=Date de fin -pollen.common.favoriteList.csvImport.help=Le fichier à importer doit être un fichier texte contenant une ligne par participant.<br/><br/>La première ligne doit contenir <strong>votingId,email</strong>, ensuite chacune des suivantes définira le nom du participant et son email séparés par une virgule.<br/><br/>Voici un exemple \:<br/> +pollen.common.favoriteList.csvImport.help=Le fichier à importer doit être un fichier texte contenant une ligne par participant.<br/><br/>Chaque ligne doit commencer par le courriel du votant.<br/><br/>On peut ensuite ajouter à la suite un nom de votant (précédé d'un espace).<br/><br/>Si le nom du votant n'est pas renseigné alors le courreil sera utilisé.<br/><br/>Voici un exemple \: pollen.common.firstName=Prénom pollen.common.functions=Fonctions pollen.common.group=groupes @@ -264,29 +264,31 @@ pollen.information.confirmDeletePollChoice=Confirmer la suppression du choix %s pollen.information.confirmDeletePollVote=Confirmer la suppression du vote de %s pollen.information.confirmDeleteUser=Confirmer la suppression de l'utilisateur \: -pollen.information.favoriteList.created=La liste %s a été créée. -pollen.information.favoriteList.deleted=La liste %s a été supprimée. +pollen.information.favoriteList.created=Liste de votants '<strong>%s</strong>' créée. +pollen.information.favoriteList.deleted=Liste de votants '<strong>%s</strong>' supprimée. +pollen.information.favoriteList.imported=Liste de votants '<strong>%s</strong>' créée et %s votants y ont été importés. pollen.information.irreversible.operation=Attention, Cette opération est irréversible. pollen.information.lostPassword=Vous allez recevoir un nouveau mot de passe sur l'e-mail suivant pollen.information.lostPassword.success=Un e-mail vous a été envoyé avec votre nouveau mot de passe. Vous pouvez le changer sur la page d'édition de votre compte. pollen.information.moderate.page=A partir de cette page vous pouvez modérer les votes et les commentaires mais pas voter. pollen.information.need.login=Vous devez être identifié pour pouvoir accéder à cette page. Veuillez remplir le formulaire ci-dessous. -pollen.information.poll.attached=Sondage '%s' rattaché à votre compte. -pollen.information.poll.closed=Sondage '%s' clos. -pollen.information.poll.created=Sondage '%s' créé. +pollen.information.poll.attached=Sondage '<strong>%s</strong>' rattaché à votre compte. +pollen.information.poll.closed=Sondage '<strong>%s</strong>' clos. +pollen.information.poll.created=Sondage '<strong>%s</strong>' créé. pollen.information.poll.form.voteStarted=Les votes ont commencé, certaines options ne sont pas modifiables. -pollen.information.poll.updated=Sondage '%s' mise à jour. -pollen.information.pollAccount.addedTofavoriteList=Le membre %s a été ajoutée à la liste des favoris. -pollen.information.pollAccount.removedFromFavoriteList=Le membre %s a été supprimé de la liste des favoris. -pollen.information.pollAccount.updatedTofavoriteList=Le membre %s a été mise à jour dans la liste des favoris. +pollen.information.poll.updated=Sondage '<strong>%s</strong>' mise à jour. +pollen.information.pollAccount.addedTofavoriteList=Le membre '<strong>%s</strong>' a été ajouté à la liste des favoris. +pollen.information.pollAccount.removedFromFavoriteList=Le membre '<strong>%s</strong>' a été supprimé de la liste des favoris. +pollen.information.pollAccount.updated=Votre compte a bien été mis à jour. +pollen.information.pollAccount.updatedTofavoriteList=Le membre '<strong>%s</strong>' a été mise à jour dans la liste des favoris. pollen.information.pollChoiceRunning=L'ajout de choix est possible. pollen.information.pollClosed=Ce sondage est clos. Vous ne pouvez plus voter. pollen.information.pollFinished=Ce sondage est terminé. Vous ne pouvez plus voter. pollen.information.pollNotStarted=Ce sondage n'a pas encore commencé. pollen.information.pollRunning=Ce sondage n'est pas terminé. Les résultats peuvent encore changer. -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.user.created=Utilisateur '<strong>%s</strong>' a été créé. +pollen.information.user.deleted=Utilisateur '<strong>%s</strong>' a été supprimé. +pollen.information.user.updated=Utilisateur '<strong>%s</strong>' a été mis à jour. pollen.information.vote.created=Vote enregistré pollen.information.vote.createdWithUpdateUrl=Vote enregistré, vous pourrez le modifier à l'adresse suivante \: <br/> <a href\="%1$s">%1$s</a> pollen.information.vote.creatorUser=Vous êtes identifié comme le créateur du sondage. Vous ne pouvez pas voter avec cette URL. Deleted: trunk/pollen-ui-struts2/src/main/resources/validators.xml =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/validators.xml 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/resources/validators.xml 2012-07-31 16:21:30 UTC (rev 3579) @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - Pollen :: UI (struts2) - $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% - --> - -<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator Config 1.0//EN" - "http://www.opensymphony.com/xwork/xwork-validator-config-1.0.dtd"> -<validators> - <!-- default validators from XWork framework --> - <validator name="int" class="com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator"/> - <validator name="long" class="com.opensymphony.xwork2.validator.validators.LongRangeFieldValidator"/> - <validator name="short" class="com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator"/> - <validator name="double" class="com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator"/> - <validator name="date" class="com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator"/> - <validator name="expression" class="com.opensymphony.xwork2.validator.validators.ExpressionValidator"/> - <validator name="fieldexpression" class="com.opensymphony.xwork2.validator.validators.FieldExpressionValidator"/> - <validator name="conversion" class="com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator"/> - <validator name="stringlength" class="com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator"/> - <validator name="required" class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/> - <validator name="requiredstring" class="com.opensymphony.xwork2.validator.validators.RequiredStringValidator"/> - - <!-- default nuiton-validator validators --> - <validator name="nfieldexpression" class="org.nuiton.validator.xwork2.field.NuitonFieldExpressionValidator"/> - <validator name="nrequired" class="org.nuiton.validator.xwork2.field.SkipableRequiredFieldValidator"/> - <validator name="nrequiredstring" class="org.nuiton.validator.xwork2.field.SkipableRequiredStringFieldValidator"/> - - <!-- Pollen validators --> - -</validators> Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/edit.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/edit.jsp 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/edit.jsp 2012-07-31 16:21:30 UTC (rev 3579) @@ -34,9 +34,10 @@ <fieldset> <legend><s:text name="pollen.fieldset.connexionInformation"/></legend> - <s:hidden key="user.topiaId" label=""/> - <s:textfield name="user.login" key="pollen.common.login" required="true"/> - <s:password name="user.password" key="pollen.common.password" + <s:hidden key="pollenUserAccount.topiaId" label=""/> + <s:textfield name="pollenUserAccount.login" key="pollen.common.login" + required="true"/> + <s:password name="pollenUserAccount.password" key="pollen.common.password" required="true"/> <s:password name="newPassword" key="pollen.common.newPassword"/> <s:password name="newPassword2" key="pollen.common.newPassword2"/> @@ -45,9 +46,12 @@ <fieldset> <legend><s:text name="pollen.fieldset.userInformation"/></legend> - <s:textfield name="user.email" key="pollen.common.email" required="true"/> - <s:textfield name="user.firstName" key="pollen.common.firstName"/> - <s:textfield name="user.lastName" key="pollen.common.lastName"/> + <s:textfield name="pollenUserAccount.email" key="pollen.common.email" + required="true"/> + <s:textfield name="pollenUserAccount.firstName" + key="pollen.common.firstName"/> + <s:textfield name="pollenUserAccount.lastName" + key="pollen.common.lastName"/> </fieldset> <br/> <s:submit action="edit" key="pollen.action.validate" align="center"/> Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp 2012-07-31 16:21:30 UTC (rev 3579) @@ -52,8 +52,6 @@ var editImg = '<s:url value='/img/edit.png'/>'; var editTitle = '<s:text name="pollen.action.editFavoriteList"/>'; var deleteImg = '<s:url value='/img/delete.png'/>'; - var csvHelp = "<div><s:text name='pollen.common.favoriteList.csvImport.help'/>" + - "<br/><img src=\"<s:url value="/img/import_csv_help.png"/>\"/></div>"; jQuery(document).ready(function () { @@ -61,6 +59,15 @@ }); </script> +<s:set name='csvHelp'> + <div><s:text name='pollen.common.favoriteList.csvImport.help'/> + <br/> +<pre style="background-color: #ffffff;color: #000000;"> + email1@domain.org voterId1 + email2@domain.org +</pre> + </div> +</s:set> <sjg:grid id="favoriteLists" dataType="json" href='%{loadFavoriteLists}' gridModel="favoriteLists" sortable="true" pager="true" pagerButtons="true" pagerInput="true" navigator="true" @@ -86,14 +93,16 @@ <s:form id='createForm' method="POST" namespace="/user" cssClass="hidden favoriteForm" enctype="multipart/form-data"> - <s:hidden name="action" value="create"/> <fieldset> <legend> <s:text name="pollen.fieldset.userFavoriteList.toCreate"/> </legend> <s:textfield key="createFavoriteList.name" required="true" size="40" label="%{getText('pollen.common.name')}"/> - <s:file key="csvImport" label="%{getText('pollen.common.csvImport')}"/> + <s:file id='csvImport' key="csvImport[0]" + label="%{getText('pollen.common.csvImport')}" + tooltip="%{csvHelp}" + tooltipIconPath="/img/tooltip.png"/> <s:textfield key="ldapImport" label="%{getText('pollen.common.ldapImport')}" size="40"/> </fieldset> Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/register.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/register.jsp 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/register.jsp 2012-07-31 16:21:30 UTC (rev 3579) @@ -29,13 +29,14 @@ <s:text name="pollen.title.register"/> </h1> -<s:form method="POST" key="registerForm"> +<s:form method="POST"> <fieldset> <legend><s:text name="pollen.fieldset.connexionInformation"/></legend> - <s:textfield name="user.login" key="pollen.common.login" required="true"/> - <s:password name="user.password" key="pollen.common.password" + <s:textfield name="pollenUserAccount.login" key="pollen.common.login" + required="true"/> + <s:password name="pollenUserAccount.password" key="pollen.common.password" required="true"/> <s:password name="password2" key="pollen.common.password2" required="true"/> </fieldset> @@ -43,9 +44,12 @@ <fieldset> <legend><s:text name="pollen.fieldset.userInformation"/></legend> - <s:textfield name="user.email" key="pollen.common.email" required="true"/> - <s:textfield name="user.firstName" key="pollen.common.firstName"/> - <s:textfield name="user.lastName" key="pollen.common.lastName"/> + <s:textfield name="pollenUserAccount.email" key="pollen.common.email" + required="true"/> + <s:textfield name="pollenUserAccount.firstName" + key="pollen.common.firstName"/> + <s:textfield name="pollenUserAccount.lastName" + key="pollen.common.lastName"/> </fieldset> <br/> <s:submit action="register" key="pollen.action.register" align="center"/> Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/show.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/show.jsp 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/show.jsp 2012-07-31 16:21:30 UTC (rev 3579) @@ -34,17 +34,17 @@ <fieldset> <legend><s:text name="pollen.fieldset.connexionInformation"/></legend> - <s:hidden key="user.topiaId" label=""/> - <s:label name="user.login" key="pollen.common.login"/> + <s:hidden key="pollenUserAccount.topiaId" label=""/> + <s:label name="pollenUserAccount.login" key="pollen.common.login"/> </fieldset> <fieldset> <legend><s:text name="pollen.fieldset.userInformation"/></legend> - <s:label name="user.email" key="pollen.common.email"/> - <s:label name="user.firstName" value="%{user.firstName}" + <s:label name="pollenUserAccount.email" key="pollen.common.email"/> + <s:label name="pollenUserAccount.firstName" value="%{pollenUserAccount.firstName}" key="pollen.common.firstName"/> - <s:label name="user.lastName" value="%{user.lastName}" + <s:label name="pollenUserAccount.lastName" value="%{pollenUserAccount.lastName}" key="pollen.common.lastName"/> </fieldset> <br/> Modified: trunk/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js 2012-07-31 16:19:27 UTC (rev 3578) +++ trunk/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js 2012-07-31 16:21:30 UTC (rev 3579) @@ -56,11 +56,9 @@ $('#createForm').show(); }); - $('[name=csvImport]').tipTip({ - content : csvHelp, - maxWidth : '340px', - defaultPosition : 'right' - }); + $('img[src$="tooltip.png"]').addClass("tooltip"); + $('.tooltip').tipTip({ maxWidth:'340px', + defaultPosition:'right' }); } function favoriteListsFunctions(cellvalue, options, rowObject) {