r442 - in trunk: . faxtomail-persistence/src/main/java/com/franciaflex/faxtomail faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities faxtomail-persistence/src/main/resources faxtomail-persistence/src/main/xmi faxtomail-service faxtomail-service/src/main/java/com/franciaflex/faxtomail/services faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/exceptions faxtom
Author: echatellier Date: 2014-07-28 15:23:59 +0200 (Mon, 28 Jul 2014) New Revision: 442 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/442 Log: refs #5542, #5541 : mise en place de flyway, migration des configurations par soci?\195?\169tes et rejet des comptes email Added: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/exceptions/ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/exceptions/AlreadyLockedMailException.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/exceptions/InvalidClientException.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/migration/ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/migration/FaxtomailFlywayMigrationService.java trunk/faxtomail-service/src/main/resources/db/ trunk/faxtomail-service/src/main/resources/db/migration/ trunk/faxtomail-service/src/main/resources/db/migration/V1_0_0_442__move_object_to_folder_configuration.sql Removed: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/FaxToMailWebApplicationContext.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InvalidClientException.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/DefaultFaxToMailWebApplicationContext.java Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java trunk/faxtomail-persistence/src/main/resources/faxToMail.properties trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo trunk/faxtomail-service/pom.xml trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceContext.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceSupport.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestData.java trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/MiscTest.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUIHandler.java trunk/faxtomail-ui-swing/src/main/resources/log4j.properties trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/FaxToMailApplicationContext.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LockAction.java trunk/pom.xml Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java 2014-07-28 13:23:59 UTC (rev 442) @@ -24,19 +24,19 @@ * #L% */ -import org.apache.commons.io.Charsets; -import org.nuiton.config.ConfigOptionDef; -import org.nuiton.util.Version; +import static org.nuiton.i18n.I18n.n; -import javax.swing.*; - -import java.awt.*; +import java.awt.Color; import java.io.File; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.Locale; -import static org.nuiton.i18n.I18n.n; +import javax.swing.KeyStroke; +import org.nuiton.config.ConfigOptionDef; +import org.nuiton.util.Version; + public enum FaxToMailConfigurationOption implements ConfigOptionDef { INSTANCE_URL( @@ -97,7 +97,7 @@ IMPORT_FILE_ENCODING( "faxtomail.import.file.encoding", "Encodage des fichiers des fichiers d'import", - Charsets.UTF_8.toString(), String.class), + StandardCharsets.UTF_8.toString(), String.class), LDAP_MOCK( "faxtomail.ldap.mock", Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java 2014-07-28 13:23:59 UTC (rev 442) @@ -375,19 +375,7 @@ } return result; } - - /** - * Retourne les email vérrouillés. - * - * @return email list - */ - public List<Email> getLockedEmail() { - String query = "FROM " + Email.class.getName() + " where " + Email.PROPERTY_LOCKED_BY + " is not null"; - List<Email> results = findAll(query); - return results; - } - public Map<Range, Long[]> computeQuantitiesByRange(List<MailFolder> folders) { String query = "SELECT range, " + "SUM(rangeRow." + RangeRow.PROPERTY_PRODUCT_QUANTITY + ") AS prodQ, " + Modified: trunk/faxtomail-persistence/src/main/resources/faxToMail.properties =================================================================== --- trunk/faxtomail-persistence/src/main/resources/faxToMail.properties 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-persistence/src/main/resources/faxToMail.properties 2014-07-28 13:23:59 UTC (rev 442) @@ -36,9 +36,6 @@ #hibernate.hbm2ddl.auto=validate hibernate.hbm2ddl.auto= -#hibernate.show_sql=true -#hibernate.format_sql=true -#hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy hibernate.c3p0.min_size=5 hibernate.c3p0.max_size=20 Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties =================================================================== --- trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties 2014-07-28 13:23:59 UTC (rev 442) @@ -97,7 +97,6 @@ com.franciaflex.faxtomail.persistence.entities.Email.attribute.emailGroup.tagvalue.lazy=false com.franciaflex.faxtomail.persistence.entities.Email.attribute.replies.tagvalue.lazy=false com.franciaflex.faxtomail.persistence.entities.Email.attribute.takenBy.tagvalue.lazy=false -com.franciaflex.faxtomail.persistence.entities.Email.attribute.lockedBy.tagvalue.lazy=false # History com.franciaflex.faxtomail.persistence.entities.History.attribute.type.tagvalue.notNull=true @@ -111,3 +110,8 @@ # GroupChef com.franciaflex.faxtomail.persistence.entities.GroupChef.attribute.userGroup.tagvalue.notNull=true + +# MailLock +com.franciaflex.faxtomail.persistence.entities.MailLock.attribute.lockBy.tagvalue.notNull=true +com.franciaflex.faxtomail.persistence.entities.MailLock.attribute.lockOn.tagvalue.notNull=true +com.franciaflex.faxtomail.persistence.entities.MailLock.attribute.lockOn.tagvalue.unique=true Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo =================================================================== (Binary files differ) Modified: trunk/faxtomail-service/pom.xml =================================================================== --- trunk/faxtomail-service/pom.xml 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-service/pom.xml 2014-07-28 13:23:59 UTC (rev 442) @@ -36,7 +36,8 @@ <name>FaxToMail :: Service</name> <properties> - + <!-- make sure flyway files are not updated by non human --> + <license.excludes>**/i18n/*.properties, **/THIRD-PARTY.properties, **/*.sh, **/*.sql</license.excludes> </properties> <dependencies> @@ -53,6 +54,11 @@ </dependency> <dependency> + <groupId>org.nuiton.topia</groupId> + <artifactId>topia-service-flyway</artifactId> + </dependency> + + <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> </dependency> Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceContext.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceContext.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceContext.java 2014-07-28 13:23:59 UTC (rev 442) @@ -34,7 +34,6 @@ import com.franciaflex.faxtomail.FaxToMailConfiguration; import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaPersistenceContext; -import com.franciaflex.faxtomail.services.service.FaxToMailWebApplicationContext; import com.franciaflex.faxtomail.services.service.LdapService; import com.franciaflex.faxtomail.services.service.ldap.LdapServiceMock; @@ -46,8 +45,6 @@ protected FaxToMailTopiaPersistenceContext persistenceContext; - protected FaxToMailWebApplicationContext webApplicationContext; - public FaxToMailConfiguration getApplicationConfig() { return applicationConfig; } @@ -72,29 +69,13 @@ } E service; - try { - Constructor<E> constructor = serviceClass.getConstructor(); - service = constructor.newInstance(); - } catch (NoSuchMethodException e) { - throw new ApplicationTechnicalException("all services must provide a non-argument constructor", e); - - } catch (InvocationTargetException e) { - + } catch (InvocationTargetException|InstantiationException|IllegalAccessException e) { throw new ApplicationTechnicalException("unable to instantiate service", e); - - } catch (InstantiationException e) { - - throw new ApplicationTechnicalException("unable to instantiate service", e); - - } catch (IllegalAccessException e) { - - throw new ApplicationTechnicalException("unable to instantiate service", e); - } service.setServiceContext(this); @@ -107,13 +88,4 @@ Date now = new Date(); return now; } - - public FaxToMailWebApplicationContext getWebApplicationContext() { - return webApplicationContext; - } - - public void setWebApplicationContext(FaxToMailWebApplicationContext webApplicationContext) { - this.webApplicationContext = webApplicationContext; - } - } Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceSupport.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceSupport.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceSupport.java 2014-07-28 13:23:59 UTC (rev 442) @@ -29,7 +29,6 @@ import com.franciaflex.faxtomail.services.service.ClientService; import com.franciaflex.faxtomail.services.service.ConfigurationService; import com.franciaflex.faxtomail.services.service.EmailService; -import com.franciaflex.faxtomail.services.service.FaxToMailWebApplicationContext; import com.franciaflex.faxtomail.services.service.MailFolderService; import com.franciaflex.faxtomail.services.service.ReferentielService; @@ -56,10 +55,6 @@ return serviceContext.getPersistenceContext(); } - public FaxToMailWebApplicationContext getWebApplicationContext() { - return serviceContext.getWebApplicationContext(); - } - public <E extends FaxToMailService> E newService(Class<E> serviceClass) { return serviceContext.newService(serviceClass); } Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-07-28 13:23:59 UTC (rev 442) @@ -51,6 +51,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.logging.Log; @@ -69,35 +70,10 @@ import org.nuiton.util.pagination.PaginationParameter; import org.nuiton.util.pagination.PaginationResult; -import com.franciaflex.faxtomail.persistence.entities.Attachment; -import com.franciaflex.faxtomail.persistence.entities.AttachmentFile; -import com.franciaflex.faxtomail.persistence.entities.AttachmentFileImpl; -import com.franciaflex.faxtomail.persistence.entities.AttachmentFileTopiaDao; -import com.franciaflex.faxtomail.persistence.entities.AttachmentImpl; -import com.franciaflex.faxtomail.persistence.entities.AttachmentTopiaDao; -import com.franciaflex.faxtomail.persistence.entities.Client; -import com.franciaflex.faxtomail.persistence.entities.DemandStatus; -import com.franciaflex.faxtomail.persistence.entities.EdiReturn; -import com.franciaflex.faxtomail.persistence.entities.EdiReturnTopiaDao; -import com.franciaflex.faxtomail.persistence.entities.Email; -import com.franciaflex.faxtomail.persistence.entities.EmailFilter; -import com.franciaflex.faxtomail.persistence.entities.EmailGroup; -import com.franciaflex.faxtomail.persistence.entities.EmailGroupTopiaDao; -import com.franciaflex.faxtomail.persistence.entities.EmailTopiaDao; -import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; -import com.franciaflex.faxtomail.persistence.entities.FaxToMailUserGroup; -import com.franciaflex.faxtomail.persistence.entities.History; -import com.franciaflex.faxtomail.persistence.entities.HistoryTopiaDao; -import com.franciaflex.faxtomail.persistence.entities.HistoryType; -import com.franciaflex.faxtomail.persistence.entities.MailField; -import com.franciaflex.faxtomail.persistence.entities.MailFolder; -import com.franciaflex.faxtomail.persistence.entities.MailFolderTopiaDao; -import com.franciaflex.faxtomail.persistence.entities.Range; -import com.franciaflex.faxtomail.persistence.entities.RangeRow; -import com.franciaflex.faxtomail.persistence.entities.RangeRowTopiaDao; -import com.franciaflex.faxtomail.persistence.entities.Reply; -import com.franciaflex.faxtomail.persistence.entities.ReplyTopiaDao; +import com.franciaflex.faxtomail.persistence.entities.*; import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; +import com.franciaflex.faxtomail.services.service.exceptions.AlreadyLockedMailException; +import com.franciaflex.faxtomail.services.service.exceptions.InvalidClientException; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; @@ -268,8 +244,16 @@ // si les gammes sont vides, la demande n'est pas valide, on ne fait rien dans ce cas // sinon on transfer à edi if (email.isRangeRowNotEmpty()) { - - if (email.getDemandType().isEdiTransfer()) { + + // recherche parmis les dossiers parent, si la configuration ediTranfer à été demandée + Boolean ediTranfer = null; + MailFolder loopFolder = email.getMailFolder(); + do { + ediTranfer = loopFolder.getEdiTransfer(); + loopFolder = loopFolder.getParent(); + } while (ediTranfer == null && loopFolder != null); + + if (BooleanUtils.isTrue(ediTranfer)) { // ajout d'un historique transmissionToEdi = historyDao.create(History.PROPERTY_TYPE, HistoryType.TRANSMISSION_TO_EDI, History.PROPERTY_MODIFICATION_DATE, new Date()); @@ -565,29 +549,44 @@ * @param emailId topiaId de la demande à vérouiller * @param currentUser user * @return email + * @throws AlreadyLockedMailException if email is already locked by another user */ - public Email lockEmail(String emailId, FaxToMailUser currentUser) { + public Email lockEmail(String emailId, FaxToMailUser currentUser) throws AlreadyLockedMailException { + + // get current lock on mail if any EmailTopiaDao emailDao = getPersistenceContext().getEmailDao(); - - // verrouillage du mail courant + MailLockTopiaDao mailLockDao = getPersistenceContext().getMailLockDao(); Email email = emailDao.forTopiaIdEquals(emailId).findUnique(); - email.setLockedBy(currentUser); - email = emailDao.update(email); - getPersistenceContext().commit(); - if (log.isDebugEnabled()) { - log.debug("[LOCK] " + emailId + " locked by " + currentUser.getLogin()); - } + MailLock mailLock = mailLockDao.forLockOnEquals(email).findUniqueOrNull(); - // dévérouillage automatique des mails qui ne font pas partit du même group que celui du mail - // qui vient d'être locké - List<Email> mailsToUnlock = emailDao.forLockedByEquals(currentUser).addNotEquals(Email.PROPERTY_EMAIL_GROUP, email.getEmailGroup()).findAll(); - for (Email mailToUnlock : mailsToUnlock) { - mailToUnlock.setLockedBy(null); - mailToUnlock = emailDao.update(mailToUnlock); + // if no lock found, create new one + if (mailLock == null) { + mailLock = new MailLockImpl(); + mailLock.setLockBy(currentUser); + mailLock.setLockOn(email); + mailLock = mailLockDao.create(mailLock); + if (log.isDebugEnabled()) { - log.debug("[UNLOCK] " + mailToUnlock.getTopiaId() + " unlocked (automatic)"); + log.debug("[LOCK] " + emailId + " locked by " + currentUser.getLogin()); } + + // dévérouillage automatique des mails qui ne font pas partit du même group que celui du mail + // qui vient d'être locké + List<MailLock> mailLocksToRemove = mailLockDao.forLockByEquals(currentUser) + .addNotEquals(MailLock.PROPERTY_LOCK_ON + "." + Email.PROPERTY_EMAIL_GROUP, email.getEmailGroup()).findAll(); + if (log.isDebugEnabled()) { + for (MailLock mailLockToRemove : mailLocksToRemove) { + log.debug("[UNLOCK] " + mailLockToRemove.getLockOn().getTopiaId() + " unlocked (automatic)"); + } + } + mailLockDao.deleteAll(mailLocksToRemove); + + getPersistenceContext().commit(); + } else if (!mailLock.getLockBy().equals(currentUser)) { + // throw exception if already locked by another user + throw new AlreadyLockedMailException(String.format("Mail %s already locked by %s", emailId, mailLock.getLockBy().getTopiaId()), mailLock.getLockBy()); } + return email; } @@ -595,18 +594,15 @@ * Dévérrouille une demande. * * @param emailId topiaId de la demande à devérouiller - * @return email */ - public Email unlockEmail(String emailId) { - EmailTopiaDao emailDao = getPersistenceContext().getEmailDao(); - Email email = emailDao.forTopiaIdEquals(emailId).findUnique(); - email.setLockedBy(null); - email = emailDao.update(email); - getPersistenceContext().commit(); + public void unlockEmail(String emailId) { + MailLockTopiaDao mailLockDao = getPersistenceContext().getMailLockDao(); + MailLock mailLock = mailLockDao.forAll().addEquals(MailLock.PROPERTY_LOCK_ON + "." + Email.PROPERTY_TOPIA_ID, emailId).findUnique(); + mailLockDao.delete(mailLock); if (log.isDebugEnabled()) { log.debug("[UNLOCK] " + emailId + " unlocked"); } - return email; + getPersistenceContext().commit(); } /** @@ -794,28 +790,25 @@ /** - * Retourne la liste des email ayant un verrouillage actif. + * Retourne la liste des vérrouillages actifs. * * @return email list */ - public List<Email> getLockedMail() { - EmailTopiaDao emailDao = getPersistenceContext().getEmailDao(); - List<Email> result = emailDao.getLockedEmail(); + public List<MailLock> getAllMailLocks() { + MailLockTopiaDao mailLockDao = getPersistenceContext().getMailLockDao(); + List<MailLock> result = mailLockDao.findAll(); return result; } /** - * Dévérrouille les mails specifié. + * Dévérrouille les mails specifiés. * - * @param unlockMails + * @param mailLockIds mail lock ids to unlock */ - public void unlockMails(List<String> unlockMails) { - EmailTopiaDao emailDao = getPersistenceContext().getEmailDao(); - for (String unlockMail : unlockMails) { - Email mail = emailDao.forTopiaIdEquals(unlockMail).findUnique(); - mail.setLockedBy(null); - emailDao.update(mail); - } + public void unlockMails(List<String> mailLockIds) { + MailLockTopiaDao mailLockDao = getPersistenceContext().getMailLockDao(); + Collection<MailLock> mailLocks = mailLockDao.forTopiaIdIn(mailLockIds).findAll(); + mailLockDao.deleteAll(mailLocks); getPersistenceContext().commit(); } Deleted: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/FaxToMailWebApplicationContext.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/FaxToMailWebApplicationContext.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/FaxToMailWebApplicationContext.java 2014-07-28 13:23:59 UTC (rev 442) @@ -1,39 +0,0 @@ -package com.franciaflex.faxtomail.services.service; - -/* - * #%L - * FaxToMail :: Service - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2014 Franciaflex, 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 Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; - -/** - * Make a service aware of way to generate URL to point to a - * precise page of the web interface. - * - * @author kmorin - */ -public interface FaxToMailWebApplicationContext { - - String getAdministrationUrl(FaxToMailUser user); - -} Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java 2014-07-28 13:23:59 UTC (rev 442) @@ -39,6 +39,7 @@ import java.util.Random; import com.franciaflex.faxtomail.persistence.entities.MailField; + import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -69,6 +70,7 @@ import com.franciaflex.faxtomail.persistence.entities.RangeTopiaDao; import com.franciaflex.faxtomail.services.DecoratorService; import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; +import com.franciaflex.faxtomail.services.service.exceptions.InvalidClientException; import com.google.common.collect.Lists; import com.google.common.collect.Sets; Deleted: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InvalidClientException.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InvalidClientException.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InvalidClientException.java 2014-07-28 13:23:59 UTC (rev 442) @@ -1,41 +0,0 @@ -package com.franciaflex.faxtomail.services.service; - -/* - * #%L - * FaxToMail :: Service - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2014 Franciaflex, 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 Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import org.nuiton.jaxx.application.ApplicationBusinessException; - -public class InvalidClientException extends ApplicationBusinessException { - - /** serialVersionUID. */ - private static final long serialVersionUID = 1926451364755356679L; - - public InvalidClientException(String message, Throwable cause) { - super(message, cause); - } - - public InvalidClientException(String message) { - super(message); - } -} Added: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/exceptions/AlreadyLockedMailException.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/exceptions/AlreadyLockedMailException.java (rev 0) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/exceptions/AlreadyLockedMailException.java 2014-07-28 13:23:59 UTC (rev 442) @@ -0,0 +1,49 @@ +package com.franciaflex.faxtomail.services.service.exceptions; + +import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; + +/* + * #%L + * FaxToMail :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, 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 Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +/** + * Exception throw when trying to define a lock on en email already locked by another user. + * + * @author Eric Chatellier + */ +public class AlreadyLockedMailException extends Exception { + + /** serialVersionUID. */ + private static final long serialVersionUID = 7090578827422040229L; + + protected FaxToMailUser lockedBy; + + public AlreadyLockedMailException(String message, FaxToMailUser lockedBy) { + super(message); + this.lockedBy = lockedBy; + } + + public FaxToMailUser getLockedBy() { + return lockedBy; + } +} Property changes on: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/exceptions/AlreadyLockedMailException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/exceptions/InvalidClientException.java (from rev 441, trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InvalidClientException.java) =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/exceptions/InvalidClientException.java (rev 0) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/exceptions/InvalidClientException.java 2014-07-28 13:23:59 UTC (rev 442) @@ -0,0 +1,41 @@ +package com.franciaflex.faxtomail.services.service.exceptions; + +/* + * #%L + * FaxToMail :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, 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 Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import org.nuiton.jaxx.application.ApplicationBusinessException; + +public class InvalidClientException extends ApplicationBusinessException { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1926451364755356679L; + + public InvalidClientException(String message, Throwable cause) { + super(message, cause); + } + + public InvalidClientException(String message) { + super(message); + } +} Added: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/migration/FaxtomailFlywayMigrationService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/migration/FaxtomailFlywayMigrationService.java (rev 0) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/migration/FaxtomailFlywayMigrationService.java 2014-07-28 13:23:59 UTC (rev 442) @@ -0,0 +1,64 @@ +package com.franciaflex.faxtomail.services.service.migration; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.flywaydb.core.Flyway; +import org.hibernate.cfg.Environment; +import org.nuiton.topia.flyway.TopiaFlywayServiceImpl; +import org.nuiton.topia.persistence.TopiaApplicationContext; + +/* + * #%L + * FaxToMail :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, 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 Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +/** + * Surcharge du service de migration flayway par default pour pouvoir définir des scripts pour + * plusieurs type de base de données. + * + * @author Eric Chatellier + */ +public class FaxtomailFlywayMigrationService extends TopiaFlywayServiceImpl { + + @Override + protected void doExtraConfiguration(Flyway flyway, TopiaApplicationContext topiaApplicationContext) { + + Map<String, String> placeholders = new HashMap<>(); + String dialect = (String)topiaApplicationContext.getConfiguration().get(Environment.DIALECT); + if (StringUtils.startsWith(dialect, "org.hibernate.dialect.SQLServer")) { + // type for sqlserver + placeholders.put("timestampType", "datetime2"); + placeholders.put("integerType", "bigint"); + placeholders.put("booleanType", "bit"); + } else { + + // types for postgresql and h2 + placeholders.put("timestampType", "timestamp"); + placeholders.put("integerType", "int8"); + placeholders.put("booleanType", "boolean"); + } + + flyway.setPlaceholders(placeholders); + } +} Property changes on: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/migration/FaxtomailFlywayMigrationService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/faxtomail-service/src/main/resources/db/migration/V1_0_0_442__move_object_to_folder_configuration.sql =================================================================== --- trunk/faxtomail-service/src/main/resources/db/migration/V1_0_0_442__move_object_to_folder_configuration.sql (rev 0) +++ trunk/faxtomail-service/src/main/resources/db/migration/V1_0_0_442__move_object_to_folder_configuration.sql 2014-07-28 13:23:59 UTC (rev 442) @@ -0,0 +1,60 @@ + +-- move lock out of business model and to his own table +alter table email drop column lockedby; +create table mailLock ( + topiaId varchar(255) not null, + topiaVersion ${integerType} not null, + topiaCreateDate ${timestampType}, + lockOn varchar(255) not null, + lockBy varchar(255) not null, + primary key (topiaId) +); +alter table mailLock + add constraint UK_cebqxr5mtsd4wmm0x0nwaa5km unique (lockOn); +alter table mailLock + add constraint FK_cebqxr5mtsd4wmm0x0nwaa5km + foreign key (lockOn) + references email; +alter table mailLock + add constraint FK_gwxpc59s0wjg60djbk5xa4d5d + foreign key (lockBy) + references faxToMailUser; + +-- edi transfer for each folder +alter table demandtype drop column ediTransfer; +alter table mailfolder add column ediTransfer ${booleanType}; +update mailfolder set ediTransfer = 'f' where parent is null; + +-- reject allowed for email account +alter table EmailAccount add column rejectAllowed ${booleanType}; +update EmailAccount set rejectAllowed = 'f'; + +-- demandtype per folder +create table demandtypes_mailfolder ( + mailFolder varchar(255) not null, + demandTypes varchar(255) not null +); +alter table demandtypes_mailfolder + add constraint FK_apld4ycj71ouug7vmg5wtr1y9 + foreign key (demandTypes) + references demandType; +alter table demandtypes_mailfolder + add constraint FK_pmybd6fsyapv8ygtn7pjw258k + foreign key (mailFolder) + references mailFolder; +CREATE INDEX idx_MailFolder_demandTypes ON demandtypes_mailfolder(mailFolder); + +-- range per folder +create table mailfolder_ranges ( + mailFolder varchar(255) not null, + ranges varchar(255) not null +); +alter table mailfolder_ranges + add constraint FK_kiolyiaeicw5he7xlima0ugbb + foreign key (ranges) + references range; +alter table mailfolder_ranges + add constraint FK_h78fwd9gc92wh7vw612q48xrr + foreign key (mailFolder) + references mailFolder; +CREATE INDEX idx_MailFolder_ranges ON mailfolder_ranges(mailFolder); Modified: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestData.java =================================================================== --- trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestData.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestData.java 2014-07-28 13:23:59 UTC (rev 442) @@ -36,6 +36,7 @@ import java.util.Map; import com.franciaflex.faxtomail.persistence.entities.MailField; + import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -60,6 +61,7 @@ import com.franciaflex.faxtomail.persistence.entities.RangeRowTopiaDao; import com.franciaflex.faxtomail.services.DecoratorService; import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; +import com.franciaflex.faxtomail.services.service.exceptions.InvalidClientException; import com.google.common.collect.Lists; import com.google.common.collect.Sets; Modified: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/MiscTest.java =================================================================== --- trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/MiscTest.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/MiscTest.java 2014-07-28 13:23:59 UTC (rev 442) @@ -31,19 +31,40 @@ import org.junit.Ignore; import org.junit.Test; -@Ignore +/** + * Class utilitaire permettant de générer facilement les schemas pour différentes base de données. + * + * @author Eric Chatellier + */ public class MiscTest extends AbstractFaxToMailServiceTest { @Override protected Map<String, String> getDatabaseConfiguration(String dataBase) { Map<String, String> hibernateH2Config = new HashMap<String, String>(); - hibernateH2Config.put(Environment.DIALECT, "org.hibernate.dialect.SQLServer2008Dialect"); - hibernateH2Config.put(Environment.DRIVER, "net.sourceforge.jtds.jdbc.Driver"); - hibernateH2Config.put(Environment.USER, "fx"); - hibernateH2Config.put(Environment.PASS, "FX2013!"); + // sqlserver config + hibernateH2Config.put(Environment.DIALECT, "org.hibernate.dialect.H2Dialect"); + hibernateH2Config.put(Environment.DRIVER, "org.h2.Driver"); + hibernateH2Config.put(Environment.USER, "sa"); + hibernateH2Config.put(Environment.PASS, ""); hibernateH2Config.put(Environment.HBM2DDL_AUTO, ""); - hibernateH2Config.put(Environment.URL, "jdbc:jtds:sqlserver://192.168.100.247:1433/faxtomailtest"); + hibernateH2Config.put(Environment.URL, "jdbc:h2:file:/tmp/faxtomail/h2data"); + + // sqlserver config + /*hibernateH2Config.put(Environment.DIALECT, "org.hibernate.dialect.SQLServer2008Dialect"); + hibernateH2Config.put(Environment.DRIVER, "org.h2.Driver"); + hibernateH2Config.put(Environment.USER, "sa"); + hibernateH2Config.put(Environment.PASS, ""); + hibernateH2Config.put(Environment.HBM2DDL_AUTO, ""); + hibernateH2Config.put(Environment.URL, "jdbc:h2:file:/tmp/faxtomail/h2data;MODE=MSSQLServer");*/ + + // postgres configuration + /*hibernateH2Config.put(Environment.DIALECT, "org.hibernate.dialect.PostgreSQL9Dialect"); + hibernateH2Config.put(Environment.DRIVER, "org.postgresql.Driver"); + hibernateH2Config.put(Environment.USER, "postgres"); + hibernateH2Config.put(Environment.PASS, "postgres"); + hibernateH2Config.put(Environment.HBM2DDL_AUTO, ""); + hibernateH2Config.put(Environment.URL, "jdbc:postgresql:faxtomail");*/ return hibernateH2Config; } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAction.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAction.java 2014-07-28 13:23:59 UTC (rev 442) @@ -37,7 +37,7 @@ import com.franciaflex.faxtomail.persistence.entities.EmailImpl; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.persistence.entities.RangeRow; -import com.franciaflex.faxtomail.services.service.InvalidClientException; +import com.franciaflex.faxtomail.services.service.exceptions.InvalidClientException; import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUI; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIHandler; Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java 2014-07-28 13:23:59 UTC (rev 442) @@ -25,6 +25,7 @@ import com.franciaflex.faxtomail.persistence.entities.Email; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.persistence.entities.MailFolder; +import com.franciaflex.faxtomail.services.service.exceptions.AlreadyLockedMailException; import com.franciaflex.faxtomail.ui.swing.FaxToMailScreen; import com.franciaflex.faxtomail.ui.swing.content.MainUIHandler; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; @@ -52,21 +53,26 @@ @Override public boolean prepareAction() throws Exception { boolean result = super.prepareAction(); - - if (result) { - DemandeUIModel currentEmail = getContext().getCurrentEmail(); - FaxToMailUser lockedByUser = currentEmail.getLockedBy(); + + DemandeUIModel currentEmail = getContext().getCurrentEmail(); + + // tentative de verrouillages des email existants + if (StringUtils.isNotBlank(currentEmail.getTopiaId())) { FaxToMailUser currentUser = getContext().getCurrentUser(); - - if (lockedByUser != null && !lockedByUser.equals(currentUser)) { - String htmlMessage = t("faxtomail.alert.alreadyLockedBy.message", decorate(lockedByUser)); + + try { + getContext().getEmailService().lockEmail(currentEmail.getTopiaId(), currentUser); + } catch (AlreadyLockedMailException ex) { + result = false; + + String htmlMessage = t("faxtomail.alert.alreadyLockedBy.message", decorate(ex.getLockedBy())); JOptionPane.showMessageDialog(getHandler().getTopestUI(), htmlMessage, t("faxtomail.alert.alreadyLockedBy.title"), JOptionPane.ERROR_MESSAGE); - result = false; } } + return result; } @@ -128,10 +134,5 @@ break; } } - - // au final, on a ouvert la demande, on peut locker la demande - if (StringUtils.isNotBlank(currentEmail.getTopiaId())) { - getContext().getEmailService().lockEmail(currentEmail.getTopiaId(), currentUser); - } } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-07-28 13:23:59 UTC (rev 442) @@ -396,7 +396,6 @@ result.add(Email.PROPERTY_HISTORY); result.add(DemandeUIModel.PROPERTY_GROUPED_DEMANDES); result.add(Email.PROPERTY_REPLIES); - result.add(Email.PROPERTY_LOCKED_BY); return result; } @@ -429,8 +428,7 @@ // mettre ca ici et non dans le close, car pour un onglet, le close n'est pas appelé if (result) { - Email email = getContext().getEmailService().unlockEmail(getModel().getTopiaId()); - getModel().fromEntity(email); + getContext().getEmailService().unlockEmail(getModel().getTopiaId()); } return result; Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-07-28 13:23:59 UTC (rev 442) @@ -381,16 +381,6 @@ return editObject.getTakenBy(); } - public FaxToMailUser getLockedBy() { - return editObject.getLockedBy(); - } - - public void setLockedBy(FaxToMailUser faxToMailUser) { - Object oldValue = getLockedBy(); - editObject.setLockedBy(faxToMailUser); - firePropertyChanged(Email.PROPERTY_LOCKED_BY, oldValue, faxToMailUser); - } - public Priority getPriority() { return editObject.getPriority(); } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUIHandler.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUIHandler.java 2014-07-28 13:23:59 UTC (rev 442) @@ -26,6 +26,7 @@ import com.franciaflex.faxtomail.persistence.entities.Email; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; +import com.franciaflex.faxtomail.services.service.exceptions.AlreadyLockedMailException; import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.content.MainUIHandler; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; @@ -158,17 +159,11 @@ FaxToMailUser takenBy = demande.getTakenBy(); FaxToMailUser currentUser = getContext().getCurrentUser(); - FaxToMailUser lockedByUser = demande.getLockedBy(); - //TODO kmorin 20140512 put this in an action - if (lockedByUser != null && !lockedByUser.equals(currentUser)) { - String htmlMessage = t("faxtomail.alert.alreadyLockedBy.message", decorate(lockedByUser)); - JOptionPane.showMessageDialog(getTopestUI(), - htmlMessage, - t("faxtomail.alert.alreadyLockedBy.title"), - JOptionPane.ERROR_MESSAGE); + try { + // tentative de verrouillage de la demande + getContext().getEmailService().lockEmail(demande.getTopiaId(), currentUser); - } else { if (demande.getArchiveDate() != null) { demande.setEditable(false); @@ -199,13 +194,16 @@ break; } } - - // au final, on a ouvert la demande, on peut locker la demande - getContext().getEmailService().lockEmail(demande.getTopiaId(), currentUser); MainUIHandler mainUIHandler = context.getMainUI().getHandler(); DemandesUI parentContainer = (DemandesUI) mainUIHandler.getCurrentBody(); parentContainer.getModel().addDemand(demande); + } catch (AlreadyLockedMailException ex) { + String htmlMessage = t("faxtomail.alert.alreadyLockedBy.message", decorate(ex.getLockedBy())); + JOptionPane.showMessageDialog(getTopestUI(), + htmlMessage, + t("faxtomail.alert.alreadyLockedBy.title"), + JOptionPane.ERROR_MESSAGE); } } Modified: trunk/faxtomail-ui-swing/src/main/resources/log4j.properties =================================================================== --- trunk/faxtomail-ui-swing/src/main/resources/log4j.properties 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-ui-swing/src/main/resources/log4j.properties 2014-07-28 13:23:59 UTC (rev 442) @@ -29,6 +29,7 @@ # faxtomail levels log4j.logger.com.franciaflex.faxtomail=INFO +log4j.logger.com.franciaflex.faxtomail.services=DEBUG #log4j.appender.file=org.apache.log4j.RollingFileAppender #log4j.appender.file.file=${faxtomail.log.file} Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/FaxToMailApplicationContext.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/FaxToMailApplicationContext.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/FaxToMailApplicationContext.java 2014-07-28 13:23:59 UTC (rev 442) @@ -24,22 +24,24 @@ * #L% */ -import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaApplicationContext; -import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaPersistenceContext; -import com.franciaflex.faxtomail.services.FaxToMailServiceContext; -import com.franciaflex.faxtomail.services.service.FaxToMailWebApplicationContext; -import com.franciaflex.faxtomail.services.service.InitFaxToMailService; -import com.franciaflex.faxtomail.web.DefaultFaxToMailWebApplicationContext; +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import javax.servlet.ServletContext; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.LogManager; import org.apache.log4j.PropertyConfigurator; +import org.nuiton.topia.flyway.TopiaFlywayService; -import java.io.File; +import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaApplicationContext; +import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaPersistenceContext; +import com.franciaflex.faxtomail.services.FaxToMailServiceContext; +import com.franciaflex.faxtomail.services.service.InitFaxToMailService; +import com.franciaflex.faxtomail.services.service.migration.FaxtomailFlywayMigrationService; -import javax.servlet.ServletContext; - public class FaxToMailApplicationContext { private static Log log = LogFactory.getLog(FaxToMailApplicationContext.class); @@ -77,11 +79,6 @@ newServiceContext.setPersistenceContext(persistenceContext); - FaxToMailWebApplicationContext webApplicationContext = - new DefaultFaxToMailWebApplicationContext(applicationConfig.getInstanceUrl()); - - newServiceContext.setWebApplicationContext(webApplicationContext); - return newServiceContext; } @@ -95,8 +92,20 @@ public void init(ServletContext servletContext) { applicationConfig = new FaxToMailConfiguration("faxToMail.properties"); - topiaApplicationContext = new FaxToMailTopiaApplicationContext(applicationConfig.getTopiaProperties()); + // it's set here for only web application to migrate schema, not client + Map<String, String> properties = new HashMap<>(); + properties.put("topia.service.migration", FaxtomailFlywayMigrationService.class.getName()); + // init base version with 1.0.0.429 (1.0-rc-2) + properties.put("topia.service.migration." + TopiaFlywayService.FLYWAY_INIT_VERSION, "1.0.0.429"); + properties.put("topia.service.migration." + TopiaFlywayService.USE_MODEL_VERSION, "false"); + + // add configuration properties after to allow override + properties.putAll(applicationConfig.getTopiaProperties()); + + // create application + topiaApplicationContext = new FaxToMailTopiaApplicationContext(properties); + if (getApplicationConfig().isLogConfigurationProvided()) { File log4jConfigurationFile = getApplicationConfig().getLogConfigurationFile(); Deleted: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/DefaultFaxToMailWebApplicationContext.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/DefaultFaxToMailWebApplicationContext.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/DefaultFaxToMailWebApplicationContext.java 2014-07-28 13:23:59 UTC (rev 442) @@ -1,86 +0,0 @@ -package com.franciaflex.faxtomail.web; - -/* - * #%L - * FaxToMail :: Web - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2014 Franciaflex, 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 Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; -import com.franciaflex.faxtomail.services.service.FaxToMailWebApplicationContext; -import com.google.common.base.Charsets; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Sets; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.jaxx.application.ApplicationTechnicalException; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.Collections; -import java.util.Map; -import java.util.SortedSet; - -public class DefaultFaxToMailWebApplicationContext implements FaxToMailWebApplicationContext { - - private static final Log log = LogFactory.getLog(DefaultFaxToMailWebApplicationContext.class); - - protected String instanceUrl; - - public DefaultFaxToMailWebApplicationContext(String instanceUrl) { - this.instanceUrl = instanceUrl; - } - - protected String formatUrl(String actionUrl) { - Map<String, String> emptyMap = Collections.emptyMap(); - return formatUrl(actionUrl, emptyMap); - } - - protected String formatUrl(String actionUrl, Map<String, String> parameters) { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(instanceUrl).append("/").append(actionUrl); - if ( ! parameters.isEmpty()) { - SortedSet<String> queryStringElements = Sets.newTreeSet(); - try { - for (Map.Entry<String, String> parameter : parameters.entrySet()) { - String queryStringElement = parameter.getKey() + '=' + URLEncoder.encode(parameter.getValue(), Charsets.UTF_8.name()); - queryStringElements.add(queryStringElement); - } - } catch (UnsupportedEncodingException e) { - if (log.isErrorEnabled()) { - log.error("should never occur", e); - } - throw new ApplicationTechnicalException(e); - } - stringBuilder.append('?').append(Joiner.on('&').join(queryStringElements)); - } - return stringBuilder.toString(); - } - - @Override - public String getAdministrationUrl(FaxToMailUser extranetUser) { - ImmutableMap<String, String> params = - ImmutableMap.of("yearlyDeclarationId", extranetUser.getTopiaId()); - return formatUrl("administration/edit-user!input", params); - } - -} Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LockAction.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LockAction.java 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LockAction.java 2014-07-28 13:23:59 UTC (rev 442) @@ -26,14 +26,12 @@ import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.InterceptorRef; import org.apache.struts2.convention.annotation.InterceptorRefs; import org.apache.struts2.convention.annotation.Result; -import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.persistence.entities.MailLock; import com.franciaflex.faxtomail.services.service.EmailService; import com.franciaflex.faxtomail.web.FaxToMailActionSupport; import com.opensymphony.xwork2.Preparable; @@ -45,13 +43,11 @@ }) public class LockAction extends FaxToMailActionSupport implements Preparable { - private static final Log log = LogFactory.getLog(LockAction.class); - protected EmailService emailService; - protected List<Email> lockedMails; + protected List<MailLock> activeLocks; - protected List<String> unlockMails; + protected List<String> mailLockIds; public void setEmailService(EmailService emailService) { this.emailService = emailService; @@ -68,24 +64,24 @@ @Override @Action("lock-input") public String input() throws Exception { - lockedMails = emailService.getLockedMail(); + activeLocks = emailService.getAllMailLocks(); return INPUT; } @Override @Action(results = {@Result(type = "redirectAction", params = {"actionName", "lock-input"})}) public String execute() throws Exception { - if (unlockMails != null) { - emailService.unlockMails(unlockMails); + if (mailLockIds != null) { + emailService.unlockMails(mailLockIds); } return SUCCESS; } - public List<Email> getLockedMails() { - return lockedMails; + public List<MailLock> getLockedMails() { + return activeLocks; } - public void setUnlockMails(List<String> unlockMails) { - this.unlockMails = unlockMails; + public void setMailLockIds(List<String> mailLockIds) { + this.mailLockIds = mailLockIds; } } Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2014-07-27 18:36:54 UTC (rev 441) +++ trunk/pom.xml 2014-07-28 13:23:59 UTC (rev 442) @@ -105,8 +105,8 @@ <nuitonValidatorVersion>3.0-rc-1</nuitonValidatorVersion> <nuitonWebVersion>1.16</nuitonWebVersion> - <eugeneVersion>2.12</eugeneVersion> - <topiaVersion>3.0-beta-8</topiaVersion> + <eugeneVersion>2.13-SNAPSHOT</eugeneVersion> + <topiaVersion>3.0-SNAPSHOT</topiaVersion> <hibernateVersion>4.3.6.Final</hibernateVersion> <h2Version>1.3.176</h2Version> @@ -197,6 +197,12 @@ <artifactId>topia-persistence</artifactId> <version>${topiaVersion}</version> </dependency> + + <dependency> + <groupId>org.nuiton.topia</groupId> + <artifactId>topia-service-flyway</artifactId> + <version>${topiaVersion}</version> + </dependency> <dependency> <groupId>org.hibernate</groupId> @@ -517,7 +523,7 @@ <dependency> <groupId>org.nuiton.js</groupId> <artifactId>nuiton-js-angularjs</artifactId> - <version>1.2.20-1</version> + <version>1.2.21-1-SNAPSHOT</version> <scope>runtime</scope> </dependency>
participants (1)
-
echatellier@users.forge.codelutin.com