Author: tchemit Date: 2012-01-23 11:32:33 +0100 (Mon, 23 Jan 2012) New Revision: 3101 Url: http://chorem.org/repositories/revision/pollen/3101 Log: update struts version add svn properties user domain is nearly done split struts config files (and use namespaces) EmailService should be ok. Added: branches/pollen-2.0-beta-1/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenUIUtils.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManagePolls.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManageUsers.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONPaginedAction.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/AbstractCheckInterceptor.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-admin.xml branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-json.xml branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-poll.xml branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-user.xml branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/template/ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/template/css_xhtml/ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/template/css_xhtml/checkbox.ftl branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/template/css_xhtml/controlheader-core.ftl branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/adminRequired.jsp branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/createPoll.jsp branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/login.jsp branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollsList.jsp branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/usersList.jsp branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/js/gridHelper.js Modified: branches/pollen-2.0-beta-1/ branches/pollen-2.0-beta-1/pollen-services/pom.xml branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/EmailService.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserService.java branches/pollen-2.0-beta-1/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties branches/pollen-2.0-beta-1/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationContext.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/CreatePoll.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/Login.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/RegisterUser.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/struts.xml branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/home.jsp branches/pollen-2.0-beta-1/pom.xml Property changes on: branches/pollen-2.0-beta-1 ___________________________________________________________________ Modified: svn:ignore - *.ipr *.iws *.iml .classpath .project target .pollen .settings nbactions.xml . .idea + *.ipr *.iws *.iml .classpath .project target .settings nbactions.xml Added: branches/pollen-2.0-beta-1/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,43 @@ +/* + * #%L + * Pollen :: Persistence + * + * $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; + +import com.google.common.base.Function; +import org.chorem.pollen.entity.UserAccount; + +/** + * USefull pollen functions. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollenFunctions { + + public static final Function<UserAccount, String> USER_BY_LOGIN = new Function<UserAccount, String>() { + @Override + public String apply(UserAccount input) { + return input.getLogin(); + } + }; +} Property changes on: branches/pollen-2.0-beta-1/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-2.0-beta-1/pollen-services/pom.xml =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/pom.xml 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-services/pom.xml 2012-01-23 10:32:33 UTC (rev 3101) @@ -98,10 +98,6 @@ <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </dependency> - <dependency> - <groupId>org.nuiton.i18n</groupId> - <artifactId>nuiton-i18n</artifactId> - </dependency> </dependencies> <!-- ************************************************************* --> Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/EmailService.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/EmailService.java 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/EmailService.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -23,32 +23,57 @@ */ package org.chorem.pollen.services; -import org.chorem.pollen.PollenBusinessException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.mail.EmailException; +import org.apache.commons.mail.SimpleEmail; +import org.chorem.pollen.PollenConfiguration; import org.chorem.pollen.PollenTechnicalException; import org.chorem.pollen.bean.PollenEmail; import org.chorem.pollen.entity.UserAccount; -import org.chorem.pollen.service.legacy.ServiceEmailImpl; public class EmailService extends PollenServiceSupport { + /** Logger. */ + private static final Log log = LogFactory.getLog(EmailService.class); + public PollenEmail createEmail() { - ServiceEmailImpl service = new ServiceEmailImpl(); - PollenEmail result = service.createEmail(); + PollenConfiguration configuration = getConfiguration(); + PollenEmail result = new PollenEmail(); + result.setHost(configuration.getEmailHost()); + result.setFrom(configuration.getEmailFrom()); + result.setPort(configuration.getEmailPort()); return result; } - public void sendEmail(PollenEmail email) { - ServiceEmailImpl service = new ServiceEmailImpl(); + public void sendEmail(PollenEmail pollenEmail) { try { - service.executeSendEmail(email); - } catch (PollenBusinessException e) { - throw new PollenTechnicalException(e); + // Create the SimpleEmail to send + SimpleEmail email = pollenEmail.createSimpleEmail( + getConfiguration().getCharset()); + email.send(); + + if (log.isInfoEnabled()) { + log.info("Mail sent to : " + pollenEmail.getTo()); + + if (log.isDebugEnabled()) { + log.debug("Email infos : " + + "\ndate: " + email.getSentDate() + + "\nhostname: " + email.getHostName() + + "\nport: " + email.getSmtpPort() + + "\nfrom: " + email.getFromAddress().toString()); + } + } + } catch (EmailException eee) { + throw new PollenTechnicalException( + "could not send email to " + pollenEmail.getTo(), eee); } } public PollenEmail getNewEmail(UserAccount toUser) { - ServiceEmailImpl service = new ServiceEmailImpl(); - return service.executeGetNewEmail(toUser); + PollenEmail email = createEmail(); + email.setTo(toUser.getEmail()); + return email; } } Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserService.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserService.java 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserService.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -23,24 +23,30 @@ */ package org.chorem.pollen.services; +import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.pollen.PollenBinderHelper; import org.chorem.pollen.PollenDAOHelper; import org.chorem.pollen.PollenException; +import org.chorem.pollen.PollenFunctions; import org.chorem.pollen.PollenTechnicalException; import org.chorem.pollen.bean.PollenEmail; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.entity.UserAccountDAO; -import org.chorem.pollen.service.legacy.ServiceUserImpl; +import org.chorem.pollen.entity.UserAccountImpl; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.EntityFilter; import org.nuiton.topia.framework.TopiaQuery; import org.nuiton.topia.persistence.util.TopiaEntityBinder; +import org.nuiton.util.PagerUtil; import org.nuiton.util.StringUtil; import org.nuiton.util.beans.Binder; +import java.net.URL; +import java.util.List; +import java.util.Locale; import java.util.Map; import static org.nuiton.i18n.I18n._; @@ -73,7 +79,8 @@ } } - public UserAccount createUser(UserAccount user, String url) throws UserLoginAlreadyUsedException, UserEmailAlreadyUsedException { + public UserAccount createUser(UserAccount user, + URL url) throws UserLoginAlreadyUsedException, UserEmailAlreadyUsedException { String password = user.getPassword(); // le mot de passe en clair @@ -102,13 +109,14 @@ throw new PollenTechnicalException(e); } - if (StringUtil.isEmail(user.getEmail())) { + if (url != null && StringUtil.isEmail(user.getEmail())) { - String subject = l_(serviceContext.getLocale(), - "pollen.email.userRegister.subject", user.getLogin()); - String content = l_(serviceContext.getLocale(), - "pollen.email.userRegister.content", user.getDisplayName(), - user.getLogin(), password, url); + Locale locale = getLocale(); + String subject = l_(locale, "pollen.email.userRegister.subject", + user.getLogin()); + String content = l_(locale, "pollen.email.userRegister.content", + user.getDisplayName(), + user.getLogin(), password, url); EmailService emailService = newService(EmailService.class); PollenEmail pollenEmail = emailService.getNewEmail(user); @@ -121,8 +129,8 @@ } public UserAccount updateUser(UserAccount user, - String newPassword, - boolean byAdmin) throws UserEmailAlreadyUsedException, UserInvalidPasswordException { + String newPassword, + boolean byAdmin) throws UserEmailAlreadyUsedException, UserInvalidPasswordException { try { @@ -168,24 +176,48 @@ } public UserAccount getNewUser() throws PollenException { - ServiceUserImpl service = new ServiceUserImpl(); - UserAccount result = service.executeGetNewUser(); + UserAccount result = new UserAccountImpl(); return result; } public void deleteUser(String login) { - ServiceUserImpl service = new ServiceUserImpl(); try { - service.executeDeleteUser(getTransaction(), login); + UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(getTransaction()); + UserAccount user = dao.findByLogin(login); + dao.delete(user); } catch (TopiaException e) { throw new PollenTechnicalException(e); } } + public List<UserAccount> getUsers(PagerUtil.PagerBean pager) { + + try { + UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(getTransaction()); + + long records = dao.count(); + pager.setRecords((int) records); + + PagerUtil.computeRecordIndexesAndPagesNumber(pager); + TopiaQuery query = dao.createQuery("e"); + query.setLimit(pager.getRecordStartIndex(), pager.getRecordEndIndex() - 1); + List<UserAccount> result = dao.findAllByQuery(query); + return result; + } catch (TopiaException e) { + throw new PollenTechnicalException(e); + } + } + public Map<String, UserAccount> getUsers(EntityFilter filter) { - ServiceUserImpl service = new ServiceUserImpl(); + try { - Map<String, UserAccount> result = service.executeGetUsers(getTransaction(), filter); + UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(getTransaction()); + + TopiaQuery query = dao.createQuery().addFilter(filter); + + List<UserAccount> users = dao.findAllByQuery(query); + Map<String, UserAccount> result = + Maps.uniqueIndex(users, PollenFunctions.USER_BY_LOGIN); return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -193,10 +225,10 @@ } public int getNbUsers() { - ServiceUserImpl service = new ServiceUserImpl(); try { - int result = service.executeGetNbUsers(getTransaction()); - return result; + UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(getTransaction()); + Long result = dao.count(); + return result.intValue(); } catch (TopiaException e) { throw new PollenTechnicalException(e); } @@ -214,7 +246,7 @@ user.setEmail(getConfiguration().getAdminEmail()); user.setNewPassword(getConfiguration().getAdminPassword()); try { - createUser(user, ""); + createUser(user, null); if (log.isInfoEnabled()) { log.info(_("pollen.info.admin.created", login)); } Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-01-23 10:32:33 UTC (rev 3101) @@ -1,3 +1,39 @@ +add=Add +addChoice-choiceDate-regexp=\\d{2}/\\d{2}/\\d{4}( \\d{2}\\\:\\d{2})? +addChoice-choiceDate-regexp-message=Date does not match pattern 12/31/2000 12\:59 AM. +addChoice-choiceDate-required-message=You must provide a choice. +addChoice-choiceImage-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$ +addChoice-choiceImage-regexp-message=The image must be a JPG, GIF or PNG file. +addChoice-choiceImage-required-message=You must provide a choice. +addChoice-choiceText-required-message=You must provide a choice. +cancel=Cancel +choiceDate-label=Date and time +choiceDescription-label=Description +choiceImage-label=Image +choiceText-label=Choice +create=Create +creatorEmail_msg=You had just created the new poll\: "%s".\nYou can access to this poll by following the links below.\n\nVote page\: \n%s\nEdit page\: \n%s +creatorEmail_subject=[Pollen] Poll creation (%s) +delete=Delete +edit=Edit +email-regexp=^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$ +email-regexp-message=Invalid email +help=Help +load=Load +login-required-message=You must provide a username +ok=Ok +pollFeed_choiceContent=%s +pollFeed_choiceTitle=New choice \: %s +pollFeed_commentContent=%s +pollFeed_commentTitle=New comment from %s +pollFeed_createContent= +pollFeed_createTitle=Poll created by %s +pollFeed_desc=%s +pollFeed_title=Pollen \: %s +pollFeed_voteContent=Poll state \: %s +pollFeed_voteTitle=New vote from %s +pollen.email.userRegister.content=Welcome %1$s. You had just created an account on the web application Pollen.\n\nLogin\: %2$s\nPassword\: %3$s\n\nYou can now manage your polls by logging on the website \: \n%4$s +pollen.email.userRegister.subject=[Pollen] Confirmation of account creation %s pollen.error.context.close= pollen.error.context.getRootContext= pollen.error.context.parse= @@ -118,3 +154,25 @@ pollen.info.started=Pollen is started \! pollen.info.stop=Stop Pollen pollen.text.empty= +pollen.ui.choice.add.submit=Add +pollen.ui.choice.add.title=Adding a choice +pollen.ui.choice.datePattern=MM/dd/yyyy h\:mm a +pollen.ui.choice.delete.confirm=Are you sure you want to delete this choice ? +pollen.ui.choice.delete.title=Delete this choice +pollen.ui.error.upload=An error occurred while uploading files. Maximum size allowed is %$1s per file, and %$2s total. +pollen.ui.user.cancelEdit=Cancel changes +pollen.ui.user.delete=Delete this user account +pollen.ui.user.delete.confirmMessage=Are you sure you want to definitively delete this user ? +pollen.ui.user.edit=Edit this user account +pollen.ui.user.save=Save this user account +pollen.ui.vote.noPager=%$1d existing votes +pollen.ui.vote.noVote=Aucune personne n'a encore participé au sondage +reminderEmail_msg=You have not yet voted for the poll "%s".\nYou can still participate with the identifier %s by following this link\: \n%s +reminderEmail_subject=[Pollen] Reminder (%s) +return=Return +save=Save +validate=Validate +voteEmail_msg=A vote has been submitted for the poll "%s". There are now %d votes for this poll.\nYou can access to this poll by following the links below.\n\nVote page\: \n%s\nEdit page\: \n%s +voteEmail_subject=[Pollen] Vote reporting (%s) +votingEmail_msg=A new poll has been created\: "%s".\nYou can participate with the identifier %s by following this link\: \n%s +votingEmail_subject=[Pollen] Invitation to vote (%s) Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-01-23 10:32:33 UTC (rev 3101) @@ -1,3 +1,46 @@ +addChoice-choiceDate-regexp=\\d{2}/\\d{2}/\\d{4}( \\d{2}\\\:\\d{2})? +addChoice-choiceDate-regexp-message=La date de début doit-être au format 31/12/2000 23\:59. +addChoice-choiceDate-required-message=Vous devez saisir un choix. +addChoice-choiceImage-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$ +addChoice-choiceImage-regexp-message=L'image doit-être au format JPG, GIF ou PNG. +addChoice-choiceImage-required-message=Vous devez saisir un choix. +addChoice-choiceText-required-message=Vous devez saisir un choix. +choiceDate-label=Date et heure +choiceDateField-label=Date et heure +choiceDateField-regexp=\\d{2}/\\d{2}/\\d{4}( \\d{2}\\\:\\d{2})? +choiceDateField-regexp-message=La date doit-être au format 31/12/2000 23\:59. +choiceDescription-label=Description +choiceImage-label=Image +choiceImageField-label=Image +choiceImageField-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$ +choiceImageField-regexp-message=L'image doit-être au format JPG, GIF ou PNG. +choiceText-label=Choix +connectionLegend=Connexion +date-pattern=dd/MM/yyyy HH\:mm +editEmail-regexp=^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$ +editEmail-regexp-message=Adresse email invalide. +email-label=Email +email-regexp=^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$ +email-regexp-message=Adresse email invalide. +firstName-label=Prénom +groupName-label=Nom du groupe +lastName-label=Nom +listName-label=Nom +listSelect-label=Liste +login-label=Identifiant +loginComp-label=Identifiant +loginComp-required-message=Vous devez entrer votre identifiant. +loginFailed=Mauvais identifiant ou mot de passe. +loginSubmit=Me connecter +name-label=Nom +participantEmail-regexp=^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$ +participantEmail-regexp-message=Adresse email invalide. +passwordComp-label=Mot de passe +passwordComp-required-message=Vous devez entrer votre mot de passe. +pollen.email.createPoll.content=Vous venez de créer le sondage "%1$s".\nVous pouvez y accéder en suivant les liens ci-dessous.\n\nPage de vote \: \n%2$s\nModération des votes \: \n%3$s\nPage de modification \: \n%4$s +pollen.email.createPoll.subject=[Pollen] Création d'un sondage (%1$s) +pollen.email.userRegister.content=Bienvenue %1$s. Vous venez de créer un compte sur l'application de sondage en ligne Pollen.\n\nIdentifiant \: %2$s\nMot de passe \: %3$s\n\nVous pouvez dès maintenant gérer vos sondages en vous identifiant sur le site \: \n%4$s +pollen.email.userRegister.subject=[Pollen] Confirmation de création du compte %s pollen.error.context.close=Erreur lors de la fermeture de la transaction pollen.error.context.getRootContext=Erreur lors de la récupération du contexte principale pollen.error.context.parse=Erreur lors du parse du fichier de configuration %1$s @@ -114,3 +157,72 @@ pollen.info.start=Démarrage de Pollen... pollen.info.started=Pollen a été démarré avec succès \! pollen.info.stop=Arrêt de Pollen +pollen.page.AdminUsers.title=Gestion des utilisateurs +pollen.page.PollLinks.title=Liens d'accès au sondage +pollen.page.UserLists.title=Vos listes de votants +pollen.ui.button.add=Ajouter +pollen.ui.button.create=Créer +pollen.ui.button.ok=Ok +pollen.ui.choice.add.submit=Ajouter +pollen.ui.choice.add.title=Ajout d'un choix +pollen.ui.choice.datePattern=dd/MM/yyyy HH\:mm +pollen.ui.choice.delete.confirm=Etes-vous sûr de vouloir définitivement supprimer ce choix ? +pollen.ui.choice.delete.title=Supprimer ce choix +pollen.ui.error.upload=Une erreur s'est produite lors du transfert des fichiers. La taille maximale autorisée est de %1$s par fichier et %2$s au total. +pollen.ui.list.create.success=La liste %1$s a été créée avec succès. +pollen.ui.list.create.title=Créer une nouvelle liste +pollen.ui.list.create.weightHelp=Ce chiffre correspond au poids du vote de la personne, c'est à dire le nombre de voix que possède la personne dans le sondage. +pollen.ui.list.delete=Supprimer la liste %1$s +pollen.ui.list.delete.confirmMessage=Etes-vous sûr de vouloir définitivement supprimer cette liste et l'intégralité de ses votants ? +pollen.ui.list.delete.success=La liste et son contenu ont été supprimé avec succès. +pollen.ui.list.emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email. +pollen.ui.list.nbParticipants=%1$d votants contenus dans cette liste +pollen.ui.list.notSelected=Aucune liste sélectionnée +pollen.ui.list.update.addParticipant=Ajouter un nouveau votant à la liste +pollen.ui.list.update.addParticipant.success=Le votant %1$s a été ajouté à la liste. +pollen.ui.list.update.cancelEdition=Annuler les changements +pollen.ui.list.update.removeParticipant=Supprimer ce votant +pollen.ui.list.update.removeParticipant.confirmMessage=Etes-vous sûr de vouloir supprimer %1$s de la liste ? +pollen.ui.list.update.removeParticipant.success=Le votant a été supprimé avec succès. +pollen.ui.list.update.saveParticipant=Enregistrer les modifications +pollen.ui.list.update.saveParticipant.success=Modification enregistrée avec succès. +pollen.ui.list.update.updateParticipant=Modifier ce votant +pollen.ui.participant.add=Nouveau participant +pollen.ui.participant.email-label=Email +pollen.ui.participant.name-label=Nom +pollen.ui.participant.weight-label=Poids +pollen.ui.poll.form.confirmlistChange=Des changements ont été effectués sur la/les liste(s), un changement de restriction supprimera les modifications. Voulez-vous continuer ? +pollen.ui.poll.links.adminVotePage=Lien d'accès modérateur à la page des votes \: +pollen.ui.poll.links.creatorEmail.notDefined=Aucun email n'a été défini à la création du sondage, vous devriez enregistrer cette page dans vos favoris pour ne pas perdre les liens. +pollen.ui.poll.links.creatorEmail.success=Un email vous a été envoyé avec les liens ci-dessous. +pollen.ui.poll.links.editPage=Lien d'accès à la modification du sondage \: +pollen.ui.poll.links.myPolls=Mes sondages +pollen.ui.poll.links.notAllowed=L'url est incorrect, vous n'êtes pas autorisé à accéder aux liens du sondage. +pollen.ui.poll.links.pollName=%1$s par %2$s +pollen.ui.poll.links.register=Si vous êtes un utilisateur identifié, vous pouvez retrouver ces liens dans la page +pollen.ui.poll.links.uriNotDefined=Page inaccessible sans identifiant du sondage dans l'url \! +pollen.ui.poll.links.votePage=Lien d'accès publique à la page des votes \: +pollen.ui.tooltip.help=Aide +pollen.ui.user.create.emailFailedShowPassword=Le mot de passe généré est le suivant \: %1$s +pollen.ui.user.create.passwordGenerated=Le mot de passe du nouvel utilisateur a été généré. +pollen.ui.user.create.passwordHelp=Si vous précisez un email, un mot de passe sera généré et envoyé à l'utilisateur. Sinon le mot de passe sera identique au login. +pollen.ui.user.create.passwordSameAsLogin=Le mot de passe du nouvel utilisateur est le même que son identifiant. +pollen.ui.user.create.sendEmail=Un email a été envoyé au nouvel utilisateur %1$s à l'adresse %2$s. +pollen.ui.user.create.success=L'utilisateur %1$s a été créé avec succès. +pollen.ui.user.create.title=Créer un nouvel utilisateur +pollen.ui.user.delete=Supprimer cet utilisateur +pollen.ui.user.delete.confirmMessage=Etes-vous sûr de vouloir définitivement supprimer cet utilisateur ? +pollen.ui.user.display.notAllowed=Vous n'avez pas les droits nécessaires pour accéder à la page %1$s. +pollen.ui.user.display.notConnected=Vous devez vous connecter pour accéder à la page %1$s. +pollen.ui.user.nbUsers=%1$d utilisateurs existants +pollen.ui.user.register.autoConnection=Vous êtes maintenant connecté avec l'identifiant %1$s. +pollen.ui.user.register.sendEmail=Un email vous a été envoyé à l'adresse %1$s. +pollen.ui.user.update.cancel=Annuler les changements +pollen.ui.user.update.edit=Modifier cet utilisateur +pollen.ui.user.update.save=Enregistrer les modifications +pollen.ui.user.update.success=Modification enregistrée avec succès. +pollen.ui.user.validate.passwords=Les deux mots de passe ne correspondent pas. +pollen.ui.vote.delete.confirmMessage=Etes-vous sûr de vouloir supprimer ce vote ? +pollen.ui.vote.noPager=%1$d votes existants +pollen.ui.vote.noVote=Aucune personne n'a encore participé au sondage +weight-label=Poids Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationContext.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationContext.java 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationContext.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -26,6 +26,8 @@ import org.chorem.pollen.PollenConfiguration; import org.nuiton.topia.TopiaContext; +import java.net.URL; + /** * @author tchemit <chemit@codelutin.com> * @since 2.0 @@ -35,6 +37,8 @@ protected PollenConfiguration configuration; protected TopiaContext rootContext; + + protected URL applicationUrl; public PollenConfiguration getConfiguration() { return configuration; @@ -52,4 +56,11 @@ this.rootContext = rootContext; } + public URL getApplicationUrl() { + return applicationUrl; + } + + public void setApplicationUrl(URL applicationUrl) { + this.applicationUrl = applicationUrl; + } } Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -46,7 +46,7 @@ @Override protected TopiaContext beginTransaction() throws TopiaRuntimeException { PollenApplicationContext applicationContext = - PollenActionSupport.getEchoBaseApplicationContext(); + PollenActionSupport.getPollenApplicationContext(); TopiaContext rootContext = applicationContext.getRootContext(); try { Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenUIUtils.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenUIUtils.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenUIUtils.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,77 @@ +/* + * #%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; + +import org.apache.struts2.ServletActionContext; +import org.chorem.pollen.PollenTechnicalException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.net.MalformedURLException; +import java.net.URL; + +/** + * Usefull ui methods. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollenUIUtils { + + public static void redirect(String url) throws Exception { + + HttpServletResponse response = ServletActionContext.getResponse(); + HttpServletRequest request = ServletActionContext.getRequest(); + + String path = request.getContextPath(); + if (!url.startsWith("/")) { + path += "/"; + } + response.sendRedirect(path + url); + } + + public static URL getApplicationBase(HttpServletRequest request) { + + // get port + String port; + if ("http".equalsIgnoreCase(request.getScheme()) && request.getServerPort() != 80 || + "https".equalsIgnoreCase(request.getScheme()) && request.getServerPort() != 443) { + port = ":" + request.getServerPort(); + } else { + port = ""; + } + + String applicationBase = request.getScheme() + "://" + request.getServerName() + + port + request.getContextPath(); + try { + return new URL(applicationBase); + } catch (MalformedURLException e) { + throw new PollenTechnicalException( + "Could not compute pollen url", e); + } + } + + protected PollenUIUtils() { + } +} Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenUIUtils.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/CreatePoll.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/CreatePoll.java 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/CreatePoll.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -23,6 +23,11 @@ */ package org.chorem.pollen.ui.actions; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.PollImpl; +import org.chorem.pollen.services.PollService; +import org.nuiton.topia.TopiaException; + /** * Creates a new poll. * @@ -32,4 +37,36 @@ public class CreatePoll extends PollenActionSupport { private static final long serialVersionUID = 1L; + + protected Poll poll; + + public String getPageLogo() { + return "Creation"; + } + + public Poll getPoll() { + if (poll == null) { + poll = new PollImpl(); + } + return poll; + } + + @Override + public String execute() throws Exception { + + PollService service = newService(PollService.class); + + + try { + Poll basicPoll = service.createBasicPoll(poll); + + return SUCCESS; + } catch (TopiaException e) { + + } + + // back to input + return INPUT; + + } } Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/Login.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/Login.java 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/Login.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -68,6 +68,7 @@ try { UserAccount userAccount = service.connect(login, password); getPollenSession().setUserAccount(userAccount); + addActionMessage(_("pollen.information.your.are.loggued")); return SUCCESS; } catch (UserNotFoundException e) { addActionError(_("pollen.error.user.bad.login.or.password")); Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManagePolls.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManagePolls.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManagePolls.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,34 @@ +/* + * #%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; + +/** + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class ManagePolls extends PollenActionSupport{ + + private static final long serialVersionUID = 1L; +} Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManagePolls.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManageUsers.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManageUsers.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManageUsers.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,34 @@ +/* + * #%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; + +/** + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class ManageUsers extends PollenActionSupport{ + + private static final long serialVersionUID = 1L; +} Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManageUsers.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -27,6 +27,7 @@ import com.opensymphony.xwork2.ActionContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.struts2.ServletActionContext; import org.apache.struts2.StrutsStatics; import org.chorem.pollen.PollenConfiguration; import org.chorem.pollen.services.PollenService; @@ -35,12 +36,14 @@ import org.chorem.pollen.services.PollenServiceFactory; import org.chorem.pollen.ui.PollenApplicationContext; import org.chorem.pollen.ui.PollenSession; +import org.chorem.pollen.ui.PollenUIUtils; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.framework.TopiaTransactionAware; import org.nuiton.web.filter.TopiaTransactionFilter; import org.nuiton.web.struts2.BaseAction; import javax.servlet.http.HttpServletRequest; +import java.net.URL; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @@ -75,7 +78,7 @@ private SimpleDateFormat monthFormat; - public static PollenApplicationContext getEchoBaseApplicationContext() { + public static PollenApplicationContext getPollenApplicationContext() { Map<String, Object> application = getActionContext().getApplication(); PollenApplicationContext applicationContext = (PollenApplicationContext) application.get(APPLICATION_CONTEXT_PARAMETER); @@ -83,7 +86,7 @@ } public PollenConfiguration getConfiguration() { - return getEchoBaseApplicationContext().getConfiguration(); + return getPollenApplicationContext().getConfiguration(); } /** Pollen User session. */ @@ -128,9 +131,23 @@ } public static String getApplicationVersion() { - return getEchoBaseApplicationContext().getConfiguration().getVersion().toString(); + return getPollenApplicationContext().getConfiguration().getVersion().toString(); } + public URL getApplicationUrl() { + URL url = getPollenApplicationContext().getApplicationUrl(); + if (url == null) { + + // first time asking this, let's compute it + url = PollenUIUtils.getApplicationBase(ServletActionContext.getRequest()); + if (log.isInfoEnabled()) { + log.info("Pollen application url : " + url); + } + getPollenApplicationContext().setApplicationUrl(url); + } + return url; + } + /** * Fabrique pour récupérer le ServiceContext tel qu'il devrait être fourni * à la fabrication d'un service. Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/RegisterUser.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/RegisterUser.java 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/RegisterUser.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -68,7 +68,7 @@ UserService service = newService(UserService.class); try { - UserAccount createdUser = service.createUser(user); + UserAccount createdUser = service.createUser(user, getApplicationUrl()); getTransaction().commitTransaction(); getPollenSession().setUserAccount(createdUser); Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONPaginedAction.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONPaginedAction.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONPaginedAction.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,119 @@ +/* + * #%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.json; + +import org.apache.commons.lang3.StringUtils; +import org.apache.struts2.json.JSONException; +import org.apache.struts2.json.JSONUtil; +import org.chorem.pollen.ui.actions.PollenActionSupport; +import org.nuiton.util.PagerUtil; + +/** + * Abstract JSON action with pagination support. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public abstract class AbstractJSONPaginedAction extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + public abstract Integer getRows(); + + public abstract Integer getPage(); + + public abstract Integer getTotal(); + + public abstract Integer getRecords(); + + protected PagerUtil.PagerBean pager = PagerUtil.newPagerBean(); + + // sorting order - asc or desc + protected String sord; + + // get index row - i.e. user click to sort. + protected String sidx; + + protected String filters; + + public void setRows(Integer rows) { + pager.setPageSize(rows); + } + + public void setPage(Integer page) { + pager.setPageIndex(page); + } + + public String getSord() { + return sord; + } + + public void setSord(String sord) { + this.sord = sord; + } + + public String getSidx() { + return sidx; + } + + public void setSidx(String sidx) { + this.sidx = sidx; + } + + public String getFilters() { + return filters; + } + + public void setFilters(String filters) { + this.filters = filters; + } + + protected String getSortColumn() { + String result = null; + if (useSort()) { + result = sidx; + } + return result; + } + + protected Boolean isSortAscendant() { + Boolean result = null; + if (useSort()) { + result = "asc".equals(sord); + } + return result; + } + + protected boolean useSort() { + return StringUtils.isNotEmpty(sidx); + } + + protected Object getFilterObject() throws JSONException { + Object filterObject = null; + if (StringUtils.isNotEmpty(filters)) { + filterObject = JSONUtil.deserialize(filters); + } + return filterObject; + } +} Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONPaginedAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,89 @@ +/* + * #%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.json; + +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.services.UserService; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +import java.util.List; +import java.util.Map; + +/** + * Obtain paginated users. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class GetPolls extends AbstractJSONPaginedAction { + + private static final long serialVersionUID = 1L; + + protected transient Map<String, Object>[] polls; + + public Map<String, Object>[] getPolls() { + return polls; + } + + @Override + public Integer getRows() { + return pager.getPageSize(); + } + + @Override + public Integer getPage() { + return pager.getPageIndex(); + } + + @Override + public Integer getTotal() { + return pager.getPagesNumber(); + } + + @Override + public Integer getRecords() { + return pager.getRecords(); + } + + @Override + public String execute() throws Exception { + + UserService userService = newService(UserService.class); + + List<UserAccount> allUsers = userService.getUsers(pager); + + polls = new Map[allUsers.size()]; + Binder<UserAccount, UserAccount> binder = + BinderFactory.newBinder(UserAccount.class); + int index = 0; + for (UserAccount user : allUsers) { + Map<String, Object> map = binder.obtainProperties(user); + map.put("id", user.getTopiaId()); + polls[index++] = map; + } + + return SUCCESS; + } +} Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,89 @@ +/* + * #%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.json; + +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.services.UserService; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +import java.util.List; +import java.util.Map; + +/** + * Obtain paginated users. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class GetUsers extends AbstractJSONPaginedAction { + + private static final long serialVersionUID = 1L; + + protected transient Map<String, Object>[] users; + + public Map<String, Object>[] getUsers() { + return users; + } + + @Override + public Integer getRows() { + return pager.getPageSize(); + } + + @Override + public Integer getPage() { + return pager.getPageIndex(); + } + + @Override + public Integer getTotal() { + return pager.getPagesNumber(); + } + + @Override + public Integer getRecords() { + return pager.getRecords(); + } + + @Override + public String execute() throws Exception { + + UserService userService = newService(UserService.class); + + List<UserAccount> allUsers = userService.getUsers(pager); + + users = new Map[allUsers.size()]; + Binder<UserAccount, UserAccount> binder = + BinderFactory.newBinder(UserAccount.class); + int index = 0; + for (UserAccount user : allUsers) { + Map<String, Object> map = binder.obtainProperties(user); + map.put("id", user.getTopiaId()); + users[index++] = map; + } + + return SUCCESS; + } +} Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/AbstractCheckInterceptor.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/AbstractCheckInterceptor.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/AbstractCheckInterceptor.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,94 @@ +/* + * #%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.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.apache.struts2.ServletActionContext; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Abstract check interceptor. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public abstract class AbstractCheckInterceptor extends AbstractInterceptor { + + private static final long serialVersionUID = -7169251953113201351L; + + /** Logger. */ + private static final Log log = + LogFactory.getLog(AbstractCheckInterceptor.class); + + /** Where to redirect where user is loggued */ + protected String redirectAction; + + public void setRedirectAction(String redirectAction) { + this.redirectAction = redirectAction; + } + + protected abstract boolean doCheck(ActionInvocation invocation); + + @Override + public String intercept(ActionInvocation invocation) throws Exception { + + boolean check = doCheck(invocation); + + if (!check) { + + String redirectUrl = getRedirectUrl(); + if (log.isInfoEnabled()) { + log.info("Will redirect to " + redirectUrl); + } + redirect(redirectUrl); + + return null; + } + + String result = invocation.invoke(); + return result; + } + + protected String getRedirectUrl() { + return redirectAction; + } + + protected void redirect(String url) throws Exception { + + HttpServletResponse response = ServletActionContext.getResponse(); + HttpServletRequest request = ServletActionContext.getRequest(); + + String path = request.getContextPath(); + if (!url.startsWith("/")) { + path += "/"; + } + response.sendRedirect(path + url); + } + +} Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/AbstractCheckInterceptor.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,53 @@ +/* + * #%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.interceptors; + +import com.google.common.base.Preconditions; +import com.opensymphony.xwork2.ActionInvocation; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.ui.PollenSession; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * To check if logged user is admin. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class CheckUserIsAdmin extends AbstractCheckInterceptor { + + private static final long serialVersionUID = 1L; + + @Override + protected boolean doCheck(ActionInvocation invocation) { + PollenActionSupport action = (PollenActionSupport) invocation.getAction(); + + PollenSession echoBaseSession = action.getPollenSession(); + + UserAccount user = echoBaseSession.getUserAccount(); + Preconditions.checkNotNull(user, "No user found is session"); + + return user.isAdmin(); + } +} Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,98 @@ +/* + * #%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.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@codelutin.com> + * @since 0.1 + */ +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(); + + PollenSession echoBaseSession = action.getPollenSession(); + boolean userLoggued = echoBaseSession.getUserAccount() != null; + + if (!userLoggued && log.isInfoEnabled()) { + log.info("No user loggued!"); + } + + 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); + + return null; + } + + // let's continue + String result = invocation.invoke(); + return result; + } + + +} Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsLogguedInterceptor.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-admin.xml =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-admin.xml (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + #%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% + --> + + +<!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" + "http://struts.apache.org/dtds/struts-2.1.7.dtd"> + +<struts> + + <package name="admin" extends="default" namespace="/admin"> + + <default-interceptor-ref name="pollenBasicAdminStack"/> + + <!-- add interceptor to be connected --> + <!-- add interceptor to be admin --> + + <!-- manage users --> + <action name="usersList" method="input" + class="org.chorem.pollen.ui.actions.ManageUsers"> + <interceptor-ref name="pollenBasicAdminStack"/> + <result name="input">/WEB-INF/jsp/usersList.jsp</result> + </action> + + <!-- manage polls --> + <action name="pollsList" method="input" + class="org.chorem.pollen.ui.actions.ManagePolls"> + <interceptor-ref name="pollenBasicAdminStack"/> + <result name="input">/WEB-INF/jsp/pollsList.jsp</result> + </action> + + </package> + + +</struts> + Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-admin.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-json.xml =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-json.xml (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + #%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% + --> + + +<!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" + "http://struts.apache.org/dtds/struts-2.1.7.dtd"> + +<struts> + + <package name="json" extends="default" namespace="/json"> + + <!-- get pagined users --> + <action name="getUsers" + class="org.chorem.pollen.ui.actions.json.GetUsers"> + <interceptor-ref name="pollenBasicLogguedStack"/> + <result type="json"/> + </action> + + <!-- get pagined polls --> + <action name="getPolls" + class="org.chorem.pollen.ui.actions.json.GetPolls"> + <interceptor-ref name="pollenBasicLogguedStack"/> + <result type="json"/> + </action> + + </package> + +</struts> + Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-json.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-poll.xml =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-poll.xml (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + #%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% + --> + + +<!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" + "http://struts.apache.org/dtds/struts-2.1.7.dtd"> + +<struts> + + <package name="poll" extends="default" namespace="/poll"> + + + <!-- create poll --> + <action name="createPoll" + class="org.chorem.pollen.ui.actions.CreatePoll"> + <result name="input">/WEB-INF/jsp/createPoll.jsp</result> + <result>/WEB-INF/jsp/home.jsp</result> + </action> + + <!-- display poll --> + <action name="displayPoll" + class="org.chorem.pollen.ui.actions.DisplayPoll"> + <result name="input">/WEB-INF/jsp/poll.jsp</result> + <result>/WEB-INF/jsp/home.jsp</result> + </action> + + <!-- display poll result --> + <action name="displayPollResult" + class="org.chorem.pollen.ui.actions.DisplayPollResult"> + <result name="input">/WEB-INF/jsp/pollResult.jsp</result> + <result>/WEB-INF/jsp/home.jsp</result> + </action> + + <!-- display createds polls --> + <action name="displayCreatedPolls" + class="org.chorem.pollen.ui.actions.DisplayCreatedPolls"> + <result name="input">/WEB-INF/jsp/createdPolls.jsp</result> + <result>/WEB-INF/jsp/home.jsp</result> + </action> + + <!-- display participated polls --> + <action name="displayParticipatedPolls" + class="org.chorem.pollen.ui.actions.DisplayParticipatedPolls"> + <result name="input">/WEB-INF/jsp/participatedPolls.jsp</result> + <result>/WEB-INF/jsp/home.jsp</result> + </action> + + + </package> + + +</struts> + Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-poll.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-user.xml =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-user.xml (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + #%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% + --> + + +<!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" + "http://struts.apache.org/dtds/struts-2.1.7.dtd"> + +<struts> + + <package name="user" extends="default" namespace="/user"> + + <!-- login --> + <action name="login" class="org.chorem.pollen.ui.actions.Login"> + <result name="error">/WEB-INF/jsp/home.jsp</result> + <result type="redirectToHome"/> + </action> + + <!-- register user --> + <action name="registerUser" + class="org.chorem.pollen.ui.actions.RegisterUser"> + <result name="input">/WEB-INF/jsp/registerUser.jsp</result> + <result type="redirectToHome"/> + </action> + + <!-- show user account --> + <action name="showUser" + class="org.chorem.pollen.ui.actions.ShowUser"> + <result>/WEB-INF/jsp/showUser.jsp</result> + </action> + + <!-- modify user account --> + <action name="updateUser" + class="org.chorem.pollen.ui.actions.UpdateUser"> + <result name="input">/WEB-INF/jsp/updateUser.jsp</result> + <result type="redirectAction"> + <param name="actionName">showUser</param> + <param name="namespace">/user</param> + </result> + </action> + + <!-- logout --> + <action name="logout" class="org.chorem.pollen.ui.actions.Logout"> + <result type="redirectToHome"/> + </action> + + </package> + + +</struts> + Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-user.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-01-23 10:32:33 UTC (rev 3101) @@ -2,6 +2,7 @@ pollen.action.modify=Modify pollen.action.register=Register pollen.action.validate=Submit +pollen.common.admin=Admin pollen.common.bugReport=Bug report pollen.common.email=Em@il pollen.common.firstName=First name @@ -24,7 +25,10 @@ pollen.error.user.invalid.password= pollen.error.user.login.already.used=This login is already used pollen.fieldset.connexionInformation=Information de connexion +pollen.fieldset.login=Login pollen.fieldset.userInformation=Informations de l'utilisateur +pollen.information.need.login=You must be logged to access this page. Please fill the form below. +pollen.information.your.are.loggued=You are logged. pollen.label.contact.administrator=Send an email to an administrator pollen.legend.login=Login pollen.menu.admin=Administration @@ -40,6 +44,8 @@ pollen.menu.polls=Polls pollen.menu.preferences=My account pollen.menu.register=Register -pollen.title.login=Page de login +pollen.title.createPoll=Nouveau sondage pollen.title.myAccount=My account +pollen.title.pollsList=Polls administration pollen.title.register=Register +pollen.title.usersList=Gestion des utilisateurs Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-01-23 10:32:33 UTC (rev 3101) @@ -2,6 +2,7 @@ pollen.action.modify=Modifier pollen.action.register=S'enregistrer pollen.action.validate=Valider +pollen.common.admin=Admin pollen.common.bugReport=Rapport de bug pollen.common.email=Em@il pollen.common.firstName=Prénom @@ -24,11 +25,14 @@ pollen.error.user.invalid.password= pollen.error.user.login.already.used=Le login saisie est déjà utilisé par un autre utilisateur pollen.fieldset.connexionInformation=Information de connexion +pollen.fieldset.login=Connexion pollen.fieldset.userInformation=Informations de l'utilisateur +pollen.information.need.login=Vous devez être identifié pour pouvoir accéder à cette page. Veuillez remplir le formulaire ci-dessous. +pollen.information.your.are.loggued=Vous êtes connecté. pollen.label.contact.administrator=Contacter un administrateur pollen.legend.login=Login pollen.menu.admin=Administration -pollen.menu.createPoll=Créer une sondage +pollen.menu.createPoll=Créer un sondage pollen.menu.displayCreatedPolls=Sondages créés pollen.menu.displayParticipatedPolls=Sondages participés pollen.menu.displayVotingLists=Listes de votants @@ -40,6 +44,8 @@ pollen.menu.polls=Sondages pollen.menu.preferences=Mon compte pollen.menu.register=Inscrivez-vous -pollen.title.login=Page de login +pollen.title.createPoll=Nouveau sondage pollen.title.myAccount=Mon compte +pollen.title.pollsList=Liste des sondages pollen.title.register=S'enregistrer +pollen.title.usersList=Gestion des utilisateurs Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/struts.xml =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/struts.xml 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/struts.xml 2012-01-23 10:32:33 UTC (rev 3101) @@ -47,140 +47,123 @@ <!--see http://struts.apache.org/2.2.3/docs/performance-tuning.html--> <constant name="struts.freemarker.templatesCache" value="true"/> - <package name="default" extends="json-default" abstract="true" namespace="/"> + <package name="default" extends="json-default" namespace="/"> + <result-types> + <result-type name="redirectToHome" + class="org.apache.struts2.dispatcher.ServletActionRedirectResult"> + <param name="namespace">/</param> + <param name="actionName">home</param> + </result-type> + </result-types> + <interceptors> <!-- to remove parameter from context --> <interceptor name="paramRemover" class="com.opensymphony.xwork2.interceptor.ParameterRemoverInterceptor"/> + <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="loginAction">/notAdmin</param> + <param name="redirectAction">/home</param> + </interceptor> + <!-- basic stack --> <interceptor-stack name="pollenBasicStack"> <interceptor-ref name="i18n"/> <interceptor-ref name="basicStack"/> + <interceptor-ref name="store"> + <param name="operationMode">STORE</param> + </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"/> <interceptor-ref name="paramsPrepareParamsStack"/> </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 --> - <default-interceptor-ref name="pollenBasicStack"/> + <default-interceptor-ref name="pollenParamsPrepareParamsStack"/> + <default-action-ref name="home"/> + <!-- default action to use everywhere (fix i18n when not translated) --> <default-class-ref class="org.chorem.pollen.ui.actions.PollenActionSupport"/> - </package> + <action name="notLoggued"> + <result>/WEB-INF/jsp/login.jsp</result> + </action> - <package name="applicationDefault" extends="default" namespace="/"> + <action name="notAdmin"> + <result>/WEB-INF/jsp/adminRequired.jsp</result> + </action> - <default-interceptor-ref name="pollenParamsPrepareParamsStack"/> - - <default-action-ref name="home"/> - - <!-- go to home --> <action name="home" class="org.chorem.pollen.ui.actions.PollenActionSupport"> - <result>/WEB-INF/jsp/home.jsp</result> - - <!--<interceptor-ref name="i18nStack"/>--> - <!--<!– remove the request_locale parameter from request –>--> - <!--<interceptor-ref name="paramRemover">--> - <!--<param name="paramNames">request_locale</param>--> - <!--</interceptor-ref>--> + <interceptor-ref name="store"> + <param name="operationMode">RETRIEVE</param> + </interceptor-ref> </action> <!-- change lang--> <action name="changeLang" class="org.chorem.pollen.ui.actions.PollenActionSupport"> - <result type="redirectAction">home</result> + <result type="redirectToHome"/> <interceptor-ref name="i18nStack"/> <!-- remove the request_locale parameter from request --> <interceptor-ref name="paramRemover"> <param name="paramNames">request_locale</param> </interceptor-ref> + <interceptor-ref name="store"> + <param name="operationMode">STORE</param> + </interceptor-ref> </action> - <!-- login --> - <action name="login" class="org.chorem.pollen.ui.actions.Login"> - <result name="error">/WEB-INF/jsp/home.jsp</result> - <result type="redirectAction">home</result> - </action> - - <!-- register user --> - <action name="registerUser" - class="org.chorem.pollen.ui.actions.RegisterUser"> - <result name="input">/WEB-INF/jsp/registerUser.jsp</result> - <result type="redirectAction">home</result> - </action> - - <!-- show user account --> - <action name="showUser" - class="org.chorem.pollen.ui.actions.ShowUser"> - <result>/WEB-INF/jsp/showUser.jsp</result> - </action> - - <!-- modify user account --> - <action name="updateUser" - class="org.chorem.pollen.ui.actions.UpdateUser"> - <result name="input">/WEB-INF/jsp/updateUser.jsp</result> - <result type="redirectAction">showUser</result> - </action> - - <!-- logout --> - <action name="logout" class="org.chorem.pollen.ui.actions.Logout"> - <result>/WEB-INF/jsp/home.jsp</result> - </action> - - <!-- create poll --> - <action name="createPoll" - class="org.chorem.pollen.ui.actions.CreatePoll"> - <result name="input">/WEB-INF/jsp/createPoll.jsp</result> - <result>/WEB-INF/jsp/home.jsp</result> - </action> - - <!-- display poll --> - <action name="displayPoll" - class="org.chorem.pollen.ui.actions.DisplayPoll"> - <result name="input">/WEB-INF/jsp/poll.jsp</result> - <result>/WEB-INF/jsp/home.jsp</result> - </action> - - <!-- display poll result --> - <action name="displayPollResult" - class="org.chorem.pollen.ui.actions.DisplayPollResult"> - <result name="input">/WEB-INF/jsp/pollResult.jsp</result> - <result>/WEB-INF/jsp/home.jsp</result> - </action> - - <!-- display createds polls --> - <action name="displayCreatedPolls" - class="org.chorem.pollen.ui.actions.DisplayCreatedPolls"> - <result name="input">/WEB-INF/jsp/createdPolls.jsp</result> - <result>/WEB-INF/jsp/home.jsp</result> - </action> - - <!-- display participated polls --> - <action name="displayParticipatedPolls" - class="org.chorem.pollen.ui.actions.DisplayParticipatedPolls"> - <result name="input">/WEB-INF/jsp/participatedPolls.jsp</result> - <result>/WEB-INF/jsp/home.jsp</result> - </action> - </package> + <include file="config/struts-json.xml"/> + <include file="config/struts-admin.xml"/> + <include file="config/struts-poll.xml"/> + <include file="config/struts-user.xml"/> + </struts> Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/template/css_xhtml/checkbox.ftl =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/template/css_xhtml/checkbox.ftl (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/template/css_xhtml/checkbox.ftl 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,109 @@ +<#-- + #%L + EchoBase :: UI + + $Id: checkbox.ftl 80 2011-11-14 15:09:26Z tchemit $ + $HeadURL: http://svn.forge.codelutin.com/svn/echobase/trunk/echobase-ui/src/main/resou... $ + %% + Copyright (C) 2011 Ifremer, 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% +--> +<#-- +NOTE: The 'header' stuff that follows is in this one file for checkbox due to the fact +that for checkboxes we do not want the label field to show up as checkboxes handle their own +lables +--> +<#assign hasFieldErrors = fieldErrors?? && fieldErrors[parameters.name]??/> +<div <#rt/><#if parameters.id??>id="wwgrp_${parameters.id}"<#rt/></#if> class="wwgrp"> + +<#if hasFieldErrors> +<div <#rt/><#if parameters.id??>id="wwerr_${parameters.id}"<#rt/></#if> class="wwerr"> +<#list fieldErrors[parameters.name] as error> + <div<#rt/> + <#if parameters.id??> + errorFor="${parameters.id}"<#rt/> + </#if> + class="errorMessage"> + ${error?html} + </div><#t/> +</#list> +</div><#t/> +</#if> +<#if parameters.labelposition?default("left") == 'left'> +<span <#rt/> +<#if parameters.id??>id="wwlbl_${parameters.id}"<#rt/></#if> class="wwlbl"> +<label<#t/> +<#if parameters.id??> + for="${parameters.id?html}"<#rt/> +</#if> +<#if hasFieldErrors> + class="checkboxErrorLabel"<#rt/> +<#else> + class="label"<#rt/> +</#if> +>${parameters.label?html} +<#if parameters.tooltip??> + <#include "/${parameters.templateDir}/xhtml/tooltip.ftl" /> +</#if> +</label><#rt/> +</span> +</#if> + +<#if parameters.labelposition?default("left") == 'top'> +<div <#rt/> +<#else> +<span <#rt/> +</#if> +<#if parameters.id??>id="wwctrl_${parameters.id}"<#rt/></#if> class="wwctrl"> + +<#if parameters.required?default(false)> + <span class="required">*</span><#t/> +</#if> + +<#include "/${parameters.templateDir}/simple/checkbox.ftl" /> +<#if parameters.labelposition?default("left") != 'left'> +<#if parameters.labelposition?default("left") == 'top'> +</div> <#rt/> +<#else> +</span> <#rt/> +</#if> +<#if parameters.label??> +<#if parameters.labelposition?default("left") == 'top'> +<div <#rt/> +<#else> +<span <#rt/> +</#if> +<#if parameters.id??>id="wwlbl_${parameters.id}"<#rt/></#if> class="wwlbl"> +<label<#t/> +<#if parameters.id??> + for="${parameters.id?html}"<#rt/> +</#if> +<#if hasFieldErrors> + class="checkboxErrorLabel"<#rt/> +<#else> + class="checkboxLabel"<#rt/> +</#if> +>${parameters.label?html}</label><#rt/> +</#if> +</#if> +<#if parameters.label??> +<#if parameters.labelposition?default("left") == 'top'> +</div> <#rt/> +<#else> +</span> <#rt/> +</#if> +</#if> +</div> Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/template/css_xhtml/controlheader-core.ftl =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/template/css_xhtml/controlheader-core.ftl (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/template/css_xhtml/controlheader-core.ftl 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,74 @@ +<#-- + #%L + EchoBase :: UI + + $Id: controlheader-core.ftl 80 2011-11-14 15:09:26Z tchemit $ + $HeadURL: http://svn.forge.codelutin.com/svn/echobase/trunk/echobase-ui/src/main/resou... $ + %% + Copyright (C) 2011 Ifremer, 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% +--> +<#-- + Only show message if errors are available. + This will be done if ActionSupport is used. +--> +<#assign hasFieldErrors = parameters.name?? && fieldErrors?? && fieldErrors[parameters.name]??/> +<div <#rt/><#if parameters.id??>id="wwgrp_${parameters.id}"<#rt/></#if> class="wwgrp"> + +<#if hasFieldErrors> +<div <#rt/><#if parameters.id??>id="wwerr_${parameters.id}"<#rt/></#if> class="wwerr"> +<#list fieldErrors[parameters.name] as error> + <div<#rt/> + <#if parameters.id??> + errorFor="${parameters.id}"<#rt/> + </#if> + class="errorMessage"> + ${error?html} + </div><#t/> +</#list> +</div><#t/> +</#if> + +<#if parameters.label??> +<#if parameters.labelposition?default("top") == 'top'> +<div <#rt/> +<#else> +<span <#rt/> +</#if> +<#if parameters.id??>id="wwlbl_${parameters.id}"<#rt/></#if> class="wwlbl"> + <label <#t/> +<#if parameters.id??> + for="${parameters.id?html}" <#t/> +</#if> +<#if hasFieldErrors> + class="errorLabel"<#t/> +<#else> + class="label"<#t/> +</#if> + ><#t/> + + ${parameters.label?html} ${parameters.labelseparator!":"?html} +<#if parameters.required?default(false)> + <span class="required">*</span><#t/> +</#if> +<#include "/${parameters.templateDir}/xhtml/tooltip.ftl" /> + </label><#t/> +<#if parameters.labelposition?default("top") == 'top'> +</div> <#rt/> +<#else> +</span> <#rt/> +</#if> +</#if> Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-01-23 10:32:33 UTC (rev 3101) @@ -65,7 +65,7 @@ <!-- Entête de la page --> <p id="po-header-logo"> - <s:a action="home"> + <s:a action="home" namespace="/"> <img src="<s:url value='/img/pollen%{pageLogo}_%{safeLanguage}.png' />" alt="Pollen"/> </s:a> @@ -102,7 +102,7 @@ <div class="dropdown_menu" id="login_menu" style="display: none;"> <div class="top_right${pageLogo}"></div> <div class="top_left${pageLogo}"></div> - <s:form id="connection" action="login" method="POST"> + <s:form id="connection" action="login" method="POST" namespace="/user"> <ul class="top_middle${pageLogo}"> <li> <label for="connection_login"> @@ -126,7 +126,7 @@ </s:form> </div> <s:text name="pollen.common.or"/> - <s:a action="registerUser" method="input"> + <s:a action="registerUser" method="input" namespace="/user"> <s:text name="pollen.menu.register"/> </s:a> </s:else> @@ -149,23 +149,23 @@ <div class="top_left${pageLogo}"></div> <ul class="top_middle${pageLogo}"> <li> - <s:a action="createPoll" method="input"> + <s:a action="createPoll" method="input" namespace="/poll"> <s:text name="pollen.menu.createPoll"/> </s:a> </li> <s:if test="userExists"> <li> - <s:a action="displayCreatedPolls" method="input"> + <s:a action="displayCreatedPolls" method="input" namespace="/poll"> <s:text name="pollen.menu.displayCreatedPolls"/> </s:a> </li> <li> - <s:a action="displayParticipatedPolls" method="input"> + <s:a action="displayParticipatedPolls" method="input" namespace="/poll"> <s:text name="pollen.menu.displayParticipatedPolls"/> </s:a> </li> <li> - <s:a action="displayVotingLists" method="input"> + <s:a action="displayVotingLists" method="input" namespace="/user"> <s:text name="pollen.menu.displayVotingLists"/> </s:a> </li> @@ -184,12 +184,12 @@ <div class="top_left${pageLogo}"></div> <ul class="top_middle${pageLogo}"> <li> - <s:a action="managePolls" method="input"> + <s:a action="pollsList" namespace="/admin"> <s:text name="pollen.menu.managePolls"/> </s:a> </li> <li> - <s:a action="manageUsers" method="input"> + <s:a action="usersList" namespace="/admin"> <s:text name="pollen.menu.manageUsers"/> </s:a> </li> Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/adminRequired.jsp =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/adminRequired.jsp (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/adminRequired.jsp 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,32 @@ +<%-- + #%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" %> + +<br/> + +<div> + La page demandé n'est accessible que par un administrateur. +</div> Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/adminRequired.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/createPoll.jsp =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/createPoll.jsp (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/createPoll.jsp 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,50 @@ +<%-- + #%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" %> + +<title><s:text name="pollen.title.createPoll"/></title> + +<h1 class="title${pageLogo}"><s:text name="pollen.title.createPoll"/></h1> + +<s:form method="POST" key="registerForm"> + + <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" required="true"/> + <s:password name="password2" key="pollen.common.password2" required="true"/> + </fieldset> + + <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"/> + </fieldset> + <br/> + <s:submit action="registerUser" key="pollen.action.register" align="center"/> +</s:form> Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/createPoll.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/home.jsp =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/home.jsp 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/home.jsp 2012-01-23 10:32:33 UTC (rev 3101) @@ -31,13 +31,13 @@ </div> <div class="center"> - <s:a action="createForm"> + <s:a action="createPoll" namespace="/poll"> <img src="<s:url value='/img/smallCreation_%{safeLanguage}.png' />" alt="poll creation"/> </s:a> - <s:a action="createForm"> + <s:a action="createForm" namespace="/poll"> <img src="<s:url value='/img/smallVote_%{safeLanguage}.png' />" alt="vote"/> </s:a> - <s:a action="createForm"> + <s:a action="createForm" namespace="/poll"> <img src="<s:url value='/img/smallVoteCounting_%{safeLanguage}.png' />" alt="voteCounting"/> </s:a> </div> \ No newline at end of file Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/login.jsp =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/login.jsp (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/login.jsp 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,69 @@ +<%-- + #%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" %> + +<div> + <strong> + <s:text name="pollen.information.need.login"/> + </strong> +</div> + +<br/> + +<s:form id="connection" action="login" method="POST" namespace="/user"> + +<fieldset> + <legend><s:text name="pollen.fieldset.login"/></legend> + + <s:textfield key="login" size="10" label="%{getText('pollen.common.login')}" + required="true"/> + <s:password key="password" + label="%{getText('pollen.common.password')}" size="10" + required="true"/> + + +</fieldset> + <br/> + <s:submit id="submitform" action="login" key="pollen.action.login" + align="center"/> + </s:form> +<div class="center" style="margin-bottom:20px;"> + <img src="<s:url value='/img/pollen_%{safeLanguage}.png' />" + alt="Pollen logo"/> +</div> +<div class="center"> + <s:a action="createForm"> + <img src="<s:url value='/img/smallCreation_%{safeLanguage}.png' />" + alt="poll creation"/> + </s:a> + <s:a action="createForm"> + <img src="<s:url value='/img/smallVote_%{safeLanguage}.png' />" alt="vote"/> + </s:a> + <s:a action="createForm"> + <img src="<s:url value='/img/smallVoteCounting_%{safeLanguage}.png' />" + alt="voteCounting"/> + </s:a> +</div> \ No newline at end of file Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/login.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollsList.jsp =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollsList.jsp (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollsList.jsp 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,61 @@ +<%-- +#%L + EchoBase :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, 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" pageEncoding="UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %> +<script type="text/javascript" + src="<s:url value='/js/gridHelper.js' />"></script> + +<title><s:text name="pollen.title.pollsList"/></title> + +<h1 class="title${pageLogo}"><s:text name="pollen.title.pollsList"/></h1> + +<s:url id="loadUrl" action="getPolls" namespace="/json" escapeAmp="false"/> + +<%--script type="text/javascript"> + + jQuery(document).ready(function () { + $.addRowSelectTopic('users'); + $.addClearSelectTopic('users'); + $.addAddRowTopic('users', '${addUrl}'); + $.addSingleRowTopic('users', 'Update', '${editUrl}', 'user.id'); + $.addSingleRowTopic('users', 'Delete', '${delUrl}', 'user.id'); + }); +</script--%> + +<sjg:grid id="users" dataType="json" href="%{loadUrl}" gridModel="users" + pager="true" pagerButtons="true" pagerInput="true" + navigator="true" rownumbers="false" autowidth="true" + onSelectRowTopics='users-rowSelect' editinline="true" 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="login" title='%{getText("pollen.common.login")}' sortable="false" editable="true"/> + <sjg:gridColumn name="firstName" title='%{getText("pollen.common.firstName")}' sortable="false" editable="true"/> + <sjg:gridColumn name="lastName" title='%{getText("pollen.common.lastName")}' sortable="false" editable="true"/> + <sjg:gridColumn name="email" title='%{getText("pollen.common.email")}' sortable="false" editable="true"/> + <sjg:gridColumn name="admin" title='%{getText("pollen.common.admin")}' sortable="false" width="100" formatter="checkbox" editable="true" edittype="checkbox"/> +</sjg:grid> Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/pollsList.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/usersList.jsp =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/usersList.jsp (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/usersList.jsp 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,61 @@ +<%-- +#%L + EchoBase :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, 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" pageEncoding="UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %> +<script type="text/javascript" + src="<s:url value='/js/gridHelper.js' />"></script> + +<title><s:text name="pollen.title.usersList"/></title> + +<h1 class="title${pageLogo}"><s:text name="pollen.title.usersList"/></h1> + +<s:url id="loadUrl" action="getUsers" namespace="/json" escapeAmp="false"/> + +<%--script type="text/javascript"> + + jQuery(document).ready(function () { + $.addRowSelectTopic('users'); + $.addClearSelectTopic('users'); + $.addAddRowTopic('users', '${addUrl}'); + $.addSingleRowTopic('users', 'Update', '${editUrl}', 'user.id'); + $.addSingleRowTopic('users', 'Delete', '${delUrl}', 'user.id'); + }); +</script--%> + +<sjg:grid id="users" dataType="json" href="%{loadUrl}" gridModel="users" + pager="true" pagerButtons="true" pagerInput="true" + navigator="true" rownumbers="false" autowidth="true" + onSelectRowTopics='users-rowSelect' editinline="true" 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="login" title='%{getText("pollen.common.login")}' sortable="false" editable="true"/> + <sjg:gridColumn name="firstName" title='%{getText("pollen.common.firstName")}' sortable="false" editable="true"/> + <sjg:gridColumn name="lastName" title='%{getText("pollen.common.lastName")}' sortable="false" editable="true"/> + <sjg:gridColumn name="email" title='%{getText("pollen.common.email")}' sortable="false" editable="true"/> + <sjg:gridColumn name="admin" title='%{getText("pollen.common.admin")}' sortable="false" width="100" formatter="checkbox" editable="true" edittype="checkbox"/> +</sjg:grid> Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/usersList.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/js/gridHelper.js =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/js/gridHelper.js (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/js/gridHelper.js 2012-01-23 10:32:33 UTC (rev 3101) @@ -0,0 +1,167 @@ +/* + * #%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 ($) { + + $.fn.extend( + { + addRowSelectTopic:function (gridId, callback) { + $.subscribe(gridId + '-rowSelect', function (event) { + if (event.originalEvent) { + var gridId = event.data.id; + var opts = jQuery.struts2_jquery[gridId] = {}; + + var id = event.originalEvent.id; + if (id) { + opts['selectedRow'] = id; + } + } + var callback = event.data.callback; + if (callback) { + callback(event); + } + }, {id:gridId, callback:callback}); + }, + + addClearSelectTopic:function (gridId, callback) { + $.subscribe(gridId + '-clearSelect', function (event) { + var gridId = event.data.id; + jQuery.struts2_jquery[gridId] = {}; + var callback = event.data.callback; + if (callback) { + callback(event); + } + }, {id:gridId, callback:callback}); + }, + + addAddRowTopic:function (gridId, url) { + $.subscribe(gridId + '-rowAdd', function (event) { + var url = event.data.url; + window.location = url; + }, {id:gridId, url:url}); + }, + + addSingleRowTopic:function (gridId, action, url, parameterName) { + $.subscribe(gridId + '-row' + action, function (event) { + var gridId = event.data.id; + var opts = jQuery.struts2_jquery[gridId]; + if (opts && opts['selectedRow']) { + var selectedId = opts['selectedRow']; + var parameterName = event.data.parameterName; + var params = {} + params[parameterName] = selectedId; + var url = $.prepareUrl(event.data.url, params); + window.location = url; + } + }, {id:gridId, url:url, parameterName:parameterName}); + }, + addMultiRowTopic:function (gridId, action, target, checkboxName, callback) { + $.subscribe(gridId + '-row' + action, function (event) { + var gridId = event.data.id; + var prefix = 'jqg_' + gridId + '_'; + var prefixLength = prefix.length; + + // get all selected ids + var inputs = $('table#' + gridId + ' :checked[id^="' + prefix + '"]'); + + if (inputs && inputs.length) { + var checkboxName = event.data.checkboxName; + inputs.each(function () { + var id = this.id; + var newId = id.substring(prefixLength); + $.attr(this, "name", checkboxName); + $.attr(this, "value", newId); + $.attr(this, "checked", "checked"); + }); + var callback = event.data.callback; + if (callback) { + callback(); + } + event.data.target.click(); + } + }, {id:gridId, + target:target, + checkboxName:checkboxName, + callback:callback}); + }, + + serializeCheckboxs:function (id, params, newId) { + var all = $(':checkbox[name="' + id + '"]'); + var selected = $(':checked[name="' + id + '"]'); + + if (all.length != selected.length) { + + // apply a year filter + var list = []; + selected.each(function () { + list.push(this.value); + }); + if (!newId) { + newId = id; + } + params[newId] = list; + } + }, + + prepareUrl:function (url, params) { + var result = url; + if (url.indexOf("?") > -1) { + result += "&"; + } else { + result += "?"; + } + result += $.param(params); + return result; + } + }); + + $.extend({ + addRowSelectTopic:function (gridId, callback) { + return $(document).addRowSelectTopic(gridId, callback); + }, + + addClearSelectTopic:function (gridId, callback) { + return $(document).addClearSelectTopic(gridId, callback); + }, + + addAddRowTopic:function (gridId, url) { + return $(document).addAddRowTopic(gridId, url); + }, + + addSingleRowTopic:function (gridId, action, url, parameterName) { + return $(document).addSingleRowTopic(gridId, action, url, parameterName); + }, + + addMultiRowTopic:function (gridId, action, target, checkboxName, calbback) { + return $(document).addMultiRowTopic(gridId, action, target, checkboxName, calbback); + }, + serializeCheckboxs:function (id, params, newId) { + return $(document).serializeCheckboxs(id, params, newId); + }, + prepareUrl:function (url, params) { + return $(document).prepareUrl(url, params); + } + }); +})(jQuery); + Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/js/gridHelper.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-2.0-beta-1/pom.xml =================================================================== --- branches/pollen-2.0-beta-1/pom.xml 2012-01-23 09:25:50 UTC (rev 3100) +++ branches/pollen-2.0-beta-1/pom.xml 2012-01-23 10:32:33 UTC (rev 3101) @@ -421,7 +421,7 @@ <nuitonUtilsVersion>2.4.4</nuitonUtilsVersion> <h2Version>1.3.163</h2Version> <postgresqlVersion>9.1-901-1.jdbc4</postgresqlVersion> - <struts2Version>2.3.1.1</struts2Version> + <struts2Version>2.3.1.2</struts2Version> <jqueryPluginVersion>3.2.1</jqueryPluginVersion> <slf4jVersion>1.6.4</slf4jVersion>