This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository faxtomail. See https://gitlab.nuiton.org/codelutin/faxtomail.git commit 263386af2927289e7b029bba680a05c72fe81472 Author: jcouteau <couteau@codelutin.com> Date: Mon Nov 9 14:31:41 2020 +0100 fixes #11068 : Pas de délock à l'archivage et délock trop tôt lorsqu'on quitte un élément --- .../services/service/EmailServiceImpl.java | 2 ++ .../ui/swing/content/demande/DemandeUIHandler.java | 16 ++++++++-- .../content/demande/actions/ArchiveAction.java | 34 ++++++++++++---------- .../content/transmit/actions/TransmitAction.java | 11 +++---- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java index 2fad48fa..8bc5457d 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java @@ -1306,6 +1306,8 @@ public class EmailServiceImpl extends FaxToMailServiceSupport implements EmailSe email.setLastPrintingUser(null); email.setLastPrintingDate(null); + unlockEmail(email.getTopiaId()); + History history = historyDao.create(History.PROPERTY_TYPE, HistoryType.TRANSMISSION, History.PROPERTY_FAX_TO_MAIL_USER, currentUser, History.PROPERTY_MODIFICATION_DATE, new Date(), diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java index 0ddc2557..219aa4cc 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java @@ -494,9 +494,9 @@ public class DemandeUIHandler extends AbstractFaxToMailUIHandler<DemandeUIModel, DemandeUIModel model = getModel(); - if (model.isEditable()) { + /*if (model.isEditable()) { serviceContext.getEmailService().unlockEmail(model.getTopiaId()); - } + }*/ model.removePropertyChangeListener(listModelListener); model.removePropertyChangeListener(Email.PROPERTY_DEMAND_TYPE, demandTypeListener); @@ -537,7 +537,7 @@ public class DemandeUIHandler extends AbstractFaxToMailUIHandler<DemandeUIModel, askCancelEditBeforeLeavingMessage = n("faxtomail.demande.askCancelEditBeforeLeaving.cancelSave.noHelp"); askSaveBeforeLeavingMessage = n("faxtomail.demande.askSaveBeforeLeaving.save.noHelp"); } - return quitScreen2( + Boolean result = quitScreen2( true, getModel().isModify(), t(askCancelEditBeforeLeavingMessage), @@ -545,6 +545,16 @@ public class DemandeUIHandler extends AbstractFaxToMailUIHandler<DemandeUIModel, showHelp, getContext().getActionFactory().createLogicAction(this, SaveDemandeAction.class) ); + + if (result) { + try(FaxToMailServiceContext faxToMailServiceContext = getContext().newServiceContext()) { + faxToMailServiceContext.getEmailService().unlockEmail(getModel().getTopiaId()); + } catch (IOException e) { + log.warn("Could not unlock email"); + } + } + + return result; } @Override diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/ArchiveAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/ArchiveAction.java index 16d96764..745ab9a0 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/ArchiveAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/actions/ArchiveAction.java @@ -26,20 +26,18 @@ package com.franciaflex.faxtomail.ui.swing.content.demande.actions; import com.franciaflex.faxtomail.persistence.entities.DemandStatus; import com.franciaflex.faxtomail.persistence.entities.MailFolder; -import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUI; -import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUIHandler; -import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUI; +import com.franciaflex.faxtomail.services.FaxToMailServiceContext; +import com.franciaflex.faxtomail.services.service.exceptions.AlreadyLockedMailException; +import com.franciaflex.faxtomail.services.service.exceptions.FolderNotReadableException; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIHandler; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; -import com.franciaflex.faxtomail.ui.swing.content.transmit.MailFolderChooserUIHandler; -import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUI; import com.google.common.base.Optional; -import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.JAXXUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import javax.swing.*; +import javax.swing.JOptionPane; +import java.io.IOException; import java.util.Collection; import java.util.Date; @@ -54,6 +52,8 @@ import static org.nuiton.i18n.I18n.t; */ public class ArchiveAction extends SaveDemandeAndExitAction { + private static final Log log = LogFactory.getLog(ArchiveAction.class); + protected DemandeUIModel previousState; public ArchiveAction(DemandeUIHandler handler) { @@ -94,12 +94,7 @@ public class ArchiveAction extends SaveDemandeAndExitAction { do { Collection<MailFolder> children = folder.getChildren(); if (children != null) { - Optional<MailFolder> optArchiveChild = Iterables.tryFind(children, new Predicate<MailFolder>() { - @Override - public boolean apply(MailFolder mailFolder) { - return mailFolder.isArchiveFolder(); - } - }); + Optional<MailFolder> optArchiveChild = Iterables.tryFind(children, mailFolder -> mailFolder.isArchiveFolder()); if (optArchiveChild.isPresent()) { archiveChild = optArchiveChild.get(); } @@ -118,6 +113,10 @@ public class ArchiveAction extends SaveDemandeAndExitAction { model.setDemandStatus(DemandStatus.ARCHIVED); model.setTakenBy(null); + try(FaxToMailServiceContext faxToMailServiceContext = getContext().newServiceContext()) { + faxToMailServiceContext.getEmailService().unlockEmail(model.getTopiaId()); + } + //cannot be reverted in postFailedAction model.clearPDFPages(); @@ -143,6 +142,11 @@ public class ArchiveAction extends SaveDemandeAndExitAction { model.setArchiveDate(null); model.setDemandStatus(previousState.getDemandStatus()); model.setTakenBy(previousState.getTakenBy()); + try(FaxToMailServiceContext faxToMailServiceContext = getContext().newServiceContext()) { + faxToMailServiceContext.getEmailService().lockEmail(model.getTopiaId(),getContext().getCurrentUser()); + } catch (AlreadyLockedMailException | FolderNotReadableException | IOException e) { + log.warn("Could not lock back email after error archiving"); + } previousState = null; } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/actions/TransmitAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/actions/TransmitAction.java index af921a02..92df334a 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/actions/TransmitAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/transmit/actions/TransmitAction.java @@ -68,7 +68,7 @@ public class TransmitAction extends AbstractFaxToMailAction<MailFolderChooserUIM boolean result = super.prepareAction(); MailFolderChooserUIModel model = getModel(); - List<DemandeUIModel> demandeUIModels = new ArrayList<DemandeUIModel>(model.getDemandeUIModels()); + List<DemandeUIModel> demandeUIModels = new ArrayList<>(model.getDemandeUIModels()); for (final DemandeUIModel demandeUIModel : model.getDemandeUIModels()) { @@ -111,12 +111,9 @@ public class TransmitAction extends AbstractFaxToMailAction<MailFolderChooserUIM @Override public void doAction() throws Exception { MailFolderChooserUIModel model = getModel(); - Collection<String> emailIds = Collections2.transform(model.getDemandeUIModels(), new Function<DemandeUIModel, String>() { - @Override - public String apply(DemandeUIModel demandeUIModel) { - return demandeUIModel.getTopiaId(); - } - }); + + Collection<String> emailIds = Collections2.transform(model.getDemandeUIModels(), DemandeUIModel::getTopiaId); + try(FaxToMailServiceContext faxToMailServiceContext = getContext().newServiceContext()) { faxToMailServiceContext.getEmailService().transmit(emailIds, model.getMailFolder(), getContext().getCurrentUser()); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.