Author: fdesbois Date: 2010-04-08 11:42:50 +0200 (Thu, 08 Apr 2010) New Revision: 2967 Log: - Update ServiceTransformer usage for ToPIA 2.3.3 - Use nuiton-utils snapshot 1.2.2 - Create PollenManager to manipulate context in Tapestry - Remove MD5 class, use StringUtil.encodeMD5 instead Added: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java trunk/pollen-business/src/main/java/org/chorem/pollen/PollenException.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java Removed: trunk/pollen-business/src/main/java/org/chorem/pollen/MD5.java Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/mail/SendMail.java trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceEmailImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.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/TestManager.java trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.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/pom.xml Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/MD5.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/MD5.java 2010-04-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/MD5.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -1,59 +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; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * Classe utilitaire permettant d'encoder des chaîne en MD5. - * - * @version $Id$ - */ -public class MD5 { - - /** - * Encode la chaine passé en paramètre avec l’algorithme MD5 - * - * @param key : la chaine à encoder - * @return la valeur (string) hexadécimale sur 32 bits - */ - public static String encode(String key) { - - byte[] uniqueKey = key.getBytes(); - byte[] hash = null; - - try { - // on récupère un objet qui permettra de crypter la chaine - hash = MessageDigest.getInstance("MD5").digest(uniqueKey); - } catch (NoSuchAlgorithmException e) { - throw new Error("no MD5 support in this VM"); - } - - StringBuffer hashString = new StringBuffer(); - for (int i = 0; i < hash.length; ++i) { - String hex = Integer.toHexString(hash[i]); - if (hex.length() == 1) { - hashString.append("0"); - hashString.append(hex.charAt(hex.length() - 1)); - } else { - hashString.append(hex.substring(hex.length() - 2)); - } - } - return hashString.toString(); - } -} Added: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -0,0 +1,123 @@ +package org.chorem.pollen; + +import java.util.Date; +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaException; +import org.nuiton.util.ApplicationConfig; + + +public interface PollenContext { + + /** + * loadConfiguration : + * Load the application configuration : + * <pre> + * - Add entities implementation classes for Topia-persistence + * - Add model version for Topia-migration-service + * </pre> + * @param config ApplicationConfig + */ + public void loadConfiguration(ApplicationConfig config); + + /** + * start : + * Start of the application. The application configuration will be loaded + * automatically if needed using {@link #loadDefaultConfiguration }. Also + * you can manually load the configuration using + * {@link #loadConfiguration(ApplicationConfig)} + * This start does : + * <pre> + * - Initialize i18n for error messages + * - Create default admin if needed (this will load the topiaRootContext). + * </pre> + */ + public void start(); + + /** + * stop : + * Stop the application. Close the Topia rootContext. + */ + public void stop(); + + /** + * getProperty : + * Get a property from the configuration. + * @param property PollenProperty + * @return String + */ + public String getProperty(PollenProperty property); + + /** + * hasProperty : + * Test if the property is defined in this context + * @param property PollenProperty + * @return boolean + */ + public boolean hasProperty(PollenProperty property); + + /** + * getConfiguration : + * Get the configuration of the application. Instantiate the default one + * if needed. + * @return ApplicationConfig + */ + public ApplicationConfig getConfiguration(); + + /** + * getCurrentDate : + * Return the current date from context + * @return Date + */ + public Date getCurrentDate(); + + /** + * encodePassword : + * @param password + * @return String + */ + public String encodePassword(String password); + + /** + * createPollenUrlId : + * Create a unique UId for entities which need it (PollAccount, Poll). + * This UId represent the entity in UI module. + * @return String + */ + public String createPollenUrlId(); + + /** + * beginTransaction : + * @return TopiaContext + * @throws TopiaException + */ + public TopiaContext beginTransaction() throws TopiaException; + + /** + * doCatch : + * @param eee + * @param message + * @param args + * @throws PollenException + */ + public void treateError(Exception eee, String message, Object... args) + throws PollenException; + + /** + * doCatch : + * @param transaction + * @param eee + * @param message + * @param args + * @throws PollenException + */ + public void treateError(TopiaContext transaction, Exception eee, + String message, Object... args) throws PollenException; + + /** + * doFinally : + * @param transaction + */ + public void closeTransaction(TopiaContext transaction); + + +} //PollenContext Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-04-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -1,16 +1,17 @@ package org.chorem.pollen; +import java.security.NoSuchAlgorithmException; import java.util.Date; import java.util.Properties; import java.util.UUID; +import java.util.logging.Level; +import java.util.logging.Logger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; //import org.chorem.pollen.PollenDAOHelper; //import org.chorem.pollen.business.services.SendMail; //import org.chorem.pollen.business.services.ServiceUserImpl; -import org.chorem.pollen.service.ServiceEmail; -import org.chorem.pollen.service.ServiceEmailImpl; import org.nuiton.i18n.I18n; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; @@ -21,6 +22,7 @@ import static org.nuiton.i18n.I18n.n_; import org.nuiton.i18n.init.DefaultI18nInitializer; import org.nuiton.topia.TopiaNotFoundException; +import org.nuiton.util.StringUtil; /** * PollenContext @@ -33,7 +35,7 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class PollenContextImpl implements PollenContextImplementor { +public class PollenContextImpl implements PollenContext { /** log. */ private static final Log log = LogFactory.getLog(PollenContextImpl.class); @@ -78,7 +80,7 @@ loadConfiguration(conf); } catch (ArgumentsParserException eee) { - doCatch(eee, n_("pollen.error.context.parse"), + treateError(eee, n_("pollen.error.context.parse"), PollenContextImpl.DEFAULT_FILENAME); } } @@ -142,7 +144,7 @@ } } catch (Exception eee) { - doCatch(eee, n_("pollen.error.context.start")); + treateError(eee, n_("pollen.error.context.start")); } } @@ -158,7 +160,7 @@ getTopiaRootContext().closeContext(); // sendMail.stopExec(); } catch (Exception eee) { - doCatch(eee, n_("pollen.error.context.stop")); + treateError(eee, n_("pollen.error.context.stop")); } } @@ -172,7 +174,6 @@ * * @param property PollenProperty * @return value of this property - * @throws PollenBusinessException */ @Override public String getProperty(PollenProperty property) { @@ -235,7 +236,7 @@ try { return TopiaContextFactory.getContext(getProperties()); } catch (TopiaNotFoundException eee) { - doCatch(eee, n_("pollen.error.context.getRootContext")); + treateError(eee, n_("pollen.error.context.getRootContext")); } return null; } @@ -264,9 +265,9 @@ * @throws PollenException which contains the exception as the cause */ @Override - public void doCatch(Exception eee, String message, Object... args) + public void treateError(Exception eee, String message, Object... args) throws PollenException { - doCatch(null, eee, message, args); + treateError(null, eee, message, args); } /** @@ -282,8 +283,8 @@ * @throws PollenException */ @Override - public void doCatch(TopiaContext transaction, Exception eee, String message, - Object... args) throws PollenException { + public void treateError(TopiaContext transaction, Exception eee, + String message, Object... args) throws PollenException { if (log.isErrorEnabled()) { log.error(_(message, args), eee); } @@ -317,10 +318,11 @@ * @param transaction current TopiaContext */ @Override - public void doFinally(TopiaContext transaction) { + public void closeTransaction(TopiaContext transaction) { if (transaction != null) { try { transaction.closeContext(); + //stop(); } catch (TopiaException eee) { if (log.isErrorEnabled()) { log.error(_("pollen.error.context.close"), eee); @@ -360,19 +362,14 @@ this.currentDate = currentDate; } -// @Override -// public ServiceEmail getServiceEmail() { -// if (serviceEmail == null) { -// ServiceEmailImpl instance = new ServiceEmailImpl(); -// instance.setContext(this); -// serviceEmail = instance; -// } -// return serviceEmail; -// } - @Override public String encodePassword(String password) { - return MD5.encode(password); + try { + return StringUtil.encodeMD5(password); + } catch (NoSuchAlgorithmException eee) { + treateError(eee, n_("pollen.error.encodePassword")); + } + return null; } } Added: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenException.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenException.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenException.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -0,0 +1,39 @@ +package org.chorem.pollen; + + + +public class PollenException extends RuntimeException { + + protected Object[] args; + /** + * PollenException : + * @param eee + * @param message + * @param args + */ + + public PollenException(Throwable eee, String message, Object... args) { + super(message, eee); + this.args = args; + } + + /** + * getArgs : + * @return Object[] + */ + + public Object[] getArgs() { + return args; + } + + /** + * hasArgs : + * @return boolean + */ + + public boolean hasArgs() { + return args.length > 0; + } + + +} //PollenException Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenException.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/mail/SendMail.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/mail/SendMail.java 2010-04-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/mail/SendMail.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -37,7 +37,7 @@ import au.com.bytecode.opencsv.CSVReader; import au.com.bytecode.opencsv.CSVWriter; import org.apache.commons.io.IOUtils; -import org.chorem.pollen.PollenContextImplementor; +import org.chorem.pollen.PollenContext; import org.chorem.pollen.PollenProperty; /** @@ -64,7 +64,7 @@ /** logger. */ private static final Logger log = LoggerFactory.getLogger(SendMail.class); - protected PollenContextImplementor context; + protected PollenContext context; public static final String EXTENSION_MAIL = ".mail"; public static final String EXTENSION_INDEX = ".index"; @@ -74,7 +74,7 @@ protected volatile boolean stop; - public SendMail(PollenContextImplementor context) { + public SendMail(PollenContext context) { this.context = context; if (log.isInfoEnabled()) { log.info("P:[ SendMail ] init"); Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceEmailImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceEmailImpl.java 2010-04-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceEmailImpl.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -6,9 +6,13 @@ import org.apache.commons.logging.LogFactory; import org.apache.commons.mail.EmailException; import org.apache.commons.mail.SimpleEmail; +import org.chorem.pollen.PollenContext; +import org.chorem.pollen.PollenException; import org.chorem.pollen.bean.PollenEmail; import org.chorem.pollen.bean.PollenEmailImpl; import org.chorem.pollen.entity.UserAccount; +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaException; /** * ServiceMailImpl @@ -25,7 +29,35 @@ private static final Log log = LogFactory.getLog(ServiceEmailImpl.class); + private PollenContext context; + + public void setContext(PollenContext context) { + this.context = context; + } + @Override + protected void treateError(TopiaContext transaction, Exception eee, + String message, Object... args) throws PollenException { + context.treateError(transaction, eee, message, args); + } + + @Override + protected void treateError(Exception eee, String message, + Object... args) throws PollenException { + context.treateError(eee, message, args); + } + + @Override + protected void closeTransaction(TopiaContext transaction) { + context.closeTransaction(transaction); + } + + @Override + protected TopiaContext beginTransaction() throws TopiaException { + return context.beginTransaction(); + } + + @Override protected void executeSendEmail(List<Object> errorArgs, PollenEmail pollenEmail) throws EmailException { Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-04-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -3,16 +3,15 @@ import java.util.List; import org.chorem.pollen.PollenBusinessException; -import org.chorem.pollen.PollenContextImplementor; +import org.chorem.pollen.PollenContext; import org.chorem.pollen.PollenDAOHelper; -import org.chorem.pollen.entity.PollDAO; +import org.chorem.pollen.PollenException; import org.chorem.pollen.entity.Choice; import org.chorem.pollen.entity.Comment; import org.chorem.pollen.entity.Poll; import org.chorem.pollen.entity.PollAccount; import org.chorem.pollen.entity.PollImpl; import org.chorem.pollen.entity.UserAccount; -import org.nuiton.i18n.I18n; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; @@ -29,7 +28,35 @@ */ public class ServicePollImpl extends ServicePollAbstract { + private PollenContext context; + + public void setContext(PollenContext context) { + this.context = context; + } + @Override + protected void treateError(TopiaContext transaction, Exception eee, + String message, Object... args) throws PollenException { + context.treateError(transaction, eee, message, args); + } + + @Override + protected void treateError(Exception eee, String message, + Object... args) throws PollenException { + context.treateError(eee, message, args); + } + + @Override + protected void closeTransaction(TopiaContext transaction) { + context.closeTransaction(transaction); + } + + @Override + protected TopiaContext beginTransaction() throws TopiaException { + return context.beginTransaction(); + } + + @Override protected Poll executeGetNewPoll() { return new PollImpl(); } @@ -53,91 +80,87 @@ @Override protected void executeUpdatePoll(TopiaContext transaction, - List<Object> errorArgs, Poll poll) throws TopiaException { + Poll poll) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected void executeSavePoll(TopiaContext transaction, - List<Object> errorArgs, Poll poll) throws TopiaException { + protected void executeSavePoll(TopiaContext transaction, Poll poll) + throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected void executeDeletePoll(TopiaContext transaction, - List<Object> errorArgs, Poll poll) throws TopiaException { + protected void executeDeletePoll(TopiaContext transaction, Poll poll) + throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected void executeDeleteChoice(TopiaContext transaction, - List<Object> errorArgs, Choice choice) throws TopiaException { + protected void executeDeleteChoice(TopiaContext transaction, Choice choice) + throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override protected void executeCreateUpdateVote(TopiaContext transaction, - List<Object> errorArgs, PollAccount person) throws TopiaException { + PollAccount person) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected void executeDeleteVote(TopiaContext transaction, - List<Object> errorArgs, Poll poll, PollAccount person) - throws TopiaException { + protected void executeDeleteVote(TopiaContext transaction, Poll poll, + PollAccount person) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected Poll executeGetPollForUpdate(TopiaContext transaction, - List<Object> errorArgs, String pollUId) - throws PollenBusinessException, TopiaException { + protected Poll executeGetPollForUpdate(TopiaContext transaction, + String pollUId) throws PollenBusinessException, TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected List<Poll> executeGetAllPolls(TopiaContext transaction, - List<Object> errorArgs) throws TopiaException { + protected List<Poll> executeGetAllPolls(TopiaContext transaction) + throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected List<Poll> executeGetRunningPolls(TopiaContext transaction, - List<Object> errorArgs) throws TopiaException { + protected List<Poll> executeGetRunningPolls(TopiaContext transaction) + throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override protected List<Poll> executeGetPollsByUser(TopiaContext transaction, - List<Object> errorArgs, UserAccount user) throws TopiaException { + UserAccount user) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override protected List<Comment> executeGetComments(TopiaContext transaction, - List<Object> errorArgs, Poll poll, int startIndex, int endIndex) + Poll poll, int startIndex, int endIndex) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override protected List<PollAccount> executeGetVotes(TopiaContext transaction, - List<Object> errorArgs, Poll poll, int startIndex, int endIndex) + Poll poll, int startIndex, int endIndex) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected Poll executeGetPollForResults(TopiaContext transaction, - List<Object> errorArgs, String pollUId) - throws PollenBusinessException, TopiaException { + protected Poll executeGetPollForResults(TopiaContext transaction, + String pollUId) throws PollenBusinessException, TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected Poll executeGetPollForVote(TopiaContext transaction, - List<Object> errorArgs, String pollUId) - throws PollenBusinessException, TopiaException { + protected Poll executeGetPollForVote(TopiaContext transaction, + String pollUId) throws PollenBusinessException, TopiaException { throw new UnsupportedOperationException("Not supported yet."); } Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -6,7 +6,9 @@ import org.apache.commons.lang.StringUtils; 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.entity.PollAccount; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.entity.UserAccountDAO; @@ -27,7 +29,35 @@ */ public class ServiceUserImpl extends ServiceUserAbstract { + private PollenContext context; + + public void setContext(PollenContext context) { + this.context = context; + } + @Override + protected void treateError(TopiaContext transaction, Exception eee, + String message, Object... args) throws PollenException { + context.treateError(transaction, eee, message, args); + } + + @Override + protected void treateError(Exception eee, String message, + Object... args) throws PollenException { + context.treateError(eee, message, args); + } + + @Override + protected void closeTransaction(TopiaContext transaction) { + context.closeTransaction(transaction); + } + + @Override + protected TopiaContext beginTransaction() throws TopiaException { + return context.beginTransaction(); + } + + @Override protected UserAccount executeConnect(TopiaContext transaction, List<Object> errorArgs, String login, String password) throws PollenBusinessException, TopiaException { @@ -91,51 +121,50 @@ } @Override - protected void executeDeleteUser(TopiaContext transaction, - List<Object> errorArgs, UserAccount user) throws TopiaException { + protected void executeDeleteUser(TopiaContext transaction, UserAccount user) + throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected List<UserAccount> executeGetUsers(TopiaContext transaction, - List<Object> errorArgs) throws TopiaException { + protected List<UserAccount> executeGetUsers(TopiaContext transaction) + throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected PollAccount executeGetNewList(TopiaContext transaction, - List<Object> errorArgs) throws TopiaException { + protected PollAccount executeGetNewList(TopiaContext transaction) + throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override protected void executeCreateUpdateList(TopiaContext transaction, - List<Object> errorArgs, PollAccount list) throws TopiaException { + PollAccount list) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override protected void executeDeleteList(TopiaContext transaction, - List<Object> errorArgs, PollAccount list) throws TopiaException { + PollAccount list) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override protected List<PollAccount> executeGetFavoriteLists( - TopiaContext transaction, List<Object> errorArgs) - throws TopiaException { + TopiaContext transaction) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override protected PollAccount executeGetNewPerson(TopiaContext transaction, - List<Object> errorArgs, UserAccount user) throws TopiaException { + UserAccount user) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override protected PollAccount executeGetPerson(TopiaContext transaction, - List<Object> errorArgs, String accountUId) + String accountUId) throws PollenBusinessException, TopiaException { throw new UnsupportedOperationException("Not supported yet."); } Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties =================================================================== --- trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-04-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-04-08 09:42:50 UTC (rev 2967) @@ -4,6 +4,7 @@ pollen.error.context.rollback= pollen.error.context.start= pollen.error.context.stop= +pollen.error.encodePassword= pollen.error.serviceEmail.getNewEmail= pollen.error.serviceEmail.sendEmail= pollen.error.serviceList.createAccountForPersonList= Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties =================================================================== --- trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-04-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-04-08 09:42:50 UTC (rev 2967) @@ -4,6 +4,7 @@ pollen.error.context.rollback=Erreur lors de l'annulation de la transaction pollen.error.context.start=Erreur lors du d\u00E9marrage de l'application pollen.error.context.stop=Erreur lors de l'arr\u00EAt de l'application +pollen.error.encodePassword= pollen.error.serviceEmail.getNewEmail= pollen.error.serviceEmail.sendEmail= pollen.error.serviceList.createAccountForPersonList= Modified: trunk/pollen-business/src/main/xmi/pollen.properties =================================================================== --- trunk/pollen-business/src/main/xmi/pollen.properties 2010-04-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-business/src/main/xmi/pollen.properties 2010-04-08 09:42:50 UTC (rev 2967) @@ -2,5 +2,6 @@ model.tagvalue.copyright=/* *##%\n Copyright (C) 2009 Pollen\n *##%*/ #model.tagvalue.dbSchema=Pollen model.tagvalue.java.lang.String=text +model.tagvalue.exceptionClass=org.chorem.pollen.PollenException #org.chorem.pollen.business.persistence.PollAccount.attribute.accountId.tagvalue.naturalId=true #org.chorem.pollen.business.persistence.Poll.attribute.pollId.tagvalue.naturalId=true \ No newline at end of file Modified: trunk/pollen-business/src/main/xmi/pollen.zargo =================================================================== (Binary files differ) Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java =================================================================== --- trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java 2010-04-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -1,8 +1,6 @@ package org.chorem.pollen.business; -import org.chorem.pollen.PollenContextImplementor; -import org.chorem.pollen.PollenContextImpl; import java.io.IOException; import java.io.InputStream; import java.util.Calendar; @@ -10,6 +8,12 @@ import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.PollenContext; +import org.chorem.pollen.PollenContextImpl; +import org.chorem.pollen.service.ServiceEmail; +import org.chorem.pollen.service.ServiceEmailImpl; +import org.chorem.pollen.service.ServicePoll; +import org.chorem.pollen.service.ServicePollImpl; import org.chorem.pollen.service.ServiceUser; import org.chorem.pollen.service.ServiceUserImpl; import org.junit.Ignore; @@ -33,7 +37,7 @@ private static final Log log = LogFactory.getLog(TestManager.class); - private static PollenContextImplementor context; + private static PollenContext context; public static void start(String dbname) throws IOException { log.info("## START ## : " + dbname); @@ -63,7 +67,7 @@ getContext().stop(); } - public static PollenContextImplementor getContext() { + public static PollenContext getContext() { if (context == null) { context = new PollenContextImpl(); } @@ -74,10 +78,22 @@ return getContext().beginTransaction(); } - public static ServiceUser newServiceUser() { + public static ServiceUser getServiceUser() { ServiceUserImpl instance = new ServiceUserImpl(); instance.setContext(getContext()); return instance; } + public static ServiceEmail getServiceEmail() { + ServiceEmailImpl instance = new ServiceEmailImpl(); + instance.setContext(getContext()); + return instance; + } + + public static ServicePoll getServicePoll() { + ServicePollImpl instance = new ServicePollImpl(); + instance.setContext(getContext()); + return instance; + } + } Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java =================================================================== --- trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java 2010-04-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -58,7 +58,7 @@ @Test public void testExecuteGetNewUser() throws Exception { TestManager.start("testGetNewUser"); - ServiceUser serviceUser = TestManager.newServiceUser(); + ServiceUser serviceUser = TestManager.getServiceUser(); UserAccount user = serviceUser.getNewUser(Locale.FRENCH); Assert.assertNotNull(user); @@ -73,7 +73,7 @@ @Test public void testExecuteCreateUpdateUser() throws Exception { TestManager.start("testCreateUpdateUser"); - ServiceUser serviceUser = TestManager.newServiceUser(); + ServiceUser serviceUser = TestManager.getServiceUser(); UserAccount user = serviceUser.getNewUser(Locale.FRENCH); user.setLogin("hsimpson"); Modified: 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-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -16,18 +16,16 @@ package org.chorem.pollen.ui.components; -import java.util.logging.Level; -import java.util.logging.Logger; 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.MD5; 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 @@ -72,6 +70,9 @@ @Inject private ServiceUser serviceUser; + @Inject + private PollenManager manager; + /** * Methode appelée lorsque l'utilisateur s'identifie * @@ -81,7 +82,8 @@ // Récupération de l'utilisateur identifié UserAccount current; try { - current = serviceUser.connect(loginComp, MD5.encode(passwordComp)); + current = serviceUser.connect(loginComp, + manager.encodePassword(passwordComp)); if (current != null) { user = current; } else { 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-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -29,7 +29,6 @@ import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.MD5; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.service.ServiceUser; import org.chorem.pollen.ui.data.AddressBarItem; 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-03 10:41:29 UTC (rev 2966) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -24,13 +24,13 @@ import org.apache.tapestry5.ioc.annotations.InjectService; import org.apache.tapestry5.ioc.services.Coercion; import org.apache.tapestry5.ioc.services.CoercionTuple; +import org.apache.tapestry5.ioc.services.RegistryShutdownHub; import org.apache.tapestry5.ioc.services.SymbolProvider; import org.apache.tapestry5.services.ApplicationStateContribution; import org.apache.tapestry5.services.ApplicationStateCreator; import org.apache.tapestry5.upload.services.UploadSymbols; import org.chorem.pollen.PollenContext; import org.chorem.pollen.PollenContextImpl; -import org.chorem.pollen.PollenContextImplementor; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.entity.UserAccountImpl; import org.chorem.pollen.service.ServiceEmail; @@ -54,40 +54,37 @@ } /** - * Build the main application context PollenContext. + * Build the application manager. * - * @return PollenContextImplementor type to use injection in services build + * @param hub to register the manager for tapestry registry shutdown + * @return PollenManager */ - public static PollenContextImplementor buildPollenContext() { - PollenContextImplementor context = new PollenContextImpl(); - context.start(); - return context; + public static PollenManager buildPollenManager(RegistryShutdownHub hub) { + PollenManager manager = new PollenManager(new PollenContextImpl()); + hub.addRegistryShutdownListener(manager); + return manager; } - public static ServiceUser buildServiceUser( - @InjectService("PollenContext") PollenContextImplementor context) { + public static ServiceUser buildServiceUser(PollenManager manager) { ServiceUserImpl service = new ServiceUserImpl(); - service.setContext(context); + service.setContext(manager.getContext()); return service; } - public static ServicePoll buildServicePoll( - @InjectService("PollenContext") PollenContextImplementor context) { + public static ServicePoll buildServicePoll(PollenManager manager) { ServicePollImpl service = new ServicePollImpl(); - service.setContext(context); + service.setContext(manager.getContext()); return service; } - public static ServiceEmail buildServiceEmail( - @InjectService("PollenContext") PollenContextImplementor context) { + public static ServiceEmail buildServiceEmail(PollenManager manager) { ServiceEmailImpl service = new ServiceEmailImpl(); - service.setContext(context); + service.setContext(manager.getContext()); return service; } - public static ServiceImage buildServiceImage( - @InjectService("PollenContext") PollenContextImplementor context) { - return new ServiceImageImpl(context); + public static ServiceImage buildServiceImage(PollenManager manager) { + return new ServiceImageImpl(manager.getContext()); } public static void contributeApplicationDefaults( Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-04-08 09:42:50 UTC (rev 2967) @@ -0,0 +1,100 @@ +/* + * *##% + * 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.services; + +import java.util.Date; +import org.apache.tapestry5.ioc.services.RegistryShutdownListener; +import org.chorem.pollen.PollenContext; +import org.chorem.pollen.PollenProperty; +import org.nuiton.util.ApplicationConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * WaoManager + * + * Created: 24 nov. 2009 + * + * @author fdesbois + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ +public class PollenManager implements Runnable, RegistryShutdownListener { + + private static final Logger log = + LoggerFactory.getLogger(PollenManager.class); + + private PollenContext context; + + /** + * Constructor of WaoManager. It needs the WaoContext to start and stop. + * + * @param context used to manage application lifecycle + */ + public PollenManager(PollenContext context) { + this.context = context; + } + + /** + * Called to start the application. + */ + @Override + public void run() { + context.start(); + } + + /** + * Called to stop the application + */ + @Override + public void registryDidShutdown() { + context.stop(); + } + + /** + * Context to inject in new service instances. + * + * @return the WaoContext of the application + */ + PollenContext getContext() { + return context; + } + + public String getProperty(PollenProperty property) { + return context.getProperty(property); + } + + public ApplicationConfig getConfiguration() { + return context.getConfiguration(); + } + + public Date getCurrentDate() { + return context.getCurrentDate(); + } + + public String encodePassword(String password) { + return context.encodePassword(password); + } + +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-04-03 10:41:29 UTC (rev 2966) +++ trunk/pom.xml 2010-04-08 09:42:50 UTC (rev 2967) @@ -309,13 +309,12 @@ <!-- customized versions --> <!--javadoc.version>2.4</javadoc.version--> - <topia.version>2.3.1</topia.version> + <topia.version>2.3.3-SNAPSHOT</topia.version> <eugene.version>2.0.1-SNAPSHOT</eugene.version> <i18n.version>1.2.1</i18n.version> <tapestry.version>5.1.0.5</tapestry.version> - <nuiton-utils.version>1.2.1-SNAPSHOT</nuiton-utils.version> + <nuiton-utils.version>1.2.2-SNAPSHOT</nuiton-utils.version> <processor.version>1.0.2</processor.version> -<!-- <chorem-commons.version>1.0.0-alpha-2-SNAPSHOT</chorem-commons.version>--> <!--Multilanguage maven-site --> <siteLocales>en,fr</siteLocales>