Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
May 2010
- 2 participants
- 39 discussions
r2991 - in trunk/pollen-business/src: main/java/org/chorem/pollen main/java/org/chorem/pollen/bean main/java/org/chorem/pollen/service test/java/org/chorem/pollen
by fdesbois@users.chorem.org 10 May '10
by fdesbois@users.chorem.org 10 May '10
10 May '10
Author: fdesbois
Date: 2010-05-10 15:22:24 +0200 (Mon, 10 May 2010)
New Revision: 2991
Url: http://chorem.org/repositories/revision/pollen/2991
Log:
Changes from ToPIA-2.4 : use exist methods to test existence + rename getTopiaId() in getId()
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java 2010-05-06 17:24:53 UTC (rev 2990)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java 2010-05-10 13:22:24 UTC (rev 2991)
@@ -144,7 +144,7 @@
* @return the property name to use in a TopiaQuery
*/
public String namePropertyId() {
- return nameProperty(TopiaEntity.TOPIA_ID);
+ return nameProperty(TopiaEntity.ID);
}
/**
@@ -153,7 +153,7 @@
* @return the property name to use in a TopiaQuery
*/
public String namePropertyCreateDate() {
- return nameProperty(TopiaEntity.TOPIA_CREATE_DATE);
+ return nameProperty(TopiaEntity.CREATE_DATE);
}
/**
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-05-06 17:24:53 UTC (rev 2990)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-05-10 13:22:24 UTC (rev 2991)
@@ -113,7 +113,7 @@
*/
public void setReference(TopiaEntity entity) {
String oldReferenceId = this.referenceId;
- this.referenceId = entity.getTopiaId();
+ this.referenceId = entity.getId();
propertyChangeSupport.firePropertyChange(PROP_REFERENCE_ID,
oldReferenceId, referenceId);
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java 2010-05-06 17:24:53 UTC (rev 2990)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java 2010-05-10 13:22:24 UTC (rev 2991)
@@ -74,21 +74,18 @@
// check favoriteList name exist for user
UserAccount user = list.getUserAccount();
- int count = dao.createQuery().
- add(FavoriteList.USER_ACCOUNT, user).
- add(FavoriteList.NAME, list.getName()).
- executeCount();
+// int count = dao.createQuery().
+// add(FavoriteList.USER_ACCOUNT, user).
+// add(FavoriteList.NAME, list.getName()).
+// executeCount();
// existing list found
- if (count > 0) {
+ if (dao.existByNaturalId(list.getName(), user)) {
throw new PollenBusinessException(
PollenExceptionType.FAVORITE_LIST_NAME_EXIST,
list.getName(), user.getDisplayName());
}
- FavoriteList newList = dao.create(
- FavoriteList.USER_ACCOUNT, list.getUserAccount(),
- FavoriteList.NAME, list.getName());
-// list.setTopiaId(newList.getTopiaId());
+ dao.create(list.getName(), list.getUserAccount());
transaction.commitTransaction();
}
@@ -98,7 +95,7 @@
FavoriteList list) throws TopiaException {
FavoriteListDAO dao = PollenDAOHelper.getFavoriteListDAO(transaction);
- FavoriteList listLoaded = dao.findByTopiaId(list.getTopiaId());
+ FavoriteList listLoaded = dao.findById(list.getId());
dao.delete(listLoaded);
transaction.commitTransaction();
@@ -136,13 +133,12 @@
add(FavoriteParticipant.EMAIL, participant.getEmail());
// Check only on entities different from the one in argument
- if (StringUtils.isNotEmpty(participant.getTopiaId())) {
- query.add(TopiaEntity.TOPIA_ID, Op.NEQ, participant.getTopiaId());
+ if (StringUtils.isNotEmpty(participant.getId())) {
+ query.add(TopiaEntity.ID, Op.NEQ, participant.getId());
}
- int count = query.executeCount();
// existing participant found
- if (count > 0) {
+ if (dao.existByQuery(query)) {
// The error type (message) depends on email nullity
if (participant.getEmail() == null) {
throw new PollenBusinessException(
@@ -181,8 +177,8 @@
// Create newParticipant with naturalId
FavoriteParticipant newParticipant =
dao.create(participant.getName(),
- participant.getEmail(),
- participant.getFavoriteList());
+ participant.getEmail(),
+ participant.getFavoriteList());
// Set other field
newParticipant.setWeight(participant.getWeight());
@@ -197,7 +193,7 @@
FavoriteParticipantDAO dao =
PollenDAOHelper.getFavoriteParticipantDAO(transaction);
- FavoriteParticipant participantLoaded = dao.findByTopiaId(id);
+ FavoriteParticipant participantLoaded = dao.findById(id);
dao.delete(participantLoaded);
@@ -215,7 +211,7 @@
checkFavoriteParticipant(dao, participant);
FavoriteParticipant participantLoaded =
- dao.findByTopiaId(participant.getTopiaId());
+ dao.findById(participant.getId());
// Set all fields except favoriteList that can't be changed
participantLoaded.setName(participant.getName());
@@ -234,7 +230,7 @@
FavoriteParticipantDAO dao =
PollenDAOHelper.getFavoriteParticipantDAO(transaction);
- FavoriteParticipant result = dao.findByTopiaId(id);
+ FavoriteParticipant result = dao.findById(id);
// Load parent list
result.getFavoriteList();
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-05-06 17:24:53 UTC (rev 2990)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-05-10 13:22:24 UTC (rev 2991)
@@ -105,12 +105,13 @@
*/
protected void checkPassword(UserAccountDAO dao, String login,
String password) throws TopiaException, PollenBusinessException {
- int count = dao.createQuery().
- add(UserAccount.LOGIN, login).
- add(UserAccount.PASSWORD, password).
- executeCount();
+// int count = dao.createQuery().
+// add(UserAccount.LOGIN, login).
+// add(UserAccount.PASSWORD, password).
+// executeCount();
// no user found
- if (count == 0) {
+ if (!dao.existByProperties(UserAccount.LOGIN, login,
+ UserAccount.PASSWORD, password)) {
throw new PollenBusinessException(
PollenExceptionType.USER_WRONG_PASSWORD, login);
}
@@ -126,11 +127,11 @@
*/
protected void checkLoginNotExist(UserAccountDAO dao, String login)
throws PollenBusinessException, TopiaException {
- int count = dao.createQuery().
- add(UserAccount.LOGIN, login).
- executeCount();
+// int count = dao.createQuery().
+// add(UserAccount.LOGIN, login).
+// executeCount();
// existing user found
- if (count > 0) {
+ if (dao.existByNaturalId(login)) {
throw new PollenBusinessException(
PollenExceptionType.USER_LOGIN_EXIST);
}
@@ -155,10 +156,10 @@
if (query == null) {
query = dao.createQuery();
}
- int count = query.add(UserAccount.EMAIL, StringUtils.lowerCase(email)).
- executeCount();
+ query.add(UserAccount.EMAIL, StringUtils.lowerCase(email));
+
// existing user found
- if (count > 0) {
+ if (dao.existByQuery(query)) {
throw new PollenBusinessException(
PollenExceptionType.USER_EMAIL_EXIST);
}
@@ -239,6 +240,7 @@
// In case of email change, check if an other user has not already
// the new email
+ // FIXME-fdesbois-20100510 : replace by using id directly
TopiaQuery query = dao.createQuery().
add(UserAccount.LOGIN, Op.NEQ, user.getLogin());
checkEmailNotExist(dao, user.getEmail(), query);
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java 2010-05-06 17:24:53 UTC (rev 2990)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java 2010-05-10 13:22:24 UTC (rev 2991)
@@ -53,7 +53,7 @@
Assert.assertEquals(builder.getQuery().fullQuery(),
"FROM " + UserAccount.class.getName() +
- " ORDER BY " + TopiaEntity.TOPIA_CREATE_DATE + " DESC");
+ " ORDER BY " + TopiaEntity.CREATE_DATE + " DESC");
}
@@ -98,7 +98,7 @@
"SELECT P FROM " + FavoriteParticipant.class.getName() + " P, "
+ FavoriteList.class.getName() + " L" +
" WHERE P IN elements (L." + FavoriteList.FAVORITE_PARTICIPANT +
- ") ORDER BY P." + TopiaEntity.TOPIA_CREATE_DATE + " DESC");
+ ") ORDER BY P." + TopiaEntity.CREATE_DATE + " DESC");
log.info("test3 : orderBy name and email desc");
String orderBy = FavoriteParticipant.NAME + ", " + FavoriteParticipant.EMAIL + " desc";
1
0
r2990 - trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components
by fdesbois@users.chorem.org 06 May '10
by fdesbois@users.chorem.org 06 May '10
06 May '10
Author: fdesbois
Date: 2010-05-06 19:24:53 +0200 (Thu, 06 May 2010)
New Revision: 2990
Url: http://chorem.org/repositories/revision/pollen/2990
Log:
missing javadoc on return parameter
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-05-06 17:22:56 UTC (rev 2989)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-05-06 17:24:53 UTC (rev 2990)
@@ -82,7 +82,7 @@
* of the component, i.e. all FavoriteParticipants need to be part of the
* FavoriteList source.
*
- * @return
+ * @return the DataSource that contains participants.
*/
public FavoriteParticipantDataSource getParticipants() {
if (participants == null) {
1
0
r2989 - in trunk/pollen-ui/src/main/java/org/chorem/pollen/ui: data services
by fdesbois@users.chorem.org 06 May '10
by fdesbois@users.chorem.org 06 May '10
06 May '10
Author: fdesbois
Date: 2010-05-06 19:22:56 +0200 (Thu, 06 May 2010)
New Revision: 2989
Url: http://chorem.org/repositories/revision/pollen/2989
Log:
Evo #191 : add javadoc on Authentication service.
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java 2010-05-06 17:03:11 UTC (rev 2988)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java 2010-05-06 17:22:56 UTC (rev 2989)
@@ -8,20 +8,20 @@
import java.lang.annotation.Target;
import org.chorem.pollen.ui.services.PollenAuthenticationFilter;
import org.chorem.pollen.ui.base.AbstractPollenPage;
-import org.nuiton.web.tapestry5.services.ServiceAuthentication;
+import org.chorem.pollen.ui.services.PollenAuthentication;
/**
* This annotation is used on pages and components that need authentication
- * to be rendered. The ServiceAuthentication is used to check authorizations
- * on each page from {@link AbstractPollenPage}. This service is called from
- * a Filter {@link PollenAuthenticationFilter} registered in Tapestry registry
- * that intercept event on component and page render.
+ * to be rendered. The {@link PollenAuthentication} service is used to check
+ * authorizations on each page from {@link AbstractPollenPage}. This service is
+ * called from a Filter {@link PollenAuthenticationFilter} registered in
+ * Tapestry registry that intercept event on component and page render.
*
* Created: 3 mai 2010
*
* @author fdesbois <fdesbois(a)codelutin.com>
* @version $Id$
- * @see ServiceAuthentication
+ * @see PollenAuthentication
* @see PollenAuthenticationFilter
*/
@Target( { ElementType.TYPE })
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java 2010-05-06 17:03:11 UTC (rev 2988)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java 2010-05-06 17:22:56 UTC (rev 2989)
@@ -1,19 +1,28 @@
package org.chorem.pollen.ui.services;
+import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.services.ApplicationStateManager;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountImpl;
import org.chorem.pollen.ui.data.PollenRequiresAuthentication;
+import org.chorem.pollen.ui.pages.admin.AdminUsers;
import org.nuiton.web.tapestry5.services.ServiceAuthenticationImpl;
/**
- * ServiceAuthenticationImpl
+ * Service to manage user connected and also check his authorizations to
+ * display Pollen pages depends on {@link PollenRequiresAuthentication}
+ * annotation over each page. This service used {@link ApplicationStateManager}
+ * service of Tapestry to store and retrieve connected user. This user
+ * can also be retrieve in pages using {@link SessionState} annotation on
+ * property of type {@link UserAccount}.
*
* Created: 4 mai 2010
*
- * @author fdesbois
- * $Id$
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ * @see ServiceAuthenticationImpl
+ * @see PollenRequiresAuthentication
*/
public class PollenAuthentication extends
ServiceAuthenticationImpl<UserAccount, PollenRequiresAuthentication> {
@@ -23,6 +32,15 @@
PollenRequiresAuthentication.class);
}
+ /**
+ * Check authorizations of {@code user} for the {@code annotation} from
+ * current page to render. The {@code annotation} contains constraint
+ * on admin user for some specific pages as {@link AdminUsers}.
+ *
+ * @param user connected user to check for authorizations.
+ * @param annotation PollenRequiresAuthentication of the page to test
+ * @return true if user is allowed to render the page, false otherwise
+ */
@Override
protected boolean checkAuthorizations(UserAccount user,
PollenRequiresAuthentication annotation) {
@@ -30,6 +48,13 @@
return user.getAdmin() || !annotation.adminOnly();
}
+ /**
+ * Instanciate a new UserAccount for ApplicationStateManager contribution
+ * in AppModule.
+ *
+ * @return a new instance of UserAccount.
+ * @see AppModule#contributeApplicationStateManager(MappedConfiguration, ServiceAuthentication)
+ */
@Override
public UserAccount getNewUserInstance() {
return new UserAccountImpl();
1
0
r2988 - in trunk/pollen-ui/src/main: java/org/chorem/pollen/ui/components java/org/chorem/pollen/ui/data java/org/chorem/pollen/ui/pages java/org/chorem/pollen/ui/pages/user java/org/chorem/pollen/ui/services resources/i18n webapp
by fdesbois@users.chorem.org 06 May '10
by fdesbois@users.chorem.org 06 May '10
06 May '10
Author: fdesbois
Date: 2010-05-06 19:03:11 +0200 (Thu, 06 May 2010)
New Revision: 2988
Url: http://chorem.org/repositories/revision/pollen/2988
Log:
- Evo #190 : javadoc and missing i18n messages
- Connexion page is renamed in Connection
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connection.java
trunk/pollen-ui/src/main/webapp/Connection.tml
Removed:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java
trunk/pollen-ui/src/main/webapp/Connexion.tml
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.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/services/PollenAuthenticationFilter.java
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-05-06 10:35:53 UTC (rev 2987)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-05-06 17:03:11 UTC (rev 2988)
@@ -17,11 +17,12 @@
import org.slf4j.Logger;
/**
- * UserListsCreate
+ * Component to create a new FavoriteList using the {@code createList} form.
*
* Created: 27 avr. 2010
*
- * @author fdesbois
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
*/
public class UserListsCreate {
@@ -53,10 +54,21 @@
@InjectComponent
private Form createList;
+ /**
+ * SETUP_RENDER :: Handler method called when the component is rendered.
+ * Will clean errors from {@code createList} form.
+ */
void setupRender() {
createList.clearErrors();
}
+ /**
+ * ON_PREPARE :: Handler method for both prepareRender and prepareSubmit
+ * events of {@code createList} form. Will instantiate a new instance
+ * of FavoriteList using {@code serviceFavorite} and user connected.
+ *
+ * @see ServiceFavorite#getNewFavoriteList(UserAccount)
+ */
void onPrepareFromCreateList() {
if (newFavoriteList == null) {
if (logger.isDebugEnabled()) {
@@ -67,6 +79,14 @@
}
}
+ /**
+ * ON_VALIDATE_FORM :: Handler method for validateForm event of the
+ * {@code createList} form. The {@code newFavoriteList} will be created
+ * using {@code serviceFavorite}. Errors from service will be recorded
+ * into the {@code createList} form.
+ *
+ * @see ServiceFavorite#createFavoriteParticipant(FavoriteParticipant)
+ */
void onValidateFormFromCreateList() {
try {
serviceFavorite.createFavoriteList(newFavoriteList);
@@ -85,12 +105,21 @@
}
}
+ /**
+ * ON_SUCCESS :: Handler method for success event of the {@code createList}
+ * form. Will display a success message and refresh the {@code page}
+ * container.
+ */
Object onSuccessFromCreateList() {
page.addInfo(messages.format("pollen.ui.list.create.success",
newFavoriteList.getName()));
return page;
}
+ /**
+ * ON_FAILURE :: Handler method for failure event of the {@code createList}
+ * form. Will refresh the form (included in a zone} to display errors.
+ */
Object onFailureFromCreateList() {
return createList;
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-05-06 10:35:53 UTC (rev 2987)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-05-06 17:03:11 UTC (rev 2988)
@@ -1,7 +1,6 @@
package org.chorem.pollen.ui.components;
-import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Parameter;
@@ -22,15 +21,17 @@
import org.slf4j.Logger;
/**
- * UserListsUpdate
+ * Component to manage FavoriteParticipant in a FavoriteList as {@code source}.
+ * The {@code participants} are displayed in an editable Grid surrounded by an
+ * unique Zone {@code updateZone}. Two forms are used, one to add a new
+ * participant in the Grid and one to edit a participant directly in the grid.
+ * Each action will return the {@code updateZone} to refresh data loaded by
+ * {@link #getParticipants()} method.
*
* Created: 27 avr. 2010
*
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$s
*/
public class UserListsUpdate {
@@ -108,7 +109,7 @@
* call prepareForSubmit
* load size of participants dataSource
* load participants data
- * load participantEdited to push form data
+ * load participantEdited to push form data (hidden fields in first)
* call selected on submit button
* call validateForm
* call success or failure
@@ -165,16 +166,17 @@
}
/**
- * ON_ACTION :: Handler method for action on deletedAccount actionLink.
- * The selected login from the Grid will be used to delete the user.
+ * ON_ACTION :: Handler method for action on removeParticipant actionLink.
+ * The selected id from the Grid will be used to delete the participant.
*
- * @param login used to delete the user
+ * @param id used to delete the participant
* @return the updateZone content to refresh
- * @see ServiceUser#deleteUser(String)
+ * @see ServiceFavorite#deleteFavoriteParticipant(String)
*/
Object onActionFromRemoveParticipant(String id) {
serviceFavorite.deleteFavoriteParticipant(id);
- participantsFeedback.addInfo("Suppression OK");
+ participantsFeedback.addInfo(
+ messages.get("pollen.ui.list.update.removeParticipant.success"));
return updateZone;
}
@@ -204,10 +206,11 @@
/**
* 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.
+ * participantsForm. The participantEdited will be updated using
+ * serviceFavorite. Errors from service will be recorded into the
+ * participantsForm.
*
- * @see ServiceUser#updateUser(UserAccount, boolean)
+ * @see ServiceFavorite#updateFavoriteParticipant(FavoriteParticipant)
*/
@Log
void onValidateFormFromParticipantsForm() {
@@ -224,29 +227,34 @@
/**
* ON_SUCCESS :: Handler method for success event of the participantsForm.
- * Refresh the page to display a success message.
- *
- * @return the page container.
+ * Clean form data (participantEdited) and display a success message.
+ * {@link #onSubmitFromParticipantsForm()} will be called after it to
+ * refresh the updateZone.
*/
- Object onSuccessFromParticipantsForm() {
- participantsFeedback.addInfo("Modification OK");
+ void onSuccessFromParticipantsForm() {
+ participantsFeedback.addInfo(
+ messages.get("pollen.ui.list.update.saveParticipant.success"));
// Clean form data before refresh zone
cleanFormData();
- return updateZone;
}
+ /**
+ * Clean the form content, i.e. the favorite participant in edition and
+ * its id.
+ */
protected void cleanFormData() {
participantEditedId = null;
participantEdited = null;
}
/**
- * ON_FAILURE :: Handler method for failure event of the participantsForm.
- * Will display errors and keep participantEdited in edition.
+ * ON_SUBMIT :: Handler method for submit event called after succes or
+ * failure of the participantsForm. Will refresh the updateZone to display
+ * errors or Grid updated.
*
* @return the updateZone to refresh
*/
- Object onFailureFromParticipantsForm() {
+ Object onSubmitFromParticipantsForm() {
return updateZone;
}
@@ -258,6 +266,13 @@
@InjectComponent
private Form addParticipant;
+ /**
+ * ON_PREPARE :: Handler method for both prepareSubmit and prepareRender
+ * events of the participantsForm. Will instantiate a new
+ * FavoriteParticipant to render or saved with form data.
+ *
+ * @see ServiceFavorite#getNewFavoriteParticipant(FavoriteList)
+ */
void onPrepareFromAddParticipant() {
if (newParticipant == null) {
newParticipant =
@@ -265,6 +280,14 @@
}
}
+ /**
+ * ON_VALIDATE_FORM :: Handler method for validateForm event of the
+ * addParticipant form. The newParticipant will be created using
+ * serviceFavorite. Errors from service will be recorded into the
+ * addParticipant form.
+ *
+ * @see ServiceFavorite#createFavoriteParticipant(FavoriteParticipant)
+ */
void onValidateFormFromAddParticipant() {
if (logger.isDebugEnabled()) {
logger.debug("FavoriteList selected : " + source);
@@ -277,8 +300,25 @@
}
}
+ /**
+ * ON_SUCCESS :: Handler method for success event of the addParticipant form.
+ * Will display a success message. {@link #onSubmitFromAddParticipant()}
+ * will be called after it to refresh the updateZone.
+ */
+ void onSuccessFromAddParticipant() {
+ participantsFeedback.addInfo(
+ messages.format("pollen.ui.list.update.addParticipant.success",
+ newParticipant.getName()));
+ }
+
+ /**
+ * ON_SUBMIT :: Handler method for submit event called after succes or
+ * failure of the addParticipant form. Will refresh the updateZone to
+ * display errors or Grid updated.
+ *
+ * @return the updateZone to refresh
+ */
Object onSubmitFromAddParticipant() {
- participantsFeedback.addInfo("Ajout OK");
return updateZone;
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java 2010-05-06 10:35:53 UTC (rev 2987)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java 2010-05-06 17:03:11 UTC (rev 2988)
@@ -6,15 +6,23 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.chorem.pollen.ui.services.PollenAuthenticationFilter;
+import org.chorem.pollen.ui.base.AbstractPollenPage;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
/**
* This annotation is used on pages and components that need authentication
- * to be rendered.
+ * to be rendered. The ServiceAuthentication is used to check authorizations
+ * on each page from {@link AbstractPollenPage}. This service is called from
+ * a Filter {@link PollenAuthenticationFilter} registered in Tapestry registry
+ * that intercept event on component and page render.
*
* Created: 3 mai 2010
*
- * @author fdesbois
- * $Id$
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ * @see ServiceAuthentication
+ * @see PollenAuthenticationFilter
*/
@Target( { ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
Copied: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connection.java (from rev 2985, trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java)
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connection.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connection.java 2010-05-06 17:03:11 UTC (rev 2988)
@@ -0,0 +1,127 @@
+
+package org.chorem.pollen.ui.pages;
+
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Log;
+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.apache.tapestry5.services.PageRenderLinkSource;
+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;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
+import org.slf4j.Logger;
+
+/**
+ * Connexion
+ *
+ * Created: 4 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class Connection extends AbstractPollenPage {
+
+ @InjectComponent
+ private Border border;
+
+ @Override
+ public Border getBorder() {
+ return border;
+ }
+
+ public AddressBar getAddressBar() {
+ return AddressBar.newBar();
+ }
+
+ @InjectComponent
+ private Form loginForm;
+
+ /**
+ * Champ login du formulaire d'identification
+ */
+ @Property
+ private String connectionLogin;
+
+ /**
+ * Champ password du formulaire d'identification
+ */
+ @Property
+ private String connectionPassword;
+
+ /** Injection des services */
+ @Inject
+ private Logger logger;
+
+ @Inject
+ private Messages messages;
+
+ @Inject
+ private ServiceAuthentication<UserAccount> serviceAuthentication;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ @Inject
+ private PollenManager manager;
+
+ @Inject
+ private PageRenderLinkSource pageRender;
+
+ private String pageName;
+
+ void onActivate(String pageName) {
+ this.pageName = pageName;
+ }
+
+ String onPassivate() {
+ return pageName;
+ }
+
+ void setupRender() {
+ addError(messages.format("pollen.ui.user.display.notConnected",
+ pageName));
+ }
+
+ void onValidateFormFromLoginForm() {
+ UserAccount current;
+ try {
+ current = serviceUser.connect(connectionLogin, connectionPassword);
+ if (current != null) {
+ serviceAuthentication.setUserConnected(current);
+ } else {
+ loginForm.recordError(messages.get("loginFailed"));
+ }
+ } catch (PollenBusinessException eee) {
+ // TODO two different errors, on password or on login
+ //addError(messages.get("loginFailed"));
+ String message = manager.getErrorMessage(eee, messages, logger);
+ loginForm.recordError(message);
+ }
+ }
+
+ /**
+ * Methode appelée lorsque l'utilisateur s'identifie
+ *
+ * @return la zone à mettre à jour
+ */
+ @Log
+ Object onSuccessFromLoginForm() {
+ if (pageName == null) {
+ pageName = "index";
+ }
+ return pageRender.createPageRenderLink(pageName);
+ }
+
+ @Log
+ void onFailureFromLoginForm() {
+
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connection.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java 2010-05-06 10:35:53 UTC (rev 2987)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java 2010-05-06 17:03:11 UTC (rev 2988)
@@ -1,127 +0,0 @@
-
-package org.chorem.pollen.ui.pages;
-
-import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.Log;
-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.apache.tapestry5.services.PageRenderLinkSource;
-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;
-import org.nuiton.web.tapestry5.services.ServiceAuthentication;
-import org.slf4j.Logger;
-
-/**
- * Connexion
- *
- * Created: 4 mai 2010
- *
- * @author fdesbois
- * $Id$
- */
-public class Connexion extends AbstractPollenPage {
-
- @InjectComponent
- private Border border;
-
- @Override
- public Border getBorder() {
- return border;
- }
-
- public AddressBar getAddressBar() {
- return AddressBar.newBar();
- }
-
- @InjectComponent
- private Form loginForm;
-
- /**
- * Champ login du formulaire d'identification
- */
- @Property
- private String connectionLogin;
-
- /**
- * Champ password du formulaire d'identification
- */
- @Property
- private String connectionPassword;
-
- /** Injection des services */
- @Inject
- private Logger logger;
-
- @Inject
- private Messages messages;
-
- @Inject
- private ServiceAuthentication<UserAccount> serviceAuthentication;
-
- @Inject
- private ServiceUser serviceUser;
-
- @Inject
- private PollenManager manager;
-
- @Inject
- private PageRenderLinkSource pageRender;
-
- private String pageName;
-
- void onActivate(String pageName) {
- this.pageName = pageName;
- }
-
- String onPassivate() {
- return pageName;
- }
-
- void setupRender() {
- addError(messages.format("pollen.ui.user.display.notConnected",
- pageName));
- }
-
- void onValidateFormFromLoginForm() {
- UserAccount current;
- try {
- current = serviceUser.connect(connectionLogin, connectionPassword);
- if (current != null) {
- serviceAuthentication.setUserConnected(current);
- } else {
- loginForm.recordError(messages.get("loginFailed"));
- }
- } catch (PollenBusinessException eee) {
- // TODO two different errors, on password or on login
- //addError(messages.get("loginFailed"));
- String message = manager.getErrorMessage(eee, messages, logger);
- loginForm.recordError(message);
- }
- }
-
- /**
- * Methode appelée lorsque l'utilisateur s'identifie
- *
- * @return la zone à mettre à jour
- */
- @Log
- Object onSuccessFromLoginForm() {
- if (pageName == null) {
- pageName = "index";
- }
- return pageRender.createPageRenderLink(pageName);
- }
-
- @Log
- void onFailureFromLoginForm() {
-
- }
-
-}
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-05-06 10:35:53 UTC (rev 2987)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-05-06 17:03:11 UTC (rev 2988)
@@ -10,7 +10,6 @@
* 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/>. ##%*/
@@ -24,20 +23,28 @@
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.apache.tapestry5.ioc.services.PropertyAccess;
import org.chorem.pollen.entity.FavoriteList;
import org.chorem.pollen.service.ServiceFavorite;
import org.chorem.pollen.ui.base.AbstractPollenPage;
import org.chorem.pollen.ui.components.Border;
+import org.chorem.pollen.ui.components.UserListsCreate;
+import org.chorem.pollen.ui.components.UserListsUpdate;
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.data.GenericSelectModel;
import org.chorem.pollen.ui.data.PollenRequiresAuthentication;
/**
- * Classe de la page d'affichage des listes de votants favorites de
- * l'utilisateur. Si l'utilisateur n'est pas identifié, on lui demande d'abord
- * de s'identifier via un formulaire.
+ * Page to manage favorite lists of the connected user only (managed thanks to
+ * {@link PollenRequiresAuthentication} annotation). This page use two main
+ * components, {@link UserListsCreate} to create a FavoriteList (from import
+ * csv, ldap or an empty one) and {@link UserListsUpdate} to manage content
+ * of the FavoriteList. This page will provide {@code favoriteListSelected}
+ * from a form with only a SelectModel loaded by {@link #getFavoriteLists()}
+ * with {@link #getFavoriteListModel()} as model. The delete action is also
+ * manage by the page using {@code serviceFavorite}.
*
* @author rannou
* @author fdesbois <fdesbois(a)codelutin.com>
@@ -47,6 +54,9 @@
@IncludeStylesheet("context:css/users.css")
public class UserLists extends AbstractPollenPage {
+ /************************** PAGE CONFIGURATION ****************************/
+
+ /** Border layout **/
@InjectComponent
private Border border;
@@ -61,23 +71,44 @@
@Property
private String title;
+ /**
+ * AddressBar for {@code border} component.
+ *
+ * @return a new AddressBar for the page.
+ */
public AddressBar getAddressBar() {
return AddressBar.newBar().appendCurrent(title);
}
+ /** Services injected **/
@Inject
private ServiceFavorite serviceFavorite;
@Inject
private PropertyAccess propertyAccess;
+ @Inject
+ private Messages messages;
+
+ /************************** SELECT FAVORITE LIST **************************/
+
private List<FavoriteList> favoriteLists;
private GenericSelectModel<FavoriteList> favoriteListModel;
+ /**
+ * Main property favoriteListSelected is keeped in Session and was
+ * used as parameter for UserListsUpdate component.
+ **/
@Persist
@Property
private FavoriteList favoriteListSelected;
+ /**
+ * Getter for SelectModel used to display select and bind entries with the
+ * FavoriteLists loaded by {@link #getFavoriteLists()}.
+ *
+ * @return a GenericSelectModel which contains Favorite lists loaded.
+ */
public GenericSelectModel<FavoriteList> getFavoriteListModel() {
if (favoriteListModel == null) {
favoriteListModel =
@@ -90,6 +121,12 @@
return favoriteListModel;
}
+ /**
+ * Getter to load data for FavoriteLists from connected user.
+ *
+ * @return a list of FavoriteList.
+ * @see ServiceFavorite#getFavoriteLists(UserAccount)
+ */
public List<FavoriteList> getFavoriteLists() {
if (favoriteLists == null) {
favoriteLists = serviceFavorite.getFavoriteLists(getUserConnected());
@@ -97,14 +134,31 @@
return favoriteLists;
}
+ /************************** SELECT FAVORITE LIST **************************/
+
+ /**
+ * Used to verify if the {@code favoriteListSelected} is set and ready
+ * to be deleted using {@code deleteList} actionLink.
+ *
+ * @return true if the {@code favoriteListSelected} is not null.
+ */
public boolean canDeleteList() {
return favoriteListSelected != null;
}
+ /**
+ * ON_ACTION :: Handler method for action on {@code deleteList} actionLink.
+ * Check is done using {@link #canDeleteList()}, then the
+ * {@code serviceFavorite} is called to execute the delete on
+ * {@code favoriteListSelected}.
+ *
+ * @see ServiceFavorite#deleteFavoriteList(FavoriteList)
+ */
void onActionFromDeleteList() {
if (canDeleteList()) {
serviceFavorite.deleteFavoriteList(favoriteListSelected);
- addInfo("Suppression OK");
+ addInfo(
+ messages.get("pollen.ui.list.delete.success"));
}
}
}
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthenticationFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthenticationFilter.java 2010-05-06 10:35:53 UTC (rev 2987)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthenticationFilter.java 2010-05-06 17:03:11 UTC (rev 2988)
@@ -1,27 +1,42 @@
package org.chorem.pollen.ui.services;
+import org.apache.tapestry5.services.ComponentRequestFilter;
import org.apache.tapestry5.services.ComponentSource;
import org.apache.tapestry5.services.PageRenderLinkSource;
import org.apache.tapestry5.services.Response;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.ui.data.PollenRequiresAuthentication;
-import org.chorem.pollen.ui.pages.Connexion;
+import org.chorem.pollen.ui.pages.Connection;
import org.chorem.pollen.ui.pages.ErrorPage;
import org.nuiton.web.tapestry5.services.AbstractAuthenticationFilter;
import org.nuiton.web.tapestry5.services.ServiceAuthentication;
/**
- * AuthenticationFilter
+ * AuthenticationFilter extends {@link AbstractAuthenticationFilter} that
+ * implents {@link ComponentRequestFilter} to provide behavior on each
+ * component and page rander. This is used for security managment and need
+ * the annotation {@link PollenAuthenticationFilter} to be put on pages that
+ * need authorization to be displayed.
*
* Created: 4 mai 2010
*
* @author fdesbois
- * $Id$
+ * @version $Id$
+ * @see AbstractAuthenticationFilter
*/
public class PollenAuthenticationFilter extends
AbstractAuthenticationFilter<UserAccount, PollenRequiresAuthentication>{
+ /**
+ * Constructor to intialize super class.
+ *
+ * @param renderLinkSource
+ * @param componentSource
+ * @param response
+ * @param serviceAuthentication
+ * @see AbstractAuthenticationFilter#AbstractAuthenticationFilter(PageRenderLinkSource, ComponentSource, Response, ServiceAuthentication, Class)
+ */
public PollenAuthenticationFilter(PageRenderLinkSource renderLinkSource,
ComponentSource componentSource, Response response,
ServiceAuthentication<UserAccount> serviceAuthentication) {
@@ -29,11 +44,22 @@
serviceAuthentication, PollenRequiresAuthentication.class);
}
+ /**
+ * Define which page Class is called to redict user after authorization
+ * problem. For a NOT_CONNECTED type, this will redirect to
+ * {@link Connection} page, and for a NOT_ALLOWED type, this will be redirect
+ * to {@link ErrorPage}. Note that both pages have in context the pageFrom
+ * called when filter intercept it.
+ *
+ * @param redirectType used to define which page will be redirected
+ * @return the page to redirect to
+ * @see AbstractAuthenticationFilter#redirectUnauthorizedUser(String)
+ */
@Override
protected Class<?> getRedirectPage(AuthenticationRedirect redirectType) {
switch (redirectType) {
case NOT_CONNECTED:
- return Connexion.class;
+ return Connection.class;
case NOT_ALLOWED:
return ErrorPage.class;
}
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-05-06 10:35:53 UTC (rev 2987)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-06 17:03:11 UTC (rev 2988)
@@ -35,17 +35,21 @@
pollen.ui.list.create.title=Cr\u00E9er une nouvelle liste
pollen.ui.list.create.success=La liste %1$s a \u00E9t\u00E9 cr\u00E9\u00E9e avec succ\u00E8s.
pollen.ui.list.create.weightHelp=Ce chiffre correspond au poids du vote de la personne, c'est \u00E0 dire le nombre de voix que poss\u00E8de la personne dans le sondage.
-pollen.ui.list.update.addParticipant=Ajouter un nouveau votant \u00E0 la liste
pollen.ui.list.delete=Supprimer la liste %1$s
pollen.ui.list.delete.confirmMessage=Etes-vous s\u00FBr de vouloir d\u00E9finitivement supprimer cette liste et l'int\u00E9gralit\u00E9 de ses votants ?
+pollen.ui.list.delete.success=La liste et son contenu ont \u00E9t\u00E9 supprim\u00E9 avec succ\u00E8s.
pollen.ui.list.notSelected=Aucune liste s\u00E9lectionn\u00E9e
pollen.ui.list.emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email.
pollen.ui.list.nbParticipants=%1$d votants contenus dans cette liste
+pollen.ui.list.update.addParticipant=Ajouter un nouveau votant \u00E0 la liste
+pollen.ui.list.update.addParticipant.success=Le votant %1$s a \u00E9t\u00E9 ajout\u00E9 \u00E0 la liste.
pollen.ui.list.update.cancelEdition=Annuler les changements
pollen.ui.list.update.saveParticipant=Enregistrer les modifications
+pollen.ui.list.update.saveParticipant.success=Modification enregistr\u00E9e avec succ\u00E8s.
pollen.ui.list.update.updateParticipant=Modifier ce votant
pollen.ui.list.update.removeParticipant=Supprimer ce votant
pollen.ui.list.update.removeParticipant.confirmMessage=Etes-vous s\u00FBr de vouloir supprimer %1$s de la liste ?
+pollen.ui.list.update.removeParticipant.success=Le votant a \u00E9t\u00E9 supprim\u00E9 avec succ\u00E8s.
# OLD LOGIN_COMPONENT
connectionLegend=Connexion
Copied: trunk/pollen-ui/src/main/webapp/Connection.tml (from rev 2983, trunk/pollen-ui/src/main/webapp/Connexion.tml)
===================================================================
--- trunk/pollen-ui/src/main/webapp/Connection.tml (rev 0)
+++ trunk/pollen-ui/src/main/webapp/Connection.tml 2010-05-06 17:03:11 UTC (rev 2988)
@@ -0,0 +1,23 @@
+<!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"
+ xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+
+ <t:form t:id="loginForm">
+ <fieldset>
+ <legend>${message:connectionLegend}</legend>
+ <t:errors />
+ <div>
+ <t:label for="connectionLogin" />
+ <input t:type="TextField" t:id="connectionLogin" validate="required" />
+ </div>
+ <div>
+ <t:label for="connectionPassword" />
+ <input t:type="PasswordField" t:id="connectionPassword" validate="required" />
+ </div>
+ <div class="buttons">
+ <input t:id="submitLoginCompForm" t:type="Submit" t:value="${message:loginSubmit}" />
+ </div>
+ </fieldset>
+ </t:form>
+
+</t:border>
\ No newline at end of file
Property changes on: trunk/pollen-ui/src/main/webapp/Connection.tml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Deleted: trunk/pollen-ui/src/main/webapp/Connexion.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/Connexion.tml 2010-05-06 10:35:53 UTC (rev 2987)
+++ trunk/pollen-ui/src/main/webapp/Connexion.tml 2010-05-06 17:03:11 UTC (rev 2988)
@@ -1,23 +0,0 @@
-<!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"
- xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
-
- <t:form t:id="loginForm">
- <fieldset>
- <legend>${message:connectionLegend}</legend>
- <t:errors />
- <div>
- <t:label for="connectionLogin" />
- <input t:type="TextField" t:id="connectionLogin" validate="required" />
- </div>
- <div>
- <t:label for="connectionPassword" />
- <input t:type="PasswordField" t:id="connectionPassword" validate="required" />
- </div>
- <div class="buttons">
- <input t:id="submitLoginCompForm" t:type="Submit" t:value="${message:loginSubmit}" />
- </div>
- </fieldset>
- </t:form>
-
-</t:border>
\ No newline at end of file
1
0
Author: fdesbois
Date: 2010-05-06 12:35:53 +0200 (Thu, 06 May 2010)
New Revision: 2987
Url: http://chorem.org/repositories/revision/pollen/2987
Log:
Evo #190 : Finish UserLists page with favoriteList and participant managment. (todo : i18n messages + javadoc)
Added:
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java
trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceFavoriteImplTest.java
trunk/pollen-ui/src/main/webapp/css/users.css
Removed:
trunk/pollen-ui/src/main/webapp/css/lists.css
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java
trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.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.properties
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.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/UserProfile.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
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/UserListsCreate.tml
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml
trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml
trunk/pollen-ui/src/main/webapp/css/common.css
trunk/pollen-ui/src/main/webapp/css/main.css
trunk/pollen-ui/src/main/webapp/user/UserLists.tml
trunk/pollen-ui/src/main/webapp/user/UserProfile.tml
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -49,7 +49,19 @@
SMTP_NOT_AVAILABLE(n_("pollen.exception.smtp_not_available")),
/** Exception when favorite list name is already defined for user **/
FAVORITE_LIST_NAME_EXIST(
- n_("pollen.exception.favorite_list_name_exist"));
+ n_("pollen.exception.favorite_list_name_exist")),
+ /**
+ * Exception when favorite participant name ($2) and email ($3) are
+ * already defined for the current list ($1).
+ **/
+ FAVORITE_PARTICIPANT_EXIST(
+ n_("pollen.exception.favorite_participant_exist")),
+ /**
+ * Exception when favorite participant name ($2) with no email is
+ * already defined for the current list ($1).
+ **/
+ FAVORITE_PARTICIPANT_EXIST_WITHOUT_EMAIL(
+ n_("pollen.exception.favorite_participant_exist_without_email"));
private String message;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -4,6 +4,8 @@
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.bean.Filter;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.persistence.TopiaDAO;
@@ -28,6 +30,8 @@
*/
public class TopiaQueryBuilder {
+ private static final Log log = LogFactory.getLog(TopiaQueryBuilder.class);
+
protected TopiaQuery query;
public TopiaQueryBuilder() {
@@ -138,6 +142,14 @@
String orderBy = filter.getOrderBy();
String referenceId = filter.getReferenceId();
+ if (log.isDebugEnabled()) {
+ log.debug("Filter added to the query : " +
+ "startIndex = " + startIndex +
+ " _ endIndex = " + endIndex +
+ " _ orderBy = " + orderBy +
+ " _ referenceId = " + referenceId);
+ }
+
// Add limits. Only startIndex do nothing.
// startIndex + endIndex provides the limit
if (filter.getStartIndex() != null && endIndex != null) {
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -0,0 +1,280 @@
+package org.chorem.pollen.service;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.PollenBusinessException.PollenExceptionType;
+import org.chorem.pollen.PollenContext;
+import org.chorem.pollen.PollenDAOHelper;
+import org.chorem.pollen.PollenException;
+import org.chorem.pollen.PollenQueryBuilder;
+import org.chorem.pollen.bean.Filter;
+import org.chorem.pollen.entity.FavoriteList;
+import org.chorem.pollen.entity.FavoriteListDAO;
+import org.chorem.pollen.entity.FavoriteListImpl;
+import org.chorem.pollen.entity.FavoriteParticipant;
+import org.chorem.pollen.entity.FavoriteParticipantDAO;
+import org.chorem.pollen.entity.FavoriteParticipantImpl;
+import org.chorem.pollen.entity.UserAccount;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * ServiceFavorite
+ *
+ * Created: 5 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class ServiceFavoriteImpl extends ServiceFavoriteAbstract {
+
+ private Log log = LogFactory.getLog(ServiceUserImpl.class);
+ private static final String BINDER_CONTEXT_FAVORITE_LIST = "favoriteList";
+ private PollenContext context;
+
+ public void setContext(PollenContext context) {
+ this.context = context;
+ }
+
+ @Override
+ protected TopiaContext beginTransaction() throws TopiaException {
+ return context.beginTransaction();
+ }
+
+ @Override
+ protected void treateError(TopiaContext transaction, Exception eee,
+ String message, Object... args) throws PollenException {
+ context.treateError(transaction, eee, message, args);
+ }
+
+ @Override
+ protected void closeTransaction(TopiaContext transaction) {
+ context.closeTransaction(transaction);
+ }
+
+ @Override
+ protected FavoriteList executeGetNewFavoriteList(UserAccount user) {
+ FavoriteList result = new FavoriteListImpl();
+ result.setUserAccount(user);
+ return result;
+ }
+
+ @Override
+ protected void executeCreateFavoriteList(TopiaContext transaction,
+ FavoriteList list) throws TopiaException, PollenBusinessException {
+
+ FavoriteListDAO dao = PollenDAOHelper.getFavoriteListDAO(transaction);
+
+ // check favoriteList name exist for user
+ UserAccount user = list.getUserAccount();
+ int count = dao.createQuery().
+ add(FavoriteList.USER_ACCOUNT, user).
+ add(FavoriteList.NAME, list.getName()).
+ executeCount();
+ // existing list found
+ if (count > 0) {
+ throw new PollenBusinessException(
+ PollenExceptionType.FAVORITE_LIST_NAME_EXIST,
+ list.getName(), user.getDisplayName());
+ }
+
+ FavoriteList newList = dao.create(
+ FavoriteList.USER_ACCOUNT, list.getUserAccount(),
+ FavoriteList.NAME, list.getName());
+// list.setTopiaId(newList.getTopiaId());
+
+ transaction.commitTransaction();
+ }
+
+ @Override
+ protected void executeDeleteFavoriteList(TopiaContext transaction,
+ FavoriteList list) throws TopiaException {
+ FavoriteListDAO dao = PollenDAOHelper.getFavoriteListDAO(transaction);
+
+ FavoriteList listLoaded = dao.findByTopiaId(list.getTopiaId());
+ dao.delete(listLoaded);
+
+ transaction.commitTransaction();
+ }
+
+ @Override
+ protected List<FavoriteList> executeGetFavoriteLists(
+ TopiaContext transaction, UserAccount user) throws TopiaException {
+
+ FavoriteListDAO dao = PollenDAOHelper.getFavoriteListDAO(transaction);
+
+ List<FavoriteList> results = dao.findAllByUserAccount(user);
+
+ return results;
+ }
+
+ /**
+ * Check if the {@code participant} doesn't already exists with same
+ * email, name and favoriteList.
+ *
+ * @param dao used to verify the existing participant
+ * @param participant FavoriteParticipant to check
+ * @throws PollenBusinessException if FavoriteParticipant already exists
+ * @throws TopiaException for technical errors from ToPIA
+ */
+ protected void checkFavoriteParticipant(FavoriteParticipantDAO dao,
+ FavoriteParticipant participant)
+ throws PollenBusinessException, TopiaException {
+
+ FavoriteList list = participant.getFavoriteList();
+
+ TopiaQuery query = dao.createQuery().
+ add(FavoriteParticipant.FAVORITE_LIST, list).
+ add(FavoriteParticipant.NAME, participant.getName()).
+ add(FavoriteParticipant.EMAIL, participant.getEmail());
+
+ // Check only on entities different from the one in argument
+ if (StringUtils.isNotEmpty(participant.getTopiaId())) {
+ query.add(TopiaEntity.TOPIA_ID, Op.NEQ, participant.getTopiaId());
+ }
+
+ int count = query.executeCount();
+ // existing participant found
+ if (count > 0) {
+ // The error type (message) depends on email nullity
+ if (participant.getEmail() == null) {
+ throw new PollenBusinessException(
+ PollenExceptionType.FAVORITE_PARTICIPANT_EXIST_WITHOUT_EMAIL,
+ list.getName(),
+ participant.getName());
+ } else {
+ throw new PollenBusinessException(
+ PollenExceptionType.FAVORITE_PARTICIPANT_EXIST,
+ list.getName(),
+ participant.getName(),
+ participant.getEmail());
+ }
+ }
+ }
+
+ @Override
+ protected FavoriteParticipant executeGetNewFavoriteParticipant(
+ FavoriteList list) {
+ FavoriteParticipant result = new FavoriteParticipantImpl();
+ result.setFavoriteList(list);
+ result.setWeight(1.);
+ return result;
+ }
+
+ @Override
+ protected void executeCreateFavoriteParticipant(TopiaContext transaction,
+ FavoriteParticipant participant)
+ throws PollenBusinessException, TopiaException {
+
+ FavoriteParticipantDAO dao =
+ PollenDAOHelper.getFavoriteParticipantDAO(transaction);
+
+ checkFavoriteParticipant(dao, participant);
+
+ // Create newParticipant with naturalId
+ FavoriteParticipant newParticipant =
+ dao.create(participant.getName(),
+ participant.getEmail(),
+ participant.getFavoriteList());
+
+ // Set other field
+ newParticipant.setWeight(participant.getWeight());
+
+ transaction.commitTransaction();
+ }
+
+ @Override
+ protected void executeDeleteFavoriteParticipant(TopiaContext transaction,
+ String id) throws TopiaException {
+
+ FavoriteParticipantDAO dao =
+ PollenDAOHelper.getFavoriteParticipantDAO(transaction);
+
+ FavoriteParticipant participantLoaded = dao.findByTopiaId(id);
+
+ dao.delete(participantLoaded);
+
+ transaction.commitTransaction();
+ }
+
+ @Override
+ protected void executeUpdateFavoriteParticipant(TopiaContext transaction,
+ FavoriteParticipant participant)
+ throws TopiaException, PollenBusinessException {
+
+ FavoriteParticipantDAO dao =
+ PollenDAOHelper.getFavoriteParticipantDAO(transaction);
+
+ checkFavoriteParticipant(dao, participant);
+
+ FavoriteParticipant participantLoaded =
+ dao.findByTopiaId(participant.getTopiaId());
+
+ // Set all fields except favoriteList that can't be changed
+ participantLoaded.setName(participant.getName());
+ participantLoaded.setEmail(participant.getEmail());
+ participantLoaded.setWeight(participant.getWeight());
+
+ dao.update(participantLoaded);
+
+ transaction.commitTransaction();
+ }
+
+ @Override
+ protected FavoriteParticipant executeGetFavoriteParticipant(
+ TopiaContext transaction, String id) throws TopiaException {
+
+ FavoriteParticipantDAO dao =
+ PollenDAOHelper.getFavoriteParticipantDAO(transaction);
+
+ FavoriteParticipant result = dao.findByTopiaId(id);
+ // Load parent list
+ result.getFavoriteList();
+
+ return result;
+ }
+
+ @Override
+ protected Map<String, FavoriteParticipant> executeGetFavoriteParticipants(
+ TopiaContext transaction, Filter filter) throws TopiaException {
+
+ PollenQueryBuilder builder = new PollenQueryBuilder();
+
+ TopiaQuery query =
+ builder.createQueryFindFavoriteParticipantsByFavoriteList(filter);
+
+ FavoriteParticipantDAO dao =
+ PollenDAOHelper.getFavoriteParticipantDAO(transaction);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Query : " + query);
+ }
+
+ query.addLoad(FavoriteParticipant.FAVORITE_LIST);
+
+ Map<String, FavoriteParticipant> results =
+ dao.findAllMappedByQuery(query);
+
+ return results;
+ }
+
+ @Override
+ protected int executeGetNbFavoriteParticipants(TopiaContext transaction,
+ Filter filter) throws TopiaException {
+
+ PollenQueryBuilder builder = new PollenQueryBuilder();
+
+ TopiaQuery query =
+ builder.createQueryFindFavoriteParticipantsByFavoriteList(filter);
+
+ int result = query.executeCount(transaction);
+ return result;
+ }
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
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-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -19,22 +19,18 @@
import org.chorem.pollen.entity.FavoriteParticipant;
import org.chorem.pollen.entity.FavoriteParticipantDAO;
import org.chorem.pollen.entity.FavoriteParticipantImpl;
-import org.chorem.pollen.entity.PollAccount;
-import org.chorem.pollen.EntityQueryProperty;
import org.chorem.pollen.PollenQueryBuilder;
import org.chorem.pollen.TopiaQueryBuilder;
-import org.chorem.pollen.entity.PollAccountDAO;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountDAO;
import org.chorem.pollen.entity.UserAccountImpl;
+import org.nuiton.i18n.I18n;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
import org.nuiton.topia.persistence.util.TopiaEntityBinder;
import org.nuiton.util.beans.Binder;
-import org.nuiton.util.beans.BinderBuilder;
-import org.nuiton.util.beans.BinderProvider;
/**
* ServiceUserImpl
@@ -51,8 +47,6 @@
private Log log = LogFactory.getLog(ServiceUserImpl.class);
- private static final String BINDER_CONTEXT_FAVORITE_LIST = "favoriteList";
-
private PollenContext context;
public void setContext(PollenContext context) {
@@ -293,152 +287,5 @@
return result;
}
- @Override
- protected FavoriteList executeGetNewFavoriteList(UserAccount user) {
- FavoriteList result = new FavoriteListImpl();
- result.setUserAccount(user);
- return result;
- }
- @Override
- protected void executeCreateFavoriteList(TopiaContext transaction,
- FavoriteList list) throws TopiaException, PollenBusinessException {
-
- FavoriteListDAO dao = PollenDAOHelper.getFavoriteListDAO(transaction);
-
- // check favoriteList name exist for user
- UserAccount user = list.getUserAccount();
- int count = dao.createQuery().
- add(FavoriteList.USER_ACCOUNT, user).
- add(FavoriteList.NAME, list.getName()).
- executeCount();
- // existing list found
- if (count > 0) {
- throw new PollenBusinessException(
- PollenExceptionType.FAVORITE_LIST_NAME_EXIST,
- list.getName(), user.getDisplayName());
- }
-
- FavoriteList newList = dao.create(
- FavoriteList.USER_ACCOUNT, list.getUserAccount(),
- FavoriteList.NAME, list.getName());
-// list.setTopiaId(newList.getTopiaId());
-
- transaction.commitTransaction();
- }
-
- @Override
- protected void executeDeleteFavoriteList(TopiaContext transaction,
- FavoriteList list) throws TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- protected List<FavoriteList> executeGetFavoriteLists(
- TopiaContext transaction, UserAccount user) throws TopiaException {
-
- FavoriteListDAO dao = PollenDAOHelper.getFavoriteListDAO(transaction);
-
- List<FavoriteList> results = dao.findAllByUserAccount(user);
-
- return results;
- }
-
- @Override
- protected FavoriteParticipant executeGetNewFavoriteParticipant(
- TopiaContext transaction, FavoriteList list)
- throws TopiaException {
- FavoriteParticipant result = new FavoriteParticipantImpl();
- result.setFavoriteList(list);
- result.setWeight(1.);
- return result;
- }
-
- @Override
- protected void executeCreateFavoriteParticipant(TopiaContext transaction,
- FavoriteParticipant participant)
- throws PollenBusinessException, TopiaException {
-
- FavoriteParticipantDAO dao =
- PollenDAOHelper.getFavoriteParticipantDAO(transaction);
-
- FavoriteList list = participant.getFavoriteList();
-// int count = dao.createQuery().
-// add(FavoriteParticipant.FAVORITE_LIST, list).
-// add(FavoriteParticipant.NAME, participant.getName()).
-// add(FavoriteParticipant.EMAIL, participant.getEmail()).
-// executeCount();
-// // existing participant found
-// if (count > 0) {
-// throw new PollenBusinessException(
-// PollenExceptionType.FAVORITE_PARTICIPANT_EXIST,
-// list.getName(), list.getName());
-// }
-
- // Create newParticipant with naturalId
- FavoriteParticipant newParticipant =
- dao.create(FavoriteParticipant.FAVORITE_LIST, list,
- FavoriteParticipant.NAME, participant.getName(),
- FavoriteParticipant.EMAIL, participant.getEmail());
-
- // Set other field
- newParticipant.setWeight(participant.getWeight());
-
- // Update input participant with new topiaId
-// participant.setTopiaId(newParticipant.getTopiaId());
-
- transaction.commitTransaction();
- }
-
- @Override
- protected void executeDeleteFavoriteParticipant(TopiaContext transaction,
- FavoriteParticipant participant) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- protected void executeUpdateFavoriteParticipant(TopiaContext transaction,
- FavoriteParticipant participant) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- protected Map<String, FavoriteParticipant> executeGetFavoriteParticipants(
- TopiaContext transaction, Filter filter) throws TopiaException {
-
- PollenQueryBuilder builder = new PollenQueryBuilder();
-
- TopiaQuery query =
- builder.createQueryFindFavoriteParticipantsByFavoriteList(filter);
-
- FavoriteParticipantDAO dao =
- PollenDAOHelper.getFavoriteParticipantDAO(transaction);
-
- if (log.isDebugEnabled()) {
- log.debug("Query : " + query);
- }
-
- Map<String, FavoriteParticipant> results =
- dao.findAllMappedByQuery(query);
-
- if (log.isDebugEnabled()) {
- log.debug("Results : " + results);
- }
-
- return results;
- }
-
- @Override
- protected int executeGetNbFavoriteParticipants(TopiaContext transaction,
- Filter filter) throws TopiaException {
-
- PollenQueryBuilder builder = new PollenQueryBuilder();
-
- TopiaQuery query =
- builder.createQueryFindFavoriteParticipantsByFavoriteList(filter);
-
- int result = query.executeCount(transaction);
- return result;
- }
-
}
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-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-06 10:35:53 UTC (rev 2987)
@@ -7,6 +7,17 @@
pollen.error.encodePassword=
pollen.error.serviceEmail.getNewEmail=
pollen.error.serviceEmail.sendEmail=
+pollen.error.serviceFavorite.createFavoriteList=
+pollen.error.serviceFavorite.createFavoriteParticipant=
+pollen.error.serviceFavorite.deleteFavoriteList=
+pollen.error.serviceFavorite.deleteFavoriteParticipant=
+pollen.error.serviceFavorite.getFavoriteLists=
+pollen.error.serviceFavorite.getFavoriteParticipant=
+pollen.error.serviceFavorite.getFavoriteParticipants=
+pollen.error.serviceFavorite.getNbFavoriteParticipants=
+pollen.error.serviceFavorite.getNewFavoriteList=
+pollen.error.serviceFavorite.getNewFavoriteParticipant=
+pollen.error.serviceFavorite.updateFavoriteParticipant=
pollen.error.serviceList.createAccountForPersonList=
pollen.error.serviceList.deleteAccountFromPersonList=
pollen.error.serviceMail.sendEmail=
@@ -65,6 +76,8 @@
pollen.error.serviceVote.getVotesByPoll=Unable to load votes from poll with uid \= %1$s
pollen.error.serviceVote.hasAlreadyVoted=Unable test vote existing for account with votingId \= %1$s and poll with uid \= %2$s
pollen.exception.favorite_list_name_exist=
+pollen.exception.favorite_participant_exist=
+pollen.exception.favorite_participant_exist_without_email=
pollen.exception.load_configuration=
pollen.exception.poll_not_exist=No such poll exists. Please make sure that you are using the correct link and copy it completely into your browser's address field.
pollen.exception.smtp_not_available=
@@ -77,3 +90,4 @@
pollen.info.start=Start Pollen
pollen.info.started=Pollen is started \!
pollen.info.stop=Stop Pollen
+pollen.text.empty=
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-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-06 10:35:53 UTC (rev 2987)
@@ -7,6 +7,17 @@
pollen.error.encodePassword=
pollen.error.serviceEmail.getNewEmail=
pollen.error.serviceEmail.sendEmail=
+pollen.error.serviceFavorite.createFavoriteList=
+pollen.error.serviceFavorite.createFavoriteParticipant=
+pollen.error.serviceFavorite.deleteFavoriteList=
+pollen.error.serviceFavorite.deleteFavoriteParticipant=
+pollen.error.serviceFavorite.getFavoriteLists=
+pollen.error.serviceFavorite.getFavoriteParticipant=
+pollen.error.serviceFavorite.getFavoriteParticipants=
+pollen.error.serviceFavorite.getNbFavoriteParticipants=
+pollen.error.serviceFavorite.getNewFavoriteList=
+pollen.error.serviceFavorite.getNewFavoriteParticipant=
+pollen.error.serviceFavorite.updateFavoriteParticipant=
pollen.error.serviceList.createAccountForPersonList=
pollen.error.serviceList.deleteAccountFromPersonList=
pollen.error.serviceMail.sendEmail=Erreur lors de l'envoi de l'email sur le serveur %1$s\:%2$d pour %3$s de la part de %4$s
@@ -64,6 +75,8 @@
pollen.error.serviceVote.getVotesByPoll=
pollen.error.serviceVote.hasAlreadyVoted=
pollen.exception.favorite_list_name_exist=La liste %1$s existe d\u00E9j\u00E0 pour l'utilisateur %2$s
+pollen.exception.favorite_participant_exist=La liste %1$s contient d\u00E9j\u00E0 un utilisateur nomm\u00E9 %2$s avec un email %3$s
+pollen.exception.favorite_participant_exist_without_email=La liste %1$s contient d\u00E9j\u00E0 un utilisateur nomm\u00E9 %2$s avec aucun email
pollen.exception.load_configuration=La configuration n'a pas \u00E9t\u00E9 charg\u00E9e correctement \! Veuillez v\u00E9rifier le d\u00E9marrage de l'application.
pollen.exception.poll_not_exist=Il n'y a pas de sondage \u00E0 cette adresse. Veuillez verifier que vous utilisez le lien correcte et copiez-le compl\u00E8tement dans le champ d'adresse de votre navigateur.
pollen.exception.smtp_not_available=Impossible d'envoyer un email \u00E0 %1$s. Serveur smtp indisponible pour l'envoi d'email, veuillez contacter un administrateur.
Modified: trunk/pollen-business/src/main/xmi/pollen.properties
===================================================================
--- trunk/pollen-business/src/main/xmi/pollen.properties 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-business/src/main/xmi/pollen.properties 2010-05-06 10:35:53 UTC (rev 2987)
@@ -12,7 +12,8 @@
org.chorem.pollen.entity.FavoriteList.attribute.userAccount.tagvalue.naturalId=true
org.chorem.pollen.entity.FavoriteList.attribute.name.tagvalue.naturalId=true
+org.chorem.pollen.entity.FavoriteParticipant.class.tagvalue.naturalIdMutable=true
org.chorem.pollen.entity.FavoriteParticipant.attribute.favoriteList.tagvalue.naturalId=true
org.chorem.pollen.entity.FavoriteParticipant.attribute.name.tagvalue.naturalId=true
org.chorem.pollen.entity.FavoriteParticipant.attribute.email.tagvalue.naturalId=true
-org.chorem.pollen.entity.FavoriteParticipant.attribute.email.tagvalue.notNull=false
\ No newline at end of file
+org.chorem.pollen.entity.FavoriteParticipant.attribute.email.tagvalue.notNull=false
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -12,8 +12,13 @@
import org.chorem.pollen.PollenContext;
import org.chorem.pollen.PollenContextImpl;
import org.chorem.pollen.PollenDAOHelper;
+import org.chorem.pollen.entity.FavoriteList;
+import org.chorem.pollen.entity.FavoriteListDAO;
+import org.chorem.pollen.entity.FavoriteParticipant;
+import org.chorem.pollen.entity.FavoriteParticipantDAO;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountDAO;
+import org.chorem.pollen.service.ServiceFavoriteImpl;
import org.chorem.pollen.service.ServiceUserImpl;
import org.junit.After;
import org.junit.Ignore;
@@ -41,6 +46,8 @@
protected ServiceUserImpl serviceUser;
+ protected ServiceFavoriteImpl serviceFavorite;
+
public void start(String dbname) throws IOException {
log.info("## START ## : " + dbname);
@@ -87,6 +94,14 @@
return serviceUser;
}
+ public ServiceFavoriteImpl getServiceFavorite() {
+ if (serviceFavorite == null) {
+ serviceFavorite = new ServiceFavoriteImpl();
+ serviceFavorite.setContext(getContext());
+ }
+ return serviceFavorite;
+ }
+
public TopiaContext beginTransaction() throws TopiaException {
return getContext().beginTransaction();
}
@@ -140,4 +155,35 @@
}
}
+ public FavoriteList createFavoriteList(String name, UserAccount user)
+ throws TopiaException {
+
+ TopiaContext transaction = beginTransaction();
+ try {
+ FavoriteListDAO dao =
+ PollenDAOHelper.getFavoriteListDAO(transaction);
+
+ FavoriteList list = dao.create(name, user);
+ transaction.commitTransaction();
+ return list;
+ } finally {
+ transaction.closeContext();
+ }
+ }
+
+ public FavoriteParticipant createFavoriteParticipant(String name,
+ String email, FavoriteList list) throws TopiaException {
+ TopiaContext transaction = beginTransaction();
+ try {
+ FavoriteParticipantDAO dao =
+ PollenDAOHelper.getFavoriteParticipantDAO(transaction);
+
+ FavoriteParticipant participant = dao.create(name, email, list);
+ transaction.commitTransaction();
+ return participant;
+ } finally {
+ transaction.closeContext();
+ }
+ }
+
}
Added: trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceFavoriteImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceFavoriteImplTest.java (rev 0)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceFavoriteImplTest.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -0,0 +1,109 @@
+
+package org.chorem.pollen.service;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.PollenBusinessException.PollenExceptionType;
+import org.chorem.pollen.PollenDAOHelper;
+import org.chorem.pollen.business.AbstractServiceTest;
+import org.chorem.pollen.entity.FavoriteList;
+import org.chorem.pollen.entity.FavoriteParticipant;
+import org.chorem.pollen.entity.FavoriteParticipantDAO;
+import org.chorem.pollen.entity.UserAccount;
+import org.junit.Assert;
+import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+
+/**
+ * ServiceFavoriteImplTest
+ *
+ * Created: 5 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class ServiceFavoriteImplTest extends AbstractServiceTest {
+
+ private static final Log log = LogFactory.getLog(ServiceUserImplTest.class);
+
+ @Test
+ public void testCreateFavoriteParticipant() throws Exception {
+ start("testCreateFavoriteParticipant");
+
+ UserAccount user = createUser(false);
+
+ final FavoriteList list = createFavoriteList("LIST", user);
+
+ log.info("test 1 : no problem on creation");
+ FavoriteParticipant participant =
+ getServiceFavorite().getNewFavoriteParticipant(list);
+
+ participant.setName("participant");
+ participant.setEmail("email");
+
+ getServiceFavorite().createFavoriteParticipant(participant);
+
+ log.info("test 2 : problem on naturalId : participant already" +
+ " set with same email");
+
+ participant =
+ getServiceFavorite().getNewFavoriteParticipant(list);
+
+ participant.setName("participant");
+ participant.setEmail("email");
+
+ try {
+ getServiceFavorite().createFavoriteParticipant(participant);
+ } catch (PollenBusinessException eee) {
+ Assert.assertEquals(PollenExceptionType.FAVORITE_PARTICIPANT_EXIST,
+ eee.getType());
+ }
+
+ log.info("test 3 : email in naturalId can be null");
+
+ participant =
+ getServiceFavorite().getNewFavoriteParticipant(list);
+
+ participant.setName("participant2");
+ participant.setEmail(null);
+
+ getServiceFavorite().createFavoriteParticipant(participant);
+
+ TopiaContext transaction = beginTransaction();
+ try {
+ FavoriteParticipantDAO dao =
+ PollenDAOHelper.getFavoriteParticipantDAO(transaction);
+ String email = null;
+
+ FavoriteParticipant result = dao.findByProperties(
+ FavoriteParticipant.NAME, "participant2",
+ FavoriteParticipant.EMAIL, email,
+ FavoriteParticipant.FAVORITE_LIST, list);
+
+ Assert.assertNotNull(result);
+ } finally {
+ transaction.closeContext();
+ }
+ }
+
+ @Test
+ public void testUpdateFavoriteParticipant() throws Exception {
+ start("testUpdateFavoriteParticipant");
+
+ /** PREPARE DATA **/
+ UserAccount user = createUser(false);
+
+ FavoriteList list = createFavoriteList("LIST", user);
+ FavoriteParticipant participant =
+ createFavoriteParticipant("participant", null, list);
+
+ /** EXEC METHOD **/
+ log.info("test 1 : update ok : add email");
+ participant.setEmail("email");
+ participant.setWeight(1.);
+
+ getServiceFavorite().updateFavoriteParticipant(participant);
+ }
+
+}
Property changes on: trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceFavoriteImplTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
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-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -8,12 +8,17 @@
import org.chorem.pollen.PollenDAOHelper;
import org.chorem.pollen.PollenException;
import org.chorem.pollen.business.AbstractServiceTest;
+import org.chorem.pollen.business.TestData;
+import org.chorem.pollen.entity.FavoriteList;
+import org.chorem.pollen.entity.FavoriteParticipant;
+import org.chorem.pollen.entity.FavoriteParticipantDAO;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountDAO;
import org.chorem.pollen.entity.UserAccountImpl;
import org.junit.Assert;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.framework.TopiaQuery;
/**
*
@@ -42,7 +47,7 @@
log.info("test 2 : Do not encode new password -> newPassword empty");
user.setPassword(expected);
user.setNewPassword(null);
- serviceUser.copyUserAccount(user, destination);
+ getServiceUser().copyUserAccount(user, destination);
Assert.assertEquals(expected, destination.getPassword());
}
@@ -62,11 +67,11 @@
UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction);
log.info("test 1 : Good password");
- serviceUser.checkPassword(dao, "homer", encodedPassword);
+ getServiceUser().checkPassword(dao, "homer", encodedPassword);
log.info("test 2 : Wrong password");
try {
- serviceUser.checkPassword(dao, "homer", "bad");
+ getServiceUser().checkPassword(dao, "homer", "bad");
} catch (PollenBusinessException eee) {
log.error("Error : " + eee.getMessage());
Assert.assertEquals(PollenExceptionType.USER_WRONG_PASSWORD,
@@ -264,14 +269,4 @@
}
}
- @Test
- public void testCreateFavoriteParticipant() throws Exception {
- start("testCreateFavoriteParticipant");
-
- UserAccount user = createUser(false);
-
- // TODO : test on naturalId and nullity
-
- }
-
}
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -11,7 +11,7 @@
import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.PollenBusinessException.PollenExceptionType;
import org.chorem.pollen.entity.FavoriteList;
-import org.chorem.pollen.service.ServiceUser;
+import org.chorem.pollen.service.ServiceFavorite;
import org.chorem.pollen.ui.base.PollenPage;
import org.chorem.pollen.ui.services.PollenManager;
import org.slf4j.Logger;
@@ -40,7 +40,7 @@
private PollenManager manager;
@Inject
- private ServiceUser serviceUser;
+ private ServiceFavorite serviceFavorite;
/** Properties **/
@Property
@@ -63,13 +63,13 @@
logger.debug("User connected : " + page.getUserConnected());
}
newFavoriteList =
- serviceUser.getNewFavoriteList(page.getUserConnected());
+ serviceFavorite.getNewFavoriteList(page.getUserConnected());
}
}
void onValidateFormFromCreateList() {
try {
- serviceUser.createFavoriteList(newFavoriteList);
+ serviceFavorite.createFavoriteList(newFavoriteList);
} catch (PollenBusinessException eee) {
String message = manager.getErrorMessage(eee, messages, logger);
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -1,21 +1,24 @@
package org.chorem.pollen.ui.components;
-import java.util.List;
-import org.apache.tapestry5.ComponentResources;
+import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Log;
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.corelib.components.Zone;
+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.entity.FavoriteList;
import org.chorem.pollen.entity.FavoriteParticipant;
-import org.chorem.pollen.entity.PollAccount;
-import org.chorem.pollen.service.ServiceUser;
+import org.chorem.pollen.service.ServiceFavorite;
import org.chorem.pollen.ui.data.EvenOdd;
import org.chorem.pollen.ui.data.FavoriteParticipantDataSource;
+import org.chorem.pollen.ui.services.PollenManager;
+import org.nuiton.web.tapestry5.components.FeedBack;
import org.slf4j.Logger;
/**
@@ -31,41 +34,34 @@
*/
public class UserListsUpdate {
+ /** Parameters of the component **/
@Parameter(required = true)
- @Property
- private List<PollAccount> source;
+ private FavoriteList source;
+ /** Services injected **/
@Inject
private Logger logger;
@Inject
- private ComponentResources resources;
+ private ServiceFavorite serviceFavorite;
@Inject
- private ServiceUser serviceUser;
+ private PollenManager manager;
- @Persist
- @Property
- private FavoriteList favoriteListSelected;
+ @Inject
+ private Messages messages;
+ /** Main properties for Grid **/
private EvenOdd evenOdd;
- @Persist
private FavoriteParticipantDataSource participants;
@Property
private FavoriteParticipant participant;
- @Property
- private FavoriteParticipant newParticipant;
-
@InjectComponent
private Zone updateZone;
- void setupRender() {
- resources.discardPersistentFieldChanges();
- }
-
public EvenOdd getEvenOdd() {
if (evenOdd == null) {
evenOdd = new EvenOdd();
@@ -74,35 +70,215 @@
}
public boolean canDisplayAccounts() {
- return favoriteListSelected != null;
+ return source != null;
}
+ /**
+ * Load participants data from serviceFavorite in a
+ * {@link FavoriteParticipantDataSource} to manage pagination and order.
+ * The filter added contains data for serviceFavorite (startIndex, endIndex,
+ * orderBy and referenceId). The reference is set to the source FavoriteList
+ * of the component, i.e. all FavoriteParticipants need to be part of the
+ * FavoriteList source.
+ *
+ * @return
+ */
public FavoriteParticipantDataSource getParticipants() {
if (participants == null) {
if (logger.isDebugEnabled()) {
logger.debug("Create DATASOURCE");
}
Filter filter = new Filter();
- filter.setReference(favoriteListSelected);
+ filter.setReference(source);
participants =
- new FavoriteParticipantDataSource(serviceUser, filter);
+ new FavoriteParticipantDataSource(serviceFavorite, filter);
}
return participants;
}
- void onActionFromRemoveParticipant(String UId) {
- // NEED DELETE ACCOUNT FOR LIST
+ /***************************** EDIT PARTICIPANT FORM **********************/
+
+ /**
+ * FORM EVENTS ORDER -> RENDER :
+ * load size of participants dataSource
+ * call prepareForRender
+ * load participants data
+ *
+ * FORM EVENTS ORDER -> SUBMIT :
+ * call prepareForSubmit
+ * load size of participants dataSource
+ * load participants data
+ * load participantEdited to push form data
+ * call selected on submit button
+ * call validateForm
+ * call success or failure
+ * call submit
+ */
+
+ @InjectComponent
+ private Form participantsForm;
+
+ @InjectComponent
+ private FeedBack participantsFeedback;
+
+ private FavoriteParticipant participantEdited;
+
+ @Property
+ private String participantEditedId;
+
+ /**
+ * Test if the edited participant is the current one in the Grid.
+ *
+ * @return true if the participantEdited is defined and correspond to the
+ * current participant in the Grid
+ */
+ public boolean isEditionMode() {
+ // The current participant in the loop is equals to the edited one
+ return participantEditedId != null &&
+ participant.getId().equals(participantEditedId);
}
+ /**
+ * ON_ACTION :: Handler method for action on editParticipant actionLink.
+ * The participantEdited will be set to the participant selected in the Grid
+ * with {@code id}.
+ *
+ * @param id key of the participant from the Grid
+ * @return the updateZone content to refresh
+ */
+ Object onActionFromEditParticipant(String id) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Participant in edition : " + id);
+ }
+ participantEditedId = id;
+ return updateZone.getBody();
+ }
+
+ /**
+ * ON_ACTION :: Handler method for action on cancelEdition actionLink.
+ * Simply refresh the zone will change edition mode.
+ *
+ * @return the updateZone content to refresh
+ */
+ Object onActionFromCancelEdition() {
+ return updateZone.getBody();
+ }
+
+ /**
+ * 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
+ * @return the updateZone content to refresh
+ * @see ServiceUser#deleteUser(String)
+ */
+ Object onActionFromRemoveParticipant(String id) {
+ serviceFavorite.deleteFavoriteParticipant(id);
+ participantsFeedback.addInfo("Suppression OK");
+ return updateZone;
+ }
+
+ /**
+ * Getter to retrieve participantEdited.
+ * <br \>
+ * The participantEditedId is needed and was provided for render by the
+ * {@link #onActionFromEditParticipant(String)} method and for submit by
+ * the hidden field in the form that keep the id after rendering the form.
+ * The participantEdited is loaded from the participants dataSource that
+ * contains all FavoriteParticipant displayed in the Grid. The submit will
+ * reload the participants dataSource before saving modification on the
+ * FavoriteParticipant edited.
+ *
+ * @return the FavoriteParticipant in edition
+ */
+ public FavoriteParticipant getParticipantEdited() {
+ if (participantEdited == null && participantEditedId != null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Load from dataSource participantEditedId : " +
+ participantEditedId);
+ }
+ participantEdited = participants.get(participantEditedId);
+ }
+ return participantEdited;
+ }
+
+ /**
+ * 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)
+ */
+ @Log
+ void onValidateFormFromParticipantsForm() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("participant saved : " + participantEdited);
+ }
+ try {
+ serviceFavorite.updateFavoriteParticipant(participantEdited);
+ } catch (PollenBusinessException eee) {
+ String message = manager.getErrorMessage(eee, messages, logger);
+ participantsForm.recordError(message);
+ }
+ }
+
+ /**
+ * ON_SUCCESS :: Handler method for success event of the participantsForm.
+ * Refresh the page to display a success message.
+ *
+ * @return the page container.
+ */
+ Object onSuccessFromParticipantsForm() {
+ participantsFeedback.addInfo("Modification OK");
+ // Clean form data before refresh zone
+ cleanFormData();
+ return updateZone;
+ }
+
+ protected void cleanFormData() {
+ participantEditedId = null;
+ participantEdited = null;
+ }
+
+ /**
+ * ON_FAILURE :: Handler method for failure event of the participantsForm.
+ * Will display errors and keep participantEdited in edition.
+ *
+ * @return the updateZone to refresh
+ */
+ Object onFailureFromParticipantsForm() {
+ return updateZone;
+ }
+
+ /***************************** NEW PARTICIPANT FORM ***********************/
+
+ @Property
+ private FavoriteParticipant newParticipant;
+
+ @InjectComponent
+ private Form addParticipant;
+
void onPrepareFromAddParticipant() {
if (newParticipant == null) {
newParticipant =
- serviceUser.getNewFavoriteParticipant(favoriteListSelected);
+ serviceFavorite.getNewFavoriteParticipant(source);
}
}
- Object onSuccessFromAddParticipant() {
- serviceUser.createFavoriteParticipant(newParticipant);
- return updateZone.getBody();
+ void onValidateFormFromAddParticipant() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("FavoriteList selected : " + source);
+ }
+ try {
+ serviceFavorite.createFavoriteParticipant(newParticipant);
+ } catch (PollenBusinessException eee) {
+ String message = manager.getErrorMessage(eee, messages, logger);
+ addParticipant.recordError(message);
+ }
}
+
+ Object onSubmitFromAddParticipant() {
+ participantsFeedback.addInfo("Ajout OK");
+ return updateZone;
+ }
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -6,8 +6,7 @@
import org.chorem.pollen.PollenException;
import org.chorem.pollen.bean.Filter;
import org.chorem.pollen.entity.FavoriteParticipant;
-import org.chorem.pollen.entity.PollAccount;
-import org.chorem.pollen.service.ServiceUser;
+import org.chorem.pollen.service.ServiceFavorite;
import org.nuiton.web.tapestry5.data.AbstractMappedGridDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -29,11 +28,12 @@
private static final Logger logger =
LoggerFactory.getLogger(FavoriteParticipantDataSource.class);
- private ServiceUser service;
+ private ServiceFavorite service;
private Filter filter;
- public FavoriteParticipantDataSource(ServiceUser service, Filter filter) {
+ public FavoriteParticipantDataSource(ServiceFavorite service,
+ Filter filter) {
this.service = service;
this.filter = filter;
}
@@ -53,12 +53,16 @@
@Override
protected int count() throws PollenException {
- return service.getNbFavoriteParticipants(filter);
+ int count = service.getNbFavoriteParticipants(filter);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Nb elements : " + count);
+ }
+ return count;
}
@Override
public Class<?> getRowType() {
- return PollAccount.class;
+ return FavoriteParticipant.class;
}
}
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-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -22,13 +22,16 @@
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.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
import org.chorem.pollen.entity.FavoriteList;
-import org.chorem.pollen.service.ServiceUser;
+import org.chorem.pollen.service.ServiceFavorite;
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.GenericSelectModel;
import org.chorem.pollen.ui.data.PollenRequiresAuthentication;
/**
@@ -41,276 +44,67 @@
* @version $Id$
*/
@PollenRequiresAuthentication
-@IncludeStylesheet("context:css/lists.css")
+@IncludeStylesheet("context:css/users.css")
public class UserLists extends AbstractPollenPage {
@InjectComponent
private Border border;
+ @Override
+ public Border getBorder() {
+ return border;
+ }
+
/** Page title from Messages **/
@Parameter(defaultPrefix = BindingConstants.MESSAGE,
value = "pollen.page.UserLists.title")
@Property
private String title;
+ public AddressBar getAddressBar() {
+ return AddressBar.newBar().appendCurrent(title);
+ }
+
@Inject
- private ServiceUser serviceUser;
+ private ServiceFavorite serviceFavorite;
+ @Inject
+ private PropertyAccess propertyAccess;
+
private List<FavoriteList> favoriteLists;
+ private GenericSelectModel<FavoriteList> favoriteListModel;
- @Override
- public Border getBorder() {
- return border;
+ @Persist
+ @Property
+ private FavoriteList favoriteListSelected;
+
+ public GenericSelectModel<FavoriteList> getFavoriteListModel() {
+ if (favoriteListModel == null) {
+ favoriteListModel =
+ new GenericSelectModel<FavoriteList>(getFavoriteLists(),
+ FavoriteList.class,
+ FavoriteList.NAME,
+ FavoriteList.NAME,
+ propertyAccess);
+ }
+ return favoriteListModel;
}
-
- public AddressBar getAddressBar() {
- return AddressBar.newBar().appendCurrent(title);
- }
public List<FavoriteList> getFavoriteLists() {
if (favoriteLists == null) {
- favoriteLists = serviceUser.getFavoriteLists(getUserConnected());
+ favoriteLists = serviceFavorite.getFavoriteLists(getUserConnected());
}
return favoriteLists;
}
-
-//
-// /**
-// * Liste de favoris sélectionnée.
-// */
-// @Persist
-// @Property
-// private PersonListDTO selectedList;
+ public boolean canDeleteList() {
+ return favoriteListSelected != null;
+ }
-// /**
-// * Nouvelle liste de favoris.
-// */
-// @Property
-// private PersonListDTO newList;
-//
-// /**
-// * Compte courant (pour l'itération des votants de la liste).
-// */
-// @SuppressWarnings("unused")
-// @Property
-// private PollAccountDTO account;
-//
-// /**
-// * Nouveau compte.
-// */
-// @Property
-// private PollAccountDTO newAccount;
-//
-// /**
-// * Fichier CSV contenant une liste de votants.
-// */
-// @Property
-// private UploadedFile accountsFile;
-//
-// /**
-// * URL de recherche LDAP pour une liste de votants.
-// */
-// @Property
-// private String accountsUrl;
-//
-// /**
-// * Zone à rafraîchir.
-// */
-// @InjectComponent
-// private Zone listsZone;
-//
-// /**
-// * Formulaire de création de liste.
-// */
-// @Component
-// private Form createListForm;
-//
-// /**
-// * Formulaire de création de compte.
-// */
-// @Component
-// private Form createAccountForm;
-//
-// /**
-// * Messages.
-// */
-// @Inject
-// private Messages messages;
-//
-// /**
-// * Objet servant à changer la couleur à chaque ligne de la liste.
-// */
-// @SuppressWarnings("unused")
-//
-// @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title")
-// @Property
-// private String title;
-//
-// @SuppressWarnings("unused")
-// @Property
-// private AddressBarItem[] address;
-//
-// /**
-// * Sert à créer listModel.
-// */
-// @Inject
-// private BeanModelSource beanModelSource;
-//
-// /**
-// * Sert à passer les messages en paramètre de la création de listModel.
-// */
-// @Inject
-// private ComponentResources componentResources;
-//
-// /**
-// * Modèle pour l'affichage de la liste des favoris.
-// */
-// @SuppressWarnings("unchecked")
-// @Property
-// @Retain
-// private BeanModel listModel;
-//
-// /** Injection des services */
-// @Inject
-// private ServiceList serviceList;
-// @Inject
-// private ServicePollAccount servicePollAccount;
-//
-// /**
-// * Méthode appelée à la création d'une liste.
-// */
-// Object onSuccessFromCreateListForm() {
-//
-// // Contrôle du nom de la liste
-// for (PersonListDTO list : lists) {
-// if (list.getName().equals(newList.getName())) {
-// createListForm.recordError(messages.format("listExists",
-// newList.getName()));
-// return this;
-// }
-// }
-//
-// // Import CVS des comptes
-// if (accountsFile != null) {
-// if (!accountsFile.getContentType().equals("text/csv")) {
-// createListForm.recordError(messages.format("invalidCsv",
-// accountsFile.getFileName()));
-// return this;
-// }
-// List<PollAccountDTO> accounts = CSVAccountUtil
-// .importList(accountsFile);
-// if (accounts.size() == 0) {
-// createListForm.recordError(messages.format("noAccountCsv",
-// accountsFile.getFileName()));
-// return this;
-// }
-// newList.getPollAccounts().addAll(accounts);
-// }
-//
-// // Import LDAP des comptes
-// if (accountsUrl != null) {
-// List<PollAccountDTO> accounts = LDAPAccountUtil
-// .importList(accountsUrl);
-// if (accounts.size() == 0) {
-// createListForm.recordError(messages.format("noAccountLdap",
-// accountsUrl));
-// return this;
-// }
-// newList.getPollAccounts().addAll(accounts);
-// }
-//
-// // Création de la nouvelle liste
-// newList.setUserId(user.getId());
-// newList.setId(serviceList.createPersonList(newList));
-//
-// // Sélection de la liste courante
-// lists = serviceList.findPersonListByUser(user.getId());
-// for (PersonListDTO list : lists) {
-// if (list.getId().equals(newList.getId())) {
-// selectedList = list;
-// }
-// }
-//
-// return this;
-// }
-//
-// /**
-// * Méthode appelée à la suppression d'une liste.
-// */
-// Object onActionFromDeleteList() {
-// if (selectedList != null) {
-// for (PersonListDTO dto : lists) {
-// if (dto.getId().equals(selectedList.getId())) {
-// if (serviceList.deletePersonList(selectedList.getId())) {
-// feedback.addInfo(messages.format("listDeleted",
-// selectedList.getName()));
-// } else {
-// feedback.addError(messages.format("listNotDeleted",
-// selectedList.getName()));
-// }
-// }
-// }
-// }
-// selectedList = null;
-// return this;
-// }
-//
-// /**
-// * Méthode appelée à la création d'un compte.
-// */
-// Object onSuccessFromCreateAccountForm() {
-// // TODO : use onValidateForm method : test return block, may be
-// // a problem between failure and success
-// for (PollAccountDTO dto : selectedList.getPollAccounts()) {
-// if (dto.getVotingId().equals(newAccount.getVotingId())) {
-// createAccountForm.recordError(messages.format("accountExists",
-// newAccount.getVotingId()));
-// }
-// }
-// if (!createAccountForm.getHasErrors()) {
-//// newAccount.setPersonListId(selectedList.getId());
-//// selectedList.getPollAccounts().add(newAccount);
-//// serviceList.updatePersonList(selectedList);
-//// selectedList = serviceList.findPersonListById(selectedList.getId());
-// serviceList.createAccountInPersonList(selectedList, account);
-// }
-// return listsZone.getBody();
-// }
-//
-// /**
-// * Méthode appelée à la suppression d'un compte.
-// */
-// Object onActionFromDeleteAccount(String accountId) {
-//// Iterator<PollAccountDTO> it = selectedList.getPollAccounts()
-//// .iterator();
-//// while (it.hasNext()) {
-//// if (accountId.equals(it.next().getId())) {
-//// it.remove();
-//// }
-//// }
-//// serviceList.updatePersonList(selectedList);
-//// servicePollAccount.deletePollAccount(accountId);
-//// selectedList = serviceList.findPersonListById(selectedList.getId());
-// serviceList.deleteAccountFromPersonList(selectedList, accountId);
-// return listsZone.getBody();
-// }
-//
-// /**
-// * Récupération des exceptions du champs d'upload de fichier.
-// */
-// Object onUploadException(FileUploadException ex) {
-// createListForm.recordError("Upload exception: " + ex.getMessage());
-// return this;
-// }
-//
-// /** Retourne vrai s'il n'existe aucune liste */
-// public boolean isListsNull() {
-// return CollectionUtils.isEmpty(lists);
-// }
-//
-// /** Retourne vrai si la liste sélectionnée est vide */
-// public boolean isSelectedListNull() {
-// return selectedList == null;
-// }
+ void onActionFromDeleteList() {
+ if (canDeleteList()) {
+ serviceFavorite.deleteFavoriteList(favoriteListSelected);
+ addInfo("Suppression OK");
+ }
+ }
}
\ No newline at end of file
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-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -100,7 +100,7 @@
/**
* UserAccount for form edition
*/
- private UserAccount userEditable;
+ private UserAccount user;
@Inject
private Locale currentLocale;
@@ -123,11 +123,11 @@
@Property
private String passwordVerify;
- public UserAccount getUserEditable() {
- if (userEditable == null) {
- userEditable = getUserConnected();
+ public UserAccount getUser() {
+ if (user == null) {
+ user = getUserConnected();
}
- return userEditable;
+ return user;
}
/**
@@ -141,7 +141,7 @@
@Log
void onValidateFormFromAccountForm() {
// Check newPassword that must be equals to passwordVerify
- String newPassword = userEditable.getNewPassword();
+ String newPassword = user.getNewPassword();
if (StringUtils.isNotEmpty(newPassword) &&
!newPassword.equals(passwordVerify)) {
accountForm.recordError(newPasswordField,
@@ -152,12 +152,12 @@
try {
// Update the user
if (logger.isDebugEnabled()) {
- logger.debug("TopiaId : " + userEditable.getTopiaId());
- logger.debug("Login : " + userEditable.getLogin());
- logger.debug("Password : " + userEditable.getPassword());
- logger.debug("NewPassword : " + userEditable.getNewPassword());
+ logger.debug("TopiaId : " + user.getTopiaId());
+ logger.debug("Login : " + user.getLogin());
+// logger.debug("Password : " + user.getPassword());
+// logger.debug("NewPassword : " + user.getNewPassword());
}
- serviceUser.updateUser(userEditable, false);
+ serviceUser.updateUser(user, false);
} catch (PollenBusinessException eee) {
String message = manager.getErrorMessage(eee, messages, logger);
switch (eee.getType()) {
@@ -181,7 +181,7 @@
// Stay in edited mode to show errors
edited = true;
// Reset new password
- userEditable.setNewPassword(null);
+ user.setNewPassword(null);
return accountForm;
}
}
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-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-06 10:35:53 UTC (rev 2987)
@@ -29,12 +29,13 @@
import org.apache.tapestry5.services.ApplicationStateCreator;
import org.apache.tapestry5.services.ApplicationStateManager;
import org.apache.tapestry5.services.ComponentRequestFilter;
-import org.apache.tapestry5.services.LibraryMapping;
import org.apache.tapestry5.upload.services.UploadSymbols;
import org.chorem.pollen.PollenContextImpl;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.service.ServiceEmail;
import org.chorem.pollen.service.ServiceEmailImpl;
+import org.chorem.pollen.service.ServiceFavorite;
+import org.chorem.pollen.service.ServiceFavoriteImpl;
import org.chorem.pollen.service.ServicePoll;
import org.chorem.pollen.service.ServicePollImpl;
import org.chorem.pollen.service.ServiceUser;
@@ -74,6 +75,12 @@
return service;
}
+ public static ServiceFavorite buildServiceFavorite(PollenManager manager) {
+ ServiceFavoriteImpl service = new ServiceFavoriteImpl();
+ service.setContext(manager.getContext());
+ return service;
+ }
+
public static ServicePoll buildServicePoll(PollenManager manager) {
ServicePollImpl service = new ServicePollImpl();
service.setContext(manager.getContext());
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-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-06 10:35:53 UTC (rev 2987)
@@ -26,17 +26,26 @@
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.emailFailedShowPassword=Le mot de passe g\u00E9n\u00E9r\u00E9 est le suivant : %1$s
pollen.ui.user.create.success=L'utilisateur %1$s a \u00E9t\u00E9 cr\u00E9\u00E9 avec succ\u00E8s.
-pollen.ui.user.nbUsers=%1$d utilisateurs existants.
-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.nbUsers=%1$d utilisateurs existants
+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 ?
pollen.ui.list.create.title=Cr\u00E9er une nouvelle liste
pollen.ui.list.create.success=La liste %1$s a \u00E9t\u00E9 cr\u00E9\u00E9e avec succ\u00E8s.
-pollen.ui.list.update.notSelected=Aucune liste s\u00E9lectionn\u00E9e.
-pollen.ui.list.update.emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email.
-pollen.ui.list.update.addParticipant=Ajouter un nouvel utilisateur \u00E0 la liste
+pollen.ui.list.create.weightHelp=Ce chiffre correspond au poids du vote de la personne, c'est \u00E0 dire le nombre de voix que poss\u00E8de la personne dans le sondage.
+pollen.ui.list.update.addParticipant=Ajouter un nouveau votant \u00E0 la liste
+pollen.ui.list.delete=Supprimer la liste %1$s
+pollen.ui.list.delete.confirmMessage=Etes-vous s\u00FBr de vouloir d\u00E9finitivement supprimer cette liste et l'int\u00E9gralit\u00E9 de ses votants ?
+pollen.ui.list.notSelected=Aucune liste s\u00E9lectionn\u00E9e
+pollen.ui.list.emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email.
+pollen.ui.list.nbParticipants=%1$d votants contenus dans cette liste
+pollen.ui.list.update.cancelEdition=Annuler les changements
+pollen.ui.list.update.saveParticipant=Enregistrer les modifications
+pollen.ui.list.update.updateParticipant=Modifier ce votant
+pollen.ui.list.update.removeParticipant=Supprimer ce votant
+pollen.ui.list.update.removeParticipant.confirmMessage=Etes-vous s\u00FBr de vouloir supprimer %1$s de la liste ?
# OLD LOGIN_COMPONENT
connectionLegend=Connexion
@@ -59,6 +68,9 @@
listSelect-label= Liste
listName-label= Nom
name-label= Nom
+weight-label=Poids
+editEmail-regexp=^([a-zA-Z0-9_.+-])+(a)(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$
+editEmail-regexp-message=Adresse email invalide.
############################ CHOICE ############################################
pollen.ui.choice.delete.confirm=Etes-vous s\u00FBr de vouloir d\u00E9finitivement supprimer ce choix ?
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-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml 2010-05-06 10:35:53 UTC (rev 2987)
@@ -156,9 +156,9 @@
<!-- Contenu -->
<div id="${pageBodyId}" class="content">
<noscript>
- <t:feedback t:id="errorJs" />
+ <div t:type="nuiton/feedback" t:id="errorJs" />
</noscript>
- <t:feedback t:id="borderFeedback" t:autoClear="false"/>
+ <div t:type="nuiton/feedback" t:id="borderFeedback" t:autoClear="false"/>
<t:body />
</div>
</div>
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsCreate.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsCreate.tml 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsCreate.tml 2010-05-06 10:35:53 UTC (rev 2987)
@@ -1,34 +1,32 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<body xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
<t:zone t:id="createZone" t:update="show">
- <form t:type="form" t:id="createList" action="tapestry" t:zone="createZone">
- <div id="createListFormDiv">
- <t:errors/>
- <fieldset>
- <legend>${message:pollen.ui.list.create.title}</legend>
- <div>
- <label t:type="label" for="listName" />* :
- <input t:type="textfield" t:id="listName" value="newFavoriteList.name" t:validate="required"/>
- </div>
- <!-- <div>
- <t:label for="accountsFile" />
- <input t:type="upload" t:id="accountsFile" />
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:accountsFile-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- </div>
- <div>
- <t:label for="accountsUrl" />
- <t:textfield t:id="accountsUrl" t:value="accountsUrl" />
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:accountsUrl-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- </div>-->
- <div class="buttons">
- <input t:type="submit" value="${message:pollen.ui.button.create}"/>
- </div>
- </fieldset>
- </div>
+ <form t:type="form" class="createList" t:id="createList" action="tapestry" t:zone="createZone">
+ <t:errors/>
+ <fieldset class="create">
+ <legend>${message:pollen.ui.list.create.title}</legend>
+ <div>
+ <label t:type="label" for="listName" />* :
+ <input t:type="textfield" t:id="listName" value="newFavoriteList.name" t:validate="required"/>
+ </div>
+ <!-- <div>
+ <t:label for="accountsFile" />
+ <input t:type="upload" t:id="accountsFile" />
+ <span t:type="ck/Tooltip" title="${message:help}" value="${message:accountsFile-help}" effect="appear">
+ <img src="${asset:context:img/help.png}" alt="${message:help}"/>
+ </span>
+ </div>
+ <div>
+ <t:label for="accountsUrl" />
+ <t:textfield t:id="accountsUrl" t:value="accountsUrl" />
+ <span t:type="ck/Tooltip" title="${message:help}" value="${message:accountsUrl-help}" effect="appear">
+ <img src="${asset:context:img/help.png}" alt="${message:help}"/>
+ </span>
+ </div>-->
+ <div class="buttons">
+ <input t:type="submit" value="${message:pollen.ui.button.create}"/>
+ </div>
+ </fieldset>
</form>
</t:zone>
</body>
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-05-06 10:35:53 UTC (rev 2987)
@@ -1,34 +1,86 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<body xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
- <form t:type="form" t:id="selectListForm" action="tapestry">
- <div>
- ${message:listSelect-label}:
- <select t:id="listSelect" t:type="ck/beanSelect" t:list="source" t:value="favoriteListSelected"
- t:labelField="literal:name" t:valueField="literal:name" />
- <input t:type="submit" value="${message:pollen.ui.button.ok}"/>
- </div>
- </form>
-
<t:if test="canDisplayAccounts()">
- <t:zone t:id="updateZone" show="show" update="show">
- <!-- Display all Accounts child of favoriteListSelected -->
- <div t:type="grid" t:source="participants" t:row="participant"
- t:include="name, email, weight" t:add="actions"
- t:rowsPerPage="20" t:rowClass="prop:evenodd.next" t:inPlace="true">
- <p:actionsCell>
- <a t:type="actionlink" t:id="removeParticipant" t:context="participant.id">
- <img src="${asset:context:img/delete.png}" alt="${message:pollen.ui.list.remove}"/>
- </a>
- </p:actionsCell>
- <p:empty>
- ${message:pollen.ui.list.update.emptyList}
- </p:empty>
- </div>
+ <div t:type="zone" class="updateZone" t:id="updateZone" t:update="show">
+ <p class="center">
+ <t:if t:test="participants.availableRows">
+ ${format:pollen.ui.list.nbParticipants=participants.availableRows}
+ <p:else>
+ ${message:pollen.ui.list.emptyList}
+ </p:else>
+ </t:if>
+ </p>
+ <form t:type="form" t:id="participantsForm" action="tapestry" t:zone="updateZone">
+ <t:errors />
+ <p><input t:type="hidden" value="participantEditedId" /></p>
+ <!-- Display all Accounts child of favoriteList -->
+ <div t:type="grid" t:source="participants" t:row="participant"
+ t:include="name, email, weight" t:add="actions"
+ t:rowsPerPage="10" t:rowClass="prop:evenodd.next" t:inPlace="true">
+ <p:nameCell>
+ <t:if t:test="editionMode">
+ <input t:type="textfield" t:id="editName" value="participantEdited.name" t:validate="required" size="10" />
+ <p:else>${participant.name}</p:else>
+ </t:if>
+ </p:nameCell>
+ <p:emailCell>
+ <t:if t:test="editionMode">
+ <input t:type="textfield" t:id="editEmail" value="participantEdited.email" t:validate="regexp" size="15" />
+ <p:else>${participant.email}</p:else>
+ </t:if>
+ </p:emailCell>
+ <p:weightCell>
+ <t:if t:test="editionMode">
+ <input t:type="textfield" t:id="editWeight" value="participantEdited.weight" t:validate="required" size="1" />
+ <p:else>${participant.weight}</p:else>
+ </t:if>
+ </p:weightCell>
+ <p:actionsCell>
+ <t:if t:test="editionMode">
+ <a t:type="actionlink" t:id="cancelEdition" title="${message:pollen.ui.list.update.cancelEdition}" t:zone="updateZone">
+ <img src="${asset:context:img/undo.png}" alt="${message:pollen.ui.list.update.cancelEdition}" />
+ </a>
+ <input t:type="submit" t:id="saveParticipant" t:image="context:img/save.png" value="Save"
+ title="${message:pollen.ui.list.update.saveParticipant}" />
+ <p:else>
+ <a t:type="actionlink" t:id="editParticipant" t:context="participant.id" t:zone="updateZone"
+ title="${message:pollen.ui.list.update.updateParticipant}">
+ <img src="${asset:context:img/editSmall.png}" alt="${message:pollen.ui.list.update.updateParticipant}" />
+ </a>
+ <a t:type="actionlink" t:id="removeParticipant" t:context="participant.id" t:zone="updateZone"
+ title="${message:pollen.ui.list.update.removeParticipant}"
+ t:mixins="nuiton/confirm" t:message="format:pollen.ui.list.update.removeParticipant.confirmMessage=participant.name">
+ <img src="${asset:context:img/delete.png}" alt="${message:pollen.ui.list.update.removeParticipant}" />
+ </a>
+ </p:else>
+ </t:if>
+ </p:actionsCell>
+ <p:empty />
+ </div>
+ </form>
+
+ <div t:type="nuiton/feedback" t:id="participantsFeedback" />
- <!-- Add a new FavoriteParticipant to favoriteListSelected -->
- <form t:type="form" t:id="addParticipant" t:zone="updateZone" action="tapestry">
- <table class="t-data-grid">
+ <!-- Add a new FavoriteParticipant to favoriteList -->
+ <form t:type="form" class="addParticipant" t:id="addParticipant" t:zone="updateZone" action="tapestry">
+ <fieldset class="create">
+ <legend>${message:pollen.ui.list.update.addParticipant}</legend>
+ <t:errors/>
+ <div>
+ <label t:type="label" for="name" />* :
+ <input t:type="textfield" t:id="name" t:value="newParticipant.name" t:validate="required" size="10"/>
+ <label t:type="label" for="email" /> :
+ <input t:type="textfield" t:id="email" t:value="newParticipant.email" t:validate="regexp" size="15"/>
+ <label t:type="label" for="weight" /> :
+ <input t:type="textfield" t:id="weight" t:value="newParticipant.weight" t:validate="required" size="1"/>
+ <span t:type="ck/Tooltip" t:title="message:pollen.ui.tooltip.help" t:value="message:pollen.ui.list.create.weightHelp" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="${message:pollen.ui.tooltip.help}"/>
+ </span>
+ <input t:type="submit" value="${message:pollen.ui.button.add}" title="${message:pollen.ui.list.update.addParticipant}"/>
+ </div>
+ </fieldset>
+ <!--<table class="t-data-grid">
<tr>
<td class="votingId">
<input t:type="textfield" t:id="name" t:value="newParticipant.name" t:validate="required" size="10"/>
@@ -43,8 +95,7 @@
<input t:type="submit" value="${message:pollen.ui.button.add}" title="${message:pollen.ui.list.update.addParticipant}"/>
</td>
</tr>
- </table>
- <t:errors/>
+ </table>-->
</form>
<!-- Delete the favoriteListSelected -->
@@ -54,10 +105,10 @@
</a>
</p>-->
- </t:zone>
+ </div>
<p:else>
- ${message:pollen.ui.list.update.notSelected}
+ <p class="center">${message:pollen.ui.list.notSelected}</p>
</p:else>
</t:if>
</body>
Modified: trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml 2010-05-06 10:35:53 UTC (rev 2987)
@@ -71,8 +71,8 @@
<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" />
- <span t:type="ck/Tooltip" title="message:pollen.ui.tooltip.help" t:value="message:pollen.ui.user.create.passwordHelp" t:effect="appear">
- <img src="${asset:context:img/help.png}" alt="message:help"/>
+ <span t:type="ck/Tooltip" t:title="message:pollen.ui.tooltip.help" t:value="message:pollen.ui.user.create.passwordHelp" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="${message:pollen.ui.tooltip.help}"/>
</span>
<input t:type="submit" value="${message:pollen.ui.button.add}" title="${message:pollen.ui.user.create.title}" />
</p>
Modified: trunk/pollen-ui/src/main/webapp/css/common.css
===================================================================
--- trunk/pollen-ui/src/main/webapp/css/common.css 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/webapp/css/common.css 2010-05-06 10:35:53 UTC (rev 2987)
@@ -34,31 +34,6 @@
display: block;
}
-/** feedback.css not worked yet in nuiton-tapestry-extra **/
-.fb-error {
- width: 400px;
- margin: auto;
- text-align: center;
- color: #000;
- font-weight: bold;
- padding: 3px;
- border: solid;
- border-color: #f00;
- border-width: 2px;
- margin-bottom: 10px;
-}
-
-.fb-info {
- width: 400px;
- margin: auto;
- text-align: center;
- color: #000;
- padding: 3px;
- border: solid;
- border-color: #000;
- border-width: 2px;
-}
-
.center {
text-align: center;
}
@@ -76,3 +51,7 @@
background: url(../img/save.png) no-repeat center center;
}
+.mbottom5 {
+ margin-bottom: 5px;
+}
+
Deleted: trunk/pollen-ui/src/main/webapp/css/lists.css
===================================================================
--- trunk/pollen-ui/src/main/webapp/css/lists.css 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/webapp/css/lists.css 2010-05-06 10:35:53 UTC (rev 2987)
@@ -1,122 +0,0 @@
-#listsZone {
- width: 970px;
- margin: auto;
- text-align: center;
- margin-bottom: 40px;
-}
-
-#createListFormDiv {
- width: 450px;
- margin: auto;
-}
-
-#createListFormDiv legend {
- color: #727a7e;
- font-weight: bold;
-}
-
-#createListFormDiv fieldset {
- width: 380px;
- border: 1px solid #aab;
- padding: 15px;
- padding-bottom: 10px;
- margin: auto;
- vertical-align: top;
- text-align: left;
-}
-
-/*#createListFormDiv label {
- display: block;
- width: 80px;
- float: left;
-}*/
-
-#createListForm div {
- margin-bottom: 10px;
-}
-
-.buttons {
- text-align: center;
- margin-top: 20px;
-}
-
-DIV.t-data-grid {
- font-family: Arial, Helvetica, sans-serif;
- margin-top:20px;
- margin-bottom:20px;
-}
-
-DIV.t-data-grid-pager {
- margin: 8px 0px;
-}
-
-DIV.t-data-grid-pager A, DIV.t-data-grid-pager SPAN.current {
- text-decoration: none;
- padding: 2px 5px;
- font-size: 14px;
- margin-right: 5px;
-}
-
-DIV.t-data-grid-pager A {
- background-color: #32b5c9;
- border: 1px solid #aab;
- color: #fff;
-}
-
-DIV.t-data-grid-pager A:hover {
- border: 1px solid #000;
- color: #000;
-}
-
-DIV.t-data-grid-pager SPAN.current {
- color: #fff;
- border: 1px solid #32b5c9;
- background-color: #000;
-}
-
-TABLE.t-data-grid {
- border-collapse: collapse;
- border-left: 1px solid #aab;
- border-top: 1px solid #aab;
- background-color: #fff;
- font-size: 14px;
- margin: auto;
- width: 400px;
-}
-
-TABLE.t-data-grid THEAD {
- border-top: 1px solid #aab; /* For Firefox */
-}
-
-TABLE.t-data-grid THEAD TR {
- color: #fff;
- background-color: #32b5c9;
-}
-
-TABLE.t-data-grid THEAD TR a {
- color: #fff;
- background-color: #32b5c9;
-}
-
-TABLE.t-data-grid THEAD TR TH {
- text-align: left;
- padding: 2px 3px;
- white-space: nowrap;
- border-right: 1px solid #aab;
- border-bottom: 1px solid #aab;
- background-color:#32b5c9;
-}
-
-TABLE.t-data-grid TBODY TR {
- background-color: #fff;
-}
-
-TABLE.t-data-grid TBODY TR.odd {
- background-color: #bce7ed;
-}
-
-TABLE.t-data-grid TBODY TR TD {
- border-right: 1px solid #aab;
- border-bottom: 1px solid #aab;
- padding: 2px 5px;
-}
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/webapp/css/main.css
===================================================================
--- trunk/pollen-ui/src/main/webapp/css/main.css 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/webapp/css/main.css 2010-05-06 10:35:53 UTC (rev 2987)
@@ -1,13 +1,13 @@
body {
- background-color: #FFF;
- background-repeat: no-repeat;
- background-position: bottom right;
- background-attachment: fixed;
- border: none;
- font-family: "Trebuchet MS", Arial, sans-serif;
- font-size: small;
- width: 1000px;
- margin: auto;
+ background-color: #FFF;
+ background-repeat: no-repeat;
+ background-position: bottom right;
+ background-attachment: fixed;
+ border: none;
+ font-family: "Trebuchet MS", Arial, sans-serif;
+ font-size: small;
+ width: 1000px;
+ margin: auto;
}
#CreationBody {
@@ -23,17 +23,17 @@
}
body a {
- color: #727a7e;
+ color: #727a7e;
}
body a img {
- border: none;
+ border: none;
}
body ul {
- list-style-type: none;
- margin: 0px;
- padding: 0px;
+ list-style-type: none;
+ margin: 0px;
+ padding: 0px;
}
/*Haut de page*/
@@ -62,31 +62,31 @@
}
#po-header-connection {
- float: right;
- vertical-align: top;
- position: relative;
- margin-right: 10px;
- text-align: right;
+ float: right;
+ vertical-align: top;
+ position: relative;
+ margin-right: 10px;
+ text-align: right;
}
#po-header-connection form {
- margin: 0px;
- padding: 0px;
- width: 200px;
+ margin: 0px;
+ padding: 0px;
+ width: 200px;
}
#po-header-connection a,
#po-header-connection span {
- padding: 1px;
- padding-left: 5px;
- padding-right: 5px;
- text-decoration: none;
- cursor: pointer;
+ padding: 1px;
+ padding-left: 5px;
+ padding-right: 5px;
+ text-decoration: none;
+ cursor: pointer;
}
#po-header-connection a:hover,
#po-header-connection span:hover {
- -moz-border-radius: 10px;
+ -moz-border-radius: 10px;
background-color: #000;
color: #fff;
}
@@ -112,80 +112,80 @@
}
#top {
- padding: 7px;
- text-align: left;
- vertical-align: middle;
+ padding: 7px;
+ text-align: left;
+ vertical-align: middle;
}
#top a {
- color: #000;
- text-decoration: none;
+ color: #000;
+ text-decoration: none;
}
#menu {
- display: inline;
+ display: inline;
}
#menu li {
- cursor: pointer;
+ cursor: pointer;
}
#menu li a {
- padding: 1px;
- padding-left: 5px;
- padding-right: 5px;
+ padding: 1px;
+ padding-left: 5px;
+ padding-right: 5px;
}
#menu li a:hover {
- -moz-border-radius: 10px;
- background-color: #000;
- color: #fff;
+ -moz-border-radius: 10px;
+ background-color: #000;
+ color: #fff;
}
.menu_elt {
- display: inline;
- margin-right: 40px;
- position: relative;
+ display: inline;
+ margin-right: 40px;
+ position: relative;
}
/** DROPDOWN MENU **/
.dropdown_menu {
- padding-top: 9px;
- position: absolute;
- z-index: 20;
+ padding-top: 9px;
+ position: absolute;
+ z-index: 20;
}
.dropdown_menu .top_leftIndex {
- height: 16px;
- width: 16px;
- border: none;
- background-image: url("../img/topleft_menuIndex.png");
- background-repeat: no-repeat;
- background-position: left;
- float: left;
+ height: 16px;
+ width: 16px;
+ border: none;
+ background-image: url("../img/topleft_menuIndex.png");
+ background-repeat: no-repeat;
+ background-position: left;
+ float: left;
}
.dropdown_menu .top_rightIndex {
- height: 16px;
- width: 16px;
- border: none;
- background-image: url("../img/topright_menuIndex.png");
- background-repeat: no-repeat;
- background-position: right;
- float: right;
+ height: 16px;
+ width: 16px;
+ border: none;
+ background-image: url("../img/topright_menuIndex.png");
+ background-repeat: no-repeat;
+ background-position: right;
+ float: right;
}
.dropdown_menu .top_middleIndex {
- margin: 15px;
- margin-bottom: 0px;
- margin-top: 0px;
- background-color: #ff0;
- border-top: none;
- -moz-border-radius-bottomright: 15px;
- -moz-border-radius-bottomleft: 15px;
- padding: 10px;
- padding-top: 0px;
- min-width: 140px;
+ margin: 15px;
+ margin-bottom: 0px;
+ margin-top: 0px;
+ background-color: #ff0;
+ border-top: none;
+ -moz-border-radius-bottomright: 15px;
+ -moz-border-radius-bottomleft: 15px;
+ padding: 10px;
+ padding-top: 0px;
+ min-width: 140px;
}
.dropdown_menu .top_leftCreation {
@@ -288,10 +288,10 @@
}
.dropdown_menu li {
- z-index: 25;
- padding: 3px;
- display: block;
- letter-spacing: 0px;
+ z-index: 25;
+ padding: 3px;
+ display: block;
+ letter-spacing: 0px;
}
#menu1 {
@@ -305,29 +305,29 @@
}
#login_menu {
- top: 12px;
- right: -10px;
+ top: 12px;
+ right: -10px;
}
#compte_menu {
- top: 12px;
- right: -25px;
+ top: 12px;
+ right: -25px;
}
HTML>BODY DIV.t-error LI {
- margin-left: 0px;
+ margin-left: 10px;
}
/* Le corps de la page */
#corps {
- text-align: justify;
- color: #000;
- border: none;
- min-height: 300px;
+ text-align: justify;
+ color: #000;
+ border: none;
+ min-height: 300px;
}
#corps h1,h2,h3,h4 {
- text-align: center;
+ text-align: center;
}
#corps .titleIndex {
@@ -353,16 +353,16 @@
}
#corps h2 {
- color: #727a7e;
+ color: #727a7e;
}
#po-header-addressBar {
- padding: 5px;
- margin-left: 350px;
+ padding: 5px;
+ margin-left: 350px;
}
.IndexAddress {
- background-color: #ffffaa;
+ background-color: #ffffaa;
}
.CreationAddress {
@@ -370,7 +370,7 @@
}
.VoteAddress {
- background-color: #b0f580;
+ background-color: #b0f580;
}
.VoteCountingAddress {
@@ -378,20 +378,20 @@
}
.content {
- padding: 15px;
+ padding: 15px;
}
/* Pied de page */
#po-footer {
- padding: 5px;
- font-size: small;
- text-align: center;
- margin-top: 20px;
+ padding: 5px;
+ font-size: small;
+ text-align: center;
+ margin-top: 20px;
}
#po-footer a,
#po-footer span {
- color:#727a7e;
+ color:#727a7e;
}
/** old LoginComponent > Connexion page **/
Added: trunk/pollen-ui/src/main/webapp/css/users.css
===================================================================
--- trunk/pollen-ui/src/main/webapp/css/users.css (rev 0)
+++ trunk/pollen-ui/src/main/webapp/css/users.css 2010-05-06 10:35:53 UTC (rev 2987)
@@ -0,0 +1,176 @@
+/*
+ Document : users
+ Created on : 5 mai 2010, 11:15:04
+ Author : fdesbois
+ Description:
+ Purpose of the stylesheet follows.
+*/
+
+/********************************************/
+/************** UserLists *****************/
+/********************************************/
+#p-userLists DIV.updateZone DIV.fb-info {
+ margin-bottom: 10px;
+}
+
+#p-userLists FIELDSET.create {
+ border: 1px solid #aab;
+ padding: 15px;
+ padding-bottom: 10px;
+ margin: auto;
+ vertical-align: top;
+ text-align: left;
+}
+
+#p-userLists FIELDSET.create LEGEND {
+ color: #727a7e;
+ font-weight: bold;
+}
+
+#p-userLists FORM.participantsForm DIV.t-error {
+ width: 600px;
+ margin: auto;
+}
+
+#p-userLists FORM.addParticipant FIELDSET {
+ width: 580px;
+ margin-bottom: 20px;
+}
+
+#p-userLists FORM.createList FIELDSET {
+ width: 450px;
+}
+
+/*#listsZone {
+ width: 970px;
+ margin: auto;
+ text-align: center;
+ margin-bottom: 40px;
+}*/
+
+.buttons {
+ text-align: center;
+ margin-top: 20px;
+}
+
+/*#createListFormDiv {
+ width: 450px;
+ margin: auto;
+}
+
+#createListFormDiv legend {
+ color: #727a7e;
+ font-weight: bold;
+}
+
+#createListFormDiv fieldset {
+ width: 380px;
+ border: 1px solid #aab;
+ padding: 15px;
+ padding-bottom: 10px;
+ margin: auto;
+ vertical-align: top;
+ text-align: left;
+}
+
+#createListForm div {
+ margin-bottom: 10px;
+}*/
+
+/*#createListFormDiv label {
+ display: block;
+ width: 80px;
+ float: left;
+}*/
+
+DIV.t-data-grid {
+ font-family: Arial, Helvetica, sans-serif;
+ margin-top:20px;
+ margin-bottom:20px;
+}
+
+DIV.t-data-grid-pager {
+ text-align: center;
+}
+
+DIV.t-data-grid-pager A, DIV.t-data-grid-pager SPAN.current {
+ text-decoration: none;
+ padding: 2px 5px;
+ font-size: 14px;
+ margin-right: 5px;
+}
+
+DIV.t-data-grid-pager A {
+ background-color: #32b5c9;
+ border: 1px solid #aab;
+ color: #fff;
+}
+
+DIV.t-data-grid-pager A:hover {
+ border: 1px solid #000;
+ color: #000;
+}
+
+DIV.t-data-grid-pager SPAN.current {
+ color: #fff;
+ border: 1px solid #32b5c9;
+ background-color: #000;
+}
+
+TABLE.t-data-grid {
+ border-collapse: collapse;
+ border-left: 1px solid #aab;
+ border-top: 1px solid #aab;
+ background-color: #fff;
+ font-size: 14px;
+ margin: auto;
+ width: 500px;
+}
+
+TABLE.t-data-grid THEAD {
+ border-top: 1px solid #aab; /* For Firefox */
+}
+
+TABLE.t-data-grid THEAD TR {
+ color: #fff;
+ background-color: #32b5c9;
+}
+
+TABLE.t-data-grid THEAD TR a {
+ color: #fff;
+ background-color: #32b5c9;
+}
+
+TABLE.t-data-grid THEAD TR TH {
+ text-align: left;
+ padding: 2px 3px;
+ white-space: nowrap;
+ border-right: 1px solid #aab;
+ border-bottom: 1px solid #aab;
+ background-color:#32b5c9;
+}
+
+TABLE.t-data-grid THEAD TR TH.weight {
+ width: 50px;
+}
+
+TABLE.t-data-grid THEAD TR TH.actions {
+ width: 50px;
+}
+
+TABLE.t-data-grid TBODY TR {
+ background-color: #fff;
+}
+
+TABLE.t-data-grid TBODY TR.odd {
+ background-color: #bce7ed;
+}
+
+TABLE.t-data-grid TBODY TR TD {
+ border-right: 1px solid #aab;
+ border-bottom: 1px solid #aab;
+ padding: 2px 5px;
+}
+
+
+
Property changes on: trunk/pollen-ui/src/main/webapp/css/users.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/webapp/user/UserLists.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/user/UserLists.tml 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/webapp/user/UserLists.tml 2010-05-06 10:35:53 UTC (rev 2987)
@@ -1,15 +1,25 @@
<!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:Creation" t:pageTitle="prop:title"
+<t:border t:addressBar="addressBar" t:pageLogo="literal:Creation" t:pageTitle="prop:title" t:pageBodyId="p-userLists"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
<h1 class="titleCreation">${title}</h1>
- <div id="listsDiv">
+ <t:if test="favoriteLists">
+ <form t:type="form" t:id="selectFavoriteList" action="tapestry">
+ <div class="center">
+ <label t:type="label" for="listSelect" /> :
+ <select t:type="select" t:id="listSelect" t:model="favoriteListModel" t:encoder="favoriteListModel"
+ t:value="favoriteListSelected" onChange="this.form.submit()" />
+ <t:if t:test="canDeleteList()">
+
+ <a t:type="actionlink" t:id="deleteList" title="${format:pollen.ui.list.delete=favoriteListSelected.name}"
+ t:mixins="nuiton/confirm" t:message="pollen.ui.list.delete.confirmMessage">
+ <img src="${asset:context:img/delete.png}" alt="${format:pollen.ui.list.delete=favoriteListSelected.name}" />
+ </a>
+ </t:if>
+ </div>
+ </form>
+ <t:userListsUpdate t:id="update" t:source="favoriteListSelected" />
+ </t:if>
- <t:if test="favoriteLists">
- <t:userListsUpdate t:source="favoriteLists" />
- </t:if>
-
- <t:userListsCreate />
-
- </div>
+ <t:userListsCreate />
</t:border>
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/webapp/user/UserProfile.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/user/UserProfile.tml 2010-05-04 16:24:31 UTC (rev 2986)
+++ trunk/pollen-ui/src/main/webapp/user/UserProfile.tml 2010-05-06 10:35:53 UTC (rev 2987)
@@ -1,98 +1,91 @@
<t:border t:addressBar="addressBar" t:pageLogo="literal:Creation"
- xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+ xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
<h1 class="titleCreation">${message:title}</h1>
- <t:if test="userExists">
-
- <t:zone t:id="accountZone" show="show" update="show">
- <t:form t:id="accountForm" zone="accountZone">
- <div id="myAccountFormDiv">
- <div id="myAccountError">
- <t:errors />
- </div>
- <FieldSet>
- <legend>${message:connectionInfoLegend}</legend>
- <div>
- <label>${message:login-label}</label>
- ${user.login}
- </div>
- <t:if test="edited">
- <div>
- <t:label for="password" />
- <t:PasswordField t:id="password" t:value="userEditable.password" t:validate="required,minlength=6" />
- </div>
- <div>
- <t:label for="newPassword1" />
- <t:PasswordField t:id="newPassword1" t:value="userEditable.newPassword" t:validate="minlength=6" />
- </div>
- <div>
- <t:label for="passwordVerify" />
- <t:PasswordField t:id="passwordVerify" t:value="passwordVerify" t:validate="minlength=6" />
- </div>
- </t:if>
- </FieldSet>
+ <t:zone t:id="accountZone" show="show" update="show">
+ <t:form t:id="accountForm" zone="accountZone">
+ <div id="myAccountFormDiv">
+ <div id="myAccountError">
+ <t:errors />
+ </div>
- <FieldSet>
- <legend>${message:userInfoLegend}</legend>
+ <FieldSet>
+ <legend>${message:connectionInfoLegend}</legend>
+ <div>
+ <label>${message:login-label}</label>
+ ${user.login}
+ </div>
+ <t:if test="edited">
<div>
- <t:label for="email" />
- <t:if test="edited">
- <t:TextField t:id="email" t:value="userEditable.email" t:validate="regexp" />
- <p:else>
- <t:if test="user.email">
- ${user.email}
- <p:else>-</p:else>
- </t:if>
- </p:else>
- </t:if>
+ <t:label for="password" />
+ <t:PasswordField t:id="password" t:value="user.password" t:validate="required,minlength=6" />
</div>
<div>
- <t:label for="firstName" />
- <t:if test="edited">
- <t:TextField t:id="firstName" t:value="userEditable.firstName" />
- <p:else>
- <t:if test="user.firstName">
- ${user.firstName}
- <p:else>-</p:else>
- </t:if>
- </p:else>
- </t:if>
+ <t:label for="newPassword1" />
+ <t:PasswordField t:id="newPassword1" t:value="user.newPassword" t:validate="minlength=6" />
</div>
<div>
- <t:label for="lastName" />
- <t:if test="edited">
- <t:TextField t:id="lastName" t:value="userEditable.lastName" />
- <p:else>
- <t:if test="user.lastName">
- ${user.lastName}
- <p:else>-</p:else>
- </t:if>
- </p:else>
- </t:if>
+ <t:label for="passwordVerify" />
+ <t:PasswordField t:id="passwordVerify" t:value="passwordVerify" t:validate="minlength=6" />
</div>
- </FieldSet>
+ </t:if>
+ </FieldSet>
- <div class="buttons">
+ <FieldSet>
+ <legend>${message:userInfoLegend}</legend>
+ <div>
+ <t:label for="email" />
<t:if test="edited">
- <input type="submit" value="${message:submit-label}" />
- <a t:type="pagelink" t:page="user/profile" style="text-decoration: none;">
- <input type="button" value="${message:cancel-action}" />
- </a>
+ <t:TextField t:id="email" t:value="user.email" t:validate="regexp" />
<p:else>
- <a t:type="actionlink" t:id="editAccount" style="text-decoration: none;">
- <input type="button" value="${message:edit-action}" />
- </a>
+ <t:if test="user.email">
+ ${user.email}
+ <p:else>-</p:else>
+ </t:if>
</p:else>
</t:if>
</div>
+ <div>
+ <t:label for="firstName" />
+ <t:if test="edited">
+ <t:TextField t:id="firstName" t:value="user.firstName" />
+ <p:else>
+ <t:if test="user.firstName">
+ ${user.firstName}
+ <p:else>-</p:else>
+ </t:if>
+ </p:else>
+ </t:if>
+ </div>
+ <div>
+ <t:label for="lastName" />
+ <t:if test="edited">
+ <t:TextField t:id="lastName" t:value="user.lastName" />
+ <p:else>
+ <t:if test="user.lastName">
+ ${user.lastName}
+ <p:else>-</p:else>
+ </t:if>
+ </p:else>
+ </t:if>
+ </div>
+ </FieldSet>
+
+ <div class="buttons">
+ <t:if test="edited">
+ <input type="submit" value="${message:submit-label}" />
+ <a t:type="pagelink" t:page="user/profile" style="text-decoration: none;">
+ <input type="button" value="${message:cancel-action}" />
+ </a>
+ <p:else>
+ <a t:type="actionlink" t:id="editAccount" style="text-decoration: none;">
+ <input type="button" value="${message:edit-action}" />
+ </a>
+ </p:else>
+ </t:if>
</div>
- </t:form>
- </t:zone>
-
- <p:else>
- <h4>${message:noUser}</h4>
- <t:LoginComponent />
- </p:else>
- </t:if>
+ </div>
+ </t:form>
+ </t:zone>
</t:border>
\ No newline at end of file
1
0
r2986 - in trunk/pollen-ui/src/main: java/org/chorem/pollen/ui/components java/org/chorem/pollen/ui/data java/org/chorem/pollen/ui/mixins java/org/chorem/pollen/ui/pages/admin java/org/chorem/pollen/ui/pages/poll java/org/chorem/pollen/ui/pages/user java/org/chorem/pollen/ui/services webapp/admin webapp/css webapp/js
by fdesbois@users.chorem.org 04 May '10
by fdesbois@users.chorem.org 04 May '10
04 May '10
Author: fdesbois
Date: 2010-05-04 18:24:31 +0200 (Tue, 04 May 2010)
New Revision: 2986
Url: http://chorem.org/repositories/revision/pollen/2986
Log:
Remove components moved in nuiton-tapestry-extra
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthenticationFilter.java
Removed:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.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/RequiresAuthentication.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/Confirm.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBinding.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBindingFactory.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java
trunk/pollen-ui/src/main/webapp/js/confirm.js
trunk/pollen-ui/src/main/webapp/js/zoneUpdater.js
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.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/java/org/chorem/pollen/ui/pages/poll/CloseValidation.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/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/UserProfile.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml
trunk/pollen-ui/src/main/webapp/css/common.css
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-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -41,6 +41,7 @@
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.pages.Index;
import org.chorem.pollen.ui.services.PollenManager;
+import org.nuiton.web.tapestry5.components.FeedBack;
import org.nuiton.web.tapestry5.services.ServiceAuthentication;
import org.slf4j.Logger;
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -1,151 +0,0 @@
-/* *##%
- * Pollen :: Pollen Web Interface
- * Copyright (C) 2009 - 2010 Code Lutin
- *
- * 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 Lesser 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>.
- * ##%*/
-
-package org.chorem.pollen.ui.components;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.MarkupWriter;
-import org.apache.tapestry5.annotations.Log;
-import org.apache.tapestry5.annotations.Parameter;
-import org.apache.tapestry5.ioc.annotations.Inject;
-
-/**
- * Composant qui affiche des messages à l'utilisateur.
- *
- * Ce composant permet d'afficher des messages avec une apparence différente
- * selon leur type (info ou erreur). Lors de l'affichage de la page, les
- * messages seront affichés et la collection de messages sera vidée.
- *
- * Pour personnaliser l'apparence des messages il faut définir les classes
- * fb-error et fb-info dans le CSS.
- *
- * <pre>
- * Utilisation :
- * <t:feedback t:id="feedback"/>
- * @Component(id = "feedback") private FeedBack feedback;
- * feedback.addInfo("message d'info");
- * feedback.addError("message d'erreur");
- * </pre>
- *
- * @author rannou
- * @version $Id$
- */
-public class FeedBack {
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL, value= "true")
- private boolean autoClear;
-
- /** Messages d'erreur */
- private List<String> errorMessages;
-
- /** Messages d'info */
- private List<String> infoMessages;
-
- private boolean errors;
-
- @Inject
- private ComponentResources resources;
-
- private boolean reload;
-
- public FeedBack() {
- errorMessages = new ArrayList<String>();
- infoMessages = new ArrayList<String>();
- }
-
- void beginRender(MarkupWriter writer) {
-
- // Rendu des messages d'erreur et vidage de la collection
- if (!errorMessages.isEmpty()) {
- errors = true;
- writer.element("div", "class", "fb-error");
- for (String message : errorMessages) {
- writer.write(message);
- writer.element("br");
- writer.end();
- }
- writer.end();
- }
- if (autoClear) {
- errorMessages.clear();
- }
-
- // Rendu des messages d'info et vidage de la collection
- if (!infoMessages.isEmpty()) {
- writer.element("div", "class", "fb-info");
- for (String message : infoMessages) {
- writer.write(message);
- writer.element("br");
- writer.end();
- }
- writer.end();
- }
- infoMessages.clear();
-
- resources.renderInformalParameters(writer);
- }
-
- void afterRender(MarkupWriter writer) {
-
- }
-
- /**
- * Ajout d'un message d'info.
- *
- * @param message le message
- */
- public void addInfo(String message) {
- if (!infoMessages.contains(message)) {
- infoMessages.add(message);
- }
- }
-
- /**
- * Ajout d'un message d'erreur.
- *
- * @param message le message
- */
- public void addError(String message) {
- if (!errorMessages.contains(message)) {
- errorMessages.add(message);
- }
- }
-
- public boolean hasErrors() {
- return errors;
- }
-
- @Log
- public void reload() {
- reload = true;
- }
-
- public boolean hasBeeanReloaded() {
- return reload;
- }
-
- public void clearErrors() {
- errorMessages.clear();
- reload = false;
- }
-}
Deleted: 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 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -1,127 +0,0 @@
-
-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;
-
-/**
- * AbstractMappedGridDataSource
- *
- * TODO : javadoc
- *
- * Created: 18 janv. 2010
- *
- * @param <K> Type of the map key
- * @param <E> Type of the map value
- * @author fdesbois <fdesbois(a)codelutin.com>
- */
-public abstract class AbstractMappedGridDataSource<K, E>
- 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 abstract Class<?> getRowType();
-
- protected abstract int count();
-
- protected abstract Map<K, E> execute(int startIndex, int endIndex,
- SortConstraint orderBy);
-
- @Override
- public int getAvailableRows() {
- if (nbRows < 0) {
- nbRows = count();
- if (log.isDebugEnabled()) {
- log.debug("Count : " + nbRows);
- }
- }
- return nbRows;
- }
-
- @Override
- public void prepare(int startIndex, int endIndex,
- List<SortConstraint> sortConstraints) {
- if (log.isDebugEnabled()) {
- log.debug("Prepare results : " + startIndex + ", " + endIndex);
- }
- nbRowsPerPage = endIndex - startIndex + 1;
- mapResults = execute(startIndex, endIndex,
- getSortConstraint(sortConstraints));
- listResults = new ArrayList<E>(mapResults.values());
- }
-
- @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);
- }
-
- public E get(K key) {
- return mapResults.get(key);
- }
-
- public List<E> values() {
- return listResults;
- }
-
- public boolean contains(K key) {
- return mapResults.containsKey(key);
- }
-
- 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;
- }
-
-}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -8,6 +8,7 @@
import org.chorem.pollen.entity.FavoriteParticipant;
import org.chorem.pollen.entity.PollAccount;
import org.chorem.pollen.service.ServiceUser;
+import org.nuiton.web.tapestry5.data.AbstractMappedGridDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Copied: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java (from rev 2983, trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java)
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -0,0 +1,25 @@
+
+package org.chorem.pollen.ui.data;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used on pages and components that need authentication
+ * to be rendered.
+ *
+ * Created: 3 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+@Target( { ElementType.TYPE })
+(a)Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface PollenRequiresAuthentication {
+
+ boolean adminOnly() default false;
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -1,25 +0,0 @@
-
-package org.chorem.pollen.ui.data;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation is used on pages and components that need authentication
- * to be rendered.
- *
- * Created: 3 mai 2010
- *
- * @author fdesbois
- * $Id$
- */
-@Target( { ElementType.TYPE })
-(a)Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface RequiresAuthentication {
-
- boolean adminOnly() default false;
-}
Modified: 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 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/UserAccountDataSource.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -7,6 +7,7 @@
import org.chorem.pollen.bean.Filter;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.service.ServiceUser;
+import org.nuiton.web.tapestry5.data.AbstractMappedGridDataSource;
/**
* UserAccountDataSource
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/Confirm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/Confirm.java 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/Confirm.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -1,47 +0,0 @@
-package org.chorem.pollen.ui.mixins;
-
-import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.ClientElement;
-import org.apache.tapestry5.RenderSupport;
-import org.apache.tapestry5.annotations.AfterRender;
-import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
-import org.apache.tapestry5.annotations.InjectContainer;
-import org.apache.tapestry5.annotations.Parameter;
-import org.apache.tapestry5.ioc.annotations.Inject;
-
-/**
- * Confirm.java
- *
- * A simple mixin for attaching a javascript confirmation box to the onclick
- * event of any component that implements ClientElement.
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author: fdesbois $
- */
-@IncludeJavaScriptLibrary("context:js/confirm.js")
-public class Confirm {
-
- @Parameter(value = "Are you sure?", defaultPrefix = BindingConstants.MESSAGE)
- private String message;
-
- @Inject
- private RenderSupport renderSupport;
-
- @InjectContainer
- private ClientElement element;
-
- @Parameter
- private boolean wDisabled;
-
- @AfterRender
- public void afterRender() {
- if (!wDisabled) {
- renderSupport.addScript(String.format("new Confirm('%s', '%s');",
- element.getClientId(), message));
- }
- }
-
-}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.java 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -1,101 +0,0 @@
-/**
- * *##%
- * Wao :: Web Interface
- * 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 Lesser 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>.
- * ##%*
- */
-package org.chorem.pollen.ui.mixins;
-
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.ClientElement;
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.Link;
-import org.apache.tapestry5.RenderSupport;
-import org.apache.tapestry5.annotations.Environmental;
-import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
-import org.apache.tapestry5.annotations.InjectContainer;
-import org.apache.tapestry5.annotations.Parameter;
-import org.apache.tapestry5.ioc.annotations.Inject;
-
-/**
- * ZoneUpdater.java
- *
- * From http://tinybits.blogspot.com/2009/05/update-zone-on-any-client-side-event.h… by ingesol
- *
- * @author ingesol
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author: fdesbois $
- */
-@IncludeJavaScriptLibrary("context:js/zoneUpdater.js")
-public class ZoneUpdater {
-
- public static final String PLACEHOLDER = "XXX";
-
- @Inject
- private ComponentResources resources;
-
- @Environmental
- private RenderSupport renderSupport;
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL)
- private String clientEvent;
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL, required = true)
- private String event;
-
- @InjectContainer
- private ClientElement element;
-
- @Parameter
- private Object[] context;
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL)
- // To enable popups to fire events on this document, enter "document" here.
- private String listeningElement;
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL, required = true)
- private String zone;
-
- protected Link createLink(Object[] context) {
-
- if (context == null) {
- context = new Object[]{PLACEHOLDER};
- } else {
- context = ArrayUtils.add(context, PLACEHOLDER); // To be replaced by javascript
- }
-
- return resources.createEventLink(event, context);
-
- }
-
- void afterRender() {
- String link = createLink(context).toAbsoluteURI();
- String elementId = element.getClientId();
- if (clientEvent == null) {
- clientEvent = event;
- }
-
- if (listeningElement == null) {
- listeningElement = "$('" + elementId + "')";
- }
- renderSupport.addScript("new ZoneUpdater('%s', %s, '%s', '%s', '%s', '%s')", elementId, listeningElement, clientEvent, link, zone, PLACEHOLDER);
-
- }
-}
Modified: 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/AdminPolls.java 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminPolls.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -28,7 +28,7 @@
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;
+import org.nuiton.web.tapestry5.components.FeedBack;
/**
* Classe de la page d'administration des sondages. Si l'utilisateur n'est pas
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -39,7 +39,7 @@
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.RequiresAuthentication;
+import org.chorem.pollen.ui.data.PollenRequiresAuthentication;
import org.chorem.pollen.ui.data.UserAccountDataSource;
import org.chorem.pollen.ui.services.PollenManager;
import org.slf4j.Logger;
@@ -50,7 +50,7 @@
* @author fdesbois <fdesbois(a)codelutin.com>
* @version $Id$
*/
-@RequiresAuthentication(adminOnly = true)
+@PollenRequiresAuthentication(adminOnly = true)
@IncludeStylesheet("context:css/usersAdmin.css")
public class AdminUsers extends AbstractPollenPage {
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-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -31,8 +31,8 @@
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;
+import org.nuiton.web.tapestry5.components.FeedBack;
/**
* Classe de la page de confirmation de la cloture d'un sondage.
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-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -29,8 +29,8 @@
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.nuiton.web.tapestry5.components.FeedBack;
/**
* Classe de la page de confirmation de la création d'un sondage.
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-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -29,8 +29,8 @@
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.nuiton.web.tapestry5.components.FeedBack;
/**
* Classe de la page de confirmation de la modification d'un sondage.
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-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -48,8 +48,8 @@
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.nuiton.web.tapestry5.components.FeedBack;
import org.slf4j.Logger;
/**
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-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -52,13 +52,13 @@
import org.chorem.pollen.service.ServiceUser;
import org.chorem.pollen.ui.base.AbstractUploadPage;
import org.chorem.pollen.ui.components.Border;
-import org.chorem.pollen.ui.components.FeedBack;
import org.chorem.pollen.ui.components.Pager;
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.data.ChoiceField;
import org.chorem.pollen.ui.data.PollUri;
import org.chorem.pollen.ui.services.PollenManager;
import org.chorem.pollen.ui.services.ServiceImage;
+import org.nuiton.web.tapestry5.components.FeedBack;
import org.slf4j.Logger;
/**
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-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -29,7 +29,7 @@
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.RequiresAuthentication;
+import org.chorem.pollen.ui.data.PollenRequiresAuthentication;
/**
* Classe de la page d'affichage des listes de votants favorites de
@@ -40,7 +40,7 @@
* @author fdesbois <fdesbois(a)codelutin.com>
* @version $Id$
*/
-@RequiresAuthentication
+@PollenRequiresAuthentication
@IncludeStylesheet("context:css/lists.css")
public class UserLists extends AbstractPollenPage {
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-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -38,7 +38,7 @@
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.RequiresAuthentication;
+import org.chorem.pollen.ui.data.PollenRequiresAuthentication;
import org.chorem.pollen.ui.services.PollenManager;
import org.slf4j.Logger;
@@ -49,7 +49,7 @@
* @author rannou
* @version $Id$
*/
-@RequiresAuthentication
+@PollenRequiresAuthentication
@IncludeStylesheet("context:css/account.css")
public class UserProfile extends AbstractPollenPage {
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-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -28,9 +28,8 @@
import org.apache.tapestry5.services.ApplicationStateContribution;
import org.apache.tapestry5.services.ApplicationStateCreator;
import org.apache.tapestry5.services.ApplicationStateManager;
-import org.apache.tapestry5.services.BindingFactory;
-import org.apache.tapestry5.services.BindingSource;
import org.apache.tapestry5.services.ComponentRequestFilter;
+import org.apache.tapestry5.services.LibraryMapping;
import org.apache.tapestry5.upload.services.UploadSymbols;
import org.chorem.pollen.PollenContextImpl;
import org.chorem.pollen.entity.UserAccount;
@@ -94,7 +93,7 @@
public ServiceAuthentication<UserAccount> buildServiceAuthentication(
ApplicationStateManager stateManager) {
ServiceAuthentication<UserAccount> instance =
- new ServiceAuthenticationImpl(stateManager);
+ new PollenAuthentication(stateManager);
return instance;
}
@@ -213,6 +212,8 @@
// .getComponentResources().getMessages();
// return new BackgroundWorkerImpl(messages, servicePoll, context);
// }
+
+
/**
* Used to instanciate SessionState UserAccount when session expires.
*
@@ -252,12 +253,6 @@
public static void contributeComponentRequestHandler(
OrderedConfiguration<ComponentRequestFilter> configuration) {
configuration.addInstance("RequiresAuthentication",
- AuthenticationFilter.class);
+ PollenAuthenticationFilter.class);
}
-
- public static void contributeBindingSource(
- MappedConfiguration<String, BindingFactory> configuration,
- BindingSource bindingSource) {
- configuration.add("format", new FormatBindingFactory(bindingSource));
- }
}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -1,43 +0,0 @@
-
-package org.chorem.pollen.ui.services;
-
-import org.apache.tapestry5.services.ComponentSource;
-import org.apache.tapestry5.services.PageRenderLinkSource;
-import org.apache.tapestry5.services.Response;
-import org.chorem.pollen.entity.UserAccount;
-import org.chorem.pollen.ui.data.RequiresAuthentication;
-import org.chorem.pollen.ui.pages.Connexion;
-import org.chorem.pollen.ui.pages.ErrorPage;
-import org.nuiton.web.tapestry5.services.AbstractAuthenticationFilter;
-import org.nuiton.web.tapestry5.services.ServiceAuthentication;
-
-/**
- * AuthenticationFilter
- *
- * Created: 4 mai 2010
- *
- * @author fdesbois
- * $Id$
- */
-public class AuthenticationFilter extends
- AbstractAuthenticationFilter<UserAccount, RequiresAuthentication>{
-
- public AuthenticationFilter(PageRenderLinkSource renderLinkSource,
- ComponentSource componentSource, Response response,
- ServiceAuthentication<UserAccount> serviceAuthentication) {
- super(renderLinkSource, componentSource, response,
- serviceAuthentication, RequiresAuthentication.class);
- }
-
- @Override
- protected Class<?> getRedirectPage(AuthenticationRedirect redirectType) {
- switch (redirectType) {
- case CONNEXION:
- return Connexion.class;
- case NOT_ALLOWED:
- return ErrorPage.class;
- }
- return null;
- }
-
-}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBinding.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBinding.java 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBinding.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -1,72 +0,0 @@
-package org.chorem.pollen.ui.services;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.tapestry5.Binding;
-import org.apache.tapestry5.internal.bindings.AbstractBinding;
-import org.apache.tapestry5.ioc.Location;
-import org.apache.tapestry5.ioc.Messages;
-
-/**
- * From <http://wiki.apache.org/tapestry/Tapestry5HowToAddMessageFormatBindingPrefix>
- *
- * Created: 27 avr. 2010
- *
- * @author fdesbois
- */
-public class FormatBinding extends AbstractBinding {
-
- private final Messages messages;
- private final boolean invariant;
- private final List<Binding> keyBindings;
- private final List<Binding> valueBindings;
-
- public FormatBinding(Location location, Messages messages, boolean invariant,
- ArrayList<Binding> keyBindings, List<Binding> valueBindings) {
- super(location);
-
- this.messages = messages;
- this.invariant = invariant;
- this.keyBindings = keyBindings;
- this.valueBindings = valueBindings;
- }
-
- public FormatBinding(Location location, Messages messages, boolean invariant, ArrayList<Binding> keyBindings) {
- super(location);
-
- this.messages = messages;
- this.invariant = invariant;
- this.keyBindings = keyBindings;
- this.valueBindings = null;
- }
-
- @Override
- public Object get() {
- String key = "";
- for (Binding keyBinding : keyBindings) {
- key += keyBinding.get();
- }
-
- if (null == valueBindings) {
- return messages.get(key);
- }
-
- List<Object> values = new ArrayList<Object>(valueBindings.size());
- for (Binding valueBinding : valueBindings) {
- values.add(valueBinding.get());
- }
-
- return messages.format(key, values.toArray());
- }
-
- @Override
- public boolean isInvariant() {
- return this.invariant;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<?> getBindingType() {
- return String.class;
- }
-}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBindingFactory.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBindingFactory.java 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBindingFactory.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -1,79 +0,0 @@
-package org.chorem.pollen.ui.services;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.tapestry5.Binding;
-import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.ioc.Location;
-import org.apache.tapestry5.services.BindingFactory;
-import org.apache.tapestry5.services.BindingSource;
-
-/**
- * From <http://wiki.apache.org/tapestry/Tapestry5HowToAddMessageFormatBindingPrefix>
- *
- * Created: 27 avr. 2010
- *
- * @author fdesbois
- */
-public class FormatBindingFactory
- implements BindingFactory {
-
- private static final String SEPARATOR = "=";
- private static final String DELIMITER = ",";
- private static final String KEY_PREFIX = BindingConstants.LITERAL;
- private static final String VALUE_PREFIX = BindingConstants.PROP;
- private final BindingSource bindingSource;
-
- public FormatBindingFactory(BindingSource bindingSource) {
- this.bindingSource = bindingSource;
- }
-
- @Override
- public Binding newBinding(String description, ComponentResources container, ComponentResources component,
- String expression, Location location) {
- int separatorIndex = expression.indexOf(SEPARATOR);
-
- if (-1 == separatorIndex) {
- List<String> keys = Arrays.asList(expression.split(DELIMITER));
-
- ArrayList<Binding> keyBindings = createBindings(description, container, component, KEY_PREFIX, keys, location);
-
- boolean invariant = isInvariant(keyBindings);
- return new FormatBinding(location, container.getMessages(), invariant, keyBindings);
- }
-
- List<String> keys = Arrays.asList(expression.substring(0, separatorIndex).split(DELIMITER));
- ArrayList<Binding> keyBindings = createBindings(description, container, component, KEY_PREFIX, keys, location);
-
- List<String> values = Arrays.asList(expression.substring(separatorIndex + 1).split(DELIMITER));
- ArrayList<Binding> valueBindings = createBindings(description, container, component, VALUE_PREFIX, values,
- location);
-
- boolean invariant = isInvariant(keyBindings) && isInvariant(valueBindings);
- return new FormatBinding(location, container.getMessages(), invariant, keyBindings, valueBindings);
- }
-
- private ArrayList<Binding> createBindings(String description, ComponentResources container,
- ComponentResources component, String defaultPrefix,
- List<String> expressions, Location location) {
- ArrayList<Binding> bindings = new ArrayList<Binding>(expressions.size());
-
- for (String expression : expressions) {
- bindings.add(bindingSource.newBinding(description, container, component, defaultPrefix, expression, location));
- }
-
- return bindings;
- }
-
- private boolean isInvariant(ArrayList<Binding> bindings) {
- for (Binding binding : bindings) {
- if (!binding.isInvariant()) {
- return false;
- }
- }
-
- return true;
- }
-}
Copied: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java (from rev 2985, trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java)
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -0,0 +1,38 @@
+
+package org.chorem.pollen.ui.services;
+
+import org.apache.tapestry5.services.ApplicationStateManager;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.entity.UserAccountImpl;
+import org.chorem.pollen.ui.data.PollenRequiresAuthentication;
+import org.nuiton.web.tapestry5.services.ServiceAuthenticationImpl;
+
+/**
+ * ServiceAuthenticationImpl
+ *
+ * Created: 4 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class PollenAuthentication extends
+ ServiceAuthenticationImpl<UserAccount, PollenRequiresAuthentication> {
+
+ public PollenAuthentication(ApplicationStateManager stateManager) {
+ super(stateManager, UserAccount.class,
+ PollenRequiresAuthentication.class);
+ }
+
+ @Override
+ protected boolean checkAuthorizations(UserAccount user,
+ PollenRequiresAuthentication annotation) {
+ // No problem for an admin or if the annotation has no limitation
+ return user.getAdmin() || !annotation.adminOnly();
+ }
+
+ @Override
+ public UserAccount getNewUserInstance() {
+ return new UserAccountImpl();
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthenticationFilter.java (from rev 2985, trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java)
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthenticationFilter.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthenticationFilter.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -0,0 +1,43 @@
+
+package org.chorem.pollen.ui.services;
+
+import org.apache.tapestry5.services.ComponentSource;
+import org.apache.tapestry5.services.PageRenderLinkSource;
+import org.apache.tapestry5.services.Response;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.ui.data.PollenRequiresAuthentication;
+import org.chorem.pollen.ui.pages.Connexion;
+import org.chorem.pollen.ui.pages.ErrorPage;
+import org.nuiton.web.tapestry5.services.AbstractAuthenticationFilter;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
+
+/**
+ * AuthenticationFilter
+ *
+ * Created: 4 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class PollenAuthenticationFilter extends
+ AbstractAuthenticationFilter<UserAccount, PollenRequiresAuthentication>{
+
+ public PollenAuthenticationFilter(PageRenderLinkSource renderLinkSource,
+ ComponentSource componentSource, Response response,
+ ServiceAuthentication<UserAccount> serviceAuthentication) {
+ super(renderLinkSource, componentSource, response,
+ serviceAuthentication, PollenRequiresAuthentication.class);
+ }
+
+ @Override
+ protected Class<?> getRedirectPage(AuthenticationRedirect redirectType) {
+ switch (redirectType) {
+ case NOT_CONNECTED:
+ return Connexion.class;
+ case NOT_ALLOWED:
+ return ErrorPage.class;
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthenticationFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java 2010-05-04 16:24:31 UTC (rev 2986)
@@ -1,37 +0,0 @@
-
-package org.chorem.pollen.ui.services;
-
-import org.apache.tapestry5.services.ApplicationStateManager;
-import org.chorem.pollen.entity.UserAccount;
-import org.chorem.pollen.entity.UserAccountImpl;
-import org.chorem.pollen.ui.data.RequiresAuthentication;
-import org.nuiton.web.tapestry5.services.ServiceAuthenticationAbstract;
-
-/**
- * ServiceAuthenticationImpl
- *
- * Created: 4 mai 2010
- *
- * @author fdesbois
- * $Id$
- */
-public class ServiceAuthenticationImpl extends
- ServiceAuthenticationAbstract<UserAccount, RequiresAuthentication> {
-
- public ServiceAuthenticationImpl(ApplicationStateManager stateManager) {
- super(stateManager, UserAccount.class, RequiresAuthentication.class);
- }
-
- @Override
- protected boolean checkAuthorizations(UserAccount user,
- RequiresAuthentication annotation) {
- // No problem for an admin or if the annotation has no limitation
- return user.getAdmin() || !annotation.adminOnly();
- }
-
- @Override
- public UserAccount getNewUserInstance() {
- return new UserAccountImpl();
- }
-
-}
Modified: trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml 2010-05-04 16:24:31 UTC (rev 2986)
@@ -53,7 +53,7 @@
<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">
+ t:mixins="nuiton/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>
Modified: trunk/pollen-ui/src/main/webapp/css/common.css
===================================================================
--- trunk/pollen-ui/src/main/webapp/css/common.css 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/webapp/css/common.css 2010-05-04 16:24:31 UTC (rev 2986)
@@ -34,6 +34,7 @@
display: block;
}
+/** feedback.css not worked yet in nuiton-tapestry-extra **/
.fb-error {
width: 400px;
margin: auto;
Deleted: trunk/pollen-ui/src/main/webapp/js/confirm.js
===================================================================
--- trunk/pollen-ui/src/main/webapp/js/confirm.js 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/webapp/js/confirm.js 2010-05-04 16:24:31 UTC (rev 2986)
@@ -1,20 +0,0 @@
-/**
- * Dialogue de confirmation
- */
-var Confirm = Class.create({
- /**
- * element : Element DOM depuis lequel le dialogue de confirmation va s'ouvrir
- * message : Message à afficher dans la boîte de dialogue
- */
- initialize: function(element, message) {
- this.message = message;
- Event.observe($(element), 'click', this.doConfirm.bindAsEventListener(this));
- },
- doConfirm: function(e) {
- //Tapestry.debug('click ' + element);
- if(! confirm(this.message)) {
- //Tapestry.debug('STOP ' + e);
- Event.stop(e);
- }
- }
-});
\ No newline at end of file
Deleted: trunk/pollen-ui/src/main/webapp/js/zoneUpdater.js
===================================================================
--- trunk/pollen-ui/src/main/webapp/js/zoneUpdater.js 2010-05-04 14:07:47 UTC (rev 2985)
+++ trunk/pollen-ui/src/main/webapp/js/zoneUpdater.js 2010-05-04 16:24:31 UTC (rev 2986)
@@ -1,103 +0,0 @@
-var ZoneUpdater = Class.create();
-
-ZoneUpdater.prototype = {
-
- initialize: function(zoneElementId, listeningElement, event, link, zone, placeholder) {
-
- this.zoneElement = $(zoneElementId);
-
- this.event = event;
-
- this.link = link;
-
- this.placeholder = placeholder;
-
- $T(this.zoneElement).zoneId = zone;
-
- listeningElement.observe(this.event, this.updateZone.bindAsEventListener(this));
-
- },
-
- updateZone: function(event) {
-
- var zoneObject = Tapestry.findZoneManager(this.zoneElement);
-
- if ( !zoneObject ) return;
-
- var param;
-
- if (this.zoneElement.value) {
-
- param = this.zoneElement.value;
-
- }
-
- if (!param) param = ' ';
-
- param = this.encodeForUrl(param);
-
- var updatedLink = this.link.gsub(this.placeholder, param);
-
- zoneObject.updateFromURL(updatedLink);
-
- },
-
- encodeForUrl: function(string) {
-
- /**
-
- * See equanda.js for updated version of this
-
- */
-
- string = string.replace(/\r\n/g,"\n");
-
- var res = "";
-
- for (var n = 0; n < string.length; n++)
-
- {
-
- var c = string.charCodeAt( n );
-
- if ( '$' == string.charAt( n ) )
-
- {
-
- res += '$$';
-
- }
-
- else if ( this.inRange( c, "AZ" ) || this.inRange( c, "az" ) || this.inRange( c, "09" ) || this.inRange( c, ".." ) )
-
- {
-
- res += string.charAt( n )
-
- }
-
- else
-
- {
-
- var tmp = c.toString(16);
-
- while ( tmp.length < 4 ) tmp = "0" + tmp;
-
- res += '$' + tmp;
-
- }
-
- }
-
- return res;
-
- },
-
- inRange: function(code, range) {
-
- return code >= range.charCodeAt( 0 ) && code <= range.charCodeAt( 1 );
-
- }
-
-}
\ No newline at end of file
1
0
r2985 - in trunk: . pollen-business/src/main/xmi pollen-ui pollen-ui/src/main/java/org/chorem/pollen/ui/base pollen-ui/src/main/java/org/chorem/pollen/ui/components pollen-ui/src/main/java/org/chorem/pollen/ui/pages pollen-ui/src/main/java/org/chorem/pollen/ui/services
by fdesbois@users.chorem.org 04 May '10
by fdesbois@users.chorem.org 04 May '10
04 May '10
Author: fdesbois
Date: 2010-05-04 16:07:47 +0200 (Tue, 04 May 2010)
New Revision: 2985
Url: http://chorem.org/repositories/revision/pollen/2985
Log:
Remove authentication services, use nuiton-tapestry-extra that provides these services.
Removed:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java
Modified:
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-ui/pom.xml
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.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/Connexion.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/AuthenticationFilter.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java
trunk/pom.xml
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/pom.xml
===================================================================
--- trunk/pollen-ui/pom.xml 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/pom.xml 2010-05-04 14:07:47 UTC (rev 2985)
@@ -31,6 +31,10 @@
<artifactId>tapestry-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.nuiton.web</groupId>
+ <artifactId>nuiton-tapestry-extra</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
Modified: 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 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -4,7 +4,7 @@
import org.apache.tapestry5.ioc.annotations.Inject;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.ui.components.Border;
-import org.chorem.pollen.ui.services.ServiceAuthentication;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
/**
* AbstractPollenPage
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-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -41,7 +41,7 @@
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.pages.Index;
import org.chorem.pollen.ui.services.PollenManager;
-import org.chorem.pollen.ui.services.ServiceAuthentication;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
import org.slf4j.Logger;
/**
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -15,7 +15,7 @@
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.services.PollenManager;
-import org.chorem.pollen.ui.services.ServiceAuthentication;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
import org.slf4j.Logger;
/**
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -1,146 +0,0 @@
-package org.chorem.pollen.ui.services;
-
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import org.apache.tapestry5.Link;
-import org.apache.tapestry5.runtime.Component;
-import org.apache.tapestry5.services.ComponentEventRequestParameters;
-import org.apache.tapestry5.services.ComponentRequestFilter;
-import org.apache.tapestry5.services.ComponentRequestHandler;
-import org.apache.tapestry5.services.ComponentSource;
-import org.apache.tapestry5.services.PageRenderLinkSource;
-import org.apache.tapestry5.services.PageRenderRequestParameters;
-import org.apache.tapestry5.services.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * AbstractAuthenticationFilter
- *
- * Created: 3 mai 2010
- *
- * @param <U> type of User
- * @param <A> type of Annotation that manage authentication on pages/components
- * @author fdesbois
- * $Id$
- */
-public abstract class AbstractAuthenticationFilter<U, A extends Annotation>
- implements ComponentRequestFilter {
-
- private static final Logger logger =
- LoggerFactory.getLogger(AbstractAuthenticationFilter.class);
-
- private final PageRenderLinkSource pageRender;
-
- private final ComponentSource componentSource;
-
- private final Response response;
-
- private final ServiceAuthentication<U> serviceAuthentication;
-
- protected Class<A> annotationClass;
-
- public AbstractAuthenticationFilter(PageRenderLinkSource renderLinkSource,
- ComponentSource componentSource, Response response,
- ServiceAuthentication<U> serviceAuthentication,
- Class<A> annotationClass) {
- this.pageRender = renderLinkSource;
- this.componentSource = componentSource;
- this.response = response;
- this.serviceAuthentication = serviceAuthentication;
- this.annotationClass = annotationClass;
-
- if (logger.isTraceEnabled()) {
- logger.trace("Construct");
- }
- }
-
- @Override
- public void handleComponentEvent(
- ComponentEventRequestParameters parameters,
- ComponentRequestHandler handler) throws IOException {
-
- if (logger.isTraceEnabled()) {
- logger.trace("handleComponentEvent");
- }
-
- if (redirectUnauthorizedUser(parameters.getActivePageName())) {
- return;
- }
-
- handler.handleComponentEvent(parameters);
-
- }
-
- @Override
- public void handlePageRender(PageRenderRequestParameters parameters,
- ComponentRequestHandler handler) throws IOException {
-
- if (logger.isTraceEnabled()) {
- logger.trace("handlePageRender");
- }
-
- if (redirectUnauthorizedUser(parameters.getLogicalPageName())) {
- return;
- }
-
- handler.handlePageRender(parameters);
- }
-
- protected boolean redirectUnauthorizedUser(String pageName)
- throws IOException {
-
- Component page = componentSource.getPage(pageName);
-
- if (logger.isTraceEnabled()) {
- logger.trace("Page name : " + pageName);
- logger.trace("Page class : " + page.getClass());
- logger.trace("RequiresLogin annotation : " +
- page.getClass().isAnnotationPresent(annotationClass));
- logger.trace("User in session : " +
- serviceAuthentication.isUserConnected());
- }
-
- if (!page.getClass().isAnnotationPresent(annotationClass)) {
- return false;
- }
-
- AuthenticationRedirect redirectType = AuthenticationRedirect.CONNEXION;
-
- if (serviceAuthentication.isUserConnected()) {
- U user = serviceAuthentication.getUserConnected();
- if (logger.isTraceEnabled()) {
- logger.trace("User connected : " + user);
- logger.trace("User allowed : " +
- serviceAuthentication.isAllowed(page.getClass()));
- }
-
- if (serviceAuthentication.isAllowed(page.getClass())) {
- return false;
- }
-
- redirectType = AuthenticationRedirect.NOT_ALLOWED;
- }
-
- Class<?> redirectPage = getRedirectPage(redirectType);
- Link link = pageRender.createPageRenderLinkWithContext(redirectPage,
- pageName);
-
- if (logger.isTraceEnabled()) {
- logger.trace("Redirection to " + redirectPage.getSimpleName() +
- " page...");
- }
-
- response.sendRedirect(link);
-
- return true;
- }
-
- protected enum AuthenticationRedirect {
- CONNEXION, NOT_ALLOWED;
- }
-
- protected abstract Class<?> getRedirectPage(
- AuthenticationRedirect redirectType);
-}
-
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-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -41,6 +41,7 @@
import org.chorem.pollen.service.ServiceUser;
import org.chorem.pollen.service.ServiceUserImpl;
import org.chorem.pollen.ui.data.PollUri;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -8,7 +8,8 @@
import org.chorem.pollen.ui.data.RequiresAuthentication;
import org.chorem.pollen.ui.pages.Connexion;
import org.chorem.pollen.ui.pages.ErrorPage;
-import org.chorem.pollen.ui.services.AbstractAuthenticationFilter.AuthenticationRedirect;
+import org.nuiton.web.tapestry5.services.AbstractAuthenticationFilter;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
/**
* AuthenticationFilter
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -1,27 +0,0 @@
-
-package org.chorem.pollen.ui.services;
-
-import org.chorem.pollen.entity.UserAccount;
-
-/**
- * ServiceAuthentication
- *
- * Created: 3 mai 2010
- *
- * @param <U> user type
- * @author fdesbois
- * $Id$
- */
-public interface ServiceAuthentication<U> {
-
- boolean isUserConnected();
-
- U getUserConnected();
-
- void setUserConnected(U user);
-
- boolean isAllowed(Class<?> page);
-
- U getNewUserInstance();
-
-}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -1,71 +0,0 @@
-
-package org.chorem.pollen.ui.services;
-
-import java.lang.annotation.Annotation;
-import org.apache.tapestry5.services.ApplicationStateManager;
-
-/**
- * ServiceAuthenticationImpl
- *
- * Created: 3 mai 2010
- *
- * @param <U>
- * @param <A>
- * @author fdesbois
- * $Id$
- */
-public abstract class ServiceAuthenticationAbstract<U, A extends Annotation>
- implements ServiceAuthentication<U> {
-
- private final ApplicationStateManager stateManager;
-
- private Class<U> userClass;
-
- private Class<A> annotationClass;
-
- public ServiceAuthenticationAbstract(ApplicationStateManager stateManager,
- Class<U> userClass, Class<A> annotationClass) {
- this.stateManager = stateManager;
- this.userClass = userClass;
- this.annotationClass = annotationClass;
- }
-
- @Override
- public boolean isUserConnected() {
- return stateManager.exists(userClass);
- }
-
- @Override
- public U getUserConnected() {
- return stateManager.getIfExists(userClass);
- }
-
- @Override
- public void setUserConnected(U user) {
- stateManager.set(userClass, user);
- }
-
- @Override
- public boolean isAllowed(Class<?> page) {
- if (page.isAnnotationPresent(annotationClass) &&
- isUserConnected()) {
-
- A check = page.getAnnotation(annotationClass);
-
- U user = getUserConnected();
-
- return checkAuthorizations(user, check);
-
- // Check if user not admin is allowed
-// if (!user.getAdmin() && check.adminOnly()) {
-// return false;
-// }
-// return false;
- }
- // No restriction if annotation is not present
- return true;
- }
-
- protected abstract boolean checkAuthorizations(U user, A annotation);
-
-}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -5,6 +5,7 @@
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountImpl;
import org.chorem.pollen.ui.data.RequiresAuthentication;
+import org.nuiton.web.tapestry5.services.ServiceAuthenticationAbstract;
/**
* ServiceAuthenticationImpl
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pom.xml 2010-05-04 14:07:47 UTC (rev 2985)
@@ -84,6 +84,11 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.nuiton.web</groupId>
+ <artifactId>nuiton-tapestry-extra</artifactId>
+ <version>${nuiton-web.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.10</version>
@@ -313,6 +318,7 @@
<eugene.version>2.0.2-SNAPSHOT</eugene.version>
<i18n.version>1.2.2</i18n.version>
<tapestry.version>5.1.0.5</tapestry.version>
+ <nuiton-web.version>0.1-SNAPSHOT</nuiton-web.version>
<nuiton-utils.version>1.2.2</nuiton-utils.version>
<processor.version>1.0.2</processor.version>
1
0
r2984 - trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services
by fdesbois@users.chorem.org 04 May '10
by fdesbois@users.chorem.org 04 May '10
04 May '10
Author: fdesbois
Date: 2010-05-04 15:22:03 +0200 (Tue, 04 May 2010)
New Revision: 2984
Url: http://chorem.org/repositories/revision/pollen/2984
Log:
rename main method for redirection if user is not allowed (or not authenticated)
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java 2010-05-04 10:11:20 UTC (rev 2983)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java 2010-05-04 13:22:03 UTC (rev 2984)
@@ -11,15 +11,11 @@
import org.apache.tapestry5.services.PageRenderLinkSource;
import org.apache.tapestry5.services.PageRenderRequestParameters;
import org.apache.tapestry5.services.Response;
-import org.chorem.pollen.entity.UserAccount;
-import org.chorem.pollen.ui.data.RequiresAuthentication;
-import org.chorem.pollen.ui.pages.Connexion;
-import org.chorem.pollen.ui.pages.ErrorPage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * RequiresAuthenticationFilter
+ * AbstractAuthenticationFilter
*
* Created: 3 mai 2010
*
@@ -68,7 +64,7 @@
logger.trace("handleComponentEvent");
}
- if (dispatchedToLoginPage(parameters.getActivePageName())) {
+ if (redirectUnauthorizedUser(parameters.getActivePageName())) {
return;
}
@@ -84,14 +80,15 @@
logger.trace("handlePageRender");
}
- if (dispatchedToLoginPage(parameters.getLogicalPageName())) {
+ if (redirectUnauthorizedUser(parameters.getLogicalPageName())) {
return;
}
handler.handlePageRender(parameters);
}
- private boolean dispatchedToLoginPage(String pageName) throws IOException {
+ protected boolean redirectUnauthorizedUser(String pageName)
+ throws IOException {
Component page = componentSource.getPage(pageName);
@@ -108,7 +105,6 @@
return false;
}
-// Class<?> redirectPage = Connexion.class;
AuthenticationRedirect redirectType = AuthenticationRedirect.CONNEXION;
if (serviceAuthentication.isUserConnected()) {
@@ -123,7 +119,6 @@
return false;
}
-// redirectPage = ErrorPage.class;
redirectType = AuthenticationRedirect.NOT_ALLOWED;
}
1
0
Author: fdesbois
Date: 2010-05-04 12:11:20 +0200 (Tue, 04 May 2010)
New Revision: 2983
Url: http://chorem.org/repositories/revision/pollen/2983
Log:
- Add license descriptor
- Evo #191 : use AuthenticationFilter and ServiceAuthentication to manage connected user authorizations
- need Javadoc + these classes can be put into nuiton-tapestry-extra (AbstratMappedGridDataSource, ServiceAuthentication, ServiceAuthenticationAbstract, AbstractAuthenticationFilter)
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java
trunk/pollen-ui/src/main/webapp/Connexion.tml
trunk/src/license/
trunk/src/license/project.xml
Removed:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent.tml
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_en.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_fr.properties
trunk/pollen-ui/src/main/webapp/css/loginComponent.css
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.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/admin/AdminUsers.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/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/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/webapp/ErrorPage.tml
trunk/pollen-ui/src/main/webapp/css/main.css
Modified: 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 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,10 +1,10 @@
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;
+import org.chorem.pollen.ui.services.ServiceAuthentication;
/**
* AbstractPollenPage
@@ -16,13 +16,9 @@
public abstract class AbstractPollenPage implements PollenPage {
/** Connected UserAccount from Session **/
- @SessionState
- @Property
- private UserAccount user;
+ @Inject
+ private ServiceAuthentication<UserAccount> serviceAuthentication;
- @Property
- private boolean userExists;
-
/**
* Retrieve the border layout of the page.
*
@@ -31,38 +27,13 @@
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
*/
@Override
public UserAccount getUserConnected() {
- if (isUserConnected()) {
- return user;
- }
- return null;
+ return serviceAuthentication.getUserConnected();
}
/**
@@ -71,7 +42,7 @@
* @param user to set in session.
*/
public void setUserConnected(UserAccount user) {
- this.user = user;
+ serviceAuthentication.setUserConnected(user);
}
/**
@@ -81,7 +52,7 @@
*/
@Override
public boolean isUserConnected() {
- return userExists;
+ return serviceAuthentication.isUserConnected();
}
/**
@@ -91,7 +62,7 @@
*/
@Override
public boolean isAdminConnected() {
- return isUserConnected() && user.getAdmin();
+ return isUserConnected() && getUserConnected().getAdmin();
}
/**
Modified: 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 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -13,20 +13,6 @@
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();
-
- /**
* Retrieve connected user from session.
*
* @return the user currently connected.
@@ -52,7 +38,7 @@
*
* @param message to display
*/
- public void addInfo(String message) ;
+ public void addInfo(String message);
/**
* Add a fatal {@code message} to display. Only the fatal {@code message}
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-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -23,14 +23,11 @@
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;
-import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.PersistentLocale;
@@ -41,10 +38,10 @@
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;
+import org.chorem.pollen.ui.services.ServiceAuthentication;
import org.slf4j.Logger;
/**
@@ -127,20 +124,7 @@
@Property
private String password;
- /**
- * Objet de session représentant l'utilisateur identifié
- */
- @SessionState
- @Property
- private UserAccount user;
- /**
- * vrai si l'utilisateur s'est identifié, faux sinon
- */
- @SuppressWarnings("unused")
- @Property
- private boolean userExists;
-
/** Locale courante */
@Inject
private Locale currentLocale;
@@ -151,11 +135,14 @@
@Inject
private PersistentLocale localeService;
+ /** Injection des services */
@Inject
private PollenManager manager;
- /** Injection des services */
@Inject
+ private ServiceAuthentication<UserAccount> serviceAuthentication;
+
+ @Inject
private ServiceUser serviceUser;
/**
@@ -173,19 +160,8 @@
@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;
/**
@@ -201,19 +177,12 @@
} 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;
- }
+// 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
@@ -231,14 +200,14 @@
return true;
}
- public Object getActiveBlock() {
- if (isNeedAuthentification()) {
- return loginBlock;
- } else if (canDisplayBody()) {
- return pageBlock;
- }
- return null;
- }
+// public Object getActiveBlock() {
+// if (isNeedAuthentification()) {
+// return loginBlock;
+// } else if (canDisplayBody()) {
+// return pageBlock;
+// }
+// return null;
+// }
public String getServerPath() {
if (serverPath == null) {
@@ -264,12 +233,12 @@
fatal = true;
}
- public boolean isNeedAuthentification() {
- return !userExists && page.isNeedAuthentification();
- }
+// public boolean isNeedAuthentification() {
+// return !userExists && page.isNeedAuthentification();
+// }
public boolean canDisplayBody() {
- return !fatal && page.canDisplayPage();
+ return !fatal/* && page.canDisplayPage()*/;
}
public DateFormat getDateFormat() {
@@ -281,6 +250,14 @@
return feedContext;
}
+ public boolean isUserExists() {
+ return serviceAuthentication.isUserConnected();
+ }
+
+ public UserAccount getUser() {
+ return serviceAuthentication.getUserConnected();
+ }
+
/**
* User connection. Call business to check user existence.
*
@@ -289,10 +266,10 @@
@Log
Object onSuccessFromConnection() {
// No need to connect if user exists
- if (!userExists) {
+ if (!serviceAuthentication.isUserConnected()) {
try {
UserAccount current = serviceUser.connect(login, password);
- user = current;
+ serviceAuthentication.setUserConnected(current);
// Change locale for user
//localeService.set(new Locale(user.getLanguage()));
feedback.addInfo(messages.get("loginOk"));
@@ -311,7 +288,7 @@
* @return la zone à mettre à jour
*/
Object onActionFromLogout() {
- user = null;
+ serviceAuthentication.setUserConnected(null);
request.getSession(false).invalidate();
return Index.class;
}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,97 +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.components;
-
-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.PollenBusinessException;
-import org.chorem.pollen.entity.UserAccount;
-import org.chorem.pollen.service.ServiceUser;
-import org.chorem.pollen.ui.services.PollenManager;
-
-/**
- * Formulaire d'identification. Formulaire que l'utilisateur doit remplir pour
- * se connecter quand il veut accéder à une page qui demande à être identifié.
- *
- * @author kmorin
- * @version $Id$
- */
-@IncludeStylesheet("context:css/loginComponent.css")
-public class LoginComponent {
-
- /** Affichage des messages pour l'utilisateur */
- @Component(id = "loginCompFeedback")
- private FeedBack feedback;
-
- /**
- * Objet de session représentant l'utilisateur identifié.
- */
- @SuppressWarnings("unused")
- @SessionState
- private UserAccount user;
- @SuppressWarnings("unused")
- @Property
- private boolean userExists;
-
- /**
- * Champ login du formulaire d'identification
- */
- @Property
- private String connectionLogin;
-
- /**
- * Champ password du formulaire d'identification
- */
- @Property
- private String connectionPassword;
-
- @Inject
- private Messages messages;
-
- /** Injection des services */
- @Inject
- private ServiceUser serviceUser;
-
- @Inject
- private PollenManager manager;
-
- /**
- * Methode appelée lorsque l'utilisateur s'identifie
- *
- * @return la zone à mettre à jour
- */
- Object onSuccessFromLoginCompForm() {
- // Récupération de l'utilisateur identifié
- UserAccount current;
- try {
- current = serviceUser.connect(connectionLogin, connectionPassword);
- if (current != null) {
- user = current;
- } else {
- feedback.addError(messages.get("loginFailed"));
- }
- } catch (PollenBusinessException eee) {
- // TODO
- feedback.addError(messages.get("loginFailed"));
- }
- return this;
- }
-}
Modified: 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 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -16,18 +16,19 @@
import org.slf4j.LoggerFactory;
/**
- * ContactDataSource
+ * AbstractMappedGridDataSource
*
+ * TODO : javadoc
+ *
* Created: 18 janv. 2010
*
* @param <K> Type of the map key
* @param <E> Type of the map value
* @author fdesbois <fdesbois(a)codelutin.com>
*/
-public abstract class AbstractMappedGridDataSource<K, E extends TopiaEntity>
+public abstract class AbstractMappedGridDataSource<K, E>
implements GridDataSource {
-
private Logger log =
LoggerFactory.getLogger(AbstractMappedGridDataSource.class);
@@ -40,15 +41,19 @@
private int nbRowsPerPage;
@Override
+ public abstract Class<?> getRowType();
+
+ protected abstract int count();
+
+ protected abstract Map<K, E> execute(int startIndex, int endIndex,
+ SortConstraint orderBy);
+
+ @Override
public int getAvailableRows() {
if (nbRows < 0) {
- try {
- nbRows = count();
- if (log.isDebugEnabled()) {
- log.debug("Count : " + nbRows);
- }
- } catch (PollenException eee) {
- throw new TapestryException("", eee);
+ nbRows = count();
+ if (log.isDebugEnabled()) {
+ log.debug("Count : " + nbRows);
}
}
return nbRows;
@@ -61,24 +66,39 @@
log.debug("Prepare results : " + startIndex + ", " + endIndex);
}
nbRowsPerPage = endIndex - startIndex + 1;
- try {
- mapResults = execute(startIndex, endIndex, getSortConstraint(sortConstraints));
- listResults = new ArrayList<E>(mapResults.values());
- } catch (PollenException eee) {
- throw new TapestryException("", eee);
+ mapResults = execute(startIndex, endIndex,
+ getSortConstraint(sortConstraints));
+ listResults = new ArrayList<E>(mapResults.values());
+ }
+
+ @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);
}
- protected abstract Map<K, E> execute(int startIndex, int endIndex,
- SortConstraint orderBy) throws PollenException;
+ public E get(K key) {
+ return mapResults.get(key);
+ }
- protected abstract int count() throws PollenException;
+ public List<E> values() {
+ return listResults;
+ }
- protected SortConstraint getSortConstraint(List<SortConstraint> sortConstraints) {
- for (SortConstraint constraint : sortConstraints)
- {
- final ColumnSort sort = constraint.getColumnSort();
+ public boolean contains(K key) {
+ return mapResults.containsKey(key);
+ }
+ protected SortConstraint getSortConstraint(
+ List<SortConstraint> sortConstraints) {
+ for (SortConstraint constraint : sortConstraints) {
+ final ColumnSort sort = constraint.getColumnSort();
if (sort != ColumnSort.UNSORTED) {
return constraint;
}
@@ -104,31 +124,4 @@
return filterOrder;
}
- @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);
- }
-
}
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,25 @@
+
+package org.chorem.pollen.ui.data;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used on pages and components that need authentication
+ * to be rendered.
+ *
+ * Created: 3 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+@Target( { ElementType.TYPE })
+(a)Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface RequiresAuthentication {
+
+ boolean adminOnly() default false;
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,127 @@
+
+package org.chorem.pollen.ui.pages;
+
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Log;
+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.apache.tapestry5.services.PageRenderLinkSource;
+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;
+import org.chorem.pollen.ui.services.ServiceAuthentication;
+import org.slf4j.Logger;
+
+/**
+ * Connexion
+ *
+ * Created: 4 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class Connexion extends AbstractPollenPage {
+
+ @InjectComponent
+ private Border border;
+
+ @Override
+ public Border getBorder() {
+ return border;
+ }
+
+ public AddressBar getAddressBar() {
+ return AddressBar.newBar();
+ }
+
+ @InjectComponent
+ private Form loginForm;
+
+ /**
+ * Champ login du formulaire d'identification
+ */
+ @Property
+ private String connectionLogin;
+
+ /**
+ * Champ password du formulaire d'identification
+ */
+ @Property
+ private String connectionPassword;
+
+ /** Injection des services */
+ @Inject
+ private Logger logger;
+
+ @Inject
+ private Messages messages;
+
+ @Inject
+ private ServiceAuthentication<UserAccount> serviceAuthentication;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ @Inject
+ private PollenManager manager;
+
+ @Inject
+ private PageRenderLinkSource pageRender;
+
+ private String pageName;
+
+ void onActivate(String pageName) {
+ this.pageName = pageName;
+ }
+
+ String onPassivate() {
+ return pageName;
+ }
+
+ void setupRender() {
+ addError(messages.format("pollen.ui.user.display.notConnected",
+ pageName));
+ }
+
+ void onValidateFormFromLoginForm() {
+ UserAccount current;
+ try {
+ current = serviceUser.connect(connectionLogin, connectionPassword);
+ if (current != null) {
+ serviceAuthentication.setUserConnected(current);
+ } else {
+ loginForm.recordError(messages.get("loginFailed"));
+ }
+ } catch (PollenBusinessException eee) {
+ // TODO two different errors, on password or on login
+ //addError(messages.get("loginFailed"));
+ String message = manager.getErrorMessage(eee, messages, logger);
+ loginForm.recordError(message);
+ }
+ }
+
+ /**
+ * Methode appelée lorsque l'utilisateur s'identifie
+ *
+ * @return la zone à mettre à jour
+ */
+ @Log
+ Object onSuccessFromLoginForm() {
+ if (pageName == null) {
+ pageName = "index";
+ }
+ return pageRender.createPageRenderLink(pageName);
+ }
+
+ @Log
+ void onFailureFromLoginForm() {
+
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.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-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -2,6 +2,8 @@
package org.chorem.pollen.ui.pages;
import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.annotations.Inject;
import org.chorem.pollen.ui.base.AbstractPollenPage;
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.data.AddressBar;
@@ -23,13 +25,33 @@
@InjectComponent
private Border border;
+ @Inject
+ private Messages messages;
+
+ private String pageName;
+
@Override
public Border getBorder() {
return border;
}
- public AddressBarItem[] getAddress() {
- return AddressBar.newBar().getItems();
+ public AddressBar getAddressBar() {
+ return AddressBar.newBar();
}
+
+ void onActivate(String pageName) {
+ this.pageName = pageName;
+ }
+
+ String onPassivate() {
+ return pageName;
+ }
+
+ void setupRender() {
+ if (pageName != null) {
+ addError(messages.format("pollen.ui.user.display.notAllowed",
+ pageName));
+ }
+ }
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -39,6 +39,7 @@
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.RequiresAuthentication;
import org.chorem.pollen.ui.data.UserAccountDataSource;
import org.chorem.pollen.ui.services.PollenManager;
import org.slf4j.Logger;
@@ -49,6 +50,7 @@
* @author fdesbois <fdesbois(a)codelutin.com>
* @version $Id$
*/
+@RequiresAuthentication(adminOnly = true)
@IncludeStylesheet("context:css/usersAdmin.css")
public class AdminUsers extends AbstractPollenPage {
@@ -66,16 +68,6 @@
return border;
}
- @Override
- public boolean isNeedAuthentification() {
- return true;
- }
-
- @Override
- public boolean canDisplayPage() {
- return isAdminConnected();
- }
-
public AddressBar getAddressBar() {
return AddressBar.newBar().appendCurrent(title);
}
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-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -29,6 +29,7 @@
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.RequiresAuthentication;
/**
* Classe de la page d'affichage des listes de votants favorites de
@@ -39,6 +40,7 @@
* @author fdesbois <fdesbois(a)codelutin.com>
* @version $Id$
*/
+@RequiresAuthentication
@IncludeStylesheet("context:css/lists.css")
public class UserLists extends AbstractPollenPage {
@@ -60,16 +62,6 @@
public Border getBorder() {
return border;
}
-
- @Override
- public boolean isNeedAuthentification() {
- return true;
- }
-
- @Override
- public boolean canDisplayPage() {
- return isUserConnected();
- }
public AddressBar getAddressBar() {
return AddressBar.newBar().appendCurrent(title);
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-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -38,6 +38,7 @@
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.RequiresAuthentication;
import org.chorem.pollen.ui.services.PollenManager;
import org.slf4j.Logger;
@@ -48,6 +49,7 @@
* @author rannou
* @version $Id$
*/
+@RequiresAuthentication
@IncludeStylesheet("context:css/account.css")
public class UserProfile extends AbstractPollenPage {
@@ -59,16 +61,6 @@
return border;
}
- @Override
- public boolean isNeedAuthentification() {
- return true;
- }
-
- @Override
- public boolean canDisplayPage() {
- return isUserConnected();
- }
-
@Inject
private Logger logger;
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-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -16,8 +16,6 @@
package org.chorem.pollen.ui.pages.user;
-
-import java.util.Locale;
import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.annotations.Component;
@@ -61,18 +59,13 @@
public Border getBorder() {
return border;
}
+//
+// @Override
+// public boolean canDisplayPage() {
+// addInfo("Vous devez vous déconnecter pour créer un compte");
+// return !isUserConnected();
+// }
- @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;
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,151 @@
+package org.chorem.pollen.ui.services;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.runtime.Component;
+import org.apache.tapestry5.services.ComponentEventRequestParameters;
+import org.apache.tapestry5.services.ComponentRequestFilter;
+import org.apache.tapestry5.services.ComponentRequestHandler;
+import org.apache.tapestry5.services.ComponentSource;
+import org.apache.tapestry5.services.PageRenderLinkSource;
+import org.apache.tapestry5.services.PageRenderRequestParameters;
+import org.apache.tapestry5.services.Response;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.ui.data.RequiresAuthentication;
+import org.chorem.pollen.ui.pages.Connexion;
+import org.chorem.pollen.ui.pages.ErrorPage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * RequiresAuthenticationFilter
+ *
+ * Created: 3 mai 2010
+ *
+ * @param <U> type of User
+ * @param <A> type of Annotation that manage authentication on pages/components
+ * @author fdesbois
+ * $Id$
+ */
+public abstract class AbstractAuthenticationFilter<U, A extends Annotation>
+ implements ComponentRequestFilter {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(AbstractAuthenticationFilter.class);
+
+ private final PageRenderLinkSource pageRender;
+
+ private final ComponentSource componentSource;
+
+ private final Response response;
+
+ private final ServiceAuthentication<U> serviceAuthentication;
+
+ protected Class<A> annotationClass;
+
+ public AbstractAuthenticationFilter(PageRenderLinkSource renderLinkSource,
+ ComponentSource componentSource, Response response,
+ ServiceAuthentication<U> serviceAuthentication,
+ Class<A> annotationClass) {
+ this.pageRender = renderLinkSource;
+ this.componentSource = componentSource;
+ this.response = response;
+ this.serviceAuthentication = serviceAuthentication;
+ this.annotationClass = annotationClass;
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Construct");
+ }
+ }
+
+ @Override
+ public void handleComponentEvent(
+ ComponentEventRequestParameters parameters,
+ ComponentRequestHandler handler) throws IOException {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("handleComponentEvent");
+ }
+
+ if (dispatchedToLoginPage(parameters.getActivePageName())) {
+ return;
+ }
+
+ handler.handleComponentEvent(parameters);
+
+ }
+
+ @Override
+ public void handlePageRender(PageRenderRequestParameters parameters,
+ ComponentRequestHandler handler) throws IOException {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("handlePageRender");
+ }
+
+ if (dispatchedToLoginPage(parameters.getLogicalPageName())) {
+ return;
+ }
+
+ handler.handlePageRender(parameters);
+ }
+
+ private boolean dispatchedToLoginPage(String pageName) throws IOException {
+
+ Component page = componentSource.getPage(pageName);
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Page name : " + pageName);
+ logger.trace("Page class : " + page.getClass());
+ logger.trace("RequiresLogin annotation : " +
+ page.getClass().isAnnotationPresent(annotationClass));
+ logger.trace("User in session : " +
+ serviceAuthentication.isUserConnected());
+ }
+
+ if (!page.getClass().isAnnotationPresent(annotationClass)) {
+ return false;
+ }
+
+// Class<?> redirectPage = Connexion.class;
+ AuthenticationRedirect redirectType = AuthenticationRedirect.CONNEXION;
+
+ if (serviceAuthentication.isUserConnected()) {
+ U user = serviceAuthentication.getUserConnected();
+ if (logger.isTraceEnabled()) {
+ logger.trace("User connected : " + user);
+ logger.trace("User allowed : " +
+ serviceAuthentication.isAllowed(page.getClass()));
+ }
+
+ if (serviceAuthentication.isAllowed(page.getClass())) {
+ return false;
+ }
+
+// redirectPage = ErrorPage.class;
+ redirectType = AuthenticationRedirect.NOT_ALLOWED;
+ }
+
+ Class<?> redirectPage = getRedirectPage(redirectType);
+ Link link = pageRender.createPageRenderLinkWithContext(redirectPage,
+ pageName);
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Redirection to " + redirectPage.getSimpleName() +
+ " page...");
+ }
+
+ response.sendRedirect(link);
+
+ return true;
+ }
+
+ protected enum AuthenticationRedirect {
+ CONNEXION, NOT_ALLOWED;
+ }
+
+ protected abstract Class<?> getRedirectPage(
+ AuthenticationRedirect redirectType);
+}
+
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
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-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -27,8 +27,10 @@
import org.apache.tapestry5.ioc.services.SymbolProvider;
import org.apache.tapestry5.services.ApplicationStateContribution;
import org.apache.tapestry5.services.ApplicationStateCreator;
+import org.apache.tapestry5.services.ApplicationStateManager;
import org.apache.tapestry5.services.BindingFactory;
import org.apache.tapestry5.services.BindingSource;
+import org.apache.tapestry5.services.ComponentRequestFilter;
import org.apache.tapestry5.upload.services.UploadSymbols;
import org.chorem.pollen.PollenContextImpl;
import org.chorem.pollen.entity.UserAccount;
@@ -88,6 +90,13 @@
return new ServiceImageImpl(manager.getContext());
}
+ public ServiceAuthentication<UserAccount> buildServiceAuthentication(
+ ApplicationStateManager stateManager) {
+ ServiceAuthentication<UserAccount> instance =
+ new ServiceAuthenticationImpl(stateManager);
+ return instance;
+ }
+
/**
* Execute PollenManager when registry startup.
* The manager will be instantiated using
@@ -207,10 +216,11 @@
* Used to instanciate SessionState UserAccount when session expires.
*
* @param configuration to add the ApplicationStateCreator.
- * @param serviceUser to instantiate user
+ * @param serviceAuthentication to instantiate user
*/
- public void contributeApplicationStateManager(MappedConfiguration<Class<?>, ApplicationStateContribution> configuration,
- final ServiceUser serviceUser) {
+ public void contributeApplicationStateManager(MappedConfiguration<Class<?>,
+ ApplicationStateContribution> configuration,
+ final ServiceAuthentication<UserAccount> serviceAuthentication) {
if (logger.isInfoEnabled()) {
logger.info("Execute contributeApplicationStateManager");
}
@@ -220,7 +230,7 @@
@Override
public UserAccount create() {
- return serviceUser.getNewUser();
+ return serviceAuthentication.getNewUserInstance();
}
};
@@ -228,6 +238,22 @@
new ApplicationStateContribution("session", creator));
}
+ /**
+ * Contribution to ComponentRequestHandler service. The
+ * {@link AuthenticationFilter} is added to the configuration of
+ * the service to provide authentication managment on user connected.
+ *
+ * @param configuration of ComponentRequestHandler
+ * @see ServiceAuthentication
+ * @see AuthenticationFilter
+ * @see ComponentRequestFilter
+ */
+ public static void contributeComponentRequestHandler(
+ OrderedConfiguration<ComponentRequestFilter> configuration) {
+ configuration.addInstance("RequiresAuthentication",
+ AuthenticationFilter.class);
+ }
+
public static void contributeBindingSource(
MappedConfiguration<String, BindingFactory> configuration,
BindingSource bindingSource) {
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,42 @@
+
+package org.chorem.pollen.ui.services;
+
+import org.apache.tapestry5.services.ComponentSource;
+import org.apache.tapestry5.services.PageRenderLinkSource;
+import org.apache.tapestry5.services.Response;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.ui.data.RequiresAuthentication;
+import org.chorem.pollen.ui.pages.Connexion;
+import org.chorem.pollen.ui.pages.ErrorPage;
+import org.chorem.pollen.ui.services.AbstractAuthenticationFilter.AuthenticationRedirect;
+
+/**
+ * AuthenticationFilter
+ *
+ * Created: 4 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class AuthenticationFilter extends
+ AbstractAuthenticationFilter<UserAccount, RequiresAuthentication>{
+
+ public AuthenticationFilter(PageRenderLinkSource renderLinkSource,
+ ComponentSource componentSource, Response response,
+ ServiceAuthentication<UserAccount> serviceAuthentication) {
+ super(renderLinkSource, componentSource, response,
+ serviceAuthentication, RequiresAuthentication.class);
+ }
+
+ @Override
+ protected Class<?> getRedirectPage(AuthenticationRedirect redirectType) {
+ switch (redirectType) {
+ case CONNEXION:
+ return Connexion.class;
+ case NOT_ALLOWED:
+ return ErrorPage.class;
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,27 @@
+
+package org.chorem.pollen.ui.services;
+
+import org.chorem.pollen.entity.UserAccount;
+
+/**
+ * ServiceAuthentication
+ *
+ * Created: 3 mai 2010
+ *
+ * @param <U> user type
+ * @author fdesbois
+ * $Id$
+ */
+public interface ServiceAuthentication<U> {
+
+ boolean isUserConnected();
+
+ U getUserConnected();
+
+ void setUserConnected(U user);
+
+ boolean isAllowed(Class<?> page);
+
+ U getNewUserInstance();
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,71 @@
+
+package org.chorem.pollen.ui.services;
+
+import java.lang.annotation.Annotation;
+import org.apache.tapestry5.services.ApplicationStateManager;
+
+/**
+ * ServiceAuthenticationImpl
+ *
+ * Created: 3 mai 2010
+ *
+ * @param <U>
+ * @param <A>
+ * @author fdesbois
+ * $Id$
+ */
+public abstract class ServiceAuthenticationAbstract<U, A extends Annotation>
+ implements ServiceAuthentication<U> {
+
+ private final ApplicationStateManager stateManager;
+
+ private Class<U> userClass;
+
+ private Class<A> annotationClass;
+
+ public ServiceAuthenticationAbstract(ApplicationStateManager stateManager,
+ Class<U> userClass, Class<A> annotationClass) {
+ this.stateManager = stateManager;
+ this.userClass = userClass;
+ this.annotationClass = annotationClass;
+ }
+
+ @Override
+ public boolean isUserConnected() {
+ return stateManager.exists(userClass);
+ }
+
+ @Override
+ public U getUserConnected() {
+ return stateManager.getIfExists(userClass);
+ }
+
+ @Override
+ public void setUserConnected(U user) {
+ stateManager.set(userClass, user);
+ }
+
+ @Override
+ public boolean isAllowed(Class<?> page) {
+ if (page.isAnnotationPresent(annotationClass) &&
+ isUserConnected()) {
+
+ A check = page.getAnnotation(annotationClass);
+
+ U user = getUserConnected();
+
+ return checkAuthorizations(user, check);
+
+ // Check if user not admin is allowed
+// if (!user.getAdmin() && check.adminOnly()) {
+// return false;
+// }
+// return false;
+ }
+ // No restriction if annotation is not present
+ return true;
+ }
+
+ protected abstract boolean checkAuthorizations(U user, A annotation);
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,36 @@
+
+package org.chorem.pollen.ui.services;
+
+import org.apache.tapestry5.services.ApplicationStateManager;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.entity.UserAccountImpl;
+import org.chorem.pollen.ui.data.RequiresAuthentication;
+
+/**
+ * ServiceAuthenticationImpl
+ *
+ * Created: 4 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class ServiceAuthenticationImpl extends
+ ServiceAuthenticationAbstract<UserAccount, RequiresAuthentication> {
+
+ public ServiceAuthenticationImpl(ApplicationStateManager stateManager) {
+ super(stateManager, UserAccount.class, RequiresAuthentication.class);
+ }
+
+ @Override
+ protected boolean checkAuthorizations(UserAccount user,
+ RequiresAuthentication annotation) {
+ // No problem for an admin or if the annotation has no limitation
+ return user.getAdmin() || !annotation.adminOnly();
+ }
+
+ @Override
+ public UserAccount getNewUserInstance() {
+ return new UserAccountImpl();
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
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-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-04 10:11:20 UTC (rev 2983)
@@ -17,8 +17,8 @@
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.display.notConnected=Vous devez vous connecter pour acc\u00E9der \u00E0 la page %1$s.
+pollen.ui.user.display.notAllowed=Vous n'avez pas les droits n\u00E9cessaires pour acc\u00E9der \u00E0 la page %1$s.
pollen.ui.user.create.title=Cr\u00E9er un nouvel utilisateur
pollen.ui.user.create.passwordGenerated=Le mot de passe du nouvel utilisateur a \u00E9t\u00E9 g\u00E9n\u00E9r\u00E9.
pollen.ui.user.create.passwordSameAsLogin=Le mot de passe du nouvel utilisateur est le m\u00EAme que son identifiant.
@@ -38,6 +38,15 @@
pollen.ui.list.update.emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email.
pollen.ui.list.update.addParticipant=Ajouter un nouvel utilisateur \u00E0 la liste
+# OLD LOGIN_COMPONENT
+connectionLegend=Connexion
+loginSubmit=Me connecter
+loginComp-label=Identifiant
+loginComp-required-message=Vous devez entrer votre identifiant.
+passwordComp-label=Mot de passe
+passwordComp-required-message=Vous devez entrer votre mot de passe.
+loginFailed=Mauvais identifiant ou mot de passe.
+
# FORM:: user
firstName-label=Pr\u00E9nom
lastName-label=Nom
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-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml 2010-05-04 10:11:20 UTC (rev 2983)
@@ -159,21 +159,7 @@
<t:feedback t:id="errorJs" />
</noscript>
<t:feedback t:id="borderFeedback" t:autoClear="false"/>
- <t:delegate t:to="activeBlock" />
- <t:block t:id="loginBlock">
- <t:LoginComponent />
- </t:block>
- <t:block t:id="pageBlock">
- <t:body />
- </t:block>
- <!--<t:if t:test="needAuthentification">
- <t:LoginComponent />
- <p:else>
- <t:if t:test="canDisplayBody()">
- <t:body />
- </t:if>
- </p:else>
- </t:if>-->
+ <t:body />
</div>
</div>
Deleted: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent.tml 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent.tml 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,18 +0,0 @@
-
-<t:form t:id="loginCompForm" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
- <FieldSet>
- <legend>${message:connectionLegend}</legend>
- <t:feedback t:id="loginCompFeedback" />
- <div>
- <t:label for="connectionLogin" />
- <input t:type="TextField" t:id="connectionLogin" validate="required" />
- </div>
- <div>
- <t:label for="connectionPassword" />
- <input t:type="PasswordField" t:id="connectionPassword" validate="required" />
- </div>
- <div class="buttons">
- <input t:id="submitLoginCompForm" t:type="Submit" t:value="${message:loginSubmit}" />
- </div>
- </FieldSet>
-</t:form>
Deleted: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_en.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_en.properties 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_en.properties 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,7 +0,0 @@
-connectionLegend=LogIn
-loginSubmit=Log me in
-loginComp-label=Login
-loginComp-required-message=You must enter your login.
-passwordComp-label=Password
-passwordComp-required-message=You must enter your password.
-loginFailed=Login or password invalid.
\ No newline at end of file
Deleted: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_fr.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_fr.properties 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_fr.properties 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,7 +0,0 @@
-connectionLegend=Connexion
-loginSubmit=Me connecter
-loginComp-label=Identifiant
-loginComp-required-message=Vous devez entrer votre identifiant.
-passwordComp-label=Mot de passe
-passwordComp-required-message=Vous devez entrer votre mot de passe.
-loginFailed=Mauvais identifiant ou mot de passe.
\ No newline at end of file
Added: trunk/pollen-ui/src/main/webapp/Connexion.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/Connexion.tml (rev 0)
+++ trunk/pollen-ui/src/main/webapp/Connexion.tml 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,23 @@
+<!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"
+ xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+
+ <t:form t:id="loginForm">
+ <fieldset>
+ <legend>${message:connectionLegend}</legend>
+ <t:errors />
+ <div>
+ <t:label for="connectionLogin" />
+ <input t:type="TextField" t:id="connectionLogin" validate="required" />
+ </div>
+ <div>
+ <t:label for="connectionPassword" />
+ <input t:type="PasswordField" t:id="connectionPassword" validate="required" />
+ </div>
+ <div class="buttons">
+ <input t:id="submitLoginCompForm" t:type="Submit" t:value="${message:loginSubmit}" />
+ </div>
+ </fieldset>
+ </t:form>
+
+</t:border>
\ No newline at end of file
Property changes on: trunk/pollen-ui/src/main/webapp/Connexion.tml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/webapp/ErrorPage.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/ErrorPage.tml 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/webapp/ErrorPage.tml 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,4 +1,4 @@
-<t:border t:address="address" t:pageLogo="literal:Index"
+<t:border t:addressBar="addressBar" t:pageLogo="literal:Index"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
</t:border>
Deleted: trunk/pollen-ui/src/main/webapp/css/loginComponent.css
===================================================================
--- trunk/pollen-ui/src/main/webapp/css/loginComponent.css 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/webapp/css/loginComponent.css 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,35 +0,0 @@
-#loginCompForm fieldset {
- border: 1px solid #aab;
- padding: 15px;
- padding-bottom: 10px;
- width: 280px;
- margin: auto;
- margin-top: 20px;
- vertical-align: top;
- text-align: left;
-}
-
-#loginCompForm div {
- margin-bottom: 10px;
-}
-
-#loginCompForm label {
- display: block;
- width: 100px;
- float: left;
-}
-
-.buttons {
- text-align: center;
- margin-top: 20px;
- padding-left: 0px;
-}
-
-.fb-error {
- width: 270px;
- margin: auto;
- text-align: center;
- color: #f00;
- font-weight: bold;
- border: 0;
-}
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/webapp/css/main.css
===================================================================
--- trunk/pollen-ui/src/main/webapp/css/main.css 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/webapp/css/main.css 2010-05-04 10:11:20 UTC (rev 2983)
@@ -392,4 +392,32 @@
#po-footer a,
#po-footer span {
color:#727a7e;
+}
+
+/** old LoginComponent > Connexion page **/
+#loginCompForm fieldset {
+ border: 1px solid #aab;
+ padding: 15px;
+ padding-bottom: 10px;
+ width: 280px;
+ margin: auto;
+ margin-top: 20px;
+ vertical-align: top;
+ text-align: left;
+}
+
+#loginCompForm div {
+ margin-bottom: 10px;
+}
+
+#loginCompForm label {
+ display: block;
+ width: 100px;
+ float: left;
+}
+
+#loginCompForm .buttons {
+ text-align: center;
+ margin-top: 20px;
+ padding-left: 0px;
}
\ No newline at end of file
Added: trunk/src/license/project.xml
===================================================================
--- trunk/src/license/project.xml (rev 0)
+++ trunk/src/license/project.xml 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,105 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<project xmlns="http://maven-site.nuiton.org/maven-license-plugin/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven-site.nuiton.org/maven-license-plugin/1.0.0 http://maven-site.nuiton.org/maven-license-plugin/licenseProjectDescriptor-…">
+ <mainLicense>gpl_v3</mainLicense>
+
+ <headers>
+
+ <header>
+ <commentStyle>java</commentStyle>
+ <fileSets>
+ <fileSet>
+ <basedir>src/main/java</basedir>
+ <include>**/*.java</include>
+ </fileSet>
+ <fileSet>
+ <!-- assets for tapestry -->
+ <basedir>src/main/webapp</basedir>
+ <includes>
+ <include>**/*.css</include>
+ <include>**/*.js</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <!-- tests -->
+ <basedir>src/test/java</basedir>
+ <include>**/*.java</include>
+ </fileSet>
+ <fileSet>
+ <!-- generated sources with EUGene -->
+ <basedir>target/generated-sources/java</basedir>
+ <include>**/*.java</include>
+ </fileSet>
+ </fileSets>
+ </header>
+
+ <header>
+ <commentStyle>rst</commentStyle>
+ <fileSet>
+ <!-- maven-site -->
+ <basedir>src/site</basedir>
+ <include>**/*.rst</include>
+ </fileSet>
+ </header>
+
+ <header>
+ <commentStyle>xml</commentStyle>
+ <fileSets>
+ <fileSet>
+ <!-- tapestry templates for pages -->
+ <basedir>src/main/webapp</basedir>
+ <includes>
+ <include>**/*.tml</include>
+ <include>**/*.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <!-- tapestry templates for components -->
+ <basedir>src/main/resources</basedir>
+ <includes>
+ <include>**/*.tml</include>
+ <include>**/*.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <!-- test pages for components -->
+ <basedir>src/test/java</basedir>
+ <include>**/*.tml</include>
+ </fileSet>
+ <fileSet>
+ <!-- maven-site -->
+ <basedir>src/site</basedir>
+ <include>**/*.xml</include>
+ </fileSet>
+ <fileSet>
+ <!-- generated sources with EUGene (hibernate mappings) -->
+ <basedir>target/generated-sources/java</basedir>
+ <include>**/*.xml</include>
+ </fileSet>
+ </fileSets>
+ </header>
+
+ <header>
+ <commentStyle>properties</commentStyle>
+ <fileSets>
+ <fileSet>
+ <!-- i18n -->
+ <basedir>src/main/resources</basedir>
+ <include>**/*.properties</include>
+ </fileSet>
+ <fileSet>
+ <!-- i18n for tapestry -->
+ <basedir>src/main/webapp</basedir>
+ <include>**/*.properties</include>
+ </fileSet>
+ <fileSet>
+ <!-- maven filtered properties -->
+ <basedir>src/main/filters</basedir>
+ <include>**/*.properties</include>
+ </fileSet>
+ </fileSets>
+ </header>
+ </headers>
+
+</project>
Property changes on: trunk/src/license/project.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0