branch develop updated (cc3c6ebe -> 6e9e26e5)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository faxtomail. See https://gitlab.nuiton.org/codelutin/faxtomail.git from cc3c6ebe [gitflow-maven-plugin]Update for next development version new 3967e9b9 Ajout d'un contact par défaut si pas de LDAP pour les tests new 6e9e26e5 Fix regression sur les pièces jointes lors des transferts The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 6e9e26e52eba668ff46bca27f74a60c391884e77 Author: jcouteau <couteau@codelutin.com> Date: Wed Nov 18 09:31:38 2020 +0100 Fix regression sur les pièces jointes lors des transferts commit 3967e9b91ef972ac02605a65fabdbb856b448a86 Author: jcouteau <couteau@codelutin.com> Date: Wed Nov 18 09:30:55 2020 +0100 Ajout d'un contact par défaut si pas de LDAP pour les tests Summary of changes: .../faxtomail/services/service/EmailService.java | 2 + .../services/service/EmailServiceImpl.java | 120 +++++++++++---------- .../faxtomail/ui/swing/FaxToMailUIContext.java | 5 + .../ui/swing/content/reply/ReplyFormUIHandler.java | 5 + 4 files changed, 78 insertions(+), 54 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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 3967e9b91ef972ac02605a65fabdbb856b448a86 Author: jcouteau <couteau@codelutin.com> Date: Wed Nov 18 09:30:55 2020 +0100 Ajout d'un contact par défaut si pas de LDAP pour les tests --- .../java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java index 89694480..61a065e4 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/FaxToMailUIContext.java @@ -445,6 +445,11 @@ public class FaxToMailUIContext extends AbstractBean implements Closeable, UIMes log.error("Error while getting contact from ldap", e); } } + } else { + Contact testContact = new Contact("Test Contact", "faxtomail-tests@codelutin.com"); + List<Contact> contacts = new ArrayList<>(); + contacts.add(testContact); + setContactCache(contacts); } List<MailFolder> folders = serviceContext.getMailFolderService() -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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 6e9e26e52eba668ff46bca27f74a60c391884e77 Author: jcouteau <couteau@codelutin.com> Date: Wed Nov 18 09:31:38 2020 +0100 Fix regression sur les pièces jointes lors des transferts --- .../faxtomail/services/service/EmailService.java | 2 + .../services/service/EmailServiceImpl.java | 120 +++++++++++---------- .../ui/swing/content/reply/ReplyFormUIHandler.java | 5 + 3 files changed, 73 insertions(+), 54 deletions(-) diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java index 7ba9c79a..64d25a78 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java @@ -197,6 +197,8 @@ public interface EmailService extends FaxToMailService { */ Attachment convertHTMLToPdf(List<Attachment> attachments, List<String> content, String name) throws IOException; + void deleteTempAttachmentFiles(List<Attachment> attachments); + GeneratedPDFPage createGeneratedPDFPage(Attachment attachment, BufferedImage image); String extractHtmlContent(List<Attachment> attachments, List<String> contentList) throws URIException; 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 8bc5457d..5fe5ccb3 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 @@ -2332,6 +2332,7 @@ public class EmailServiceImpl extends FaxToMailServiceSupport implements EmailSe try { String content = extractHtmlContent(attachments, contentList); + deleteTempAttachmentFiles(attachments); Html2Image html2Image = Html2Image.fromHtml(content); ImageRenderer imageRenderer = html2Image.getImageRenderer().setWidth((int) PageSize.A4.getWidth()); org.w3c.dom.Document doc = html2Image.getParser().getDocument(); @@ -2426,80 +2427,91 @@ public class EmailServiceImpl extends FaxToMailServiceSupport implements EmailSe return result; } + /** + * + * WARNING, must call deleteTempAttachmentFiles afterwards so temp directory does not grow indefinitely ! + * Could not be integrated in this method as on transfer, it deletes attachment before really using it + * + * @param attachments list of attachments that might be present in c + * @param contentList email html content + * @return email html content with attachments and inline attachments curated + * @throws URIException + */ public String extractHtmlContent(List<Attachment> attachments, List<String> contentList) throws URIException { List<String> contents = new ArrayList<>(); - Collection<File> fileToDelete = new ArrayList<>(); - try { - if (contentList != null) { - for (String content : contentList) { - content = content.replaceAll("<meta (.*?)>(</meta>)?", ""); - // remove the images whose sources are on the filesystem of the sender (yes, it happens...) - // cf #6996 - content = content.replaceAll("(\\w+)=([\"'])file://.*?([\"'])", ""); - - for (Attachment attachment : attachments) { - String key = attachment.getContentId(); - if (key == null) { - key = attachment.getOriginalFileName(); - } + if (contentList != null) { + for (String content : contentList) { + content = content.replaceAll("<meta (.*?)>(</meta>)?", ""); + // remove the images whose sources are on the filesystem of the sender (yes, it happens...) + // cf #6996 + content = content.replaceAll("(\\w+)=([\"'])file://.*?([\"'])", ""); + + for (Attachment attachment : attachments) { + String key = attachment.getContentId(); + if (key == null) { + key = attachment.getOriginalFileName(); + } - // get file content - AttachmentFile attachmentFile = attachment.getOriginalFile(); - if (attachmentFile != null) { - File file = attachmentFile.getFile(); - fileToDelete.add(file); - - // replace the inline attachments with the extracted attachment file url - // match les patterns: - // <td background="cid:bg.gif" height="52"> - // <img border=0 src="cid:bg.gif" /> - // <img src='cid:5e9ef859-ea65-4f9b-a9fa-30d4a2c5837c' - content = content.replaceAll("(\\w+)=([\"'])cid:" + Pattern.quote(key) + "([\"'])", "$1=$2" + file.toURI() + "$3"); - - if (log.isDebugEnabled()) { - log.debug("Mapping attachment id " + key + " to file " + file.toURI()); - } + // get file content + AttachmentFile attachmentFile = attachment.getOriginalFile(); + if (attachmentFile != null) { + File file = attachmentFile.getFile(); + + // replace the inline attachments with the extracted attachment file url + // match les patterns: + // <td background="cid:bg.gif" height="52"> + // <img border=0 src="cid:bg.gif" /> + // <img src='cid:5e9ef859-ea65-4f9b-a9fa-30d4a2c5837c' + content = content.replaceAll("(\\w+)=([\"'])cid:" + Pattern.quote(key) + "([\"'])", "$1=$2" + file.toURI() + "$3"); + + if (log.isDebugEnabled()) { + log.debug("Mapping attachment id " + key + " to file " + file.toURI()); } } + } - // remove the remaining cids whose attachment is not in the email (yes, it happens) - // cf #6996 - content = content.replaceAll("(\\w+)=([\"'])cid:.*?([\"'])", ""); + // remove the remaining cids whose attachment is not in the email (yes, it happens) + // cf #6996 + content = content.replaceAll("(\\w+)=([\"'])cid:.*?([\"'])", ""); - // on reformate les urls pour supprimer les caractères qui vont pas (ex espaces) - // cf #7740 - String defaultImageIfMalformedUrl = serviceContext.getApplicationConfig().getDefaultImageIfMalformedUrl(); - content = FaxToMailServiceUtils.encodeImageSourcesInEmail(content, defaultImageIfMalformedUrl); + // on reformate les urls pour supprimer les caractères qui vont pas (ex espaces) + // cf #7740 + String defaultImageIfMalformedUrl = serviceContext.getApplicationConfig().getDefaultImageIfMalformedUrl(); + content = FaxToMailServiceUtils.encodeImageSourcesInEmail(content, defaultImageIfMalformedUrl); - //On remplace les font-size:0 pour éviter les font-size too small - //cf #10123 - content = content.replace("font-size:0", "font-size:1"); + //On remplace les font-size:0 pour éviter les font-size too small + //cf #10123 + content = content.replace("font-size:0", "font-size:1"); - content = content.replaceAll("(.+) width=([\"])(.+)([\"])", "$1"); - content = content.replaceAll("(.+) width=(['])(.+)(['])", "$1"); - content = content.replaceAll("(.+) height=([\"])(.+)([\"])", "$1"); - content = content.replaceAll("(.+) height=(['])(.+)(['])", "$1"); - content = content.replaceAll("(style=\\\")([a-zA-Z0-9:;\\.\\s\\(\\)\\-\\,]*)(\\\")", "$1$3"); - content = content.replaceAll("(style=\\\')([a-zA-Z0-9:;\\.\\s\\(\\)\\-\\,]*)(\\\')", "$1$3"); - content = content.replace(" ", ""); + content = content.replaceAll("(.+) width=([\"])(.+)([\"])", "$1"); + content = content.replaceAll("(.+) width=(['])(.+)(['])", "$1"); + content = content.replaceAll("(.+) height=([\"])(.+)([\"])", "$1"); + content = content.replaceAll("(.+) height=(['])(.+)(['])", "$1"); + content = content.replaceAll("(style=\\\")([a-zA-Z0-9:;\\.\\s\\(\\)\\-\\,]*)(\\\")", "$1$3"); + content = content.replaceAll("(style=\\\')([a-zA-Z0-9:;\\.\\s\\(\\)\\-\\,]*)(\\\')", "$1$3"); + content = content.replace(" ", ""); - contents.add(content); - } - } - } finally { - // on supprime les fichiers avant le delete on exit pour eviter que le disque ne se remplissent trop vite - for (File file : fileToDelete) { - file.delete(); + contents.add(content); } } return StringUtils.join(contents, "<hr/>"); } + public void deleteTempAttachmentFiles(List<Attachment> attachments) { + for (Attachment attachment : attachments) { + AttachmentFile attachmentFile = attachment.getOriginalFile(); + if (attachmentFile != null) { + File file = attachmentFile.getFile(); + file.delete(); + } + } + } + public GeneratedPDFPage createGeneratedPDFPage(Attachment attachment, BufferedImage image) { GeneratedPDFPageTopiaDao dao = getPersistenceContext().getGeneratedPDFPageDao(); diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java index d6cb442c..19b83461 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java @@ -316,6 +316,11 @@ public class ReplyFormUIHandler extends AbstractFaxToMailUIHandler<ReplyFormUIMo @Override public void onCloseUI() { + try(FaxToMailServiceContext serviceContext = getContext().newServiceContext()) { + serviceContext.getEmailService().deleteTempAttachmentFiles(getModel().getOriginalDemand().getAttachment()); + } catch (IOException eee){ + log.error("Error deleting temp files",eee); + } } @Override -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm