Faxtomail-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
November 2014
- 1 participants
- 27 discussions
17 Nov '14
Author: kmorin
Date: 2014-11-17 16:58:10 +0000 (Mon, 17 Nov 2014)
New Revision: 691
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/691
Log:
fix missing 3rd party
Modified:
trunk/faxtomail-ui-swing/src/license/THIRD-PARTY.properties
Modified: trunk/faxtomail-ui-swing/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/faxtomail-ui-swing/src/license/THIRD-PARTY.properties 2014-11-17 15:30:51 UTC (rev 690)
+++ trunk/faxtomail-ui-swing/src/license/THIRD-PARTY.properties 2014-11-17 16:58:10 UTC (rev 691)
@@ -40,9 +40,10 @@
# Please fill the missing licenses for dependencies :
#
#
-#Wed Oct 15 19:01:07 CEST 2014
+#Mon Nov 17 17:38:01 CET 2014
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
dom4j--dom4j--1.6.1=BSD License
+gui.ava--html2image--2.0.1=GNU Lesser General Public License, Version 2.1
javax.media.jai--com.springsource.javax.media.jai.codec--1.1.3=Apache License
javax.media.jai--com.springsource.javax.media.jai.core--1.1.3=Apache License
org.nuiton.thirdparty--sdoc--0.5.0-beta-patchcl=Lesser General Public License (LGPL) v 3.0
1
0
17 Nov '14
Author: kmorin
Date: 2014-11-17 15:30:51 +0000 (Mon, 17 Nov 2014)
New Revision: 690
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/690
Log:
add license headers + refactoring + add email content attachment in archive import
Modified:
trunk/faxtomail-service/pom.xml
trunk/faxtomail-service/src/license/THIRD-PARTY.properties
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportResult.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/InvalidArchiveImportBeanException.java
trunk/faxtomail-service/src/main/resources/i18n/faxtomail-service_fr_FR.properties
trunk/faxtomail-ui-web/pom.xml
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailExecuteAndWaitInterceptor.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/HasUploadedFile.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/DemandDetailAction.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/job/MailFilterJob.java
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-wait.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/search-input.jsp
trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css
trunk/faxtomail-ui-web/src/main/webapp/js/demand-detail.js
Modified: trunk/faxtomail-service/pom.xml
===================================================================
--- trunk/faxtomail-service/pom.xml 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-service/pom.xml 2014-11-17 15:30:51 UTC (rev 690)
@@ -191,11 +191,27 @@
<groupId>com.github.spullara.mustache.java</groupId>
<artifactId>compiler</artifactId>
</dependency>
-
+
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf-itext5</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>gui.ava</groupId>
+ <artifactId>html2image</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.itextpdf</groupId>
+ <artifactId>itextpdf</artifactId>
+ </dependency>
+
</dependencies>
<build>
Modified: trunk/faxtomail-service/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/faxtomail-service/src/license/THIRD-PARTY.properties 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-service/src/license/THIRD-PARTY.properties 2014-11-17 15:30:51 UTC (rev 690)
@@ -12,7 +12,11 @@
# - Eclipse Distribution License (EDL), Version 1.0
# - Eclipse Public License (EPL), Version 1.0
# - Eclipse Public License, Version 1.0
+# - GNU Affero General Public License v3
+# - GNU General Public License version 2 (GPLv2)
# - GNU General Public License, Version 2 with the Classpath Exception
+# - GNU Lesser General Public License (LGPL), version 2.1
+# - GNU Lesser General Public License version 2.1 (LGPLv2.1)
# - GNU Lesser General Public License, Version 2.1
# - GNU Library or Lesser General Public License
# - GPLv2+CE
@@ -28,10 +32,12 @@
# - Public Domain
# - The Apache Software License, Version 2.0
# - The H2 License, Version 1.0
+# - UnboundID LDAP SDK Free Use License
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
-#Fri Apr 25 11:47:01 CEST 2014
+#Mon Nov 17 16:20:10 CET 2014
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
dom4j--dom4j--1.6.1=BSD License
+gui.ava--html2image--2.0.1=GNU Lesser General Public License, Version 2.1
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-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-11-17 15:30:51 UTC (rev 690)
@@ -34,10 +34,13 @@
import java.util.Set;
import javax.mail.MessagingException;
+import javax.mail.Part;
import com.franciaflex.faxtomail.persistence.entities.EmailFilter;
+import com.franciaflex.faxtomail.persistence.entities.ExtensionCommand;
import com.franciaflex.faxtomail.persistence.entities.SearchFilter;
import com.franciaflex.faxtomail.services.service.imports.ArchiveImportResult;
+import com.itextpdf.text.DocumentException;
import org.apache.commons.mail.EmailException;
import org.nuiton.util.pagination.PaginationParameter;
import org.nuiton.util.pagination.PaginationResult;
@@ -139,4 +142,46 @@
* @param attachmentBase base folder containing attachment listed in csv file
*/
ArchiveImportResult importArchive(InputStream is, File attachmentBase);
+
+ /**
+ * Decompose a multipart part.
+ * - sets the email content if the part contains a text bodypart
+ * - adds attachments to the email
+ *
+ * @param part the part to decompose
+ * @throws Exception
+ */
+ String decomposeMultipartEmail(List<Attachment> attachments, Part part) throws Exception;
+
+ /**
+ * Retourne un input stream sur une piece jointe convertie ou pas.
+ *
+ * @param attachment to convert
+ * @return attachment
+ * @throws IOException
+ */
+ Attachment convertIfNecessary(Attachment attachment) throws IOException;
+
+ /**
+ * Convert attachment to pdf.
+ *
+ * @param attachment attachment to convert
+ * @param extensionCommand command
+ * @return
+ * @throws IOException
+ */
+ Attachment convertToPdf(Attachment attachment, ExtensionCommand extensionCommand) throws IOException;
+
+ Attachment convertTextToPdf(String content, String name) throws IOException, DocumentException;
+
+ /**
+ * Convert html content to image.
+ *
+ * @param attachments attachment content to link content to
+ * @param content html content
+ * @param name result attachment name
+ * @return image attachment or {@code null} if content can't be converted
+ * @throws IOException
+ */
+ Attachment convertHTMLToPdf(List<Attachment> attachments, String content, String name) throws IOException;
}
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-11-17 15:30:51 UTC (rev 690)
@@ -37,6 +37,7 @@
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
+import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -58,10 +59,16 @@
import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
+import java.util.regex.Pattern;
+import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.MessagingException;
+import javax.mail.Part;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMultipart;
+import javax.mail.internet.MimeUtility;
import com.franciaflex.faxtomail.persistence.entities.Email;
import com.franciaflex.faxtomail.services.service.imports.ArchiveImportExportBean;
@@ -71,10 +78,17 @@
import com.google.common.base.Optional;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
+import com.itextpdf.text.Document;
+import com.itextpdf.text.DocumentException;
+import com.itextpdf.text.PageSize;
+import com.itextpdf.text.Paragraph;
+import com.itextpdf.text.pdf.PdfWriter;
+import gui.ava.html.Html2Image;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.BooleanUtils;
@@ -98,6 +112,7 @@
import org.nuiton.topia.persistence.support.TopiaHibernateSupport;
import org.nuiton.topia.persistence.support.TopiaSqlSupport;
import org.nuiton.topia.persistence.support.TopiaSqlWork;
+import org.nuiton.util.StringUtil;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
import org.nuiton.util.pagination.PaginationParameter;
@@ -1648,6 +1663,25 @@
// email.addHistory(history);
+ try {
+ Attachment contentAttachment = convertTextToPdf(email.getOriginalEmail(),
+ t("faxtomail.email.content.attachment.plainfileName"));
+
+ AttachmentFile contentAttachmentFile = contentAttachment.getOriginalFile();
+ contentAttachmentFile.setTopiaId(getTopiaId(AttachmentFile.class, contentAttachmentFile));
+ statelessSession.insert(contentAttachmentFile);
+
+ contentAttachment.setEmail(email);
+ contentAttachment.setTopiaId(getTopiaId(Attachment.class, contentAttachment));
+ statelessSession.insert(contentAttachment);
+
+ } catch (IOException | DocumentException e) {
+ if (log.isErrorEnabled()) {
+ log.error("error while creating email content attachment", e);
+ }
+ }
+
+
// manage attachments
if (archiveBean.getAttachmentPaths() != null) {
Iterable<String> itAttachmentPaths = Splitter.on(',').omitEmptyStrings().trimResults().split(archiveBean.getAttachmentPaths());
@@ -1665,6 +1699,7 @@
Attachment attachment = attachmentDao.newInstance();
attachment.setEmail(email);
+ attachment.setTopiaId(getTopiaId(Attachment.class, attachment));
AttachmentFile attachmentFile = attachmentFileDao.newInstance();
attachmentFile.setFilename(attFile.getName());
@@ -1679,8 +1714,15 @@
statelessSession.insert(attachmentFile);
attachment.setOriginalFile(attachmentFile);
+ try {
+ convertIfNecessary(attachment);
- attachment.setTopiaId(getTopiaId(Attachment.class, attachment));
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("error while converting attachment", e);
+ }
+ }
+
statelessSession.insert(attachment);
// email.addAttachment(attachment);
@@ -1773,4 +1815,281 @@
long result = emailDao.forDemandStatusEquals(DemandStatus.ARCHIVED).count();
return result;
}
+
+ @Override
+ public String decomposeMultipartEmail(List<Attachment> attachments, Part part) throws Exception {
+ String result = null;
+
+
+ DataSource dataSource = part.getDataHandler().getDataSource();
+ MimeMultipart mimeMultipart = new MimeMultipart(dataSource);
+ int multiPartCount = mimeMultipart.getCount();
+
+ for (int j = 0; j < multiPartCount; j++) {
+ MimeBodyPart bp = (MimeBodyPart) mimeMultipart.getBodyPart(j);
+
+ // if it is a text part, then this is the email content
+ String disposition = bp.getDisposition();
+ if (bp.isMimeType("text/*") && !Part.ATTACHMENT.equals(disposition)) {
+
+ Charset charset = FaxToMailServiceUtils.getCharset(bp);
+ String content = IOUtils.toString(bp.getInputStream(), charset);
+
+ if (bp.isMimeType("text/plain")) {
+ Attachment attachment = convertTextToPdf(content, t("faxtomail.email.content.attachment.plainfileName"));
+ attachments.add(attachment);
+
+ } else {
+ result = content;
+ }
+
+ // if it is multipart part, decompose it
+ } else if (bp.isMimeType("multipart/*")) {
+ String htmlContent = decomposeMultipartEmail(attachments, bp);
+ if (htmlContent != null) {
+ result = htmlContent;
+ }
+
+ // else, this is an attachment
+ } else {
+ String fileName = bp.getFileName();
+
+ // parse Content-ID (content identifier in html mail content)
+ String[] headers = bp.getHeader("Content-ID");
+ String contentID = null;
+ if (headers != null) {
+ contentID = headers[0];
+ contentID = contentID.replaceFirst("^<(.*)>$", "$1");
+ }
+
+ // remove the guillemets between the id
+
+ if (fileName == null && contentID == null) {
+ break;
+ } else if (fileName == null) {
+ fileName = contentID;
+ }
+
+ try {
+ fileName = MimeUtility.decodeText(fileName);
+ if (log.isDebugEnabled()) {
+ log.debug("FileName : " + fileName + ", Content-ID : " + contentID);
+ }
+ } catch (UnsupportedEncodingException ex) {
+ // don't care, use filename raw value
+ if (log.isWarnEnabled()) {
+ log.warn("Can't debug email file name", ex);
+ }
+ }
+
+ DataHandler dh = bp.getDataHandler();
+
+ // create new attachment
+ Attachment attachment = new AttachmentImpl();
+ attachment.setAddedByUser(false);
+ AttachmentFile attachmentFile = getAttachmentFileFromStream(dh.getInputStream());
+ attachmentFile.setFilename(fileName);
+ attachment.setOriginalFile(attachmentFile);
+ attachment.setContentId(contentID);
+
+ // convert attachment if defined by admin
+ convertIfNecessary(attachment);
+
+ // save attachment
+ attachments.add(attachment);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public Attachment convertIfNecessary(Attachment attachment) throws IOException {
+
+ // get file extension
+ String filename = attachment.getOriginalFileName();
+ String extension = FilenameUtils.getExtension(filename);
+
+ if (StringUtils.isNotBlank(extension)) {
+ ExtensionCommand command = getConfigurationService().getExtensionCommand(extension);
+
+ // si une extension est configurée avec une commande non vide
+ if (command != null && StringUtils.isNotBlank(command.getConvertToPdfCommand())) {
+ attachment = convertToPdf(attachment, command);
+ }
+ }
+ return attachment;
+ }
+
+ @Override
+ public Attachment convertToPdf(Attachment attachment, ExtensionCommand extensionCommand) throws IOException {
+
+ // get file extension
+ String filename = attachment.getOriginalFileName();
+ String basename = FilenameUtils.getBaseName(filename);
+ String extension = FilenameUtils.getExtension(filename);
+
+ // copy file to temp file
+ File file = File.createTempFile("faxtomail-" + basename, "." + extension);
+ file.deleteOnExit();
+ // on creer un nouveau nom de fichier ou seulement le nom de l'extension change
+ // cela permet de fonctionner avec openoffice par exemple où il n'est pas possible
+ // de specifier le nom du fichier de sortie
+ String fullname = StringUtils.removeEnd(file.getAbsolutePath(), "." + extension);
+ File outfile = new File(fullname + ".pdf");
+ outfile.deleteOnExit();
+ FileUtils.writeByteArrayToFile(file, attachment.getOriginalFile().getContent());
+
+ // get process command
+ String command = extensionCommand.getConvertToPdfCommand();
+ String[] args = StringUtil.split(command, " ");
+ List<String> comArgs = new ArrayList<String>();
+ for (String arg : args) {
+ String localArg = arg;
+ localArg = localArg.replace("%f", file.getAbsolutePath());
+ localArg = localArg.replace("%o", outfile.getAbsolutePath());
+ comArgs.add(localArg);
+ }
+ ProcessBuilder pb = new ProcessBuilder(comArgs);
+ // run process
+ if (log.isDebugEnabled()) {
+ log.debug("Convert attachment with command : " + comArgs);
+ }
+ try {
+ Process process = pb.start();
+ process.waitFor();
+
+ // read output to save into attachment
+ byte[] outContent = FileUtils.readFileToByteArray(outfile);
+
+ // on va dire que normalement un pdf ca fait plus de 1 octet
+ if (outContent.length >= 1) {
+ AttachmentFile editedFile = new AttachmentFileImpl();
+ editedFile.setContent(outContent);
+ editedFile.setFilename(basename + "-converted.pdf");
+ attachment.setEditedFile(editedFile);
+ } else if (log.isWarnEnabled()) {
+ log.warn("Can't convert extension to pdf (content is empty)");
+ }
+
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Cannot run convert command", e);
+ }
+ } catch (InterruptedException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Cannot run convert command", e);
+ }
+ }
+
+ // cleanup
+ file.delete();
+ outfile.delete();
+
+ return attachment;
+ }
+
+ @Override
+ public Attachment convertTextToPdf(String content, String name) throws IOException, DocumentException {
+ //File target = File.createTempFile("faxtomail-", ".tmp");
+ //target.deleteOnExit();
+
+ Document document = new Document();
+ //FileOutputStream fos = new FileOutputStream(target);
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ PdfWriter writer = PdfWriter.getInstance(document, os);
+ writer.open();
+
+ document.setPageSize(PageSize.A4);
+ document.open();
+
+ document.add(new Paragraph(content));
+
+ document.close();
+ writer.close();
+
+ // convert content to blob
+ AttachmentFile attachmentFileNew = new AttachmentFileImpl();
+ attachmentFileNew.setContent(os.toByteArray());
+ attachmentFileNew.setFilename(name + ".pdf");
+
+ Attachment attachment = new AttachmentImpl();
+ attachment.setOriginalFile(attachmentFileNew);
+ attachment.setOriginalFileName(name + ".pdf");
+ attachment.setAddedByUser(false);
+
+ //target.delete();
+
+ return attachment;
+ }
+
+ @Override
+ public Attachment convertHTMLToPdf(List<Attachment> attachments, String content, String name) throws IOException {
+ Attachment result = null;
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ Collection<File> fileToDelete = new ArrayList<File>();
+ try {
+ content = content.replaceAll("<meta (.*?)>(</meta>)?", "");
+
+ for (Attachment attachment : attachments) {
+ String key = attachment.getContentId();
+ if (key == null) {
+ key = attachment.getOriginalFileName();
+ }
+
+ // get file content
+ AttachmentFile attachmentFile = attachment.getOriginalFile();
+ 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=$2file://" + file.getAbsolutePath() + "$3");
+
+ if (log.isDebugEnabled()) {
+ log.debug("Mapping attachment id " + key + " to file " + file.getAbsolutePath());
+ }
+ }
+
+ Html2Image image = Html2Image.fromHtml(content);
+ //ImageRenderer imageRenderer = image.getImageRenderer();
+ //imageRenderer.saveImage(os, true);
+ org.w3c.dom.Document doc = image.getParser().getDocument();
+
+ // convert to pdf
+ ITextRenderer renderer = new ITextRenderer();
+ renderer.setDocument(doc, null);
+ renderer.layout();
+ renderer.createPDF(os);
+
+ // convert content to blob
+ AttachmentFile attachmentFileNew = new AttachmentFileImpl();
+ attachmentFileNew.setContent(os.toByteArray());
+ attachmentFileNew.setFilename(name + ".pdf");
+
+ result = new AttachmentImpl();
+ result.setOriginalFile(attachmentFileNew);
+ result.setOriginalFileName(name + ".pdf");
+ result.setAddedByUser(false);
+
+ } catch (OutOfMemoryError er) {
+ // certains mails (spam) très compliqué ne peuvent pas être convertit en images
+ if (log.isWarnEnabled()) {
+ log.warn("Can't convert html content to pdf", er);
+ }
+ } catch (DocumentException ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't convert html content to pdf", ex);
+ }
+ } 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();
+ }
+ }
+
+ return result;
+ }
}
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportResult.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportResult.java 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportResult.java 2014-11-17 15:30:51 UTC (rev 690)
@@ -1,5 +1,29 @@
package com.franciaflex.faxtomail.services.service.imports;
+/*
+ * #%L
+ * FaxToMail :: Service
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2014 Mac-Groupe, 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 java.io.File;
/**
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/InvalidArchiveImportBeanException.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/InvalidArchiveImportBeanException.java 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/InvalidArchiveImportBeanException.java 2014-11-17 15:30:51 UTC (rev 690)
@@ -1,5 +1,29 @@
package com.franciaflex.faxtomail.services.service.imports;
+/*
+ * #%L
+ * FaxToMail :: Service
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2014 Mac-Groupe, 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%
+ */
+
/**
* @author Kevin Morin (Code Lutin)
* @since 1.1
Modified: trunk/faxtomail-service/src/main/resources/i18n/faxtomail-service_fr_FR.properties
===================================================================
--- trunk/faxtomail-service/src/main/resources/i18n/faxtomail-service_fr_FR.properties 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-service/src/main/resources/i18n/faxtomail-service_fr_FR.properties 2014-11-17 15:30:51 UTC (rev 690)
@@ -3,6 +3,7 @@
faxtomail.archives.import.error.persistence=Erreur technique de persistence
faxtomail.archives.import.error.readingAttachmentFile=Erreur lors de la lecture de la PJ %s
faxtomail.attachment.demand.filename=Détail de la demande
+faxtomail.email.content.attachment.plainfileName=
faxtomail.email.projectReference.default=Votre demande du %s
faxtomail.service.email.save.clientCode.error=Impossible de trouver le client %s \!
faxtomail.validator.error.email.clientCode.required=
Modified: trunk/faxtomail-ui-web/pom.xml
===================================================================
--- trunk/faxtomail-ui-web/pom.xml 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-ui-web/pom.xml 2014-11-17 15:30:51 UTC (rev 690)
@@ -284,22 +284,6 @@
</dependency>
<dependency>
- <groupId>com.itextpdf</groupId>
- <artifactId>itextpdf</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.xhtmlrenderer</groupId>
- <artifactId>flying-saucer-pdf-itext5</artifactId>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>gui.ava</groupId>
- <artifactId>html2image</artifactId>
- </dependency>
-
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailExecuteAndWaitInterceptor.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailExecuteAndWaitInterceptor.java 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailExecuteAndWaitInterceptor.java 2014-11-17 15:30:51 UTC (rev 690)
@@ -1,5 +1,29 @@
package com.franciaflex.faxtomail.web;
+/*
+ * #%L
+ * FaxToMail :: Web
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2014 Mac-Groupe, 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.opensymphony.xwork2.ActionInvocation;
import org.apache.commons.io.FileUtils;
import org.apache.struts2.interceptor.BackgroundProcess;
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/HasUploadedFile.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/HasUploadedFile.java 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/HasUploadedFile.java 2014-11-17 15:30:51 UTC (rev 690)
@@ -1,5 +1,29 @@
package com.franciaflex.faxtomail.web;
+/*
+ * #%L
+ * FaxToMail :: Web
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2014 Mac-Groupe, 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 java.io.File;
/**
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/DemandDetailAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/DemandDetailAction.java 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/DemandDetailAction.java 2014-11-17 15:30:51 UTC (rev 690)
@@ -1,5 +1,29 @@
package com.franciaflex.faxtomail.web.action;
+/*
+ * #%L
+ * FaxToMail :: Web
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2014 Mac-Groupe, 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.Attachment;
import com.franciaflex.faxtomail.persistence.entities.AttachmentFile;
import com.franciaflex.faxtomail.persistence.entities.AttachmentFileImpl;
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java 2014-11-17 15:30:51 UTC (rev 690)
@@ -1,5 +1,29 @@
package com.franciaflex.faxtomail.web.action;
+/*
+ * #%L
+ * FaxToMail :: Web
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2014 Mac-Groupe, 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.Attachment;
import com.franciaflex.faxtomail.persistence.entities.Client;
import com.franciaflex.faxtomail.persistence.entities.Email;
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/job/MailFilterJob.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/job/MailFilterJob.java 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/job/MailFilterJob.java 2014-11-17 15:30:51 UTC (rev 690)
@@ -466,12 +466,12 @@
if (message.isMimeType("multipart/*")) {
// manage boundary id
- String htmlContent = decomposeMultipartEmail(attachments, message, email, emailService);
+ String htmlContent = emailService.decomposeMultipartEmail(attachments, message);
if (htmlContent != null) {
if (log.isDebugEnabled()) {
log.debug("Converting html content to pdf : " + message.getSubject());
}
- Attachment attachment = convertHTMLToPdf(attachments, htmlContent, t("faxtomail.email.content.attachment.htmlfileName"));
+ Attachment attachment = emailService.convertHTMLToPdf(attachments, htmlContent, t("faxtomail.email.content.attachment.htmlfileName"));
if (attachment != null) {
//remove text plain attachement if exists, to avoid having twice the mail content in the attachments
String plainTextFileName = t("faxtomail.email.content.attachment.plainfileName") + ".pdf";
@@ -487,7 +487,7 @@
} else {
// convertit le contenu texte en PDF
String content = IOUtils.toString(message.getInputStream(), charset);
- Attachment attachment = convertTextToPdf(content, t("faxtomail.email.content.attachment.plainfileName"));
+ Attachment attachment = emailService.convertTextToPdf(content, t("faxtomail.email.content.attachment.plainfileName"));
attachments.add(0, attachment);
}
@@ -537,310 +537,4 @@
}
}
- /**
- * Decompose a multipart part.
- * - sets the email content if the part contains a text bodypart
- * - adds attachments to the email
- *
- * @param part the part to decompose
- * @param email the email object to fill with the attachments or content
- * @param emailService email service
- * @throws Exception
- */
- protected String decomposeMultipartEmail(List<Attachment> attachments, Part part, Email email, EmailService emailService) throws Exception {
- String result = null;
-
-
- DataSource dataSource = part.getDataHandler().getDataSource();
- MimeMultipart mimeMultipart = new MimeMultipart(dataSource);
- int multiPartCount = mimeMultipart.getCount();
-
- for (int j = 0; j < multiPartCount; j++) {
- MimeBodyPart bp = (MimeBodyPart) mimeMultipart.getBodyPart(j);
-
- // if it is a text part, then this is the email content
- String disposition = bp.getDisposition();
- if (bp.isMimeType("text/*") && !Part.ATTACHMENT.equals(disposition)) {
-
- Charset charset = FaxToMailServiceUtils.getCharset(bp);
- String content = IOUtils.toString(bp.getInputStream(), charset);
-
- if (bp.isMimeType("text/plain")) {
- Attachment attachment = convertTextToPdf(content, t("faxtomail.email.content.attachment.plainfileName"));
- attachments.add(attachment);
-
- } else {
- result = content;
- }
-
- // if it is multipart part, decompose it
- } else if (bp.isMimeType("multipart/*")) {
- String htmlContent = decomposeMultipartEmail(attachments, bp, email, emailService);
- if (htmlContent != null) {
- result = htmlContent;
- }
-
- // else, this is an attachment
- } else {
- String fileName = bp.getFileName();
-
- // parse Content-ID (content identifier in html mail content)
- String[] headers = bp.getHeader("Content-ID");
- String contentID = null;
- if (headers != null) {
- contentID = headers[0];
- contentID = contentID.replaceFirst("^<(.*)>$", "$1");
- }
-
- // remove the guillemets between the id
-
- if (fileName == null && contentID == null) {
- break;
- } else if (fileName == null) {
- fileName = contentID;
- }
-
- try {
- fileName = MimeUtility.decodeText(fileName);
- if (log.isDebugEnabled()) {
- log.debug("FileName : " + fileName + ", Content-ID : " + contentID);
- }
- } catch (UnsupportedEncodingException ex) {
- // don't care, use filename raw value
- if (log.isWarnEnabled()) {
- log.warn("Can't debug email file name", ex);
- }
- }
-
- DataHandler dh = bp.getDataHandler();
-
- // create new attachment
- Attachment attachment = new AttachmentImpl();
- attachment.setAddedByUser(false);
- AttachmentFile attachmentFile = emailService.getAttachmentFileFromStream(dh.getInputStream());
- attachmentFile.setFilename(fileName);
- attachment.setOriginalFile(attachmentFile);
- attachment.setContentId(contentID);
-
- // convert attachment if defined by admin
- convertIfNecessary(attachment);
-
- // save attachment
- attachments.add(attachment);
- }
- }
- return result;
- }
-
- /**
- * Retourne un input stream sur une piece jointe convertie ou pas.
- *
- * @param attachment to convert
- * @return attachment
- * @throws IOException
- */
- protected Attachment convertIfNecessary(Attachment attachment) throws IOException {
-
- // get file extension
- String filename = attachment.getOriginalFileName();
- String extension = FilenameUtils.getExtension(filename);
-
- if (StringUtils.isNotBlank(extension)) {
- ExtensionCommand command = configurationService.getExtensionCommand(extension);
-
- // si une extension est configurée avec une commande non vide
- if (command != null && StringUtils.isNotBlank(command.getConvertToPdfCommand())) {
- attachment = convertToPdf(attachment, command);
- }
- }
- return attachment;
- }
-
- /**
- * Convert attachment to pdf.
- *
- * @param attachment attachment to convert
- * @param extensionCommand command
- * @return
- * @throws IOException
- */
- protected Attachment convertToPdf(Attachment attachment, ExtensionCommand extensionCommand) throws IOException {
-
- // get file extension
- String filename = attachment.getOriginalFileName();
- String basename = FilenameUtils.getBaseName(filename);
- String extension = FilenameUtils.getExtension(filename);
-
- // copy file to temp file
- File file = File.createTempFile("faxtomail-" + basename, "." + extension);
- file.deleteOnExit();
- // on creer un nouveau nom de fichier ou seulement le nom de l'extension change
- // cela permet de fonctionner avec openoffice par exemple où il n'est pas possible
- // de specifier le nom du fichier de sortie
- String fullname = StringUtils.removeEnd(file.getAbsolutePath(), "." + extension);
- File outfile = new File(fullname + ".pdf");
- outfile.deleteOnExit();
- FileUtils.writeByteArrayToFile(file, attachment.getOriginalFile().getContent());
-
- // get process command
- String command = extensionCommand.getConvertToPdfCommand();
- String[] args = StringUtil.split(command, " ");
- List<String> comArgs = new ArrayList<String>();
- for (String arg : args) {
- String localArg = arg;
- localArg = localArg.replace("%f", file.getAbsolutePath());
- localArg = localArg.replace("%o", outfile.getAbsolutePath());
- comArgs.add(localArg);
- }
- ProcessBuilder pb = new ProcessBuilder(comArgs);
- // run process
- if (log.isDebugEnabled()) {
- log.debug("Convert attachment with command : " + comArgs);
- }
- try {
- Process process = pb.start();
- process.waitFor();
-
- // read output to save into attachment
- byte[] outContent = FileUtils.readFileToByteArray(outfile);
-
- // on va dire que normalement un pdf ca fait plus de 1 octet
- if (outContent.length >= 1) {
- AttachmentFile editedFile = new AttachmentFileImpl();
- editedFile.setContent(outContent);
- editedFile.setFilename(basename + "-converted.pdf");
- attachment.setEditedFile(editedFile);
- } else if (log.isWarnEnabled()) {
- log.warn("Can't convert extension to pdf (content is empty)");
- }
-
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Cannot run convert command", e);
- }
- } catch (InterruptedException e) {
- if (log.isErrorEnabled()) {
- log.error("Cannot run convert command", e);
- }
- }
-
- // cleanup
- file.delete();
- outfile.delete();
-
- return attachment;
- }
-
- protected Attachment convertTextToPdf(String content, String name) throws IOException, DocumentException {
- //File target = File.createTempFile("faxtomail-", ".tmp");
- //target.deleteOnExit();
-
- Document document = new Document();
- //FileOutputStream fos = new FileOutputStream(target);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- PdfWriter writer = PdfWriter.getInstance(document, os);
- writer.open();
-
- document.setPageSize(PageSize.A4);
- document.open();
-
- document.add(new Paragraph(content));
-
- document.close();
- writer.close();
-
- // convert content to blob
- AttachmentFile attachmentFileNew = new AttachmentFileImpl();
- attachmentFileNew.setContent(os.toByteArray());
- attachmentFileNew.setFilename(name + ".pdf");
-
- Attachment attachment = new AttachmentImpl();
- attachment.setOriginalFile(attachmentFileNew);
- attachment.setOriginalFileName(name + ".pdf");
- attachment.setAddedByUser(false);
-
- //target.delete();
-
- return attachment;
- }
-
- /**
- * Convert html content to image.
- *
- * @param attachments attachment content to link content to
- * @param content html content
- * @param name result attachment name
- * @return image attachment or {@code null} if content can't be converted
- * @throws IOException
- */
- protected Attachment convertHTMLToPdf(List<Attachment> attachments, String content, String name) throws IOException {
-
-
- Attachment result = null;
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- Collection<File> fileToDelete = new ArrayList<File>();
- try {
- content = content.replaceAll("<meta (.*?)>(</meta>)?", "");
-
- for (Attachment attachment : attachments) {
- String key = attachment.getContentId();
- if (key == null) {
- key = attachment.getOriginalFileName();
- }
-
- // get file content
- AttachmentFile attachmentFile = attachment.getOriginalFile();
- 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=$2file://" + file.getAbsolutePath() + "$3");
-
- if (log.isDebugEnabled()) {
- log.debug("Mapping attachment id " + key + " to file " + file.getAbsolutePath());
- }
- }
-
- Html2Image image = Html2Image.fromHtml(content);
- //ImageRenderer imageRenderer = image.getImageRenderer();
- //imageRenderer.saveImage(os, true);
- org.w3c.dom.Document doc = image.getParser().getDocument();
-
- // convert to pdf
- ITextRenderer renderer = new ITextRenderer();
- renderer.setDocument(doc, null);
- renderer.layout();
- renderer.createPDF(os);
-
- // convert content to blob
- AttachmentFile attachmentFileNew = new AttachmentFileImpl();
- attachmentFileNew.setContent(os.toByteArray());
- attachmentFileNew.setFilename(name + ".pdf");
-
- result = new AttachmentImpl();
- result.setOriginalFile(attachmentFileNew);
- result.setOriginalFileName(name + ".pdf");
- result.setAddedByUser(false);
- } catch (OutOfMemoryError er) {
- // certains mails (spam) très compliqué ne peuvent pas être convertit en images
- if (log.isWarnEnabled()) {
- log.warn("Can't convert html content to pdf", er);
- }
- } catch (DocumentException ex) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert html content to pdf", ex);
- }
- } 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();
- }
- }
-
- return result;
- }
}
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-wait.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-wait.jsp 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-wait.jsp 2014-11-17 15:30:51 UTC (rev 690)
@@ -1,3 +1,26 @@
+<%--
+ #%L
+ FaxToMail :: Web
+ $Id:$
+ $HeadURL:$
+ %%
+ Copyright (C) 2014 Mac-Groupe, 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%
+ --%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<%@taglib uri="/struts-tags" prefix="s" %>
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-11-17 15:30:51 UTC (rev 690)
@@ -1,3 +1,26 @@
+<%--
+ #%L
+ FaxToMail :: Web
+ $Id:$
+ $HeadURL:$
+ %%
+ Copyright (C) 2014 Mac-Groupe, 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%
+ --%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<%@taglib uri="/struts-tags" prefix="s" %>
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/search-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/search-input.jsp 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/search-input.jsp 2014-11-17 15:30:51 UTC (rev 690)
@@ -1,3 +1,26 @@
+<%--
+ #%L
+ FaxToMail :: Web
+ $Id:$
+ $HeadURL:$
+ %%
+ Copyright (C) 2014 Mac-Groupe, 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%
+ --%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<%@taglib uri="/struts-tags" prefix="s" %>
Modified: trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css 2014-11-17 15:30:51 UTC (rev 690)
@@ -1,3 +1,26 @@
+/*
+ * #%L
+ * FaxToMail :: Web
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2014 Mac-Groupe, 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%
+ */
.float-right {
float: right;
}
Modified: trunk/faxtomail-ui-web/src/main/webapp/js/demand-detail.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/demand-detail.js 2014-11-17 13:46:57 UTC (rev 689)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/demand-detail.js 2014-11-17 15:30:51 UTC (rev 690)
@@ -1,3 +1,26 @@
+/*
+ * #%L
+ * FaxToMail :: Web
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2014 Mac-Groupe, 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%
+ */
var DemandDetailModule = angular.module('DemandDetailModule', ['FaxToMail', 'ngSanitize']);
DemandDetailModule.controller('DemandDetailController', ['$scope', 'DemandDetailData',
1
0
r689 - trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities
by kmorin@users.forge.codelutin.com 17 Nov '14
by kmorin@users.forge.codelutin.com 17 Nov '14
17 Nov '14
Author: kmorin
Date: 2014-11-17 13:46:57 +0000 (Mon, 17 Nov 2014)
New Revision: 689
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/689
Log:
fixes #6109
Modified:
trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java
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-11-17 13:30:11 UTC (rev 688)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java 2014-11-17 13:46:57 UTC (rev 689)
@@ -458,7 +458,7 @@
//Hibernate.initialize(email.getTakenBy());
Hibernate.initialize(email.getReplies());
Hibernate.initialize(email.getAttachment());
- List<History> histories = email.getHistory();
+ Collection<History> histories = email.getHistory();
if (histories != null) {
for (History history : histories) {
Hibernate.initialize(history.getFaxToMailUser());
@@ -571,7 +571,7 @@
//Hibernate.initialize(email.getTakenBy());
Hibernate.initialize(email.getReplies());
Hibernate.initialize(email.getAttachment());
- List<History> histories = email.getHistory();
+ Collection<History> histories = email.getHistory();
if (histories != null) {
for (History history : histories) {
Hibernate.initialize(history.getFaxToMailUser());
1
0
17 Nov '14
Author: kmorin
Date: 2014-11-17 13:30:11 +0000 (Mon, 17 Nov 2014)
New Revision: 688
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/688
Log:
fixes #6109 Import Archives : les collections ne sont pas li?\195?\169es aux emails
Modified:
trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailImpl.java
trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.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/replies/DemandRepliesUIHandler.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java
Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailImpl.java
===================================================================
--- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailImpl.java 2014-11-17 07:21:06 UTC (rev 687)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailImpl.java 2014-11-17 13:30:11 UTC (rev 688)
@@ -169,7 +169,7 @@
}
@Override
- public void setHistory(List<History> history) {
+ public void setHistory(Collection<History> history) {
firstOpeningHistory = null;
lastModificationHistory = null;
lastAttachmentOpeningInFolderHistory = null;
Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo
===================================================================
(Binary files differ)
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-11-17 07:21:06 UTC (rev 687)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-11-17 13:30:11 UTC (rev 688)
@@ -172,7 +172,7 @@
//Hibernate.initialize(email.getTakenBy());
Hibernate.initialize(email.getReplies());
Hibernate.initialize(email.getAttachment());
- List<History> histories = email.getHistory();
+ Collection<History> histories = email.getHistory();
if (histories != null) {
for (History history : histories) {
Hibernate.initialize(history.getFaxToMailUser());
@@ -331,12 +331,14 @@
if (fieldSet.contains(Email.PROPERTY_ARCHIVE_DATE)) {
history = historyDao.create(History.PROPERTY_TYPE, HistoryType.ARCHIVED,
History.PROPERTY_FAX_TO_MAIL_USER, user,
- History.PROPERTY_MODIFICATION_DATE, now);
+ History.PROPERTY_MODIFICATION_DATE, now,
+ History.PROPERTY_EMAIL, email);
} else if (fieldSet.contains(Email.PROPERTY_MAIL_FOLDER)) {
history = historyDao.create(History.PROPERTY_TYPE, HistoryType.TRANSMISSION,
History.PROPERTY_FAX_TO_MAIL_USER, user,
- History.PROPERTY_MODIFICATION_DATE, now);
+ History.PROPERTY_MODIFICATION_DATE, now,
+ History.PROPERTY_EMAIL, email);
} else {
if (email.getTakenBy() == null &&
@@ -349,8 +351,9 @@
if (historyEmpty || !fieldSet.isEmpty()) {
history = historyDao.create(History.PROPERTY_TYPE, historyEmpty ? HistoryType.CREATION : HistoryType.MODIFICATION,
History.PROPERTY_FAX_TO_MAIL_USER, user,
- History.PROPERTY_MODIFICATION_DATE, now);
- history.setFields(fieldSet);
+ History.PROPERTY_MODIFICATION_DATE, now,
+ History.PROPERTY_EMAIL, email,
+ History.PROPERTY_FIELDS_JSON, AbstractFaxToMailTopiaDao.GSON_INSTANCE.toJson(fieldSet));
}
}
if (history != null) {
@@ -394,11 +397,12 @@
AttachmentTopiaDao attachmentTopiaDao = getPersistenceContext().getAttachmentDao();
HistoryTopiaDao historyTopiaDao = getPersistenceContext().getHistoryDao();
- List<Attachment> currentAttachments = attachmentTopiaDao.forTopiaIdIn(email.getAttachmentTopiaIds()).findAll();
+ List<Attachment> currentAttachments = attachmentTopiaDao.forEmailEquals(email).findAll();
if (currentAttachments == null) {
currentAttachments = new ArrayList<>();
}
- Map<String, Attachment> currentAttachmentIndex = new HashMap<>(Maps.uniqueIndex(currentAttachments, TopiaEntities.getTopiaIdFunction()));
+ Map<String, Attachment> currentAttachmentIndex = new HashMap<>(Maps.uniqueIndex(currentAttachments,
+ TopiaEntities.getTopiaIdFunction()));
Set<String> newFiles = new HashSet<>();
@@ -430,6 +434,7 @@
// copy new data
attachmentBinder.copyExcluding(attachment, currentAttachment,
+ Attachment.PROPERTY_EMAIL,
Attachment.PROPERTY_EDITED_FILE,
Attachment.PROPERTY_EDITED_FILE_NAME,
Attachment.PROPERTY_ORIGINAL_FILE,
@@ -438,6 +443,7 @@
Attachment.PROPERTY_TOPIA_ID,
Attachment.PROPERTY_TOPIA_VERSION);
+ currentAttachment.setEmail(email);
currentAttachment.setEditedFile(editedFile);
currentAttachment.setOriginalFile(originalFile);
@@ -465,15 +471,20 @@
if (!currentAttachment.isPersisted()) {
// persist using cascade
+ currentAttachment = attachmentTopiaDao.create(currentAttachment);
currentAttachments.add(currentAttachment);
+
+ } else {
+ attachmentTopiaDao.update(currentAttachment);
}
}
if (!newFiles.isEmpty()) {
History history = historyTopiaDao.create(History.PROPERTY_TYPE, HistoryType.ATTACHMENT_ADDITION,
History.PROPERTY_FAX_TO_MAIL_USER, user,
- History.PROPERTY_MODIFICATION_DATE, new Date());
- history.setFields(newFiles);
+ History.PROPERTY_MODIFICATION_DATE, new Date(),
+ History.PROPERTY_EMAIL, email,
+ History.PROPERTY_FIELDS_JSON, AbstractFaxToMailTopiaDao.GSON_INSTANCE.toJson(newFiles));
email.addHistory(history);
}
@@ -507,7 +518,8 @@
if (BooleanUtils.isTrue(ediTranfer)) {
// ajout d'un historique
transmissionToEdi = historyDao.create(History.PROPERTY_TYPE, HistoryType.TRANSMISSION_TO_EDI,
- History.PROPERTY_MODIFICATION_DATE, new Date());
+ History.PROPERTY_MODIFICATION_DATE, new Date(),
+ History.PROPERTY_EMAIL, email);
email.addHistory(transmissionToEdi);
// changement du status
@@ -517,7 +529,8 @@
} else {
// TODO echatellier : pas sur qu'il faille l'ajouter tout le temps, mais sinon, le transfer se reproduira
transmissionToEdi = historyDao.create(History.PROPERTY_TYPE, HistoryType.TRANSMISSION_TO_EDI,
- History.PROPERTY_MODIFICATION_DATE, new Date());
+ History.PROPERTY_MODIFICATION_DATE, new Date(),
+ History.PROPERTY_EMAIL, email);
email.addHistory(transmissionToEdi);
// passage en status
@@ -530,7 +543,8 @@
// TODO echatellier : pas sur qu'il faille l'ajouter tout le temps, mais sinon, le transfer se reproduira
transmissionToEdi = historyDao.create(History.PROPERTY_TYPE, HistoryType.TRANSMISSION_TO_EDI,
- History.PROPERTY_MODIFICATION_DATE, new Date());
+ History.PROPERTY_MODIFICATION_DATE, new Date(),
+ History.PROPERTY_EMAIL, email);
email.addHistory(transmissionToEdi);
// passage en status
@@ -814,8 +828,9 @@
HistoryTopiaDao historyDao = getPersistenceContext().getHistoryDao();
History history = historyDao.create(History.PROPERTY_TYPE, type,
History.PROPERTY_FAX_TO_MAIL_USER, user,
- History.PROPERTY_MODIFICATION_DATE, date);
- history.setFields(Sets.newHashSet(fields));
+ History.PROPERTY_MODIFICATION_DATE, date,
+ History.PROPERTY_EMAIL, email,
+ History.PROPERTY_FIELDS_JSON, AbstractFaxToMailTopiaDao.GSON_INSTANCE.toJson(fields));
email.addHistory(history);
@@ -847,13 +862,17 @@
HistoryTopiaDao historyDao = getPersistenceContext().getHistoryDao();
History history = historyDao.create(History.PROPERTY_TYPE, HistoryType.OPENING,
History.PROPERTY_FAX_TO_MAIL_USER, user,
- History.PROPERTY_MODIFICATION_DATE, new Date());
+ History.PROPERTY_MODIFICATION_DATE, new Date(),
+ History.PROPERTY_EMAIL, email);
email.addHistory(history);
if (takeEmail) {
+
+ String jsonFields = AbstractFaxToMailTopiaDao.GSON_INSTANCE.toJson(Sets.newHashSet(Email.PROPERTY_TAKEN_BY));
history = historyDao.create(History.PROPERTY_TYPE, HistoryType.MODIFICATION,
History.PROPERTY_FAX_TO_MAIL_USER, user,
- History.PROPERTY_MODIFICATION_DATE, new Date());
- history.setFields(Sets.newHashSet(Email.PROPERTY_TAKEN_BY));
+ History.PROPERTY_MODIFICATION_DATE, new Date(),
+ History.PROPERTY_EMAIL, email,
+ History.PROPERTY_FIELDS_JSON, jsonFields);
email.addHistory(history);
email.setTakenBy(user);
}
@@ -1072,18 +1091,21 @@
HistoryTopiaDao historyDao = getPersistenceContext().getHistoryDao();
Date now = new Date();
+ String jsonFields = AbstractFaxToMailTopiaDao.GSON_INSTANCE.toJson(Sets.newHashSet(email2.getObject()));
History history = historyDao.create(History.PROPERTY_TYPE, HistoryType.GROUP,
History.PROPERTY_FAX_TO_MAIL_USER, user,
- History.PROPERTY_MODIFICATION_DATE, now);
- history.setFields(Sets.newHashSet(email2.getObject()));
+ History.PROPERTY_MODIFICATION_DATE, now,
+ History.PROPERTY_EMAIL, email1,
+ History.PROPERTY_FIELDS_JSON, jsonFields);
email1.addHistory(history);
-
Email result = emailDao.update(email1);
+ jsonFields = AbstractFaxToMailTopiaDao.GSON_INSTANCE.toJson(Sets.newHashSet(email1.getObject()));
History history2 = historyDao.create(History.PROPERTY_TYPE, HistoryType.GROUP,
History.PROPERTY_FAX_TO_MAIL_USER, user,
- History.PROPERTY_MODIFICATION_DATE, now);
- history2.setFields(Sets.newHashSet(email1.getObject()));
+ History.PROPERTY_MODIFICATION_DATE, now,
+ History.PROPERTY_EMAIL, email2,
+ History.PROPERTY_FIELDS_JSON, jsonFields);
email2.addHistory(history2);
emailDao.update(email2);
@@ -1183,7 +1205,8 @@
HistoryTopiaDao historyDao = getPersistenceContext().getHistoryDao();
History history = historyDao.create(History.PROPERTY_TYPE, HistoryType.REPLY,
History.PROPERTY_FAX_TO_MAIL_USER, user,
- History.PROPERTY_MODIFICATION_DATE, now);
+ History.PROPERTY_MODIFICATION_DATE, now,
+ History.PROPERTY_EMAIL, email);
email.addHistory(history);
Client client = email.getClient();
@@ -1205,7 +1228,8 @@
History history = historyDao.create(History.PROPERTY_TYPE, HistoryType.TRANSMISSION,
History.PROPERTY_FAX_TO_MAIL_USER, currentUser,
- History.PROPERTY_MODIFICATION_DATE, new Date());
+ History.PROPERTY_MODIFICATION_DATE, new Date(),
+ History.PROPERTY_EMAIL, email);
email.addHistory(history);
}
@@ -1611,16 +1635,18 @@
Client client = getClientService().getClientForCode(archiveBean.getClientCode(), company);
email.setClient(client);
+ // persist it
+ email.setTopiaId(getTopiaId(Email.class, email));
+ statelessSession.insert(email);
+
History history = historyDao.newInstance();
history.setType(HistoryType.ARCHIVED);
history.setModificationDate(new Date());
+ history.setEmail(email);
history.setTopiaId(getTopiaId(History.class, history));
statelessSession.insert(history);
- email.addHistory(history);
- // persist it
- email.setTopiaId(getTopiaId(Email.class, email));
- statelessSession.insert(email);
+// email.addHistory(history);
// manage attachments
if (archiveBean.getAttachmentPaths() != null) {
@@ -1638,6 +1664,8 @@
}
Attachment attachment = attachmentDao.newInstance();
+ attachment.setEmail(email);
+
AttachmentFile attachmentFile = attachmentFileDao.newInstance();
attachmentFile.setFilename(attFile.getName());
@@ -1655,7 +1683,7 @@
attachment.setTopiaId(getTopiaId(Attachment.class, attachment));
statelessSession.insert(attachment);
- email.addAttachment(attachment);
+// email.addAttachment(attachment);
}
statelessSession.update(email);
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-11-17 07:21:06 UTC (rev 687)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-11-17 13:30:11 UTC (rev 688)
@@ -504,12 +504,12 @@
return editObject.getReference();
}
- public void setHistory(List<History> history) {
+ public void setHistory(Collection<History> history) {
editObject.setHistory(history);
firePropertyChanged(Email.PROPERTY_HISTORY, null, history);
}
- public List<History> getHistory() {
+ public Collection<History> getHistory() {
return editObject.getHistory();
}
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java 2014-11-17 07:21:06 UTC (rev 687)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java 2014-11-17 13:30:11 UTC (rev 688)
@@ -305,7 +305,9 @@
fileName = fileName.replaceFirst("^<(.*)>$", "$1");
}
fileName = MimeUtility.decodeText(fileName);
- log.info("FileName : " + fileName);
+ if (log.isDebugEnabled()) {
+ log.debug("FileName : " + fileName);
+ }
/*File dir = new File(FileUtils.getTempDirectory(), topiaId);
if (!dir.exists()) {
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java 2014-11-17 07:21:06 UTC (rev 687)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java 2014-11-17 13:30:11 UTC (rev 688)
@@ -311,11 +311,11 @@
break;
case ATTACHMENT:
- List<Attachment> attachments = email.getAttachment();
+ Collection<Attachment> attachments = email.getAttachment();
if (CollectionUtils.isNotEmpty(attachments)) {
final Decorator<Attachment> decorator = decoratorService.getDecoratorByType(Attachment.class);
- List<String> attachmentNames = Lists.transform(attachments, new Function<Attachment, String>() {
+ Collection<String> attachmentNames = Collections2.transform(attachments, new Function<Attachment, String>() {
@Override
public String apply(Attachment attachment) {
String name = decorator.toString(attachment);
1
0
17 Nov '14
Author: kmorin
Date: 2014-11-17 07:21:06 +0000 (Mon, 17 Nov 2014)
New Revision: 687
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/687
Log:
fixes #5944 Erreur ?\195?\160 l'ouverture d'un ?\195?\169l?\195?\169ment
fixes #6100 El?\195?\169ment du dossier Traitement/commandes/fse/ client P56789, si on veut visualiser la r?\195?\169ponse au mail, on plante syst?\195?\169matiquement.
fixes #6102 Erreur lors de l'alimentation de la priorit?\195?\169 depuis la liste lorsqu'un ?\195?\169l?\195?\169ment a au moins une r?\195?\169ponse
fixes #6110 Un historique de modification de PJ est ajout?\195?\169 m?\195?\170me si on ne sauvegarde pas l'email
Modified:
trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/HistoryType.java
trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_fr_FR.properties
trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/LoadFolderEmailsAction.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentCellEditor.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIHandler.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/replies/DemandRepliesUIHandler.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/RepliesCellEditor.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchToGroupUIHandler.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchUIHandler.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/DemandeTableModel.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java
trunk/pom.xml
Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/HistoryType.java
===================================================================
--- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/HistoryType.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/HistoryType.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -42,6 +42,7 @@
ARCHIVED(n("faxtomail.historyType.archive"), true),
GROUP(n("faxtomail.historyType.group"), true),
ATTACHMENT_OPENING(n("faxtomail.historyType.attachmentOpening"), false),
+ ATTACHMENT_ADDITION(n("faxtomail.historyType.attachmentAddition"), true),
ATTACHMENT_MODIFICATION(n("faxtomail.historyType.attachmentModification"), true);
protected String labelKey;
Modified: trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_fr_FR.properties
===================================================================
--- trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_fr_FR.properties 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_fr_FR.properties 2014-11-17 07:21:06 UTC (rev 687)
@@ -30,6 +30,7 @@
faxtomail.demandStatus.transmittedToEdi=Transmis à l'EDI
faxtomail.demandStatus.untreated=Non traité
faxtomail.historyType.archive=Archivage
+faxtomail.historyType.attachmentAddition=Ajout de pièce jointe
faxtomail.historyType.attachmentModification=Modification de pièce jointe
faxtomail.historyType.attachmentOpening=Ouverture de pièce jointe
faxtomail.historyType.creation=Création
Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties
===================================================================
--- trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties 2014-11-17 07:21:06 UTC (rev 687)
@@ -58,7 +58,7 @@
com.franciaflex.faxtomail.persistence.entities.EmailAccount.attribute.login.tagvalue.naturalId=true
-#�Configuration
+#�Configuration
com.franciaflex.faxtomail.persistence.entities.Configuration.attribute.searchDisplayColumns.tagvalue.hibernateAttributeType=com.franciaflex.faxtomail.persistence.hibernate.MailFieldEnumListUserType
com.franciaflex.faxtomail.persistence.entities.Configuration.attribute.invalidFormDisabledActions.tagvalue.hibernateAttributeType=com.franciaflex.faxtomail.persistence.hibernate.MailActionEnumSetUserType
@@ -87,7 +87,7 @@
# MailFilter
com.franciaflex.faxtomail.persistence.entities.MailFilter.attribute.expression.tagvalue.naturalId=true
com.franciaflex.faxtomail.persistence.entities.MailFilter.attribute.mailFolder.tagvalue.notNull=true
-#�TODO echatellier 20141003 : wrong property, fix it with stereotype=unique
+#�TODO echatellier 20141003 : wrong property, fix it with stereotype=unique
com.franciaflex.faxtomail.persistence.entities.MailFilter.attribute.position.tagvalue.unique=true
# Email
@@ -101,7 +101,6 @@
com.franciaflex.faxtomail.persistence.entities.Reply.attribute.recipient.tagvalue.notNull=true
com.franciaflex.faxtomail.persistence.entities.Reply.attribute.sentBy.tagvalue.notNull=true
com.franciaflex.faxtomail.persistence.entities.Reply.attribute.replyContent.tagvalue.notNull=true
-com.franciaflex.faxtomail.persistence.entities.Reply.attribute.replyContent.tagvalue.notNull=true
# ReplyContent
com.franciaflex.faxtomail.persistence.entities.ReplyContent.attribute.source.tagvalue.notNull=true
@@ -128,5 +127,5 @@
# MailLock
com.franciaflex.faxtomail.persistence.entities.MailLock.attribute.lockBy.tagvalue.notNull=true
com.franciaflex.faxtomail.persistence.entities.MailLock.attribute.lockOn.tagvalue.notNull=true
-#�TODO echatellier 20141003 : wrong property, fix it with stereotype=unique
+#�TODO echatellier 20141003 : wrong property, fix it with stereotype=unique
com.franciaflex.faxtomail.persistence.entities.MailLock.attribute.lockOn.tagvalue.unique=true
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -43,6 +43,7 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -62,26 +63,26 @@
import javax.activation.FileDataSource;
import javax.mail.MessagingException;
+import com.franciaflex.faxtomail.persistence.entities.Email;
import com.franciaflex.faxtomail.services.service.imports.ArchiveImportExportBean;
import com.franciaflex.faxtomail.services.service.imports.ArchiveImportExportModel;
import com.franciaflex.faxtomail.services.service.imports.ArchiveImportResult;
import com.franciaflex.faxtomail.services.service.imports.InvalidArchiveImportBeanException;
import com.google.common.base.Optional;
+import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.ArrayUtils;
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;
import org.apache.commons.logging.LogFactory;
-import org.apache.commons.mail.DefaultAuthenticator;
-import org.apache.commons.mail.EmailConstants;
-import org.apache.commons.mail.EmailException;
-import org.apache.commons.mail.MultiPartEmail;
+import org.apache.commons.mail.*;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.StatelessSession;
@@ -237,7 +238,7 @@
@Override
public Email saveEmail(Email email, FaxToMailUser user, String... modifiedFields) throws InvalidClientException {
Client client = email.getClient();
- return saveEmail(email, null, null, client != null ? client.getCode() : null, user, modifiedFields);
+ return saveEmail(email, null, email.getReplies(), client != null ? client.getCode() : null, user, modifiedFields);
}
@Override
@@ -271,8 +272,9 @@
email.setClient(client);
if (attachments != null) {
- updateAttachments(email, attachments);
+ updateAttachments(email, attachments, user);
}
+
if (replies != null) {
updateReplies(email);
}
@@ -316,6 +318,15 @@
handleEdiTransmission(email, historyDao, fieldSet);
}
+ if (email.getHistory() != null) {
+ historyDao.createAll(Collections2.filter(email.getHistory(), new com.google.common.base.Predicate<History>() {
+ @Override
+ public boolean apply(History history) {
+ return !history.isPersisted();
+ }
+ }));
+ }
+
History history = null;
if (fieldSet.contains(Email.PROPERTY_ARCHIVE_DATE)) {
history = historyDao.create(History.PROPERTY_TYPE, HistoryType.ARCHIVED,
@@ -377,9 +388,11 @@
*
* @param email
* @param attachments
+ * @param user
*/
- protected void updateAttachments(Email email, Collection<Attachment> attachments) {
+ protected void updateAttachments(Email email, Collection<Attachment> attachments, FaxToMailUser user) {
AttachmentTopiaDao attachmentTopiaDao = getPersistenceContext().getAttachmentDao();
+ HistoryTopiaDao historyTopiaDao = getPersistenceContext().getHistoryDao();
List<Attachment> currentAttachments = attachmentTopiaDao.forTopiaIdIn(email.getAttachmentTopiaIds()).findAll();
if (currentAttachments == null) {
@@ -387,6 +400,8 @@
}
Map<String, Attachment> currentAttachmentIndex = new HashMap<>(Maps.uniqueIndex(currentAttachments, TopiaEntities.getTopiaIdFunction()));
+ Set<String> newFiles = new HashSet<>();
+
AttachmentFileTopiaDao attachementFileTopiaDao = getPersistenceContext().getAttachmentFileDao();
for (Attachment attachment : attachments) {
@@ -433,6 +448,8 @@
if (!originalFile.isPersisted()) {
attachementFileTopiaDao.create(originalFile);
+ newFiles.add(originalFile.getFilename());
+
} else {
attachementFileTopiaDao.update(originalFile);
}
@@ -440,6 +457,7 @@
if (editedFile != null) {
if (!editedFile.isPersisted()) {
attachementFileTopiaDao.create(editedFile);
+
} else {
attachementFileTopiaDao.update(editedFile);
}
@@ -451,6 +469,14 @@
}
}
+ if (!newFiles.isEmpty()) {
+ History history = historyTopiaDao.create(History.PROPERTY_TYPE, HistoryType.ATTACHMENT_ADDITION,
+ History.PROPERTY_FAX_TO_MAIL_USER, user,
+ History.PROPERTY_MODIFICATION_DATE, new Date());
+ history.setFields(newFiles);
+ email.addHistory(history);
+ }
+
// delete not found attachments
for (Attachment attachment : currentAttachmentIndex.values()) {
currentAttachments.remove(attachment);
@@ -1160,7 +1186,8 @@
History.PROPERTY_MODIFICATION_DATE, now);
email.addHistory(history);
- email = saveEmail(email, user);
+ Client client = email.getClient();
+ email = saveEmail(email, null, null, client != null ? client.getCode() : null, user);
return email;
}
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -245,7 +245,7 @@
FaxToMailServiceContext serviceContext = getContext().newServiceContext();
AttachmentFile attachmentFileNew = serviceContext.getEmailService().getAttachmentFileFromStream(is);
attachmentFileNew.setRotation(rotation);
- String fileName = model.getNotNullFile().getFilename();
+ String fileName = model.getOriginalFile().getFilename();
attachmentFileNew.setFilename(FaxToMailUIUtil.getEditedFileName(fileName));
model.setEditedFile(attachmentFileNew);
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/LoadFolderEmailsAction.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/LoadFolderEmailsAction.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/LoadFolderEmailsAction.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -34,6 +34,7 @@
import com.franciaflex.faxtomail.persistence.entities.WaitingState;
import com.franciaflex.faxtomail.persistence.entities.MailField;
+import com.franciaflex.faxtomail.ui.swing.util.DemandeTableModel;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import jaxx.runtime.JAXXUtil;
@@ -42,7 +43,6 @@
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import org.nuiton.decorator.Decorator;
-import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel;
import org.nuiton.topia.persistence.TopiaEntities;
import org.nuiton.util.pagination.PaginationResult;
@@ -169,8 +169,7 @@
if (currentEmail != null) {
JXTable dataTable = getUI().getDataTable();
- AbstractApplicationTableModel<DemandeUIModel> dataTableModel =
- (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel();
+ DemandeTableModel dataTableModel = (DemandeTableModel) dataTable.getModel();
int row = dataTableModel.getRowIndex(currentEmail);
if (row > 0) {
dataTable.setRowSelectionInterval(row, row);
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentCellEditor.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentCellEditor.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentCellEditor.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -31,13 +31,13 @@
import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext;
import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel;
import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailBeanUIModel;
+import com.franciaflex.faxtomail.ui.swing.util.DemandeTableModel;
import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUI;
import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil;
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel;
import javax.swing.*;
import javax.swing.border.LineBorder;
@@ -96,8 +96,7 @@
boolean isSelected,
int row,
int column) {
- AbstractApplicationTableModel<AbstractFaxToMailBeanUIModel> tableModel =
- (AbstractApplicationTableModel<AbstractFaxToMailBeanUIModel>) table.getModel();
+ DemandeTableModel tableModel = (DemandeTableModel) table.getModel();
int modelRow = table.convertRowIndexToModel(row);
final DemandeUIModel model = (DemandeUIModel) tableModel.getEntry(modelRow);
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIHandler.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIHandler.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIHandler.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -56,6 +56,7 @@
import com.franciaflex.faxtomail.services.service.EmailService;
import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext;
import com.franciaflex.faxtomail.ui.swing.actions.OpenMailFolderChooserFromListAction;
+import com.franciaflex.faxtomail.ui.swing.util.DemandeTableModel;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.swing.table.filter.TableFilter;
import jaxx.runtime.swing.table.filter.TableRowFilterSupport;
@@ -70,8 +71,6 @@
import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.nuiton.decorator.Decorator;
import org.nuiton.jaxx.application.swing.action.ApplicationUIAction;
-import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel;
-import org.nuiton.jaxx.application.swing.table.ColumnIdentifier;
import org.nuiton.jaxx.application.swing.util.CloseableUI;
import com.franciaflex.faxtomail.persistence.entities.Attachment;
@@ -183,7 +182,7 @@
model.setSelectedEmails(null);
} else {
List<DemandeUIModel> selectedRows = new ArrayList<DemandeUIModel>();
- AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel();
+ DemandeTableModel dataTableModel = (DemandeTableModel) dataTable.getModel();
for (int i = source.getMinSelectionIndex(); i <= source.getMaxSelectionIndex(); i++) {
if (source.isSelectedIndex(i)) {
selectedRows.add(dataTableModel.getEntry(i));
@@ -198,7 +197,7 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
List<DemandeUIModel> emails = (List<DemandeUIModel>) evt.getNewValue();
- AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel();
+ DemandeTableModel dataTableModel = (DemandeTableModel) dataTable.getModel();
dataTableModel.setRows(emails);
int quotationNb = 0;
@@ -382,7 +381,7 @@
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
int viewRow = adapter.row;
int modelRow = adapter.convertRowIndexToModel(viewRow);
- DemandeUIModel row = ((AbstractApplicationTableModel<DemandeUIModel>) table.getModel()).getEntry(modelRow);
+ DemandeUIModel row = ((DemandeTableModel) table.getModel()).getEntry(modelRow);
MailFolder folder = getModel().getSelectedFolder();
while (folder.getOpenAttachmentReportNoTaken() == null
&& folder.getParent() != null) {
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-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -47,6 +47,9 @@
import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableCellEditor;
+import com.franciaflex.faxtomail.persistence.entities.History;
+import com.franciaflex.faxtomail.persistence.entities.HistoryImpl;
+import com.google.common.collect.Sets;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections4.CollectionUtils;
@@ -375,13 +378,21 @@
public void onAttachmentEdited(Attachment attachment) {
String topiaId = getModel().getTopiaId();
if (topiaId != null && attachment.isPersisted()) {
- FaxToMailServiceContext serviceContext = getContext().newServiceContext();
- Email email = serviceContext.getEmailService().addToHistory(topiaId,
- HistoryType.ATTACHMENT_MODIFICATION,
- getContext().getCurrentUser(),
- new Date(),
- FaxToMailUIUtil.getEditedFileName(attachment.getOriginalFileName()));
- getModel().setHistory(email.getHistory());
+ //TODO create a history manually and add it to the email, but do not save it
+// FaxToMailServiceContext serviceContext = getContext().newServiceContext();
+// Email email = serviceContext.getEmailService().addToHistory(topiaId,
+// HistoryType.ATTACHMENT_MODIFICATION,
+// getContext().getCurrentUser(),
+// new Date(),
+// FaxToMailUIUtil.getEditedFileName(attachment.getOriginalFileName()));
+// getModel().setHistory(email.getHistory());
+
+ History history = new HistoryImpl();
+ history.setType(HistoryType.ATTACHMENT_MODIFICATION);
+ history.setFaxToMailUser(getContext().getCurrentUser());
+ history.setModificationDate(new Date());
+ history.setFields(Sets.newHashSet(attachment.getOriginalFileName()));
+ getModel().getHistory().add(history);
}
getModel().setModify(true);
}
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-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -42,7 +42,10 @@
import javax.mail.Part;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
+import javax.mail.internet.MimeUtility;
+import com.google.common.collect.Lists;
+import com.sun.mail.util.MimeUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@@ -871,7 +874,7 @@
try {
// ce code peut provoquer une NPE avec les données de test
Message message = new MimeMessage(null, new ByteArrayInputStream(getOriginalEmail().getBytes(StandardCharsets.UTF_8)));
- subject = message.getSubject();
+ subject = MimeUtility.decodeText(message.getSubject());
toRecipients = new ArrayList<String>();
ccRecipients = new ArrayList<String>();
@@ -897,10 +900,12 @@
}
} catch (Exception e) {
- //TODO kmorin 20140516 do something when we use the real data
- if (log.isErrorEnabled()) {
- log.error("", e);
+ if (log.isWarnEnabled()) {
+ log.warn("error while parsing the original email content, may come from the imported archives", e);
}
+ //may comes from the imported archives
+ plainContent = getOriginalEmail();
+ toRecipients = Lists.newArrayList(getRecipient());
}
}
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -41,6 +41,7 @@
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;
import javax.mail.internet.MimeMultipart;
+import javax.mail.internet.MimeUtility;
import javax.swing.AbstractCellEditor;
import javax.swing.JComponent;
import javax.swing.JTable;
@@ -303,7 +304,8 @@
// remove the guillemets between the id
fileName = fileName.replaceFirst("^<(.*)>$", "$1");
}
- log.debug("FileName : " + fileName);
+ fileName = MimeUtility.decodeText(fileName);
+ log.info("FileName : " + fileName);
/*File dir = new File(FileUtils.getTempDirectory(), topiaId);
if (!dir.exists()) {
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/RepliesCellEditor.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/RepliesCellEditor.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/RepliesCellEditor.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -27,11 +27,11 @@
import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext;
import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel;
import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailBeanUIModel;
+import com.franciaflex.faxtomail.ui.swing.util.DemandeTableModel;
import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUI;
import com.google.common.base.Preconditions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel;
import javax.swing.*;
import javax.swing.border.LineBorder;
@@ -86,8 +86,7 @@
boolean isSelected,
int row,
int column) {
- AbstractApplicationTableModel<AbstractFaxToMailBeanUIModel> tableModel =
- (AbstractApplicationTableModel<AbstractFaxToMailBeanUIModel>) table.getModel();
+ DemandeTableModel tableModel = (DemandeTableModel) table.getModel();
int modelRow = table.convertRowIndexToModel(row);
final DemandeUIModel model = (DemandeUIModel) tableModel.getEntry(modelRow);
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchToGroupUIHandler.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchToGroupUIHandler.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchToGroupUIHandler.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -51,6 +51,7 @@
import com.franciaflex.faxtomail.persistence.entities.HasLabel;
import com.franciaflex.faxtomail.persistence.entities.SearchFilter;
import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext;
+import com.franciaflex.faxtomail.ui.swing.util.DemandeTableModel;
import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
import jaxx.runtime.validator.swing.SwingValidator;
@@ -61,7 +62,6 @@
import org.jdesktop.swingx.decorator.ColorHighlighter;
import org.jdesktop.swingx.decorator.ComponentAdapter;
import org.jdesktop.swingx.decorator.HighlightPredicate;
-import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel;
import org.nuiton.jaxx.application.swing.util.Cancelable;
import com.franciaflex.faxtomail.persistence.entities.DemandStatus;
@@ -177,7 +177,7 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
List<DemandeUIModel> emails = (List<DemandeUIModel>) evt.getNewValue();
- AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel();
+ DemandeTableModel dataTableModel = (DemandeTableModel) dataTable.getModel();
dataTableModel.setRows(emails);
DemandeUIModel currentEmail = getContext().getCurrentEmail();
@@ -197,7 +197,7 @@
ListSelectionModel selectionModel = (ListSelectionModel) e.getSource();
SearchUIModel model = getModel();
int selectedIndex = selectionModel.getLeadSelectionIndex();
- AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel();
+ DemandeTableModel dataTableModel = (DemandeTableModel) dataTable.getModel();
DemandeUIModel selectedModel = selectedIndex < 0 ? null : dataTableModel.getEntry(selectedIndex);
model.setGroupEnabled(!selectionModel.isSelectionEmpty() && isDemandSelectable(selectedModel));
}
@@ -209,7 +209,7 @@
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
int viewRow = adapter.row;
int modelRow = adapter.convertRowIndexToModel(viewRow);
- AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel();
+ DemandeTableModel dataTableModel = (DemandeTableModel) dataTable.getModel();
DemandeUIModel row = dataTableModel.getEntry(modelRow);
return !isDemandSelectable(row);
}
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchUIHandler.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchUIHandler.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchUIHandler.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -50,7 +50,6 @@
import org.jdesktop.swingx.JXDatePicker;
import org.jdesktop.swingx.JXTable;
import org.nuiton.jaxx.application.swing.action.ApplicationActionEngine;
-import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel;
import org.nuiton.jaxx.application.swing.util.CloseableUI;
import com.franciaflex.faxtomail.persistence.entities.DemandStatus;
@@ -165,7 +164,7 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
List<DemandeUIModel> emails = (List<DemandeUIModel>) evt.getNewValue();
- AbstractApplicationTableModel<DemandeUIModel> dataTableModel = (AbstractApplicationTableModel<DemandeUIModel>) dataTable.getModel();
+ DemandeTableModel dataTableModel = (DemandeTableModel) dataTable.getModel();
dataTableModel.setRows(emails);
DemandeUIModel currentEmail = getContext().getCurrentEmail();
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -42,6 +42,7 @@
import javax.swing.event.ChangeListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableModel;
import com.franciaflex.faxtomail.persistence.entities.Email;
import com.franciaflex.faxtomail.persistence.entities.EmailGroup;
@@ -57,7 +58,6 @@
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.jdesktop.swingx.table.TableColumnModelExt;
import org.nuiton.decorator.Decorator;
-import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel;
import org.nuiton.validator.NuitonValidator;
import org.nuiton.validator.NuitonValidatorFactory;
import org.nuiton.validator.NuitonValidatorResult;
@@ -101,7 +101,7 @@
public Component highlight(Component renderer, ComponentAdapter adapter) {
int viewRow = adapter.row;
int modelRow = adapter.convertRowIndexToModel(viewRow);
- DemandeUIModel row = ((AbstractApplicationTableModel<DemandeUIModel>) table.getModel()).getEntry(modelRow);
+ DemandeUIModel row = ((DemandeTableModel) table.getModel()).getEntry(modelRow);
boolean highlight = row.getTakenBy() == null;
if (highlight) {
Font font = renderer.getFont();
@@ -136,7 +136,7 @@
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
int viewRow = adapter.row;
int modelRow = adapter.convertRowIndexToModel(viewRow);
- DemandeUIModel row = ((AbstractApplicationTableModel<DemandeUIModel>) table.getModel()).getEntry(modelRow);
+ DemandeUIModel row = ((DemandeTableModel) table.getModel()).getEntry(modelRow);
return !row.isValid() && row.getTakenBy() != null;
}
};
@@ -237,8 +237,7 @@
}
}
- final AbstractApplicationTableModel<DemandeUIModel> tableModel = new DemandeTableModel(columnModel,
- getEditableTableProperties());
+ TableModel tableModel = new DemandeTableModel(columnModel, getEditableTableProperties());
table.setModel(tableModel);
table.setColumnModel(columnModel);
@@ -256,8 +255,7 @@
}
rowIndex = table.convertRowIndexToModel(rowIndex);
- AbstractApplicationTableModel<DemandeUIModel> tableModel =
- (AbstractApplicationTableModel<DemandeUIModel>) table.getModel();
+ DemandeTableModel tableModel = (DemandeTableModel) table.getModel();
DemandeUIModel selectedEmail = tableModel.getEntry(rowIndex);
onDoubleClickOnDemande(selectedEmail);
@@ -321,7 +319,7 @@
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column);
- AbstractApplicationTableModel<DemandeUIModel> tableModel = (AbstractApplicationTableModel<DemandeUIModel>) table.getModel();
+ DemandeTableModel tableModel = (DemandeTableModel) table.getModel();
int rowInModel = table.convertRowIndexToModel(row);
DemandeUIModel demande = tableModel.getEntry(rowInModel);
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/DemandeTableModel.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/DemandeTableModel.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/DemandeTableModel.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -25,14 +25,27 @@
import com.franciaflex.faxtomail.persistence.entities.Email;
import com.franciaflex.faxtomail.persistence.entities.MailField;
import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.table.TableColumnModelExt;
-import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel;
import org.nuiton.jaxx.application.swing.table.ColumnIdentifier;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableColumn;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import static org.nuiton.i18n.I18n.n;
@@ -40,8 +53,12 @@
* @author kmorin - kmorin(a)codelutin.com
*
*/
-public class DemandeTableModel extends AbstractApplicationTableModel<DemandeUIModel> {
+public class DemandeTableModel extends AbstractTableModel {
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(DemandeTableModel.class);
+
public static final Map<MailField, ColumnIdentifier<Email>> COLUMN_IDENTIFIERS = new HashMap<MailField, ColumnIdentifier<Email>>() {{
put(MailField.SENDER,
ColumnIdentifier.<Email>newReadOnlyId(
@@ -184,7 +201,12 @@
}};
public DemandeTableModel(TableColumnModelExt columnModel, MailField... editableProperties) {
- super(columnModel, false, false);
+
+ this.identifiers = Lists.newArrayListWithCapacity(columnModel.getColumnCount());
+ for (TableColumn tc : columnModel.getColumns(true)) {
+ this.identifiers.add((ColumnIdentifier<DemandeUIModel>) tc.getIdentifier());
+ }
+
List<ColumnIdentifier> nonEditableColumns = new ArrayList<ColumnIdentifier>(COLUMN_IDENTIFIERS.values());
for (MailField editableProperty : editableProperties) {
nonEditableColumns.remove(COLUMN_IDENTIFIERS.get(editableProperty));
@@ -192,8 +214,282 @@
setNoneEditableCols(nonEditableColumns.toArray(new ColumnIdentifier[nonEditableColumns.size()]));
}
- @Override
public DemandeUIModel createNewRow() {
return new DemandeUIModel();
}
+
+ /**
+ * Data in the model.
+ *
+ * @since 0.2
+ */
+ protected List<DemandeUIModel> rows;
+
+ /**
+ * Set of non editable columns.
+ *
+ * @since 0.2
+ */
+ protected Set<ColumnIdentifier<?>> noneEditableCols;
+
+ /**
+ * Identifiers of columns (in initial order).
+ *
+ * @since 1.1
+ */
+ protected final List<ColumnIdentifier<DemandeUIModel>> identifiers;
+
+ public final List<DemandeUIModel> getRows() {
+ return rows;
+ }
+
+ public final void setRows(List<DemandeUIModel> data) {
+
+ // can't accept a empty data list
+ Preconditions.checkNotNull(data, "Data list can not be null.");
+
+ this.rows = null;
+ if (log.isDebugEnabled()) {
+ log.debug("Set " + data.size() + " row(s) in table model " + this);
+ }
+ this.rows = data;
+ onRowsChanged(data);
+ fireTableDataChanged();
+ }
+
+ public final void addNewRow() {
+ DemandeUIModel newValue = createNewRow();
+ addNewRow(newValue);
+ }
+
+ public final void addNewRow(DemandeUIModel newValue) {
+
+ addNewRow(getRowCount(), newValue);
+ }
+
+ public final void addNewRow(int rowIndex, DemandeUIModel newValue) {
+
+ Preconditions.checkNotNull(newValue, "Row can not be null.");
+
+ List<DemandeUIModel> data = getRows();
+ Preconditions.checkNotNull(data, "Data list can not be null.");
+
+ data.add(rowIndex, newValue);
+
+ onRowAdded(rowIndex, newValue);
+ fireTableRowsInserted(rowIndex, rowIndex);
+ }
+
+ public final void fireTableRowsInserted(DemandeUIModel newValue) {
+
+ Preconditions.checkNotNull(newValue, "Row can not be null.");
+
+ int rowIndex = getRowIndex(newValue);
+ fireTableRowsInserted(rowIndex, rowIndex);
+ }
+
+ public final int updateRow(DemandeUIModel row) {
+ Preconditions.checkNotNull(row, "Row can not be null.");
+
+ List<DemandeUIModel> data = getRows();
+ Preconditions.checkNotNull(data, "Data list can not be null.");
+
+ int rowIndex = data.indexOf(row);
+
+ fireTableRowsUpdated(rowIndex, rowIndex);
+ return rowIndex;
+ }
+
+ public final DemandeUIModel removeRow(int rowIndex) {
+ SwingUtil.ensureRowIndex(this, rowIndex);
+
+ List<DemandeUIModel> data = getRows();
+
+ DemandeUIModel result = data.remove(rowIndex);
+
+ fireTableRowsDeleted(rowIndex, rowIndex);
+ return result;
+ }
+
+ protected void onRowsChanged(List<DemandeUIModel> data) {
+ // by default do nothing
+ }
+
+ protected void onRowAdded(int rowIndex, DemandeUIModel newValue) {
+ // by default do nothing
+ }
+
+ public final int getRowIndex(DemandeUIModel row) {
+ int result = rows == null ? -1 : rows.indexOf(row);
+ return result;
+ }
+
+ public final DemandeUIModel getEntry(int rowIndex) {
+ SwingUtil.ensureRowIndex(this, rowIndex);
+ int rowCount = getRowCount();
+ if (rowIndex > rowCount) {
+ log.error("Error getting entry " + rowIndex + " int table model with " + rowCount + " items");
+ return null;
+ }
+ List<DemandeUIModel> data = getRows();
+ DemandeUIModel result = data == null ? null : data.get(rowIndex);
+ return result;
+ }
+
+ public final void setNoneEditableCols(ColumnIdentifier<?>... noneEditableCols) {
+ this.noneEditableCols = Sets.newHashSet(noneEditableCols);
+ }
+
+ @Override
+ public final int getRowCount() {
+ return rows == null ? 0 : rows.size();
+ }
+
+ @Override
+ public final int getColumnCount() {
+ return identifiers.size();
+ }
+
+ @Override
+ public final Object getValueAt(int rowIndex, int columnIndex) {
+ DemandeUIModel entry = getEntry(rowIndex);
+ ColumnIdentifier<DemandeUIModel> identifier = getIdentifier(columnIndex);
+ if (log.isDebugEnabled()) {
+ log.debug("columnIndex: " + columnIndex + " :: " + identifier.getPropertyName());
+ }
+ Object result = identifier.getValue(entry);
+ return result;
+ }
+
+ @Override
+ public final void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+ if (log.isDebugEnabled()) {
+ log.debug("setValueAt " + aValue);
+ }
+ DemandeUIModel entry = getEntry(rowIndex);
+ ColumnIdentifier<DemandeUIModel> identifier = getIdentifier(columnIndex);
+ setValueAt(aValue, rowIndex, columnIndex, identifier, entry);
+ }
+
+ @Override
+ public final boolean isCellEditable(int rowIndex, int columnIndex) {
+ ColumnIdentifier<DemandeUIModel> identifier = getIdentifier(columnIndex);
+ boolean result = isCellEditable(rowIndex, columnIndex, identifier);
+ return result;
+ }
+
+ protected void setValueAt(Object aValue,
+ int rowIndex,
+ int columnIndex,
+ ColumnIdentifier<DemandeUIModel> propertyName,
+ DemandeUIModel entry) {
+ if (log.isDebugEnabled()) {
+ log.debug("setValueAt " + aValue);
+ }
+ propertyName.setValue(entry, aValue);
+ }
+
+ protected boolean isCellEditable(int rowIndex,
+ int columnIndex,
+ ColumnIdentifier<DemandeUIModel> propertyName) {
+ boolean result = !noneEditableCols.contains(propertyName);
+ return result;
+ }
+
+ public final void fireTableCellUpdated(int rowIndex,
+ ColumnIdentifier<DemandeUIModel>... identifiers) {
+ for (ColumnIdentifier<DemandeUIModel> identifier : identifiers) {
+ int columnIndex = this.identifiers.indexOf(identifier);
+ fireTableCellUpdated(rowIndex, columnIndex);
+ }
+ }
+
+ public final void fireTableRowUpdatedShell(Set<DemandeUIModel> shell) {
+
+ int minRowIndex1 = getColumnCount();
+ int maxRowIndex1 = 0;
+
+ for (DemandeUIModel r : shell) {
+ int rowIndex1 = getRowIndex(r);
+ minRowIndex1 = Math.min(minRowIndex1, rowIndex1);
+ maxRowIndex1 = Math.max(maxRowIndex1, rowIndex1);
+ }
+ fireTableRowsUpdated(minRowIndex1, maxRowIndex1);
+ }
+
+ protected void collectShell(DemandeUIModel row, Set<DemandeUIModel> collectedRows) {
+
+ // by default just add the incoming row
+ collectedRows.add(row);
+ }
+
+ @Override
+ public String getColumnName(int columnIndex) {
+ return getIdentifier(columnIndex).getPropertyName();
+ }
+
+ protected ColumnIdentifier<DemandeUIModel> getIdentifier(int columnIndex) {
+ ColumnIdentifier<DemandeUIModel> identifier = identifiers.get(columnIndex);
+ return identifier;
+ }
+
+ public int getColumnIndex(final String propertyName) {
+ return Iterables.indexOf(identifiers, new Predicate<ColumnIdentifier<DemandeUIModel>>() {
+ @Override
+ public boolean apply(ColumnIdentifier<DemandeUIModel> input) {
+ return ObjectUtils.equals(propertyName, input.getPropertyName());
+ }
+ });
+ }
+
+ public Pair<Integer, Integer> getCell(DemandeUIModel row, final String propertyName) {
+
+ int rowIndex = getRowIndex(row);
+ int columnIndex = getColumnIndex(propertyName);
+
+ Pair<Integer, Integer> cell = Pair.of(rowIndex, columnIndex);
+
+ return cell;
+ }
+
+ public void moveUp(DemandeUIModel row) {
+
+ int rowIndex = getRowIndex(row);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will move up row of index: " + rowIndex);
+ }
+ rows.remove(rowIndex);
+ rows.add(rowIndex - 1, row);
+ fireTableRowsUpdated(rowIndex - 1, rowIndex);
+
+ }
+
+ public void moveDown(DemandeUIModel row) {
+
+ int rowIndex = getRowIndex(row);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will move down row of index: " + rowIndex);
+ }
+ rows.remove(rowIndex);
+ rows.add(rowIndex + 1, row);
+ fireTableRowsUpdated(rowIndex, rowIndex + 1);
+
+ }
+
+ public boolean isFirstRow(DemandeUIModel row) {
+
+ int rowIndex = getRowIndex(row);
+ return rowIndex == 0;
+
+ }
+
+ public boolean isLastRow(DemandeUIModel row) {
+
+ int rowIndex = getRowIndex(row);
+ return rowIndex == getRowCount() - 1;
+
+ }
+
}
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-11-17 07:21:06 UTC (rev 687)
@@ -633,7 +633,7 @@
public static String getEditedFileName(String originalFileName) {
- return t("faxtomail.attachment.editedFile.name", originalFileName) + "-.pdf";
+ return t("faxtomail.attachment.editedFile.name", originalFileName) + ".pdf";
}
/**
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-11-07 15:58:09 UTC (rev 686)
+++ trunk/pom.xml 2014-11-17 07:21:06 UTC (rev 687)
@@ -111,7 +111,7 @@
<h2Version>1.3.176</h2Version>
<guavaVersion>18.0</guavaVersion>
- <jaxxVersion>2.14</jaxxVersion>
+ <jaxxVersion>2.17-SNAPSHOT</jaxxVersion>
<!-- do not upgrade to 1.6.5-1 -->
<swingXVersion>1.6.4</swingXVersion>
<xworkVersion>2.3.16.3</xworkVersion>
1
0
r686 - in trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing: content/attachment util
by kmorin@users.forge.codelutin.com 07 Nov '14
by kmorin@users.forge.codelutin.com 07 Nov '14
07 Nov '14
Author: kmorin
Date: 2014-11-07 15:58:09 +0000 (Fri, 07 Nov 2014)
New Revision: 686
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/686
Log:
- agrandissement des polices des emails html
- s?\195?\169lection de fichier seulement pour les pj
Modified:
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUI.css
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUI.css
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUI.css 2014-11-07 09:05:56 UTC (rev 685)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUI.css 2014-11-07 15:58:09 UTC (rev 686)
@@ -50,6 +50,11 @@
labelFor: { file };
}
+#file {
+ directoryEnabled: false;
+ fileEnabled: true;
+}
+
#addButton {
actionIcon: add;
toolTipText: "faxtomail.attachmentEditor.action.add.tip";
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-11-07 09:05:56 UTC (rev 685)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-11-07 15:58:09 UTC (rev 686)
@@ -56,11 +56,11 @@
import java.util.regex.Pattern;
import javax.media.jai.PlanarImage;
-import javax.swing.Icon;
-import javax.swing.JTextPane;
-import javax.swing.JTree;
+import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
@@ -326,9 +326,13 @@
String content = demandeUIModel.getHtmlContent();
if (content != null) {
textPane.setContentType("text/html");
-
HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
textPane.setEditorKit(htmlEditorKit);
+
+ textPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
+ Font font = new Font(Font.MONOSPACED, Font.PLAIN, 16);
+ textPane.setFont(font);
+
textPane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
1
0
Author: kmorin
Date: 2014-11-07 09:05:56 +0000 (Fri, 07 Nov 2014)
New Revision: 685
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/685
Log:
upgrade log4j version
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-10-31 15:14:53 UTC (rev 684)
+++ trunk/pom.xml 2014-11-07 09:05:56 UTC (rev 685)
@@ -119,7 +119,7 @@
<jqueryPluginVersion>3.7.1</jqueryPluginVersion>
<bootstrapPluginVersion>2.0.0</bootstrapPluginVersion>
<slf4jVersion>1.7.7</slf4jVersion>
- <log4jVersion>2.0.2</log4jVersion>
+ <log4jVersion>2.1</log4jVersion>
<postgresqlDriverVersion>9.3-1102-jdbc41</postgresqlDriverVersion>
<commonsEmailVersion>1.3.3</commonsEmailVersion>
1
0