Author: fdesbois Date: 2010-04-23 19:09:22 +0200 (Fri, 23 Apr 2010) New Revision: 2973 Log: - Refactor page AdminUsers (behavior and render) - Add AbstractMappedGridDataSource + create UserAccountDataSource to manage pagination on users list. Use Filter bean in business to prepare the TopiaQuery to retrieve userAccount list - Add PollenPage and AbstractPollenPage to manage permissions from Border layout component + loginComponent use if necessary (using a delegate) - Remove useless language property from model - Add createDefaultAdmin if it's not already exist Added: trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollsPage.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/UserAccountDataSource.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminPolls.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminPolls_en.properties trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminPolls_fr.properties trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminUsers_en.properties trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminUsers_fr.properties trunk/pollen-ui/src/main/webapp/admin/AdminPolls.tml trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml trunk/pollen-ui/src/main/webapp/img/save.png trunk/pollen-ui/src/main/webapp/img/undo.png Removed: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/PollsAdmin.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/PasswordGenerator.java trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/PollsAdmin_en.properties trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/PollsAdmin_fr.properties trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/UsersAdmin_en.properties trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/UsersAdmin_fr.properties trunk/pollen-ui/src/main/webapp/admin/PollsAdmin.tml trunk/pollen-ui/src/main/webapp/admin/UsersAdmin.tml Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceEmailImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties trunk/pollen-business/src/main/xmi/pollen.zargo trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractUploadPage.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Index.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsCreated.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java trunk/pollen-ui/src/main/resources/i18n/pollen-ui-en_GB.properties trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border_fr.properties trunk/pollen-ui/src/main/webapp/css/common.css trunk/pom.xml Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,6 +1,7 @@ package org.chorem.pollen; import java.util.Date; +import org.chorem.pollen.service.ServiceUser; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.util.ApplicationConfig; @@ -17,7 +18,7 @@ * </pre> * @param config ApplicationConfig */ - public void loadConfiguration(ApplicationConfig config); + void loadConfiguration(ApplicationConfig config); /** * start : @@ -30,14 +31,15 @@ * - Initialize i18n for error messages * - Create default admin if needed (this will load the topiaRootContext). * </pre> + * @param serviceUser to manage default admin if needed */ - public void start(); + void start(ServiceUser serviceUser); /** * stop : * Stop the application. Close the Topia rootContext. */ - public void stop(); + void stop(); /** * getProperty : @@ -45,7 +47,7 @@ * @param property PollenProperty * @return String */ - public String getProperty(PollenProperty property); + String getProperty(PollenProperty property); /** * hasProperty : @@ -53,7 +55,7 @@ * @param property PollenProperty * @return boolean */ - public boolean hasProperty(PollenProperty property); + boolean hasProperty(PollenProperty property); /** * getConfiguration : @@ -61,21 +63,21 @@ * if needed. * @return ApplicationConfig */ - public ApplicationConfig getConfiguration(); + ApplicationConfig getConfiguration(); /** * getCurrentDate : * Return the current date from context * @return Date */ - public Date getCurrentDate(); + Date getCurrentDate(); /** * encodePassword : * @param password * @return String */ - public String encodePassword(String password); + String encodePassword(String password); /** * createPollenUrlId : @@ -83,14 +85,14 @@ * This UId represent the entity in UI module. * @return String */ - public String createPollenUrlId(); + String createPollenUrlId(); /** * beginTransaction : * @return TopiaContext * @throws TopiaException */ - public TopiaContext beginTransaction() throws TopiaException; + TopiaContext beginTransaction() throws TopiaException; /** * doCatch : @@ -99,7 +101,7 @@ * @param args * @throws PollenException */ - public void treateError(Exception eee, String message, Object... args) + void treateError(Exception eee, String message, Object... args) throws PollenException; /** @@ -110,14 +112,14 @@ * @param args * @throws PollenException */ - public void treateError(TopiaContext transaction, Exception eee, + void treateError(TopiaContext transaction, Exception eee, String message, Object... args) throws PollenException; /** * doFinally : * @param transaction */ - public void closeTransaction(TopiaContext transaction); + void closeTransaction(TopiaContext transaction); } //PollenContext Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -3,10 +3,13 @@ import java.security.NoSuchAlgorithmException; import java.util.Date; +import java.util.Locale; import java.util.Properties; import java.util.UUID; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.service.ServiceUser; import org.nuiton.i18n.I18n; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; @@ -102,31 +105,26 @@ * */ @Override - public void start() { + public void start(ServiceUser serviceUser) { try { - if (log.isInfoEnabled()) { - log.info("Start Pollen"); -// log.info("Initialize i18n bundle"); - } I18n.setInitializer(new DefaultI18nInitializer("pollen-business")); I18n.init(); + if (log.isInfoEnabled()) { + log.info(_("pollen.info.start")); + } + // Set context in PollenProperty enum to use easily method // getValue() on PollenProperty PollenProperty.setContext(this); - -// ServiceUserImpl serviceUser = new ServiceUserImpl(this); -// serviceUser.createDefaultAdmin( -// getProperty(PollenProperty.ADMIN_LOGIN), -// getProperty(PollenProperty.ADMIN_PASSWORD), -// getProperty(PollenProperty.ADMIN_EMAIL) -// ); + + createSuperAdmin(serviceUser); // // sendMail = new SendMail(this); // sendMail.start(); if (log.isInfoEnabled()) { - log.info("pollen is started !"); + log.info(_("pollen.info.started")); } } catch (Exception eee) { @@ -135,13 +133,43 @@ } /** + * Create the super admin if needed using {@code serviceUser}. + * The login, password and email are defined from configuration (in + * properties file). + * + * @param serviceUser used to create the admin user + * @see PollenProperty#ADMIN_EMAIL + * @see PollenProperty#ADMIN_LOGIN + * @see PollenProperty#ADMIN_PASSWORD + */ + protected void createSuperAdmin(ServiceUser serviceUser) { + UserAccount user = serviceUser.getNewUser(); + user.setAdmin(true); + String login = PollenProperty.ADMIN_LOGIN.getValue(); + user.setLogin(login); + user.setEmail(PollenProperty.ADMIN_EMAIL.getValue()); + user.setNewPassword(PollenProperty.ADMIN_PASSWORD.getValue()); + try { + serviceUser.createUser(user); + if (log.isInfoEnabled()) { + log.info(_("pollen.info.admin.created", login)); + } + } catch (PollenBusinessException eee) { + if (log.isInfoEnabled()) { + log.info(_("pollen.info.admin.exists") + " : " + + _(eee.getMessage())); + } + } + } + + /** * Stop the application. Close the Topia rootContext. */ @Override public void stop() { try { if (log.isDebugEnabled()) { - log.debug("Stop Pollen"); + log.debug(_("pollen.info.stop")); } getTopiaRootContext().closeContext(); // sendMail.stopExec(); Added: trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,143 @@ + +package org.chorem.pollen.bean; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import org.apache.commons.lang.StringUtils; +import org.nuiton.topia.framework.TopiaQuery; +import org.nuiton.topia.persistence.TopiaEntity; + +/** + * Filter + * + * Created: 23 avr. 2010 + * + * @author fdesbois + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ +public class Filter { + + protected Integer startIndex; + + protected Integer endIndex; + + protected String orderBy; + + private PropertyChangeSupport propertyChangeSupport = + new PropertyChangeSupport(this); + + public static final String PROPERTY_START_INDEX = "startIndex"; + + public static final String PROPERTY_END_INDEX = "endIndex"; + + public static final String PROPERTY_ORDER_BY = "orderBy"; + + /** + * Get the value of startIndex + * + * @return the value of startIndex + */ + public Integer getStartIndex() { + return startIndex; + } + + /** + * Set the value of startIndex + * + * @param startIndex new value of startIndex + */ + public void setStartIndex(Integer startIndex) { + Integer oldStartIndex = this.startIndex; + this.startIndex = startIndex; + propertyChangeSupport.firePropertyChange(PROPERTY_START_INDEX, oldStartIndex, startIndex); + } + + /** + * Get the value of orderBy + * + * @return the value of orderBy + */ + public String getOrderBy() { + return orderBy; + } + + /** + * Set the value of orderBy + * + * @param orderBy new value of orderBy + */ + public void setOrderBy(String orderBy) { + String oldOrderBy = this.orderBy; + this.orderBy = orderBy; + propertyChangeSupport.firePropertyChange(PROPERTY_ORDER_BY, oldOrderBy, orderBy); + } + + /** + * Get the value of endIndex + * + * @return the value of endIndex + */ + public Integer getEndIndex() { + return endIndex; + } + + /** + * Set the value of endIndex + * + * @param endIndex new value of endIndex + */ + public void setEndIndex(Integer endIndex) { + Integer oldEndIndex = this.endIndex; + this.endIndex = endIndex; + propertyChangeSupport.firePropertyChange(PROPERTY_END_INDEX, oldEndIndex, endIndex); + } + + /** + * Add PropertyChangeListener. + * + * @param listener + */ + public void addPropertyChangeListener(PropertyChangeListener listener) { + propertyChangeSupport.addPropertyChangeListener(listener); + } + + /** + * Remove PropertyChangeListener. + * + * @param listener + */ + public void removePropertyChangeListener(PropertyChangeListener listener) { + propertyChangeSupport.removePropertyChangeListener(listener); + } + + public void prepareQuery(TopiaQuery query) { + // Add limits. Only startIndex do nothing. + // startIndex + endIndex provides the limit + if (startIndex != null && endIndex != null) { + query.setLimit(startIndex, endIndex); + + // endIndex only provides the maxResults wanted + } else if (endIndex != null) { + query.setMaxResults(endIndex); + } + } + + public void prepareQueryWithOrder(TopiaQuery query) { + // Add order to the query, splitted by comma and trimmed using + // {@link StringUtils#stripAll(String[])} + if (orderBy != null) { + String[] order = StringUtils.stripAll(orderBy.split(",")); + query.addOrder(order); + + // Default order by creation date + } else { + query.addOrderDesc(TopiaEntity.TOPIA_CREATE_DATE); + } + + prepareQuery(query); + } + +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceEmailImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceEmailImpl.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceEmailImpl.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -84,7 +84,7 @@ } throw new PollenBusinessException(eee, PollenExceptionType.SMTP_NOT_AVAILABLE, - pollenEmail.getTo()); + pollenEmail.getTo()); } } Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -3,6 +3,7 @@ import java.util.List; import java.util.Locale; +import java.util.Map; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -11,6 +12,7 @@ import org.chorem.pollen.PollenContext; import org.chorem.pollen.PollenDAOHelper; import org.chorem.pollen.PollenException; +import org.chorem.pollen.bean.Filter; import org.chorem.pollen.entity.PollAccount; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.entity.UserAccountDAO; @@ -19,6 +21,8 @@ import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaQuery; import org.nuiton.topia.framework.TopiaQuery.Op; +import org.nuiton.util.beans.BinderBuilder; +import org.nuiton.util.beans.BinderProvider; /** * ServiceUserImpl @@ -39,8 +43,35 @@ public void setContext(PollenContext context) { this.context = context; + prepareUserAccountBinder(); } + protected void prepareUserAccountBinder() { + BinderBuilder builder = new BinderBuilder(UserAccount.class, + UserAccount.ADMIN, + UserAccount.FIRST_NAME, + UserAccount.LAST_NAME); + BinderProvider.registerBinder(builder); + } + + /** + * Copy {@code source} user account to {@code destination} one. + * The email is lower cased in the {@code destination} user account. + * + * @param source user account to copy + * @param destination which receive the copy + * @see org.nuiton.util.beans.Binder#copy(Object, Object, String...) + */ + protected void copyUserAccount(UserAccount source, UserAccount destination) { + BinderProvider.getBinder(UserAccount.class).copy(source, destination); + destination.setEmail(StringUtils.lowerCase(source.getEmail())); + // Manage new password if needed + String password = source.getNewPassword(); + if (StringUtils.isNotEmpty(password)) { + destination.setPassword(context.encodePassword(password)); + } + } + @Override protected TopiaContext beginTransaction() throws TopiaException { return context.beginTransaction(); @@ -58,27 +89,6 @@ } /** - * Used to manage the new password of the user. This newPassword will be - * encoded then set into the real password. - * - * @param user to treate - * @return true if the newPassword is encoded and set, false otherwise - */ - protected boolean manageNewPassword(UserAccount user) { - // Manage password encoding - String newPassword = user.getNewPassword(); - if (StringUtils.isNotEmpty(newPassword)) { - user.setPassword(context.encodePassword(newPassword)); - if (log.isDebugEnabled()) { - log.debug("Reset newPassword from UserAccount"); - } - user.setNewPassword(null); - return true; - } - return false; - } - - /** * Check if the {@code login} and {@code password} correspond to an * existing user. * @@ -140,7 +150,7 @@ if (query == null) { query = dao.createQuery(); } - int count = query.add(UserAccount.EMAIL, email). + int count = query.add(UserAccount.EMAIL, StringUtils.lowerCase(email)). executeCount(); // existing user found if (count > 0) { @@ -172,16 +182,14 @@ } @Override - protected UserAccount executeGetNewUser(Locale locale) { + protected UserAccount executeGetNewUser() { UserAccount user = new UserAccountImpl(); - user.setAdmin(false); - user.setLanguage(locale.getLanguage()); return user; } @Override protected void executeCreateUser(TopiaContext transaction, - List<Object> errorArgs, UserAccount user) + List<Object> errorArgs, UserAccount user) throws TopiaException, PollenBusinessException { errorArgs.add(user.getLogin()); @@ -196,9 +204,11 @@ // Check email not exist checkEmailNotExist(dao, user.getEmail(), null); + // Execute create - manageNewPassword(user); - dao.create(user); + UserAccount newUser = dao.create(user.getLogin()); + copyUserAccount(user, newUser); + user.setTopiaId(newUser.getTopiaId()); transaction.commitTransaction(); } @@ -207,7 +217,7 @@ @Override protected void executeUpdateUser(TopiaContext transaction, - List<Object> errorArgs, UserAccount user) + List<Object> errorArgs, UserAccount user, boolean byAdmin) throws TopiaException, PollenBusinessException { errorArgs.add(user.getLogin()); @@ -215,16 +225,12 @@ errorArgs.add(user.getAdmin()); UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction); - - // Check the password - String encodedPassword = context.encodePassword(user.getPassword()); - checkPassword(dao, user.getLogin(), encodedPassword); - // Change password if needed - boolean passwordChanged = manageNewPassword(user); - // Otherwise set the encodedPassword to properly save the user - if (!passwordChanged) { - user.setPassword(encodedPassword); + // Do not manage password for an admin update + if (!byAdmin) { + // Check the password + String encodedPassword = context.encodePassword(user.getPassword()); + checkPassword(dao, user.getLogin(), encodedPassword); } // In case of email change, check if an other user has not already @@ -234,24 +240,50 @@ checkEmailNotExist(dao, user.getEmail(), query); // Execute update - dao.update(user); + UserAccount editedUser = dao.findByLogin(user.getLogin()); + copyUserAccount(user, editedUser); + dao.update(editedUser); transaction.commitTransaction(); } @Override - protected void executeDeleteUser(TopiaContext transaction, UserAccount user) + protected void executeDeleteUser(TopiaContext transaction, String login) throws TopiaException { - throw new UnsupportedOperationException("Not supported yet."); + UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction); + UserAccount user = dao.findByLogin(login); + dao.delete(user); + transaction.commitTransaction(); } @Override - protected List<UserAccount> executeGetUsers(TopiaContext transaction) - throws TopiaException { - throw new UnsupportedOperationException("Not supported yet."); + protected Map<String, UserAccount> executeGetUsers(TopiaContext transaction, + Filter filter) throws TopiaException { + + UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction); + TopiaQuery query = dao.createQuery(); + + filter.prepareQueryWithOrder(query); + + Map<String, UserAccount> results = dao.findAllMappedByQuery(query, + UserAccount.LOGIN, String.class); + return results; } @Override + protected int executeGetNbUsers(TopiaContext transaction, + Filter filter) throws TopiaException { + + UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction); + TopiaQuery query = dao.createQuery(); + + filter.prepareQuery(query); + + int result = query.executeCount(); + return result; + } + + @Override protected PollAccount executeGetNewList(TopiaContext transaction) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties =================================================================== --- trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -41,6 +41,7 @@ pollen.error.serviceUser.deleteList= pollen.error.serviceUser.deleteUser= pollen.error.serviceUser.getFavoriteLists= +pollen.error.serviceUser.getNbUsers= pollen.error.serviceUser.getNewList= pollen.error.serviceUser.getNewPerson= pollen.error.serviceUser.getNewUser= @@ -57,3 +58,8 @@ pollen.exception.user_login_exist= pollen.exception.user_not_exist= pollen.exception.user_wrong_password= +pollen.info.admin.created=Super admin was created with login %1$s +pollen.info.admin.exists=Super admin already exists +pollen.info.start=Start Pollen +pollen.info.started=Pollen is started \! +pollen.info.stop=Stop Pollen Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties =================================================================== --- trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -40,6 +40,7 @@ pollen.error.serviceUser.deleteList= pollen.error.serviceUser.deleteUser= pollen.error.serviceUser.getFavoriteLists= +pollen.error.serviceUser.getNbUsers= pollen.error.serviceUser.getNewList= pollen.error.serviceUser.getNewPerson= pollen.error.serviceUser.getNewUser=Impossible d'instancier un nouvel utilisateur. @@ -56,3 +57,8 @@ pollen.exception.user_login_exist=Un utilisateur est d\u00E9j\u00E0 enregistr\u00E9 avec cet identifiant. pollen.exception.user_not_exist=L'identifiant '%1$s' ne correspond \u00E0 aucun utilisateur connu. pollen.exception.user_wrong_password=Le mot de passe renseign\u00E9 est incorrect pour l'utilisateur '%1$s'. +pollen.info.admin.created=Le super admin a \u00E9t\u00E9 cr\u00E9\u00E9 avec l'identifiant %1$s. +pollen.info.admin.exists=Le super admin existe d\u00E9j\u00E0 +pollen.info.start=D\u00E9marrage de Pollen... +pollen.info.started=Pollen a \u00E9t\u00E9 d\u00E9marr\u00E9 avec succ\u00E8s \! +pollen.info.stop=Arr\u00EAt de Pollen Modified: trunk/pollen-business/src/main/xmi/pollen.zargo =================================================================== (Binary files differ) Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java =================================================================== --- trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -56,7 +56,7 @@ ); getContext().loadConfiguration(config); - getContext().start(); + getContext().start(getServiceUser()); // Set currentDate to 23/02/2010 for tests Calendar calendar = new GregorianCalendar(2010, 1, 23, 0, 0, 0); Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java =================================================================== --- trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -2,7 +2,6 @@ package org.chorem.pollen.service; import java.io.IOException; -import java.util.Locale; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.pollen.PollenBusinessException; @@ -12,6 +11,7 @@ import org.chorem.pollen.business.TestManager; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.entity.UserAccountDAO; +import org.chorem.pollen.entity.UserAccountImpl; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -19,7 +19,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.nuiton.topia.TopiaContext; -import org.nuiton.topia.TopiaException; /** * @@ -50,26 +49,28 @@ } @Test - public void testManageNewPassword() throws Exception { + public void testCopyUserAccount() throws Exception { TestManager.start("testManageNewPassword"); ServiceUserImpl serviceUser = TestManager.getServiceUser(); - UserAccount user = serviceUser.getNewUser(Locale.FRENCH); + UserAccount user = serviceUser.getNewUser(); user.setLogin("homer"); user.setNewPassword("wouhou"); log.info("test 1 : Encode new password"); - boolean result = serviceUser.manageNewPassword(user); - Assert.assertTrue(result); + UserAccount destination = new UserAccountImpl(); + serviceUser.copyUserAccount(user, destination); + Assert.assertNotNull(destination.getPassword()); String expected = TestManager.getContext().encodePassword("wouhou"); - Assert.assertEquals(expected, user.getPassword()); - Assert.assertNull(user.getNewPassword()); + Assert.assertEquals(expected, destination.getPassword()); log.info("test 2 : Do not encode new password -> newPassword empty"); - result = serviceUser.manageNewPassword(user); - Assert.assertFalse(result); + user.setPassword(expected); + user.setNewPassword(null); + serviceUser.copyUserAccount(user, destination); + Assert.assertEquals(expected, destination.getPassword()); } @Test @@ -78,7 +79,7 @@ ServiceUserImpl serviceUser = TestManager.getServiceUser(); - UserAccount user = serviceUser.getNewUser(Locale.FRENCH); + UserAccount user = serviceUser.getNewUser(); user.setLogin("homer"); user.setNewPassword("wouhou"); serviceUser.createUser(user); @@ -115,7 +116,7 @@ ServiceUser serviceUser = TestManager.getServiceUser(); - UserAccount user = serviceUser.getNewUser(Locale.FRENCH); + UserAccount user = serviceUser.getNewUser(); user.setLogin("hsimpson"); user.setEmail("hsimpson@springfield.us"); user.setNewPassword("wouhou"); @@ -152,11 +153,9 @@ TestManager.start("testGetNewUser"); ServiceUser serviceUser = TestManager.getServiceUser(); - UserAccount user = serviceUser.getNewUser(Locale.FRENCH); + UserAccount user = serviceUser.getNewUser(); Assert.assertNotNull(user); Assert.assertEquals(false, user.getAdmin()); - Assert.assertEquals("fr", user.getLanguage()); - Assert.assertEquals(Locale.FRENCH, new Locale(user.getLanguage())); } /** @@ -167,7 +166,7 @@ TestManager.start("testCreateUser"); ServiceUser serviceUser = TestManager.getServiceUser(); - UserAccount user = serviceUser.getNewUser(Locale.FRENCH); + UserAccount user = serviceUser.getNewUser(); user.setLogin("hsimpson"); user.setEmail("hsimpson@springfield.us"); user.setNewPassword("wouhou"); @@ -181,7 +180,7 @@ Assert.assertNotSame(encodedPassword, user.getPassword()); log.info("test 2 : Creation problem on login -> user exist"); - UserAccount user2 = serviceUser.getNewUser(Locale.FRENCH); + UserAccount user2 = serviceUser.getNewUser(); user2.setLogin("hsimpson"); // Not the same email user2.setEmail("hsimpson@springfield.com"); @@ -196,7 +195,7 @@ } log.info("test 3 : Creation problem on email -> user exist"); - UserAccount user3 = serviceUser.getNewUser(Locale.FRENCH); + UserAccount user3 = serviceUser.getNewUser(); user3.setLogin("homer"); user3.setEmail("hsimpson@springfield.us"); user3.setNewPassword("troubidou"); @@ -210,7 +209,7 @@ } log.info("test 4 : Creation OK with no email"); - UserAccount user4 = serviceUser.getNewUser(Locale.FRENCH); + UserAccount user4 = serviceUser.getNewUser(); user4.setLogin("marge"); user4.setNewPassword("troubidou"); @@ -226,13 +225,13 @@ TestManager.start("testUpdateUser"); ServiceUser serviceUser = TestManager.getServiceUser(); - UserAccount user1 = serviceUser.getNewUser(Locale.FRENCH); + UserAccount user1 = serviceUser.getNewUser(); user1.setLogin("hsimpson"); user1.setEmail("hsimpson@springfield.us"); user1.setNewPassword("wouhou"); serviceUser.createUser(user1); - UserAccount user2 = serviceUser.getNewUser(Locale.FRENCH); + UserAccount user2 = serviceUser.getNewUser(); String user2Password = "wouhou"; user2.setLogin("homer"); user2.setEmail("hsimpson@springfield.fr"); @@ -243,7 +242,7 @@ user2.setLogin("homersimpson"); user2.setPassword(user2Password); try { - serviceUser.updateUser(user2); + serviceUser.updateUser(user2, false); } catch (PollenBusinessException eee) { log.error("Error : " + eee.getMessage()); Assert.assertEquals(PollenExceptionType.USER_WRONG_PASSWORD, @@ -254,26 +253,54 @@ log.info("test 2 : Change email OK"); user2.setEmail("homersimpson@springield.fr"); user2.setPassword(user2Password); - serviceUser.updateUser(user2); + serviceUser.updateUser(user2, false); log.info("test 3 : Change email problem -> user exist"); user2.setEmail(user1.getEmail()); user2.setPassword(user2Password); try { - serviceUser.updateUser(user2); + serviceUser.updateUser(user2, false); } catch (PollenBusinessException eee) { log.error("Error : " + eee.getMessage()); Assert.assertEquals(PollenExceptionType.USER_EMAIL_EXIST, eee.getType()); } + + // TODO test 4 with byAdmin = true } /** * Test of executeDeleteUser method, of class ServiceUserImpl. + * @throws Exception */ - //@Test + @Test public void testExecuteDeleteUser() throws Exception { - System.out.println("executeDeleteUser"); + TestManager.start("testUpdateUser"); + ServiceUser serviceUser = TestManager.getServiceUser(); + + try { + serviceUser.deleteUser("test"); + } catch (PollenException eee) { + log.error(eee); + Assert.assertEquals(IllegalArgumentException.class, + eee.getCause().getClass()); + } + + UserAccount user = serviceUser.getNewUser(); + user.setLogin("user"); + serviceUser.createUser(user); + + serviceUser.deleteUser("user"); + + TopiaContext transaction = null; + try { + transaction = TestManager.beginTransaction(); + UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction); + UserAccount userFound = dao.findByLogin("user"); + Assert.assertNull(userFound); + } finally { + transaction.closeContext(); + } } /** Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,128 @@ + +package org.chorem.pollen.ui.base; + +import org.apache.tapestry5.annotations.Property; +import org.apache.tapestry5.annotations.SessionState; +import org.apache.tapestry5.ioc.annotations.Inject; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.ui.components.Border; + +/** + * AbstractPollenPage + * + * Created: 22 avr. 2010 + * + * @author fdesbois + */ +public abstract class AbstractPollenPage implements PollenPage { + + /** Connected UserAccount from Session **/ + @SessionState + @Property + private UserAccount user; + + @Property + private boolean userExists; + + /** + * Retrieve the border layout of the page. + * + * @return the Border + */ + public abstract Border getBorder(); + + /** + * Default value set to false for needAuthentification. + * + * @return false + * @see PollenPage#isNeedAuthentification() + */ + @Override + public boolean isNeedAuthentification() { + return false; + } + + /** + * Default value set to true for canDisplayPage. + * + * @return true + * @see PollenPage#canDisplayPage() + */ + @Override + public boolean canDisplayPage() { + return true; + } + + /** + * Retrieve the connected user from Session. + * + * @return the UserAccount corresponding to connected user + */ + public UserAccount getUserConnected() { + return user; + } + + /** + * Change connected user in session. + * + * @param user to set in session. + */ + public void setUserConnected(UserAccount user) { + this.user = user; + } + + /** + * Return true if a user is already connected to the application. + * + * @return true if connected user is defined. + */ + public boolean isUserConnected() { + return userExists; + } + + /** + * Return true if the connected user is an admin. + * + * @return true if the connected user is an admin. + */ + public boolean isAdminConnected() { + return isUserConnected() && user.getAdmin(); + } + + /** + * Add an info {@code message} to display. + * + * @param message to display + */ + public void addInfo(String message) { + getBorder().addInfo(message); + } + + /** + * Add a fatal {@code message} to display. Only the fatal {@code message} + * will be displayed, not other elements in the page will be showed. + * + * @param message to display + */ + public void addFatal(String message) { + getBorder().addFatal(message); + } + + /** + * Add an error {@code message} to display. + * + * @param message to display + */ + public void addError(String message) { + getBorder().addError(message); + } + + /** + * Retrieve the current url of the page. + * + * @return the current url of the page. + */ + public String getUrl() { + return getBorder().getServerPath(); + } +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Copied: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollsPage.java (from rev 2972, trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java) =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollsPage.java (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollsPage.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,202 @@ +/* *##% Pollen + * Copyright (C) 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/ + +package org.chorem.pollen.ui.base; + +import java.util.List; + +import org.apache.tapestry5.BindingConstants; +import org.apache.tapestry5.ComponentResources; +import org.apache.tapestry5.annotations.InjectPage; +import org.apache.tapestry5.annotations.Parameter; +import org.apache.tapestry5.annotations.Property; +import org.apache.tapestry5.annotations.Retain; +import org.apache.tapestry5.beaneditor.BeanModel; +import org.apache.tapestry5.ioc.annotations.Inject; +import org.apache.tapestry5.services.BeanModelSource; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.service.ServicePoll; +import org.chorem.pollen.ui.data.EvenOdd; +import org.chorem.pollen.ui.data.AddressBarItem; +import org.chorem.pollen.ui.data.PollAction; +import org.chorem.pollen.ui.pages.admin.AdminPolls; +import org.chorem.pollen.ui.pages.poll.ConfirmPoll; +import org.chorem.pollen.ui.pages.user.UserPollsCreated; + +/** + * Classe de la page d'affichage des sondages. + * + * @author kmorin + * @author rannou + * @version $Id$ + */ +public abstract class AbstractPollsPage extends AbstractPollenPage { + + /** + * Liste de sondages de l'utilisateur + */ + @SuppressWarnings("unused") + private List<Poll> polls; + + /** + * Sondage servant à l'itération des sondages de la liste + */ + @Property + private Poll poll; + + /** + * Objet servant à changer la couleur à chaque ligne de la liste des + * sondages + */ + @SuppressWarnings("unused") + @Property + private EvenOdd evenOdd; + + @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") + @Property + private String title; + + @SuppressWarnings("unused") + @Property + private AddressBarItem[] address; + + /** + * Sert à créer pollsModel + */ + @Inject + private BeanModelSource beanModelSource; + + /** + * Sert à passer les messages en paramètre de la création de pollsModel + */ + @Inject + private ComponentResources componentResources; + + /** + * Modèle pour l'affichage de la liste des sondages + */ + @SuppressWarnings("unchecked") + @Property + @Retain + private BeanModel pollsModel; + + /** Page de validation de la fermeture d'un sondage */ + @InjectPage + private ConfirmPoll confirmPoll; + + /** Injection des services */ + @Inject + private ServicePoll servicePoll; +// @Inject +// private ServicePollAccount servicePollAccount; +// @Inject +// private ServiceResults serviceResults; + + /** + * Récupération de l'identifiant de modification du sondage. + * + * @return l'identifiant. + */ +// public String getAdminId() { +// PollAccount creator = servicePollAccount.findPollAccountById(poll +// .getCreatorId()); +// return poll.getPollUId() + ":" + creator.getAccountUId(); +// } + + /** + * Fermeture du sondage. + * + * @return la page de validation + */ + public Object onActionFromClose(String id) { + return prepareConfirmPage(id, PollAction.CLOSE); + } + + /** + * Suppression du sondage. + * + * @return la page des sondages + */ + public Object onActionFromDeletePoll(String id) { + return prepareConfirmPage(id, PollAction.DELETE); + } + + /** + * Préparation de la page de confirmation. + * + * @return la page de confirmation + */ + private Object prepareConfirmPage(String pollId, PollAction pollAction) { + String backPage = ""; + if (this instanceof UserPollsCreated) { + backPage = "user/PollsCreated"; + } else if (this instanceof AdminPolls) { + backPage = "admin/PollsAdmin"; + } + confirmPoll.setBackPage(backPage); + confirmPoll.setAction(pollAction); + confirmPoll.setPoll(poll); + return confirmPoll; + } + + /** + * Export XML du sondage. + * + * @return le flux correspondant au fichier + */ + public Object onActionFromExport(String id) { + // FIXME : create service for export + +// final String filename = serviceResults.exportPoll(id); +// +// // Retour d'un StreamResponse contenant le fichier XML +// return new StreamResponse() { +// public String getContentType() { +// return "text/xml"; +// } +// +// public InputStream getStream() throws IOException { +// return new FileInputStream(new File(filename)); +// } +// +// public void prepareResponse(Response response) { +// } +// }; + return null; + } + + /** + * Méthode d'initialisation des sondages + */ + public void onActivate() { + evenOdd = new EvenOdd(); + } + + /** + * Initialisation de l'affichage + */ + public void setupRender() { + address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"), + new AddressBarItem(title, null) }; + + pollsModel = beanModelSource.createDisplayModel(Poll.class, + componentResources.getMessages()); + pollsModel.add("functions", null); + pollsModel.include("title", "description", "beginChoiceDate", + "beginDate", "endDate", "functions"); + } + +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollsPage.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Rev Revision" Added: svn:mergeinfo + Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractUploadPage.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractUploadPage.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractUploadPage.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -21,7 +21,7 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class AbstractUploadPage { +public abstract class AbstractUploadPage extends AbstractPollenPage { @InjectPage private ErrorPage errorPage; Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,26 @@ + +package org.chorem.pollen.ui.base; + +/** + * PollenPage + * + * Created: 22 avr. 2010 + * + * @author fdesbois + */ +public interface PollenPage { + + /** + * Return true if the page need an authentification to be displayed. + * + * @return true for authentification needed + */ + boolean isNeedAuthentification(); + + /** + * Return true if the page can be displayed, depends on user rights. + * + * @return true for display allowed + */ + boolean canDisplayPage(); +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,221 +0,0 @@ -/* *##% Pollen - * Copyright (C) 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/ - -package org.chorem.pollen.ui.base; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import org.apache.tapestry5.BindingConstants; -import org.apache.tapestry5.ComponentResources; -import org.apache.tapestry5.StreamResponse; -import org.apache.tapestry5.annotations.InjectPage; -import org.apache.tapestry5.annotations.Parameter; -import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.annotations.Retain; -import org.apache.tapestry5.annotations.SessionState; -import org.apache.tapestry5.beaneditor.BeanModel; -import org.apache.tapestry5.ioc.annotations.Inject; -import org.apache.tapestry5.services.BeanModelSource; -import org.apache.tapestry5.services.Response; -import org.chorem.pollen.entity.Poll; -import org.chorem.pollen.entity.UserAccount; -import org.chorem.pollen.service.ServicePoll; -import org.chorem.pollen.ui.data.EvenOdd; -import org.chorem.pollen.ui.data.AddressBarItem; -import org.chorem.pollen.ui.data.PollAction; -import org.chorem.pollen.ui.pages.admin.PollsAdmin; -import org.chorem.pollen.ui.pages.poll.ConfirmPoll; -import org.chorem.pollen.ui.pages.user.UserPollsCreated; - -/** - * Classe de la page d'affichage des sondages. - * - * @author kmorin - * @author rannou - * @version $Id$ - */ -public class Polls { - - /** - * Objet de session représentant l'utilisateur identifié. - */ - @SuppressWarnings("unused") - @SessionState - @Property - private UserAccount user; - @SuppressWarnings("unused") - @Property - private boolean userExists; - - /** - * Liste de sondages de l'utilisateur - */ - @SuppressWarnings("unused") - private List<Poll> polls; - - /** - * Sondage servant à l'itération des sondages de la liste - */ - @Property - private Poll poll; - - /** - * Objet servant à changer la couleur à chaque ligne de la liste des - * sondages - */ - @SuppressWarnings("unused") - @Property - private EvenOdd evenOdd; - - @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") - @Property - private String title; - - @SuppressWarnings("unused") - @Property - private AddressBarItem[] address; - - /** - * Sert à créer pollsModel - */ - @Inject - private BeanModelSource beanModelSource; - - /** - * Sert à passer les messages en paramètre de la création de pollsModel - */ - @Inject - private ComponentResources componentResources; - - /** - * Modèle pour l'affichage de la liste des sondages - */ - @SuppressWarnings("unchecked") - @Property - @Retain - private BeanModel pollsModel; - - /** Page de validation de la fermeture d'un sondage */ - @InjectPage - private ConfirmPoll confirmPoll; - - /** Injection des services */ - @Inject - private ServicePoll servicePoll; -// @Inject -// private ServicePollAccount servicePollAccount; -// @Inject -// private ServiceResults serviceResults; - - /** - * Récupération de l'identifiant de modification du sondage. - * - * @return l'identifiant. - */ -// public String getAdminId() { -// PollAccount creator = servicePollAccount.findPollAccountById(poll -// .getCreatorId()); -// return poll.getPollUId() + ":" + creator.getAccountUId(); -// } - - /** - * Fermeture du sondage. - * - * @return la page de validation - */ - public Object onActionFromClose(String id) { - return prepareConfirmPage(id, PollAction.CLOSE); - } - - /** - * Suppression du sondage. - * - * @return la page des sondages - */ - public Object onActionFromDeletePoll(String id) { - return prepareConfirmPage(id, PollAction.DELETE); - } - - /** - * Préparation de la page de confirmation. - * - * @return la page de confirmation - */ - private Object prepareConfirmPage(String pollId, PollAction pollAction) { - String backPage = ""; - if (this instanceof UserPollsCreated) { - backPage = "user/PollsCreated"; - } else if (this instanceof PollsAdmin) { - backPage = "admin/PollsAdmin"; - } - confirmPoll.setBackPage(backPage); - confirmPoll.setAction(pollAction); - confirmPoll.setPoll(poll); - return confirmPoll; - } - - /** - * Export XML du sondage. - * - * @return le flux correspondant au fichier - */ - public Object onActionFromExport(String id) { - // FIXME : create service for export - -// final String filename = serviceResults.exportPoll(id); -// -// // Retour d'un StreamResponse contenant le fichier XML -// return new StreamResponse() { -// public String getContentType() { -// return "text/xml"; -// } -// -// public InputStream getStream() throws IOException { -// return new FileInputStream(new File(filename)); -// } -// -// public void prepareResponse(Response response) { -// } -// }; - return null; - } - - /** - * Méthode d'initialisation des sondages - */ - public void onActivate() { - evenOdd = new EvenOdd(); - } - - /** - * Initialisation de l'affichage - */ - public void setupRender() { - address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"), - new AddressBarItem(title, null) }; - - pollsModel = beanModelSource.createDisplayModel(Poll.class, - componentResources.getMessages()); - pollsModel.add("functions", null); - pollsModel.include("title", "description", "beginChoiceDate", - "beginDate", "endDate", "functions"); - } - -} Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -23,8 +23,10 @@ import java.util.Locale; import org.apache.tapestry5.BindingConstants; +import org.apache.tapestry5.Block; import org.apache.tapestry5.annotations.Component; import org.apache.tapestry5.annotations.InjectComponent; +import org.apache.tapestry5.annotations.InjectContainer; import org.apache.tapestry5.annotations.Log; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Property; @@ -39,6 +41,7 @@ import org.chorem.pollen.ui.data.AddressBarItem; import org.chorem.pollen.PollenBusinessException; import org.chorem.pollen.service.ServiceUser; +import org.chorem.pollen.ui.base.PollenPage; import org.chorem.pollen.ui.data.AddressBar; import org.chorem.pollen.ui.pages.Index; import org.chorem.pollen.ui.services.PollenManager; @@ -103,8 +106,8 @@ /** * Objet de session (SSO) représentant l'adresse du site. */ - @SessionState - private String siteURL; +// @SessionState +// private String siteURL; /** * Chaine definissant le logo de la page @@ -170,16 +173,29 @@ @InjectComponent private ContextLink feedContext; + @InjectContainer + private PollenPage page; + + @Inject + private Block loginBlock; + + @Inject + private Block pageBlock; + private boolean fatal; + private boolean needAuthentification; + + private String serverPath; + /** * Initialisation de l'affichage */ void setupRender() { // URL du site - siteURL = "http://" + request.getHeader("host") + - request.getContextPath() + "/"; +// siteURL = "http://" + request.getHeader("host") + +// request.getContextPath() + "/"; errorJs.addError(messages.get("errorJs")); @@ -189,9 +205,20 @@ } else { logo = "pollen" + pageLogo + "_en.png"; } + + // Error messages for display authorization + if (isNeedAuthentification()) { + addError(messages.get("pollen.ui.user.display.notConnected")); + } else if (!page.canDisplayPage()) { + addError(messages.get("pollen.ui.user.display.notAllowed")); + } } boolean afterRender() { + if (needAuthentification) { + return false; + } + // Check if fatal errors has been added to the border // Reload the page if feedBack hasn't been reloaded yet to display // errors @@ -208,6 +235,26 @@ return true; } + public Object getActiveBlock() { + if (isNeedAuthentification()) { + return loginBlock; + } else if (canDisplayBody()) { + return pageBlock; + } + return null; + } + + public String getServerPath() { + if (serverPath == null) { + serverPath = "http://" + request.getHeader("host") + + request.getContextPath(); + if (logger.isDebugEnabled()) { + logger.debug("URL : " + serverPath); + } + } + return serverPath; + } + public void addInfo(String message) { feedback.addInfo(message); } @@ -221,8 +268,12 @@ fatal = true; } + public boolean isNeedAuthentification() { + return !userExists && page.isNeedAuthentification(); + } + public boolean canDisplayBody() { - return !fatal; + return !fatal && page.canDisplayPage(); } public DateFormat getDateFormat() { @@ -247,7 +298,7 @@ UserAccount current = serviceUser.connect(login, password); user = current; // Change locale for user - localeService.set(new Locale(user.getLanguage())); + //localeService.set(new Locale(user.getLanguage())); feedback.addInfo(messages.get("loginOk")); } catch (PollenBusinessException eee) { feedback.addError( Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,211 @@ +/* + * #%L + * Wao :: Web Interface + * + * $Id$ + * $HeadURL: svn+ssh://fdesbois@labs.libre-entreprise.org/svnroot/suiviobsmer/trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java $ + * %% + * Copyright (C) 2009 - 2010 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.pollen.ui.data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.apache.commons.collections.CollectionUtils; +import org.apache.tapestry5.beaneditor.PropertyModel; +import org.apache.tapestry5.grid.ColumnSort; +import org.apache.tapestry5.grid.GridDataSource; +import org.apache.tapestry5.grid.SortConstraint; +import org.apache.tapestry5.ioc.internal.util.TapestryException; +import org.chorem.pollen.PollenException; +import org.nuiton.topia.persistence.TopiaEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * ContactDataSource + * + * Created: 18 janv. 2010 + * + * @param <K> Type of the map key + * @param <E> Type of the map value + * @author fdesbois <fdesbois@codelutin.com> + */ +public abstract class AbstractMappedGridDataSource<K, E extends TopiaEntity> implements GridDataSource { + + + private Logger log = LoggerFactory.getLogger(AbstractMappedGridDataSource.class); + + private Map<K, E> mapResults; + + private List<E> listResults; + + private int nbRows = -1; + + private int nbRowsPerPage; + + @Override + public int getAvailableRows() { + if (nbRows < 0) { + try { + nbRows = count(); + if (log.isTraceEnabled()) { + log.trace("Count : " + nbRows); + } + } catch (PollenException eee) { + throw new TapestryException("", eee); + } + } + return nbRows; + } + + @Override + public void prepare(int startIndex, int endIndex, List<SortConstraint> sortConstraints) { + if (log.isTraceEnabled()) { + log.trace("Prepare results : " + startIndex + ", " + endIndex); + } + nbRowsPerPage = endIndex - startIndex + 1; + try { + mapResults = execute(startIndex, endIndex, getSortConstraint(sortConstraints)); + listResults = new ArrayList<E>(mapResults.values()); + + // FIXME manage sort columns in execute ???? seems obvious --> needed for Contacts, done for Boats + //sortResults(sortConstraints); + } catch (PollenException eee) { + throw new TapestryException("", eee); + } + } + + protected abstract Map<K, E> execute(int startIndex, int endIndex, + SortConstraint orderBy) throws PollenException; + + protected abstract int count() throws PollenException; + + protected SortConstraint getSortConstraint(List<SortConstraint> sortConstraints) { + for (SortConstraint constraint : sortConstraints) + { + final ColumnSort sort = constraint.getColumnSort(); + + if (sort != ColumnSort.UNSORTED) { + return constraint; + } + } + return null; + } + + protected String resolveOrderBy(SortConstraint orderBy) { + String filterOrder = null; + if (orderBy != null) { + PropertyModel property = orderBy.getPropertyModel(); + filterOrder = property.getPropertyName(); + + ColumnSort sort = orderBy.getColumnSort(); + if (sort.equals(ColumnSort.DESCENDING)) { + filterOrder += " desc"; + } + + if (log.isDebugEnabled()) { + log.debug("Order : " + filterOrder); + } + } + return filterOrder; + } + +// protected void sortResults(List<SortConstraint> sortConstraints) { +// +// for (SortConstraint constraint : sortConstraints) +// { +// final ColumnSort sort = constraint.getColumnSort(); +// +// if (sort == ColumnSort.UNSORTED) continue; +// +// final PropertyConduit conduit = constraint.getPropertyModel().getConduit(); +// +// final Comparator valueComparator = new Comparator<Comparable>() +// { +// public int compare(Comparable o1, Comparable o2) +// { +// // Simplify comparison, and handle case where both are nulls. +// +// if (o1 == o2) return 0; +// +// if (o2 == null) return 1; +// +// if (o1 == null) return -1; +// +// return o1.compareTo(o2); +// } +// }; +// +// final Comparator rowComparator = new Comparator() +// { +// public int compare(Object row1, Object row2) +// { +// Comparable value1 = (Comparable) conduit.get(row1); +// Comparable value2 = (Comparable) conduit.get(row2); +// +// return valueComparator.compare(value1, value2); +// } +// }; +// +// final Comparator reverseComparator = new Comparator() +// { +// public int compare(Object o1, Object o2) +// { +// int modifier = sort == ColumnSort.ASCENDING ? 1 : -1; +// +// return modifier * rowComparator.compare(o1, o2); +// } +// }; +// +// // We can freely sort this list because its just a copy. +// +// Collections.sort(listResults, reverseComparator); +// } +// } + + @Override + public Object getRowValue(int index) { + index = index % nbRowsPerPage; + if (index >= listResults.size()) { + if (log.isErrorEnabled()) { + log.error("Size error : " + index + " / " + listResults.size()); + } + return null; + } + return CollectionUtils.get(listResults, index); + } + + @Override + public abstract Class<?> getRowType(); + + public E get(K key) { + return mapResults.get(key); + } + + public List<E> values() { + return listResults; + } + + public boolean contains(K key) { + return mapResults.containsKey(key); + } + +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/UserAccountDataSource.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/UserAccountDataSource.java (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/UserAccountDataSource.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,52 @@ + +package org.chorem.pollen.ui.data; + +import java.util.Map; +import org.apache.tapestry5.grid.SortConstraint; +import org.chorem.pollen.PollenException; +import org.chorem.pollen.bean.Filter; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.service.ServiceUser; + +/** + * UserAccountDataSource + * + * Created: 23 avr. 2010 + * + * @author fdesbois + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ +public class UserAccountDataSource extends AbstractMappedGridDataSource<String, UserAccount> { + + private ServiceUser service; + + private Filter filter; + + public UserAccountDataSource(ServiceUser service, Filter filter) { + this.service = service; + this.filter = filter; + } + + @Override + protected Map<String, UserAccount> execute(int startIndex, int endIndex, + SortConstraint orderBy) throws PollenException { + filter.setStartIndex(startIndex); + filter.setEndIndex(endIndex); + filter.setOrderBy(resolveOrderBy(orderBy)); + return service.getUsers(filter); + } + + @Override + protected int count() throws PollenException { + return service.getNbUsers(filter); + } + + @Override + public Class<?> getRowType() { + return UserAccount.class; + } + +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/UserAccountDataSource.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -2,6 +2,7 @@ package org.chorem.pollen.ui.pages; import org.apache.tapestry5.annotations.InjectComponent; +import org.chorem.pollen.ui.base.AbstractPollenPage; import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.data.AddressBar; import org.chorem.pollen.ui.data.AddressBarItem; @@ -17,13 +18,14 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class ErrorPage { +public class ErrorPage extends AbstractPollenPage { @InjectComponent private Border border; - public void addError(String message) { - border.addError(message); + @Override + public Border getBorder() { + return border; } public AddressBarItem[] getAddress() { Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Index.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Index.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Index.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -17,6 +17,7 @@ package org.chorem.pollen.ui.pages; import org.apache.tapestry5.annotations.InjectComponent; +import org.chorem.pollen.ui.base.AbstractPollenPage; import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.data.AddressBar; @@ -28,20 +29,17 @@ * @author fdesbois <fdesbois@codelutin.com> * @version $Id$ */ -public class Index { +public class Index extends AbstractPollenPage { @InjectComponent private Border border; + @Override + public Border getBorder() { + return border; + } + public AddressBar getAddressBar() { return AddressBar.newEmptyBar().appendCurrent("Pollen"); } - - public void addInfo(String message) { - border.addInfo(message); - } - - public void addError(String message) { - border.addError(message); - } } Copied: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminPolls.java (from rev 2972, trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/PollsAdmin.java) =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminPolls.java (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminPolls.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,85 @@ +/* *##% Pollen + * Copyright (C) 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/ + +package org.chorem.pollen.ui.pages.admin; + +import java.util.List; + +import org.apache.tapestry5.annotations.Component; +import org.apache.tapestry5.annotations.IncludeStylesheet; +import org.apache.tapestry5.annotations.InjectComponent; +import org.apache.tapestry5.annotations.Property; +import org.apache.tapestry5.ioc.Messages; +import org.apache.tapestry5.ioc.annotations.Inject; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.service.ServicePoll; +import org.chorem.pollen.ui.base.AbstractPollsPage; +import org.chorem.pollen.ui.components.Border; +import org.chorem.pollen.ui.components.FeedBack; + +/** + * Classe de la page d'administration des sondages. Si l'utilisateur n'est pas + * identifié, on lui demande d'abord de s'identifier via un formulaire. + * + * @author rannou + * @version $Id$ + */ +@IncludeStylesheet("context:css/pollsAdmin.css") +public class AdminPolls extends AbstractPollsPage { + + @InjectComponent + private Border border; + + @Override + public Border getBorder() { + return border; + } + + /** Affichage des messages pour l'utilisateur */ + @Component(id = "feedback") + private FeedBack feedback; + + /** + * Liste de sondages de l'utilisateur + */ + @SuppressWarnings("unused") + @Property + private List<Poll> polls; + + /** + * Messages. + */ + @Inject + private Messages messages; + + /** Injection des services */ + @Inject + private ServicePoll servicePoll; + + /** + * Méthode d'initialisation des sondages + */ + @Override + public void onActivate() { + super.onActivate(); + polls = servicePoll.getAllPolls(); + + // Affichage des erreurs + if (!isAdminConnected()) { + feedback.addError(messages.get("userNotAllowed")); + } + } +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminPolls.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Rev Revision" Added: svn:mergeinfo + Copied: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java (from rev 2972, trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java) =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,351 @@ +/* *##% Pollen + * Copyright (C) 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/ + +package org.chorem.pollen.ui.pages.admin; + + +import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.tapestry5.BindingConstants; +import org.apache.tapestry5.ComponentResources; +import org.apache.tapestry5.Field; +import org.apache.tapestry5.annotations.IncludeStylesheet; +import org.apache.tapestry5.annotations.InjectComponent; +import org.apache.tapestry5.annotations.Parameter; +import org.apache.tapestry5.annotations.Persist; +import org.apache.tapestry5.annotations.Property; +import org.apache.tapestry5.corelib.components.Form; +import org.apache.tapestry5.ioc.Messages; +import org.apache.tapestry5.ioc.annotations.Inject; +import org.chorem.pollen.PollenBusinessException; +import org.chorem.pollen.bean.Filter; +import org.chorem.pollen.bean.PollenEmail; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.service.ServiceEmail; +import org.chorem.pollen.service.ServiceUser; +import org.chorem.pollen.ui.base.AbstractPollenPage; +import org.chorem.pollen.ui.components.Border; +import org.chorem.pollen.ui.data.AddressBar; +import org.chorem.pollen.ui.data.UserAccountDataSource; +import org.chorem.pollen.ui.services.PollenManager; +import org.slf4j.Logger; + +/** + * Management of users by an admin. + * + * @author fdesbois <fdesbois@codelutin.com> + * @version $Id$ + */ +@IncludeStylesheet("context:css/usersAdmin.css") +public class AdminUsers extends AbstractPollenPage { + + @InjectComponent + private Border border; + + /** Page title from Messages **/ + @Parameter(defaultPrefix = BindingConstants.MESSAGE, + value = "pollen.page.AdminUsers.title") + @Property + private String title; + + @Override + public Border getBorder() { + return border; + } + + @Override + public boolean isNeedAuthentification() { + return true; + } + + @Override + public boolean canDisplayPage() { + return isAdminConnected(); + } + + public AddressBar getAddressBar() { + return AddressBar.newBar().appendCurrent(title); + } + + /** Services used by the page **/ + @Inject + private Logger logger; + + @Inject + private ComponentResources resources; + + @Inject + private Messages messages; + + @Inject + private PollenManager manager; + + @Inject + private ServiceUser serviceUser; + + @Inject + private ServiceEmail serviceEmail; + + /***************************** USERS GRID/FORM ****************************/ + + /** Components of the page **/ + @InjectComponent + private Form usersForm; + + /** + * Users list : the {@link Persist} is used to keep current page and order + * from dataSource. + */ + @Persist + private UserAccountDataSource accounts; + + /** Current user from iteration on accounts **/ + @Property + private UserAccount account; + + /** Edited user **/ + @Property + private UserAccount accountEdited; + + /** + * Use the {@link UserAccountDataSource} to retrieve existing user accounts. + * This will manage pagination and order of the grid. + * + * @return the UserAccountDataSource which contains displayed users + */ + public UserAccountDataSource getAccounts() { + if (accounts == null) { + accounts = new UserAccountDataSource(serviceUser, new Filter()); + } + return accounts; + } + + /** + * Test if the edited account is the current one in the Grid. + * + * @return true if the accountEdited is defined and correspond to the + * current account in the Grid + */ + public boolean isEditionMode() { + // The current account in the loop is equals to the edited one + return accountEdited != null && account.equals(accountEdited); + } + + /** + * Test if the current account in the Grid is the connected user. + * + * @return true if the current account is the user connected + */ + public boolean isAccountConnected() { + // The current account in the loop is equals to the edited one + return account.equals(getUserConnected()); + } + + /** + * ON_ACTION :: Handler method for action on editAccount actionLink. + * The accountEdited will be set to the user selected in the Grid with + * {@code login}. + * + * @param login key of the user from the Grid + * @return the usersForm to display form with accountEdited + */ + public Object onActionFromEditAccount(String login) { + if (logger.isDebugEnabled()) { + logger.debug("User in edition : " + login); + } + accountEdited = accounts.get(login); + return usersForm; + } + + /** + * ON_ACTION :: Handler method for action on deletedAccount actionLink. + * The selected login from the Grid will be used to delete the user. + * + * @param login used to delete the user + * @see ServiceUser#deleteUser(String) + */ + public void onActionFromDeleteAccount(String login) { + serviceUser.deleteUser(login); + } + + /** + * ON_PREPARE_FOR_SUBMIT :: Handler method for prepareSubmit event of the + * usersForm. The accountEdited will be initialized to properly be saved in + * {@link #onValidateFormFromUsersForm()} + */ + public void onPrepareForSubmitFromUsersForm() { + if (accountEdited == null) { + accountEdited = serviceUser.getNewUser(); + } + } + + /** + * ON_VALIDATE_FORM :: Handler method for validateForm event of the + * usersForm. The accountEdited will be updated using serviceUser. Errors + * from service will be recorded into the usersForm. + * + * @see ServiceUser#updateUser(UserAccount, boolean) + */ + public void onValidateFormFromUsersForm() { + try { + serviceUser.updateUser(accountEdited, true); + } catch (PollenBusinessException eee) { + String message = manager.getErrorMessage(eee, messages, logger); + usersForm.recordError(message); + } + } + + /** + * ON_SUCCESS :: Handler method for success event of the usersForm. + * No error occurs from validation, a message will be displayed to client. + * + * @return the current page to refresh + */ + public Object onSuccessFromUsersForm() { + addInfo(messages.get("pollen.ui.user.update.success")); + return this; + } + + /** + * ON_FAILURE :: Handler method for failure event of the usersForm. + * Errors were recorded into the usersForm. The usersForm will be refresh + * to display error messages. + * + * @return the usersForm to refresh (in the usersZone) + */ + public Object onFailureFromUsersForm() { + return usersForm; + } + + /***************************** NEW USER FORM ******************************/ + + /** newUser to create from newUserForm **/ + @Property + private UserAccount newUser; + + /** Components used for refresh or validations **/ + @InjectComponent + private Form newUserForm; + + @InjectComponent + private Field newLogin; + + @InjectComponent + private Field newEmail; + + /** newPassword created for the newUser **/ + private String newPassword; + + /** + * ON_PREPARE :: Handler method for prepare events of the newUserForm. + * The newUser will be initialized if needed before render and before + * submit. + */ + public void onPrepareFromNewUserForm() { + if (newUser == null) { + newUser = serviceUser.getNewUser(); + } + } + + /** + * ON_VALIDATE_FORM :: Handler method for validateForm event of the + * newUserForm. The newUser will be created using serviceUser. Errors + * from service will be recorded into the newUserForm. The password will + * be generated if an email is set into the form. Otherwise the password + * will be the same as the newUser login. + * + * @see ServiceUser#createUser(UserAccount) + */ + public void onValidateFormFromNewUserForm() { + try { + String passwordInfo; + if (StringUtils.isNotEmpty(newUser.getEmail())) { + // Generate new password + newPassword = RandomStringUtils.randomAlphanumeric(8); + passwordInfo = + messages.get("pollen.ui.user.create.passwordGenerated"); + } else { + // Password will be the same as the login + newPassword = newUser.getLogin(); + passwordInfo = + messages.get("pollen.ui.user.create.passwordSameAsLogin"); + } + + newUser.setNewPassword(newPassword); + serviceUser.createUser(newUser); + addInfo(passwordInfo); + } catch (PollenBusinessException eee) { + String message = manager.getErrorMessage(eee, messages, logger); + switch (eee.getType()) { + case USER_EMAIL_EXIST: + newUserForm.recordError(newEmail, message); break; + case USER_LOGIN_EXIST: + newUserForm.recordError(newLogin, message); + } + } + } + + /** + * ON_SUCCESS :: Handler method for success event of the newUserForm. + * No error occurs from validation, success message is displayed to client + * and an email is sent to the newUser created if it's defined. + * The persist fields of the page will be discarded to refresh the grid with + * no order or page filter. + * + * @return the current page to refresh + * @see ServiceEmail#sendEmail(PollenEmail) + */ + public Object onSuccessFromNewUserForm() { + addInfo(messages.format("pollen.ui.user.create.success", + newUser.getLogin())); + // send email if needed + if (StringUtils.isNotEmpty(newUser.getEmail())) { + try { + PollenEmail email = serviceEmail.getNewEmail(newUser); + email.setSubject( + messages.format("pollen.email.userRegister.subject", + newUser.getLogin())); + email.setContent( + messages.format("pollen.email.userRegister.content", + newUser.getDisplayName(), newUser.getLogin(), + newPassword, getUrl())); + + serviceEmail.sendEmail(email); + addInfo(messages.format("pollen.ui.user.create.sendEmail", + newUser.getLogin(), newUser.getEmail())); + + } catch (PollenBusinessException eee) { + String message = manager.getErrorMessage(eee, messages, logger); + addError(message); + } + } + // Remove accounts to reset order and current page + // This will display the new user created in the first row of the grid + resources.discardPersistentFieldChanges(); + return this; + } + + /** + * ON_FAILURE :: Handler method for failure event of the newUserForm. + * Errors were recorded into the newUserForm. The newUserForm will be + * refresh to display error messages. + * + * @return the newUserForm to refresh (in the newUserZone) + */ + public Object onFailureFromNewUserForm() { + return newUserForm; + } +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Rev Revision" Added: svn:mergeinfo + Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/PollsAdmin.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/PollsAdmin.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/PollsAdmin.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,84 +0,0 @@ -/* *##% Pollen - * Copyright (C) 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/ - -package org.chorem.pollen.ui.pages.admin; - -import java.util.List; - -import org.apache.tapestry5.annotations.Component; -import org.apache.tapestry5.annotations.IncludeStylesheet; -import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.annotations.SessionState; -import org.apache.tapestry5.ioc.Messages; -import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.entity.Poll; -import org.chorem.pollen.entity.UserAccount; -import org.chorem.pollen.service.ServicePoll; -import org.chorem.pollen.ui.base.Polls; -import org.chorem.pollen.ui.components.FeedBack; - -/** - * Classe de la page d'administration des sondages. Si l'utilisateur n'est pas - * identifié, on lui demande d'abord de s'identifier via un formulaire. - * - * @author rannou - * @version $Id$ - */ -@IncludeStylesheet("context:css/pollsAdmin.css") -public class PollsAdmin extends Polls { - - /** Affichage des messages pour l'utilisateur */ - @Component(id = "feedback") - private FeedBack feedback; - - /** - * Objet de session représentant l'utilisateur identifié. - */ - @SessionState - private UserAccount user; - private boolean userExists; - - /** - * Liste de sondages de l'utilisateur - */ - @SuppressWarnings("unused") - @Property - private List<Poll> polls; - - /** - * Messages. - */ - @Inject - private Messages messages; - - /** Injection des services */ - @Inject - private ServicePoll servicePoll; - - /** - * Méthode d'initialisation des sondages - */ - @Override - public void onActivate() { - super.onActivate(); - polls = servicePoll.getAllPolls(); - - // Affichage des erreurs - if (userExists && !user.getAdmin()) { - feedback.addError(messages.get("userNotAllowed")); - } - } -} Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,257 +0,0 @@ -/* *##% Pollen - * Copyright (C) 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/ - -package org.chorem.pollen.ui.pages.admin; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tapestry5.BindingConstants; -import org.apache.tapestry5.ComponentResources; -import org.apache.tapestry5.ValueEncoder; -import org.apache.tapestry5.annotations.Component; -import org.apache.tapestry5.annotations.IncludeStylesheet; -import org.apache.tapestry5.annotations.Parameter; -import org.apache.tapestry5.annotations.Persist; -import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.annotations.SessionState; -import org.apache.tapestry5.ioc.Messages; -import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.PollenProperty; -import org.chorem.pollen.entity.UserAccount; -import org.chorem.pollen.mail.PreventRuleManager; -import org.chorem.pollen.service.ServiceUser; -import org.chorem.pollen.ui.components.FeedBack; -import org.chorem.pollen.ui.data.AddressBarItem; -import org.chorem.pollen.ui.services.PollenManager; - -/** - * Classe d'administration des comptes utilisateurs. Si l'utilisateur n'est pas - * identifié, on lui demande d'abord de s'identifier via un formulaire. - * - * @author rannou - * @version $Id$ - */ -@IncludeStylesheet("context:css/usersAdmin.css") -public class UsersAdmin { - - /** Affichage des messages pour l'utilisateur */ - @Component(id = "feedback") - private FeedBack feedback; - - /** - * Objet de session représentant l'url du site. - */ - @SessionState - private String siteURL; - - /** - * Objet de session représentant l'utilisateur identifié. - */ - @SessionState - @Property - private UserAccount user; - @Property - private boolean userExists; - - /** - * Titre de la page. - */ - @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") - @Property - private String title; - - /** - * Adresse de la page. - */ - @SuppressWarnings("unused") - @Property - private AddressBarItem[] address; - - /** - * Liste des utilisateurs. - */ - @Property - @Persist - private List<UserAccount> accounts; - - /** - * Utilisateur courant. - */ - @Property - private UserAccount account; - - /** - * Ressources de la page. - */ - @Inject - private ComponentResources resources; - - /** - * Messages. - */ - @Inject - private Messages messages; - - /** Injection des services */ - @Inject - private ServiceUser serviceUser; -// @Inject -// private ServiceList serviceList; - - /** - * Initialisation du formulaire. - */ - public void onPrepareFromUsersForm() { - if (accounts == null) { - accounts = serviceUser.getUsers(); - } - } - - /** - * Méthode appelée lors de la soumission du formulaire. - */ - public Object onSuccessFromUsersForm() { - for (UserAccount usr : accounts) { -// serviceUser.createUpdateUser(usr); - - // FIXME : test and refactor to manage errors - -// if (serviceUser.findUserById(usr.getId()) != null) { -// serviceUser.createUpdateUser(usr); -// } else { -// String password = PasswordGenerator.generate(8); -// if (serviceUser.createUser(usr, MD5.encode(password)) != null) { -// feedback.addInfo(messages.format("userCreated", usr -// .getLogin())); -// sendMailNotification(usr, password); -// } else { -// feedback.addError(messages.format("userNotCreated", usr -// .getLogin())); -// } -// } - } - feedback.addInfo(messages.get("dataSaved")); - resources.discardPersistentFieldChanges(); - return this; - } - - /** - * Méthode appelée lors de l'ajout d'un utilisateur. - */ -// Object onAddRowFromUsersLoop() { -// // FIXME : wtf ? -// -// -// UserAccount usr = new UserAccountImpl(); -// //usr.setId(String.valueOf(System.nanoTime())); -// accounts.add(usr); -// return usr; -// } - - /** - * Méthode appelée lors de la suppression d'un utilisateur. - */ -// void onRemoveRowFromUsersLoop(UserAccount usr) { -// if (serviceUser.findUserById(usr.getId()) != null) { -// -// // suppression des listes de votants de l'utilisateur -// serviceList.deletePersonLists(usr.getId()); -// -// // suppression de l'utilisateur -// if (serviceUser.deleteUser(usr)) { -// accounts.remove(usr); -// } -// } else { -// accounts.remove(usr); -// } -// } - - /** - * Encoder permettant de transformer un ID en user. - */ - public ValueEncoder<UserAccount> getUserEncoder() { - return new ValueEncoder<UserAccount>() { - - public String toClient(UserAccount value) { - return value.getTopiaId(); - } - - public UserAccount toValue(String key) { - for (UserAccount usr : accounts) { - if (key.equals(usr.getTopiaId())) { - return usr; - } - } - throw new IllegalArgumentException("La clé \"" + key - + "\" n'existe pas dans la collection : " + accounts); - } - }; - } - - @Inject - private PollenManager manager; - - /** Envoi du mail de notification */ - private void sendMailNotification(UserAccount newUser, String password) { - Map<String, String> data = new HashMap<String, String>(); - data.put("host", manager.getProperty(PollenProperty.EMAIL_HOST)); - data.put("port", manager.getProperty(PollenProperty.EMAIL_PORT)); - data.put("from", manager.getProperty(PollenProperty.EMAIL_FROM)); - data.put("to", newUser.getEmail()); - data.put("title", messages.format("registerEmail_subject", newUser - .getLogin())); - data.put("msg", messages.format("registerEmail_msg", newUser - .getFirstName(), newUser.getLastName(), newUser.getLogin(), - password, siteURL)); - - // FIXME call directly MailUtil.sendMail() - // skip fill map, get from map... - PreventRuleManager.emailAction(data); - } - - /** - * Détermine si le compte courant est le compte de l'utilisateur. - */ - public boolean isMyAccount() { - if (userExists) { - return user.equals(account); - } - return false; - } - - /** - * Méthode d'activation de la page. - */ - public void onActivate() { - - // Affichage des erreurs - if (userExists && !user.getAdmin()) { - feedback.addError(messages.get("userNotAllowed")); - } - } - - /** - * Initialisation de l'affichage. - */ - public void setupRender() { - accounts = serviceUser.getUsers(); - - address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"), - new AddressBarItem(title, null) }; - } -} Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -18,6 +18,7 @@ import org.apache.tapestry5.BindingConstants; import org.apache.tapestry5.annotations.Component; +import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; @@ -28,6 +29,8 @@ import org.chorem.pollen.entity.PollAccount; import org.chorem.pollen.service.ServicePoll; import org.chorem.pollen.service.ServiceUser; +import org.chorem.pollen.ui.base.AbstractPollenPage; +import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.components.FeedBack; import org.chorem.pollen.ui.data.AddressBarItem; @@ -38,8 +41,16 @@ * @author rannou * @version $Id$ */ -public class CloseValidation { +public class CloseValidation extends AbstractPollenPage { + @InjectComponent + private Border border; + + @Override + public Border getBorder() { + return border; + } + /** Affichage des messages pour l'utilisateur */ @Component(id = "feedback") private FeedBack feedback; Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -19,15 +19,17 @@ import java.util.Date; import org.apache.tapestry5.BindingConstants; +import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.InjectPage; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.entity.Choice; import org.chorem.pollen.entity.Poll; import org.chorem.pollen.service.ServicePoll; +import org.chorem.pollen.ui.base.AbstractPollenPage; +import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.data.AddressBarItem; import org.chorem.pollen.ui.data.PollAction; @@ -38,8 +40,16 @@ * @author rannou * @version $Id$ */ -public class ConfirmPoll { +public class ConfirmPoll extends AbstractPollenPage { + @InjectComponent + private Border border; + + @Override + public Border getBorder() { + return border; + } + @Persist private Poll poll; Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -18,6 +18,7 @@ import org.apache.tapestry5.BindingConstants; import org.apache.tapestry5.annotations.Component; +import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; @@ -26,9 +27,10 @@ import org.apache.tapestry5.ioc.annotations.Inject; import org.chorem.pollen.entity.Poll; import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.ui.base.AbstractPollenPage; +import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.components.FeedBack; import org.chorem.pollen.ui.data.AddressBarItem; -import org.chorem.pollen.votecounting.dto.PollDTO; /** * Classe de la page de confirmation de la création d'un sondage. @@ -37,8 +39,16 @@ * @author rannou * @version $Id$ */ -public class CreationValidation { +public class CreationValidation extends AbstractPollenPage { + @InjectComponent + private Border border; + + @Override + public Border getBorder() { + return border; + } + /** Affichage des messages pour l'utilisateur */ @Component(id = "feedback") private FeedBack feedback; Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -18,6 +18,7 @@ import org.apache.tapestry5.BindingConstants; import org.apache.tapestry5.annotations.Component; +import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; @@ -26,6 +27,8 @@ import org.apache.tapestry5.ioc.annotations.Inject; import org.chorem.pollen.entity.Poll; import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.ui.base.AbstractPollenPage; +import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.components.FeedBack; import org.chorem.pollen.ui.data.AddressBarItem; @@ -36,8 +39,16 @@ * @author rannou * @version $Id$ */ -public class ModificationValidation { +public class ModificationValidation extends AbstractPollenPage { + @InjectComponent + private Border border; + + @Override + public Border getBorder() { + return border; + } + /** Affichage des messages pour l'utilisateur */ @Component(id = "feedback") private FeedBack feedback; Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -16,7 +16,6 @@ import org.apache.tapestry5.annotations.Log; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.corelib.components.Form; import org.apache.tapestry5.corelib.components.FormFragment; import org.apache.tapestry5.ioc.Messages; @@ -27,9 +26,9 @@ import org.chorem.pollen.entity.Choice; import org.chorem.pollen.entity.Poll; import org.chorem.pollen.entity.PreventRule; -import org.chorem.pollen.entity.UserAccount; -import org.chorem.pollen.mail.PreventRuleManager; import org.chorem.pollen.service.ServicePoll; +import org.chorem.pollen.ui.base.AbstractPollenPage; +import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.data.AddressBar; import org.chorem.pollen.ui.data.ChoiceField; import org.slf4j.Logger; @@ -61,17 +60,19 @@ */ @IncludeStylesheet("context:css/poll.css") @IncludeJavaScriptLibrary("context:js/pollForm.js") -public class PollForm { +public class PollForm extends AbstractPollenPage { + @InjectComponent + private Border border; + + @Override + public Border getBorder() { + return border; + } + @Inject private Logger log; - - @SessionState - private UserAccount user; - @Property - private boolean userExists; - @Inject private Messages messages; Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -22,12 +22,9 @@ import java.util.Collections; import java.util.Comparator; import java.util.Date; -import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Set; -import java.util.Map.Entry; import org.apache.tapestry5.BindingConstants; import org.apache.tapestry5.annotations.Component; @@ -48,12 +45,11 @@ import org.chorem.pollen.entity.PollAccount; import org.chorem.pollen.entity.Result; import org.chorem.pollen.service.ServicePoll; +import org.chorem.pollen.ui.base.AbstractPollenPage; +import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.components.Chart; import org.chorem.pollen.ui.components.FeedBack; import org.chorem.pollen.ui.data.AddressBarItem; -import org.chorem.pollen.votecounting.business.NumberMethod; -import org.chorem.pollen.votecounting.dto.ChoiceDTO; -import org.chorem.pollen.votecounting.dto.VoteCountingResultDTO; import org.slf4j.Logger; /** @@ -64,7 +60,16 @@ */ @IncludeStylesheet({"context:css/results.css", "context:css/lightbox.css"}) @IncludeJavaScriptLibrary({"${tapestry.scriptaculous}/builder.js","context:js/lightbox.js"}) -public class Results { +public class Results extends AbstractPollenPage { + + @InjectComponent + private Border border; + + @Override + public Border getBorder() { + return border; + } + @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") @Property private String title; Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -36,7 +36,6 @@ import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; @@ -48,7 +47,6 @@ import org.chorem.pollen.entity.CommentImpl; import org.chorem.pollen.entity.Poll; import org.chorem.pollen.entity.PollAccount; -import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.entity.Vote; import org.chorem.pollen.service.ServicePoll; import org.chorem.pollen.service.ServiceUser; @@ -73,6 +71,14 @@ @IncludeStylesheet({"context:css/vote.css", "context:css/lightbox.css"}) @IncludeJavaScriptLibrary({"${tapestry.scriptaculous}/builder.js","context:js/lightbox.js"}) public class VoteForPoll extends AbstractUploadPage { + + @InjectComponent + private Border border; + + @Override + public Border getBorder() { + return border; + } // // @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") // @Property @@ -936,9 +942,6 @@ @Property private PollUri uri; - - @InjectComponent - private Border border; /** TEMP : Affichage des messages pour l'utilisateur */ @Component(id = "feedback") @@ -966,15 +969,6 @@ @Property private boolean pollNull; - - /** - * Objet de session représentant l'utilisateur identifié. - */ - @SessionState - private UserAccount user; - - @Property - private boolean userExists; /** Compte du votant */ private PollAccount pollAccount; @@ -1103,7 +1097,7 @@ } if (pollAccount == null) { - pollAccount = serviceUser.getNewPerson(user);//new PollAccountDTO(); + pollAccount = serviceUser.getNewPerson(getUserConnected());//new PollAccountDTO(); // if (userExists) { // if (user.getFirstName() != null && user.getLastName() != null) { // pollAccount.setVotingId( @@ -1128,7 +1122,8 @@ * @throws PollenBusinessException */ public boolean isCreatorUser() throws PollenBusinessException { - return userExists && user.equals(getPoll().getCreator().getUserAccount()); + return isUserConnected() && getUserConnected().equals( + getPoll().getCreator().getUserAccount()); } /************** PAGER *****************************************************/ Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -16,7 +16,6 @@ package org.chorem.pollen.ui.pages.user; -import java.util.List; import org.apache.commons.fileupload.FileUploadException; import org.apache.tapestry5.BindingConstants; @@ -25,10 +24,8 @@ import org.apache.tapestry5.annotations.IncludeStylesheet; import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.Parameter; -import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.Retain; -import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.beaneditor.BeanModel; import org.apache.tapestry5.corelib.components.Form; import org.apache.tapestry5.corelib.components.Zone; @@ -37,12 +34,11 @@ import org.apache.tapestry5.services.BeanModelSource; import org.apache.tapestry5.upload.services.UploadedFile; import org.chorem.pollen.entity.PollAccount; -import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.ui.base.AbstractPollenPage; +import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.components.FeedBack; import org.chorem.pollen.ui.data.EvenOdd; import org.chorem.pollen.ui.data.AddressBarItem; -import org.chorem.pollen.ui.utils.CSVAccountUtil; -import org.chorem.pollen.ui.utils.LDAPAccountUtil; /** * Classe de la page d'affichage des listes de votants favorites de @@ -53,16 +49,16 @@ * @version $Id$ */ @IncludeStylesheet("context:css/lists.css") -public class UserLists { +public class UserLists extends AbstractPollenPage { - /** - * Objet de session représentant l'utilisateur identifié. - */ - @SessionState - private UserAccount user; - @Property - private boolean userExists; + @InjectComponent + private Border border; + @Override + public Border getBorder() { + return border; + } + /** Affichage des messages pour l'utilisateur */ @Component(id = "feedback") private FeedBack feedback; Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsCreated.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsCreated.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsCreated.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -19,16 +19,16 @@ import java.util.List; import org.apache.tapestry5.annotations.IncludeStylesheet; +import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.corelib.components.Form; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.upload.services.UploadedFile; import org.chorem.pollen.entity.Poll; -import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.service.ServicePoll; -import org.chorem.pollen.ui.base.Polls; +import org.chorem.pollen.ui.base.AbstractPollsPage; +import org.chorem.pollen.ui.components.Border; /** * Classe de la page d'affichage des sondages que l'utilisateur a créés. Si @@ -39,15 +39,16 @@ * @version $Id$ */ @IncludeStylesheet("context:css/pollsCreated.css") -public class UserPollsCreated extends Polls { +public class UserPollsCreated extends AbstractPollsPage { - /** - * Objet de session représentant l'utilisateur identifié. - */ - @SessionState - private UserAccount user; - private boolean userExists; + @InjectComponent + private Border border; + @Override + public Border getBorder() { + return border; + } + /** * Liste de sondages de l'utilisateur */ @@ -103,8 +104,8 @@ @Override public void onActivate() { super.onActivate(); - if (userExists) { - polls = servicePoll.getPollsByUser(user); + if (isUserConnected()) { + polls = servicePoll.getPollsByUser(getUserConnected()); } } } Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -19,14 +19,13 @@ import java.util.List; import org.apache.tapestry5.annotations.IncludeStylesheet; +import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.ioc.annotations.Inject; import org.chorem.pollen.entity.Poll; -import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.service.ServicePoll; -import org.chorem.pollen.ui.base.Polls; -import org.chorem.pollen.votecounting.dto.PollDTO; +import org.chorem.pollen.ui.base.AbstractPollsPage; +import org.chorem.pollen.ui.components.Border; /** * Classe de la page d'affichage des sondages auxquels l'utilisateur a @@ -37,15 +36,16 @@ * @version $Id$ */ @IncludeStylesheet("context:css/pollsParticipated.css") -public class UserPollsParticipated extends Polls { +public class UserPollsParticipated extends AbstractPollsPage { - /** - * Objet de session représentant l'utilisateur identifié. - */ - @SessionState - private UserAccount user; - private boolean userExists; + @InjectComponent + private Border border; + @Override + public Border getBorder() { + return border; + } + /** * Liste des sondages auxquels l'utilisateur a participé */ @@ -86,8 +86,9 @@ @Override public void onActivate() { super.onActivate(); - if (userExists) { - invitedPolls = participatedPolls = servicePoll.getPollsByUser(user); + if (isUserConnected()) { + invitedPolls = participatedPolls = servicePoll.getPollsByUser( + getUserConnected()); // invitedPolls = servicePoll.findInvitedPolls(user.getId()); } } Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -27,7 +27,6 @@ import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.corelib.components.Form; import org.apache.tapestry5.corelib.components.PasswordField; import org.apache.tapestry5.corelib.components.TextField; @@ -36,6 +35,7 @@ import org.chorem.pollen.PollenBusinessException; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.service.ServiceUser; +import org.chorem.pollen.ui.base.AbstractPollenPage; import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.data.AddressBar; import org.chorem.pollen.ui.services.PollenManager; @@ -49,26 +49,32 @@ * @version $Id$ */ @IncludeStylesheet("context:css/account.css") -public class UserProfile { +public class UserProfile extends AbstractPollenPage { + @InjectComponent + private Border border; + + @Override + public Border getBorder() { + return border; + } + + @Override + public boolean isNeedAuthentification() { + return true; + } + + @Override + public boolean canDisplayPage() { + return isUserConnected(); + } + @Inject private Logger logger; @Inject private PollenManager manager; - @InjectComponent - private Border border; - - /** - * Objet de session représentant l'utilisateur identifié. - */ - @SessionState - @Property - private UserAccount user; - @Property - private boolean userExists; - @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") @Property private String title; @@ -127,7 +133,7 @@ public UserAccount getUserEditable() { if (userEditable == null) { - userEditable = user; + userEditable = getUserConnected(); } return userEditable; } @@ -135,10 +141,10 @@ /** * ON_VALIDATE_FORM :: <br \> * UI validation : check if the two passwords are equals. <br \> - * BUSINESS validation : execute {@link org.chorem.pollen.service.ServiceUser#updateUser(org.chorem.pollen.entity.UserAccount) } + * BUSINESS validation : execute {@link ServiceUser#updateUser(UserAccount) } * which throws errors - * {@link org.chorem.pollen.PollenBusinessException.PollenExceptionType.USER_WRONG_PASSWORD} - * and {@link org.chorem.pollen.PollenBusinessException.PollenExceptionType.USER_EMAIL_EXIST}. + * {@link PollenBusinessException.PollenExceptionType.USER_WRONG_PASSWORD} + * and {@link PollenBusinessException.PollenExceptionType.USER_EMAIL_EXIST}. */ @Log void onValidateFormFromAccountForm() { @@ -147,19 +153,19 @@ if (StringUtils.isNotEmpty(newPassword) && !newPassword.equals(passwordVerify)) { accountForm.recordError(newPasswordField, - messages.get("pollen.ui.user.passwordsDontMatch")); + messages.get("pollen.ui.user.validate.passwords")); } // If no UI errors, call business to save the user if (!accountForm.getHasErrors()) { try { // Update the user if (logger.isDebugEnabled()) { - logger.debug("TopiaId : " + user.getTopiaId()); - logger.debug("Login : " + user.getLogin()); - logger.debug("Password : " + user.getPassword()); - logger.debug("NewPassword : " + user.getNewPassword()); + logger.debug("TopiaId : " + userEditable.getTopiaId()); + logger.debug("Login : " + userEditable.getLogin()); + logger.debug("Password : " + userEditable.getPassword()); + logger.debug("NewPassword : " + userEditable.getNewPassword()); } - serviceUser.updateUser(userEditable); + serviceUser.updateUser(userEditable, false); } catch (PollenBusinessException eee) { String message = manager.getErrorMessage(eee, messages, logger); switch (eee.getType()) { @@ -174,7 +180,7 @@ @Log Object onSuccessFromAccountForm() { - border.addInfo(messages.get("pollen.ui.user.updateSuccess")); + addInfo(messages.get("pollen.ui.user.update.success")); return this; } Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -26,7 +26,6 @@ import org.apache.tapestry5.annotations.InjectPage; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.corelib.components.Form; import org.apache.tapestry5.corelib.components.PasswordField; import org.apache.tapestry5.corelib.components.TextField; @@ -37,6 +36,7 @@ import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.service.ServiceEmail; import org.chorem.pollen.service.ServiceUser; +import org.chorem.pollen.ui.base.AbstractPollenPage; import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.data.AddressBar; import org.chorem.pollen.ui.pages.Index; @@ -52,24 +52,31 @@ * @version $Id$ */ @IncludeStylesheet("context:css/register.css") -public class UserRegister { +public class UserRegister extends AbstractPollenPage { - @Inject - private Logger logger; - @InjectComponent private Border border; - /** - * Identified user - */ - @SessionState - private UserAccount user; + @Override + public Border getBorder() { + return border; + } - @Property - private boolean userExists; + @Override + public boolean isNeedAuthentification() { + return false; + } + @Override + public boolean canDisplayPage() { + addInfo("Vous devez vous déconnecter pour créer un compte"); + return !isUserConnected(); + } + @Inject + private Logger logger; + + @Inject private ServiceUser serviceUser; @Inject @@ -85,16 +92,9 @@ @Property private String title; - /** - * Session property loaded from configuration to know what is the current - * server url - */ - @SessionState - private String siteURL; +// @Inject +// private Locale currentLocale; - @Inject - private Locale currentLocale; - /** * New user to create */ @@ -129,7 +129,7 @@ public UserAccount getNewUser() { if (newUser == null) { - newUser = serviceUser.getNewUser(currentLocale); + newUser = serviceUser.getNewUser(); } return newUser; } @@ -137,17 +137,17 @@ /** * ON_VALIDATE_FORM :: <br \> * UI validation : check if the two passwords are equals. <br \> - * BUSINESS validation : execute {@link org.chorem.pollen.service.ServiceUser#createUser(org.chorem.pollen.entity.UserAccount) } + * BUSINESS validation : execute {@link ServiceUser#createUser(UserAccount)} * which throws errors - * {@link org.chorem.pollen.PollenBusinessException.PollenExceptionType.USER_LOGIN_EXIST} - * and {@link org.chorem.pollen.PollenBusinessException.PollenExceptionType.USER_EMAIL_EXIST}. + * {@link PollenBusinessException.PollenExceptionType.USER_LOGIN_EXIST} + * and {@link PollenBusinessException.PollenExceptionType.USER_EMAIL_EXIST}. */ void onValidateFormFromRegister() { // Check newPassword that must be equals to passwordVerify String password = newUser.getNewPassword(); if (!password.equals(passwordVerify)) { register.recordError(passwordField, - messages.get("pollen.ui.user.passwordsDontMatch")); + messages.get("pollen.ui.user.validate.passwords")); } // If no UI errors, call business to save the user @@ -180,30 +180,30 @@ */ Object onSuccessFromRegister() { // Set the newUser in session : connect the new registered user - user = newUser; + setUserConnected(newUser); index.addInfo( - messages.format("pollen.ui.user.autoConnection", - user.getLogin())); + messages.format("pollen.ui.user.register.autoConnection", + newUser.getLogin())); // Send an email to the new user if not empty - if (StringUtils.isNotEmpty(user.getEmail())) { + if (StringUtils.isNotEmpty(newUser.getEmail())) { try { - PollenEmail mail = serviceEmail.getNewEmail(user); + PollenEmail mail = serviceEmail.getNewEmail(newUser); mail.setSubject( messages.format("pollen.email.userRegister.subject", - user.getLogin())); + newUser.getLogin())); mail.setContent( messages.format("pollen.email.userRegister.content", - user.getDisplayName(), user.getLogin(), - passwordForEmail, siteURL)); + newUser.getDisplayName(), newUser.getLogin(), + passwordForEmail, getUrl())); serviceEmail.sendEmail(mail); index.addInfo( - messages.format("pollen.ui.user.sendRegisterEmail", - user.getEmail())); + messages.format("pollen.ui.user.register.sendEmail", + newUser.getEmail())); } catch (PollenBusinessException eee) { String message = manager.getErrorMessage(eee, messages, logger); Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -16,6 +16,7 @@ package org.chorem.pollen.ui.services; +import java.util.Locale; import org.apache.tapestry5.SymbolConstants; import org.apache.tapestry5.ioc.Configuration; import org.apache.tapestry5.ioc.MappedConfiguration; @@ -96,15 +97,20 @@ * * @param configuration to add the manager to registry startup * @param manager to launch at startup + * @param serviceUser used to start pollen context in manager * @param shutdownHub to register manager for registry shutdown */ public static void contributeRegistryStartup( OrderedConfiguration<Runnable> configuration, - PollenManager manager, RegistryShutdownHub shutdownHub) { + ServiceUser serviceUser, + PollenManager manager, + RegistryShutdownHub shutdownHub) { + if (logger.isInfoEnabled()) { logger.info("Execute contributeRegistryStartup"); } shutdownHub.addRegistryShutdownListener(manager); + manager.setServiceUser(serviceUser); configuration.add("PollenStartup", manager); } @@ -204,9 +210,11 @@ * Used to instanciate SessionState UserAccount when session expires. * * @param configuration to add the ApplicationStateCreator. + * @param serviceUser to instantiate user */ public void contributeApplicationStateManager(MappedConfiguration<Class<?>, - ApplicationStateContribution> configuration) { + ApplicationStateContribution> configuration, + final ServiceUser serviceUser) { if (logger.isInfoEnabled()) { logger.info("Execute contributeApplicationStateManager"); } @@ -215,7 +223,7 @@ new ApplicationStateCreator<UserAccount>() { @Override public UserAccount create() { - return new UserAccountImpl(); + return serviceUser.getNewUser(); } }; Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -32,6 +32,8 @@ import org.chorem.pollen.PollenBusinessException; import org.chorem.pollen.PollenContext; import org.chorem.pollen.PollenProperty; +import org.chorem.pollen.service.ServiceUser; +import org.chorem.pollen.ui.base.PollenPage; import org.nuiton.util.ApplicationConfig; import org.slf4j.Logger; @@ -58,6 +60,8 @@ private PollenContext context; + private ServiceUser serviceUser; + /** * Constructor of WaoManager. It needs the WaoContext to start and stop. * @@ -67,12 +71,16 @@ this.context = context; } + void setServiceUser(ServiceUser serviceUser) { + this.serviceUser = serviceUser; + } + /** * Called to start the application. */ @Override public void run() { - context.start(); + context.start(serviceUser); // Copy properties to propertiesMap (insentitive) for SymbolProvider Properties properties = getConfiguration().getOptions(); for (Object key : properties.keySet()) { Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/PasswordGenerator.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/PasswordGenerator.java 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/PasswordGenerator.java 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,56 +0,0 @@ -/* *##% Pollen - * Copyright (C) 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/ - -package org.chorem.pollen.ui.utils; - -/** - * Classe permettant de générer un mot de passe aléatoire. - * - * @author rannou - * @version $Id$ - */ -public class PasswordGenerator { - - /** - * Génération d'un mot de passe aléatoire. - * - * @param length longueur du mot de passe - */ - public static String generate(int length) { - char[] chars = new char[length]; - int c = '0'; - - for (int i = 0; i < length; i++) { - int charType = (int) (Math.random() * 3); - switch (charType) { - case 0: - c = '0' + (int) (Math.random() * 10); - break; - case 1: - c = 'a' + (int) (Math.random() * 26); - break; - case 2: - c = 'A' + (int) (Math.random() * 26); - break; - default: - break; - } - chars[i] = (char) c; - } - - return String.copyValueOf(chars); - } -} Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-en_GB.properties =================================================================== --- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-en_GB.properties 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-en_GB.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,6 +1,6 @@ # User registration emails -pollen.mail.userRegister.subject=[Pollen] Confirmation of account creation %s -pollen.mail.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.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 # Poll creation emails creatorEmail_subject=[Pollen] Poll creation (%s) @@ -50,6 +50,16 @@ pollen.ui.choice.add.submit=Add pollen.ui.error.upload=An error occurred while uploading files. Maximum size allowed is %$1s per file, and %$2s total. +pollen.ui.user.edit=Edit this user account +pollen.ui.user.cancelEdit=Cancel changes +pollen.ui.user.save=Save this user account +pollen.ui.user.delete=Delete this user account +pollen.ui.user.delete.confirmMessage=Are you sure you want to definitively delete this user ? + +email-regexp=^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$ +email-regexp-message=Invalid email +login-required-message=You must provide a username + # Tapestry messages for VoteForPoll.tml # FORM:: addChoice choiceDescription-label=Description @@ -62,4 +72,4 @@ choiceImage-label=Image 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. \ No newline at end of file +addChoice-choiceImage-required-message=You must provide a choice. Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties =================================================================== --- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,51 +1,42 @@ -# User registration emails +############################ PAGES ############################################# +pollen.page.AdminUsers.title=Gestion des utilisateurs + +############################ EMAIL ############################################# pollen.email.userRegister.subject=[Pollen] Confirmation de cr\u00E9ation du compte %s pollen.email.userRegister.content=Bienvenue %1$s. Vous venez de cr\u00E9er un compte sur l'application de sondage en ligne Pollen.\n\nIdentifiant : %2$s\nMot de passe : %3$s\n\nVous pouvez d\u00E8s maintenant g\u00E9rer vos sondages en vous identifiant sur le site : \n%4$s -# Poll creation emails -creatorEmail_subject=[Pollen] Cr\u00E9ation d'un sondage (%s) -creatorEmail_msg=Vous venez de cr\u00E9er le sondage "%s".\nVous pouvez y acc\u00E9der en suivant les liens ci-dessous.\n\nPage de vote : \n%s\nPage de modification : \n%s -votingEmail_subject=[Pollen] Invitation au vote (%s) -votingEmail_msg=Un nouveau sondage a \u00E9t\u00E9 cr\u00E9\u00E9 : "%s".\nVous pouvez y participer avec l'identifiant %s \u00E0 l'adresse suivante : \n%s +############################ USER ############################################## +pollen.ui.user.register.autoConnection=Vous \u00EAtes maintenant connect\u00E9 avec l'identifiant %1$s. +pollen.ui.user.register.sendEmail=Un email vous a \u00E9t\u00E9 envoy\u00E9 \u00E0 l'adresse %1$s. +pollen.ui.user.validate.passwords=Les deux mots de passe ne correspondent pas. +pollen.ui.user.update.success=Modification enregistr\u00E9e avec succ\u00E8s. +pollen.ui.user.display.notConnected=Vous devez vous connecter pour acc\u00E9der \u00E0 cette page. +pollen.ui.user.display.notAllowed=Vous n'avez pas les droits n\u00E9cessaires pour acc\u00E9der \u00E0 cette page. +pollen.ui.user.create=Ajouter +pollen.ui.user.create.title=Cr\u00E9er un nouvel utilisateur +pollen.ui.user.create.passwordGenerated=Le password du nouvel utilisateur a \u00E9t\u00E9 g\u00E9n\u00E9r\u00E9. +pollen.ui.user.create.passwordSameAsLogin=Le password du nouvel utilisateur est le m\u00EAme que son identifiant. +pollen.ui.user.create.sendEmail=Un email a \u00E9t\u00E9 envoy\u00E9 au nouvel utilisateur %1$s \u00E0 l'adresse %2$s. +pollen.ui.user.create.success=L'utilisateur %1$s a \u00E9t\u00E9 cr\u00E9\u00E9 avec succ\u00E8s. +pollen.ui.user.update.edit=Modifier cet utilisateur. +pollen.ui.user.update.save=Enregistrer les modifications. +pollen.ui.user.update.cancel=Annuler les changements. +pollen.ui.user.delete=Supprimer cet utilisateur. +pollen.ui.user.delete.confirmMessage=Etes-vous s\u00FBr de vouloir d\u00E9finitivement supprimer cet utilisateur ? -# Notification emails -voteEmail_subject=[Pollen] Notification de vote (%s) -voteEmail_msg=Un vote vient d'\u00EAtre enregistr\u00E9 pour le sondage "%s". Ce sondage compte d\u00E9sormais %d votes.\nVous pouvez acc\u00E9der \u00E0 ce sondage en suivant les liens ci-dessous.\n\nPage de vote : \n%s\nPage de modification : \n%s +# FORM:: user +firstName-label=Pr\u00E9nom +lastName-label=Nom +login-label=Identifiant +email-label=Email -# Reminder emails -reminderEmail_subject=[Pollen] Rappel (%s) -reminderEmail_msg=Vous n'avez pas encore vot\u00E9 pour le sondage "%s".\nVous pouvez encore y participer avec l'identifiant %s \u00E0 l'adresse suivante : \n%s +login-required-message=Vous devez fournir un identifiant +email-regexp=^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$ +email-regexp-message=Email invalide +newEmail-regexp=^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$ +newEmail-regexp-message=Email invalide -# Poll feed -pollFeed_title=Pollen : %s -pollFeed_desc=%s -pollFeed_createTitle=Sondage cr\u00E9\u00E9 par %s -pollFeed_createContent= -pollFeed_voteTitle=Nouveau vote de %s -pollFeed_voteContent=\u00C9tat du sondage : %s -pollFeed_choiceTitle=Nouveau choix : %s -pollFeed_choiceContent=%s -pollFeed_commentTitle=Nouveau commentaire de %s -pollFeed_commentContent=%s - -# Actions -create=Cr\u00E9er -edit=Modifier -delete=Supprimer -add=Ajouter -save=Enregistrer -load=Charger -ok=Ok -validate=Valider -cancel=Annuler -return=Retour -help=Aide - -pollen.ui.user.autoConnection=Vous \u00EAtes maintenant connect\u00E9 avec l'identifiant %1$s. -pollen.ui.user.sendRegisterEmail=Un email vous a \u00E9t\u00E9 envoy\u00E9 \u00E0 l'adresse %1$s. -pollen.ui.user.passwordsDontMatch=Les deux mots de passe ne correspondent pas. -pollen.ui.user.updateSuccess=Modification enregistr\u00E9e avec succ\u00E8s. - +############################ CHOICE ############################################ pollen.ui.choice.delete.confirm=Etes-vous s\u00FBr de vouloir d\u00E9finitivement supprimer ce choix ? pollen.ui.choice.delete.title=Supprimer ce choix pollen.ui.vote.noVote=Aucune personne n'a encore particip\u00E9 au sondage @@ -68,3 +59,43 @@ addChoice-choiceImage-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$ addChoice-choiceImage-regexp-message=L'image doit-\u00EAtre au format JPG, GIF ou PNG. addChoice-choiceImage-required-message=Vous devez saisir un choix. + + +# Poll creation emails +#creatorEmail_subject=[Pollen] Cr\u00E9ation d'un sondage (%s) +#creatorEmail_msg=Vous venez de cr\u00E9er le sondage "%s".\nVous pouvez y acc\u00E9der en suivant les liens ci-dessous.\n\nPage de vote : \n%s\nPage de modification : \n%s +#votingEmail_subject=[Pollen] Invitation au vote (%s) +#votingEmail_msg=Un nouveau sondage a \u00E9t\u00E9 cr\u00E9\u00E9 : "%s".\nVous pouvez y participer avec l'identifiant %s \u00E0 l'adresse suivante : \n%s + +# Notification emails +#voteEmail_subject=[Pollen] Notification de vote (%s) +#voteEmail_msg=Un vote vient d'\u00EAtre enregistr\u00E9 pour le sondage "%s". Ce sondage compte d\u00E9sormais %d votes.\nVous pouvez acc\u00E9der \u00E0 ce sondage en suivant les liens ci-dessous.\n\nPage de vote : \n%s\nPage de modification : \n%s + +# Reminder emails +#reminderEmail_subject=[Pollen] Rappel (%s) +#reminderEmail_msg=Vous n'avez pas encore vot\u00E9 pour le sondage "%s".\nVous pouvez encore y participer avec l'identifiant %s \u00E0 l'adresse suivante : \n%s + +# Poll feed +#pollFeed_title=Pollen : %s +#pollFeed_desc=%s +#pollFeed_createTitle=Sondage cr\u00E9\u00E9 par %s +#pollFeed_createContent= +#pollFeed_voteTitle=Nouveau vote de %s +#pollFeed_voteContent=\u00C9tat du sondage : %s +#pollFeed_choiceTitle=Nouveau choix : %s +#pollFeed_choiceContent=%s +#pollFeed_commentTitle=Nouveau commentaire de %s +#pollFeed_commentContent=%s + +# Actions +#create=Cr\u00E9er +#edit=Modifier +#delete=Supprimer +#add=Ajouter +#save=Enregistrer +#load=Charger +#ok=Ok +#validate=Valider +#cancel=Annuler +#return=Retour +#help=Aide Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml 2010-04-23 17:09:22 UTC (rev 2973) @@ -101,13 +101,13 @@ </li> <t:if test="userExists"> <li> - <t:pagelink t:page="user/UserPollsCreated">${message:createdPolls}</t:pagelink> + <t:pagelink t:page="user/pollsCreated">${message:createdPolls}</t:pagelink> </li> <li> - <t:pagelink t:page="user/UserPollsParticipated">${message:participatedPolls}</t:pagelink> + <t:pagelink t:page="user/pollsParticipated">${message:participatedPolls}</t:pagelink> </li> <li> - <t:pagelink t:page="user/UserLists">${message:votingLists}</t:pagelink> + <t:pagelink t:page="user/lists">${message:votingLists}</t:pagelink> </li> </t:if> </ul> @@ -122,10 +122,10 @@ <div class="top_left${pageLogo}"></div> <ul class ="top_middle${pageLogo}"> <li> - <t:pagelink t:page="admin/PollsAdmin">${message:pollsAdmin}</t:pagelink> + <t:pagelink t:page="admin/polls">${message:pollsAdmin}</t:pagelink> </li> <li> - <t:pagelink t:page="admin/UsersAdmin">${message:usersAdmin}</t:pagelink> + <t:pagelink t:page="admin/users">${message:usersAdmin}</t:pagelink> </li> </ul> </div> @@ -159,9 +159,21 @@ <t:feedback t:id="errorJs" /> </noscript> <t:feedback t:id="borderFeedback" t:autoClear="false"/> - <t:if t:test="canDisplayBody()"> + <t:delegate t:to="activeBlock" /> + <t:block t:id="loginBlock"> + <t:LoginComponent /> + </t:block> + <t:block t:id="pageBlock"> <t:body /> - </t:if> + </t:block> + <!--<t:if t:test="needAuthentification"> + <t:LoginComponent /> + <p:else> + <t:if t:test="canDisplayBody()"> + <t:body /> + </t:if> + </p:else> + </t:if>--> </div> </div> Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border_fr.properties =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border_fr.properties 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border_fr.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -11,8 +11,8 @@ createdPolls=Sondages cr\u00E9\u00E9s participatedPolls=Sondages particip\u00E9s votingLists=Listes de votants -pollsAdmin=G\u00E9rer les sondages -usersAdmin=G\u00E9rer les utilisateurs +pollsAdmin=Sondages +usersAdmin=Utilisateurs account=Mon compte logout=D\u00E9connexion or=ou Copied: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminPolls_en.properties (from rev 2972, trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/PollsAdmin_en.properties) =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminPolls_en.properties (rev 0) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminPolls_en.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,4 @@ +title=Polls administration +noUser=You must be logged to access polls administration.\n Please fill the form below. +userNotAllowed=You are not allowed to access this page. +noPolls=No poll exists. \ No newline at end of file Property changes on: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminPolls_en.properties ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminPolls_fr.properties (from rev 2972, trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/PollsAdmin_fr.properties) =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminPolls_fr.properties (rev 0) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminPolls_fr.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,4 @@ +title=Gestion des sondages +noUser=Vous devez \u00EAtre identifi\u00E9 pour pouvoir administrer les sondages.\n Veuillez remplir le formulaire ci-dessous. +userNotAllowed=Vous n'\u00EAtes pas autoris\u00E9 \u00E0 acc\u00E9der \u00E0 cette page. +noPolls=Aucun sondage existant. \ No newline at end of file Property changes on: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminPolls_fr.properties ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminUsers_en.properties (from rev 2972, trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/UsersAdmin_en.properties) =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminUsers_en.properties (rev 0) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminUsers_en.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,23 @@ +title=Users administration +noUser=You must be logged to access users administration.\n Please fill the form below. +userNotAllowed=You are not allowed to access this page. +noPolls=No user exists. +userCreated=User %s created. +userNotCreated=Error in creating user %s. +userUpdated=User %s updated. +userNotUpdated=Error in updating user %s. +userDeleted=User %s deleted. +userNotDeleted=Error in deleting user %s. +dataSaved=Data saved. + +#grid +login-label=Login +firstName-label=First Name +lastName-label=Last Name +email-label=Email +administrator-label=Admin +addUser=Add user + +login-required-message=You must provide a username. +email-regexp=^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$ +email-regexp-message=Invalid email. \ No newline at end of file Property changes on: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminUsers_en.properties ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminUsers_fr.properties (from rev 2972, trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/UsersAdmin_fr.properties) =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminUsers_fr.properties (rev 0) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminUsers_fr.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,25 @@ +#title=Gestion des utilisateurs + + +#noUser=Vous devez \u00EAtre identifi\u00E9 pour pouvoir administrer les utilisateurs.\n Veuillez remplir le formulaire ci-dessous. +#userNotAllowed=Vous n'\u00EAtes pas autoris\u00E9 \u00E0 acc\u00E9der \u00E0 cette page. +#noPolls=Aucun utilisateur existant. +#userCreated=L'utilisateur %s a \u00E9t\u00E9 cr\u00E9\u00E9. +#userNotCreated=Erreur lors de la cr\u00E9ation de l'utilisateur %s. +#userUpdated=L'utilisateur %s a \u00E9t\u00E9 mis \u00E0 jour. +#userNotUpdated=Erreur lors de la mise \u00E0 jour de l'utilisateur %s. +#userDeleted=L'utilisateur %s a \u00E9t\u00E9 supprim\u00E9. +#userNotDeleted=Erreur lors de la suppression de l'utilisateur %s. +#dataSaved=Les donn\u00E9es ont \u00E9t\u00E9 enregistr\u00E9es. +# +##grid +#login-label=Identifiant +#firstName-label=Pr\u00E9nom +#lastName-label=Nom +#email-label=Email +#administrator-label=Admin +#addUser=Ajouter un utilisateur +# +#login-required-message=Vous devez fournir un identifiant. +#email-regexp=^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$ +#email-regexp-message=Email invalide. \ No newline at end of file Property changes on: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/AdminUsers_fr.properties ___________________________________________________________________ Added: svn:mergeinfo + Deleted: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/PollsAdmin_en.properties =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/PollsAdmin_en.properties 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/PollsAdmin_en.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,4 +0,0 @@ -title=Polls administration -noUser=You must be logged to access polls administration.\n Please fill the form below. -userNotAllowed=You are not allowed to access this page. -noPolls=No poll exists. \ No newline at end of file Deleted: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/PollsAdmin_fr.properties =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/PollsAdmin_fr.properties 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/PollsAdmin_fr.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,4 +0,0 @@ -title=Gestion des sondages -noUser=Vous devez \u00EAtre identifi\u00E9 pour pouvoir administrer les sondages.\n Veuillez remplir le formulaire ci-dessous. -userNotAllowed=Vous n'\u00EAtes pas autoris\u00E9 \u00E0 acc\u00E9der \u00E0 cette page. -noPolls=Aucun sondage existant. \ No newline at end of file Deleted: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/UsersAdmin_en.properties =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/UsersAdmin_en.properties 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/UsersAdmin_en.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,23 +0,0 @@ -title=Users administration -noUser=You must be logged to access users administration.\n Please fill the form below. -userNotAllowed=You are not allowed to access this page. -noPolls=No user exists. -userCreated=User %s created. -userNotCreated=Error in creating user %s. -userUpdated=User %s updated. -userNotUpdated=Error in updating user %s. -userDeleted=User %s deleted. -userNotDeleted=Error in deleting user %s. -dataSaved=Data saved. - -#grid -login-label=Login -firstName-label=First Name -lastName-label=Last Name -email-label=Email -administrator-label=Admin -addUser=Add user - -login-required-message=You must provide a username. -email-regexp=^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$ -email-regexp-message=Invalid email. \ No newline at end of file Deleted: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/UsersAdmin_fr.properties =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/UsersAdmin_fr.properties 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/admin/UsersAdmin_fr.properties 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,23 +0,0 @@ -title=Gestion des utilisateurs -noUser=Vous devez \u00EAtre identifi\u00E9 pour pouvoir administrer les utilisateurs.\n Veuillez remplir le formulaire ci-dessous. -userNotAllowed=Vous n'\u00EAtes pas autoris\u00E9 \u00E0 acc\u00E9der \u00E0 cette page. -noPolls=Aucun utilisateur existant. -userCreated=L'utilisateur %s a \u00E9t\u00E9 cr\u00E9\u00E9. -userNotCreated=Erreur lors de la cr\u00E9ation de l'utilisateur %s. -userUpdated=L'utilisateur %s a \u00E9t\u00E9 mis \u00E0 jour. -userNotUpdated=Erreur lors de la mise \u00E0 jour de l'utilisateur %s. -userDeleted=L'utilisateur %s a \u00E9t\u00E9 supprim\u00E9. -userNotDeleted=Erreur lors de la suppression de l'utilisateur %s. -dataSaved=Les donn\u00E9es ont \u00E9t\u00E9 enregistr\u00E9es. - -#grid -login-label=Identifiant -firstName-label=Pr\u00E9nom -lastName-label=Nom -email-label=Email -administrator-label=Admin -addUser=Ajouter un utilisateur - -login-required-message=Vous devez fournir un identifiant. -email-regexp=^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$ -email-regexp-message=Email invalide. \ No newline at end of file Copied: trunk/pollen-ui/src/main/webapp/admin/AdminPolls.tml (from rev 2972, trunk/pollen-ui/src/main/webapp/admin/PollsAdmin.tml) =================================================================== --- trunk/pollen-ui/src/main/webapp/admin/AdminPolls.tml (rev 0) +++ trunk/pollen-ui/src/main/webapp/admin/AdminPolls.tml 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,50 @@ + +<t:border t:address="address" t:pageLogo="literal:Index" + xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> + + <t:feedback t:id="feedback"/> + <t:if test="userExists"> + <t:if test="user.administrator"> + <h1 class="titleIndex">${message:title}</h1> + + <t:grid t:id="pollsGrid" t:source="polls" t:row="poll" model="pollsModel" t:inPlace="true" + t:rowsPerPage="10" t:pagerPosition="bottom" t:rowClass="prop:evenodd.next"> + <p:functionsCell> + <t:PageLink t:page="poll/VoteForPoll" t:context="poll.pollId"> + <img src="${asset:context:img/vote.png}" title="${message:vote-help}" alt="${message:vote}" /> + </t:PageLink> + <t:PageLink t:page="poll/results" t:context="adminId"> + <img src="${asset:context:img/count.png}" title="${message:count-help}" alt="${message:count}" /> + </t:PageLink> + + <t:unless test="poll.isClosed()"> + <t:PageLink t:page="poll/modification" t:context="adminId"> + <img src="${asset:context:img/edit.png}" title="${message:edit-help}" alt="${message:edit}" /> + </t:PageLink> + <t:ActionLink t:id="close" t:context="poll.pollId"> + <img src="${asset:context:img/close.png}" title="${message:close-help}" alt="${message:close}" /> + </t:ActionLink> + </t:unless> + + <t:ActionLink t:id="export" t:context="poll.pollId"> + <img src="${asset:context:img/export.png}" title="${message:export-help}" alt="${message:export}" /> + </t:ActionLink> + <t:PageLink t:page="poll/creation" t:context="poll.pollId"> + <img src="${asset:context:img/copy.png}" title="${message:copy-help}" alt="${message:copy}" /> + </t:PageLink> + <t:ActionLink t:id="deletePoll" t:context="poll.pollId"> + <img src="${asset:context:img/delete.png}" title="${message:delete-help}" alt="${message:delete}" /> + </t:ActionLink> + </p:functionsCell> + <p:empty> + ${message:noPolls} + </p:empty> + </t:grid> + + </t:if> + <p:else> + <h4>${message:noUser}</h4> + <t:LoginComponent /> + </p:else> + </t:if> +</t:border> \ No newline at end of file Property changes on: trunk/pollen-ui/src/main/webapp/admin/AdminPolls.tml ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml (from rev 2972, trunk/pollen-ui/src/main/webapp/admin/UsersAdmin.tml) =================================================================== --- trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml (rev 0) +++ trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml 2010-04-23 17:09:22 UTC (rev 2973) @@ -0,0 +1,78 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<t:border t:addressBar="addressBar" t:pageLogo="literal:Index" t:pageTitle="prop:title" + xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> + + <h1 class="titleIndex">${title}</h1> + + <t:zone t:id="usersZone" t:update="show"> + <t:form t:id="usersForm" t:zone="usersZone"> + <t:if t:test="accountEdited"> + <input t:type="hidden" value="accountEdited.login" /> + </t:if> + <t:errors /> + <div t:type="grid" t:source="accounts" t:row="account" + t:include="login, firstName, lastName, email, admin" t:add="actions" t:rowsPerPage="20"> + <p:firstNameCell> + <t:if t:test="editionMode"> + <input t:type="textfield" t:id="firstName" value="accountEdited.firstName" /> + <p:else>${account.firstName}</p:else> + </t:if> + </p:firstNameCell> + <p:lastNameCell> + <t:if t:test="editionMode"> + <input t:type="textfield" t:id="lastName" value="accountEdited.lastName" /> + <p:else>${account.lastName}</p:else> + </t:if> + </p:lastNameCell> + <p:emailCell> + <t:if t:test="editionMode"> + <input t:type="textfield" t:id="email" value="accountEdited.email" t:validate="regexp" /> + <p:else>${account.email}</p:else> + </t:if> + </p:emailCell> + <p:adminCell> + <t:if t:test="editionMode"> + <input t:type="checkbox" t:id="admin" value="accountEdited.admin" disabled="accountConnected" /> + <!-- Keep the admin value, the disabled checkbox is not saved in form submission --> + <t:if t:test="accountConnected"> + <input t:type="hidden" value="accountEdited.admin" /> + </t:if> + <p:else> + <t:if t:test="account.admin">X</t:if> + </p:else> + </t:if> + </p:adminCell> + <p:actionsCell> + <t:if t:test="editionMode"> + <a t:type="pagelink" t:page="admin/users" t:id="cancelEdition"> + <img src="${asset:context:img/undo.png}" alt="Cancel" title="${message:pollen.ui.user.update.cancel}" /> + </a> + <input t:type="submit" class="ico save" t:id="save" value="Save" title="${message:pollen.ui.user.update.save}" /> + <p:else> + <a t:type="actionlink" t:id="editAccount" t:context="account.login" t:zone="usersZone"> + <img src="${asset:context:img/editSmall.png}" alt="Edit" title="${message:pollen.ui.user.update.edit}" /> + </a> + <a t:type="actionlink" t:id="deleteAccount" t:context="account.login" + t:mixins="confirm" t:message="pollen.ui.user.delete.confirmMessage"> + <img src="${asset:context:img/delete.png}" alt="Delete" title="${message:pollen.ui.user.delete}"/> + </a> + </p:else> + </t:if> + </p:actionsCell> + </div> + </t:form> + </t:zone> + <t:zone t:id="newUserZone" t:update="show"> + <h2>${message:pollen.ui.user.create.title}</h2> + <form t:type="form" t:id="newUserForm" action="tapestry"> + <p><t:errors /></p> + <p class="center"> + <label t:type="label" for="newLogin">${message:login-label}</label>* : + <input t:type="textfield" t:id="newLogin" value="newUser.login" t:validate="required" /> + <label t:type="label" for="newEmail">${message:email-label}</label> : + <input t:type="textfield" t:id="newEmail" value="newUser.email" t:validate="regexp" /> + <input t:type="submit" value="${message:pollen.ui.user.create}" title="${message:pollen.ui.user.create.title}" /> + </p> + </form> + </t:zone> +</t:border> \ No newline at end of file Property changes on: trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml ___________________________________________________________________ Added: svn:mergeinfo + Deleted: trunk/pollen-ui/src/main/webapp/admin/PollsAdmin.tml =================================================================== --- trunk/pollen-ui/src/main/webapp/admin/PollsAdmin.tml 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/webapp/admin/PollsAdmin.tml 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,50 +0,0 @@ - -<t:border t:address="address" t:pageLogo="literal:Index" - xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> - - <t:feedback t:id="feedback"/> - <t:if test="userExists"> - <t:if test="user.administrator"> - <h1 class="titleIndex">${message:title}</h1> - - <t:grid t:id="pollsGrid" t:source="polls" t:row="poll" model="pollsModel" t:inPlace="true" - t:rowsPerPage="10" t:pagerPosition="bottom" t:rowClass="prop:evenodd.next"> - <p:functionsCell> - <t:PageLink t:page="poll/VoteForPoll" t:context="poll.pollId"> - <img src="${asset:context:img/vote.png}" title="${message:vote-help}" alt="${message:vote}" /> - </t:PageLink> - <t:PageLink t:page="poll/results" t:context="adminId"> - <img src="${asset:context:img/count.png}" title="${message:count-help}" alt="${message:count}" /> - </t:PageLink> - - <t:unless test="poll.isClosed()"> - <t:PageLink t:page="poll/modification" t:context="adminId"> - <img src="${asset:context:img/edit.png}" title="${message:edit-help}" alt="${message:edit}" /> - </t:PageLink> - <t:ActionLink t:id="close" t:context="poll.pollId"> - <img src="${asset:context:img/close.png}" title="${message:close-help}" alt="${message:close}" /> - </t:ActionLink> - </t:unless> - - <t:ActionLink t:id="export" t:context="poll.pollId"> - <img src="${asset:context:img/export.png}" title="${message:export-help}" alt="${message:export}" /> - </t:ActionLink> - <t:PageLink t:page="poll/creation" t:context="poll.pollId"> - <img src="${asset:context:img/copy.png}" title="${message:copy-help}" alt="${message:copy}" /> - </t:PageLink> - <t:ActionLink t:id="deletePoll" t:context="poll.pollId"> - <img src="${asset:context:img/delete.png}" title="${message:delete-help}" alt="${message:delete}" /> - </t:ActionLink> - </p:functionsCell> - <p:empty> - ${message:noPolls} - </p:empty> - </t:grid> - - </t:if> - <p:else> - <h4>${message:noUser}</h4> - <t:LoginComponent /> - </p:else> - </t:if> -</t:border> \ No newline at end of file Deleted: trunk/pollen-ui/src/main/webapp/admin/UsersAdmin.tml =================================================================== --- trunk/pollen-ui/src/main/webapp/admin/UsersAdmin.tml 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/webapp/admin/UsersAdmin.tml 2010-04-23 17:09:22 UTC (rev 2973) @@ -1,76 +0,0 @@ - -<t:border t:address="address" t:pageLogo="literal:Index" - xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> - - <t:feedback t:id="feedback"/> - <t:if test="userExists"> - <t:if test="user.administrator"> - <h1 class="titleIndex">${message:title}</h1> - - <t:form t:id="usersForm"> - <t:errors /> - - <div class="t-data-grid"> - <table class="t-data-grid"> - <thead> - <tr> - <th>${message:login-label}</th> - <th>${message:firstName-label}</th> - <th>${message:lastName-label}</th> - <th>${message:email-label}</th> - <th>${message:administrator-label}</th> - <th></th> - </tr> - </thead> - <tbody> - <tr t:type="ajaxformloop" t:id="usersLoop" source="accounts" value="account" encoder="userEncoder"> - <t:unless test="account.login"> - <td> - <t:textfield t:id="login" value="account.login" size="15" t:validate="required"/> - </td> - <p:else> - <td align="left">${account.login}</td> - </p:else> - </t:unless> - <td> - <t:textfield t:id="firstName" value="account.firstName" size="15"/> - </td> - <td> - <t:textfield t:id="lastName" value="account.lastName" size="15"/> - </td> - <td> - <t:textfield t:id="email" value="account.email" size="20" t:validate="required, regexp"/> - </td> - <td> - <t:checkbox t:id="administrator" value="account.administrator" disabled="myAccount"/> - </td> - <td> - <t:unless test="myAccount"> - <t:removerowlink> - <img src="${asset:context:img/delete.png}" alt="${message:delete}"/> - </t:removerowlink> - </t:unless> - </td> - <t:parameter name="addRow"> - <td colspan="6" style="text-align: center"> - <t:addrowlink>${message:addUser}</t:addrowlink> - </td> - </t:parameter> - </tr> - </tbody> - </table> - </div> - - <div class="center"> - <input type="submit" value="${message:save}" style="text-align:center"/> - </div> - - </t:form> - - </t:if> - <p:else> - <h4>${message:noUser}</h4> - <t:LoginComponent /> - </p:else> - </t:if> -</t:border> \ No newline at end of file Modified: trunk/pollen-ui/src/main/webapp/css/common.css =================================================================== --- trunk/pollen-ui/src/main/webapp/css/common.css 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pollen-ui/src/main/webapp/css/common.css 2010-04-23 17:09:22 UTC (rev 2973) @@ -62,3 +62,16 @@ text-align: center; } +input.ico { + border: 0 none; + font-size: 0; + width: 16px; + height: 16px; + cursor: pointer; + vertical-align: top; +} + +input.save { + background: url(../img/save.png) no-repeat center center; +} + Added: trunk/pollen-ui/src/main/webapp/img/save.png =================================================================== (Binary files differ) Property changes on: trunk/pollen-ui/src/main/webapp/img/save.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/pollen-ui/src/main/webapp/img/undo.png =================================================================== (Binary files differ) Property changes on: trunk/pollen-ui/src/main/webapp/img/undo.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-04-20 14:05:44 UTC (rev 2972) +++ trunk/pom.xml 2010-04-23 17:09:22 UTC (rev 2973) @@ -309,11 +309,11 @@ <!-- customized versions --> <!--javadoc.version>2.4</javadoc.version--> - <topia.version>2.3.3-SNAPSHOT</topia.version> - <eugene.version>2.0.1-SNAPSHOT</eugene.version> + <topia.version>2.4-SNAPSHOT</topia.version> + <eugene.version>2.0.1</eugene.version> <i18n.version>1.2.1</i18n.version> <tapestry.version>5.1.0.5</tapestry.version> - <nuiton-utils.version>1.2.2-SNAPSHOT</nuiton-utils.version> + <nuiton-utils.version>1.2.2</nuiton-utils.version> <processor.version>1.0.2</processor.version> <!--Multilanguage maven-site -->