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
- 1934 discussions
r314 - in trunk/faxtomail-ui-web/src/main/webapp: WEB-INF/content/admin js
by echatellier@users.forge.codelutin.com 02 Jul '14
by echatellier@users.forge.codelutin.com 02 Jul '14
02 Jul '14
Author: echatellier
Date: 2014-07-02 15:51:52 +0200 (Wed, 02 Jul 2014)
New Revision: 314
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/314
Log:
Ajout de check sur les doublons
Modified:
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp
trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-07-02 13:26:03 UTC (rev 313)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-07-02 13:51:52 UTC (rev 314)
@@ -462,7 +462,7 @@
<div class="form-group">
<label for="newCustomerResponsibleField" class="control-label">Nouveau :</label>
<select id="newCustomerResponsibleField" class="form-control" ng-model="newCustomerResponsible"
- ng-options="user as user.firstName + ' ' + user.lastName for user in users"></select>
+ ng-options="user as user.firstName + ' ' + user.lastName for user in users|filter:filterByAlreadyInCollection(selectedMailFolder.customerResponsibles)"></select>
</div>
<a class="btn btn-success btn-xs" ng-click="addCustomerResponsible()" ng-disabled="!newCustomerResponsible">
<span class="glyphicon glyphicon-plus"></span>
@@ -499,7 +499,7 @@
</td>
</tr>
- <tr ng-repeat="replyAddress in selectedMailFolder.replyAddresses track by $index">
+ <tr ng-repeat="replyAddress in selectedMailFolder.replyAddresses">
<td>
<span class="glyphicon glyphicon-user"></span>
{{replyAddress}}</td>
@@ -545,7 +545,7 @@
</td>
</tr>
- <tr ng-repeat="replyDomain in selectedMailFolder.replyDomains track by $index">
+ <tr ng-repeat="replyDomain in selectedMailFolder.replyDomains">
<td>
<span class="glyphicon glyphicon-globe"></span>
{{replyDomain}}</td>
@@ -592,19 +592,23 @@
ng-value="false" ng-change="initFolderEtatAttente()" />
Hériter des états d'attente déclarés sur les dossiers parent :
</label>
- <label class="checkbox" ng-repeat="etatAttente in etatAttentes" ng-if="selectedMailFolder.$parent && !selectedMailFolder.useCurrentLevelEtatAttente">
- <input type="checkbox" ng-checked="parentScopeValues.etatAttentes.containsByTopiaId(etatAttente)"
- disabled> {{etatAttente.label}}
- </label>
+ <div class="checkbox" ng-repeat="etatAttente in etatAttentes" ng-if="selectedMailFolder.$parent && !selectedMailFolder.useCurrentLevelEtatAttente">
+ <label>
+ <input type="checkbox" ng-checked="parentScopeValues.etatAttentes.containsByTopiaId(etatAttente)"
+ disabled> {{etatAttente.label}}
+ </label>
+ </div>
<label>
<input type="radio" ng-model="selectedMailFolder.useCurrentLevelEtatAttente" ng-value="true"
ng-change="initFolderEtatAttente()" ng-if="selectedMailFolder.$parent" />
Définir des états d'attente pour ce dossier :
</label>
- <label class="checkbox" ng-repeat="etatAttente in etatAttentes" ng-if="selectedMailFolder.useCurrentLevelEtatAttente || !selectedMailFolder.$parent">
- <input type="checkbox" ng-checked="selectedMailFolder.etatAttentes.containsByTopiaId(etatAttente)"
- ng-click="changeFolderEtatAttente(etatAttente)"> {{etatAttente.label}}
- </label>
+ <div class="checkbox" ng-repeat="etatAttente in etatAttentes" ng-if="selectedMailFolder.useCurrentLevelEtatAttente || !selectedMailFolder.$parent">
+ <label>
+ <input type="checkbox" ng-checked="selectedMailFolder.etatAttentes.containsByTopiaId(etatAttente)"
+ ng-click="changeFolderEtatAttente(etatAttente)"> {{etatAttente.label}}
+ </label>
+ </div>
</div>
</div>
</div>
@@ -771,7 +775,8 @@
<div class="form-group">
<label for="newRightUserField" class="control-label">Nouveau utilisateur :</label>
<select id="newRightUserField" class="form-control"
- ng-model="newRightUser" ng-options="user as user.firstName + ' ' + user.lastName for user in users">
+ ng-model="newRightUser"
+ ng-options="user as user.firstName + ' ' + user.lastName for user in users|filter:filterByAlreadyInCollection(selectedMailFolder.rightUsers)">
</select>
<a class="btn btn-success btn-xs" ng-click="addRightUser()" ng-disabled="!newRightUser">
<span class="glyphicon glyphicon-plus"></span>
@@ -783,7 +788,8 @@
<div class="form-group">
<label for="newRightGroupField" class="control-label">Nouveau groupe :</label>
<select id="newRightGroupField" class="form-control"
- ng-model="newRightGroup" ng-options="group as group.completeName for group in groups">
+ ng-model="newRightGroup"
+ ng-options="group as group.completeName for group in groups|filter:filterByAlreadyInCollection(selectedMailFolder.rightGroups)">
</select>
<a class="btn btn-success btn-xs" ng-click="addRightGroup()" ng-disabled="!newRightGroup">
<span class="glyphicon glyphicon-plus"></span>
Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-07-02 13:26:03 UTC (rev 313)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-07-02 13:51:52 UTC (rev 314)
@@ -134,6 +134,13 @@
// update when root folder collection changes (and for init)
$scope.$watchCollection("mailFolders", $scope.updateMetaFilter);
+
+ // filtre qui supprime les items déjà present dans une collection donnée
+ $scope.filterByAlreadyInCollection = function(coll) {
+ return function(item) {
+ return coll && !coll.containsByTopiaId(item);
+ }
+ }
}]);
/**
@@ -794,9 +801,14 @@
// add reply address
$scope.addReplyAddress = function() {
- $scope.selectedMailFolder.replyAddresses.push($scope.newReplyAddress);
- delete $scope.newReplyAddress;
- $scope.addAddressForm.$setPristine();
+ // check if already exists
+ if ($scope.selectedMailFolder.replyAddresses.indexOf($scope.newReplyAddress) != -1) {
+ $window.alert("Cette adresse existe déjà !");
+ } else {
+ $scope.selectedMailFolder.replyAddresses.push($scope.newReplyAddress);
+ delete $scope.newReplyAddress;
+ $scope.addAddressForm.$setPristine();
+ }
};
// remove customer responsible
@@ -808,9 +820,14 @@
// add reply domain
$scope.addReplyDomain = function() {
- $scope.selectedMailFolder.replyDomains.push($scope.newReplyDomain);
- delete $scope.newReplyDomain;
- $scope.addDomainForm.$setPristine();
+ // check if already exists
+ if ($scope.selectedMailFolder.replyDomains.indexOf($scope.newReplyDomain) != -1) {
+ $window.alert("Ce domaine existe déjà !");
+ } else {
+ $scope.selectedMailFolder.replyDomains.push($scope.newReplyDomain);
+ delete $scope.newReplyDomain;
+ $scope.addDomainForm.$setPristine();
+ }
};
// remove customer responsible
1
0
r313 - in trunk: . faxtomail-ui-web faxtomail-ui-web/src/main/webapp/js
by echatellier@users.forge.codelutin.com 02 Jul '14
by echatellier@users.forge.codelutin.com 02 Jul '14
02 Jul '14
Author: echatellier
Date: 2014-07-02 15:26:03 +0200 (Wed, 02 Jul 2014)
New Revision: 313
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/313
Log:
Ajout de check sur les doublons
Modified:
trunk/faxtomail-ui-web/pom.xml
trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js
trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js
trunk/pom.xml
Modified: trunk/faxtomail-ui-web/pom.xml
===================================================================
--- trunk/faxtomail-ui-web/pom.xml 2014-07-02 12:00:40 UTC (rev 312)
+++ trunk/faxtomail-ui-web/pom.xml 2014-07-02 13:26:03 UTC (rev 313)
@@ -296,8 +296,19 @@
<dependency>
<groupId>gui.ava</groupId>
<artifactId>html2image</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>core-renderer</artifactId>
+ <groupId>org.xhtmlrenderer</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
+ <dependency>
+ <groupId>org.xhtmlrenderer</groupId>
+ <artifactId>flying-saucer-core</artifactId>
+ <version>9.0.6</version>
+ </dependency>
</dependencies>
<build>
Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-07-02 12:00:40 UTC (rev 312)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-07-02 13:26:03 UTC (rev 313)
@@ -205,10 +205,16 @@
topiaId : "new_" + guid(),
label: label
};
- $scope.etatAttentes.push(newEtatAttente);
- // auto select
- $scope.editEtatAttente(newEtatAttente);
+ // check if already exists
+ if ($scope.etatAttentes.indexOfBy('label', newEtatAttente) != -1) {
+ $window.alert("Cet état d'attente existe déjà !");
+ } else {
+ $scope.etatAttentes.push(newEtatAttente);
+
+ // auto select
+ $scope.editEtatAttente(newEtatAttente);
+ }
}
};
@@ -287,10 +293,16 @@
topiaId : "new_" + guid(),
label: label
};
- $scope.demandTypes.push(newDemandType);
-
- // auto select
- $scope.editDemandType(newDemandType);
+
+ // check if already exists
+ if ($scope.demandTypes.indexOfBy('label', newDemandType) != -1) {
+ $window.alert("Ce type de demande existe déjà !");
+ } else {
+ $scope.demandTypes.push(newDemandType);
+
+ // auto select
+ $scope.editDemandType(newDemandType);
+ }
}
};
@@ -341,13 +353,20 @@
useCurrentLevelEdiFolder: true,
useCurrentLevelRejectResponseMessage: true,
useCurrentLevelRejectResponseMailAddress: true,
- archiveContainer: false
+ archiveFolder: false
};
- $scope.mailFolders.push(newRoot);
- $scope._updateFlatMailFolders(); // update flat map
- // edition automatique
- $scope.editMailFolder(newRoot);
+ // check if already exists
+ if ($scope.mailFolders.indexOfBy('name', newRoot) != -1) {
+ $window.alert("Un noeud de même nom existe déjà à ce niveau !");
+ } else {
+ // add node
+ $scope.mailFolders.push(newRoot);
+ // update flat map
+ $scope._updateFlatMailFolders();
+ // edition automatique
+ $scope.editMailFolder(newRoot);
+ }
};
};
@@ -366,16 +385,22 @@
useCurrentLevelEdiFolder: false,
useCurrentLevelRejectResponseMessage: false,
useCurrentLevelRejectResponseMailAddress: false,
- archiveContainer: false
+ archiveFolder: false
};
- // extend node (in faxtomail collapsed = extended)
- scope.collapse();
- // append new node
- nodeData.children.push(newNode);
- // edition automatique
- $scope.editMailFolder(newNode);
- // update flat map
- $scope._updateFlatMailFolders();
+
+ // check if already exists
+ if (nodeData.children.indexOfBy('name', newNode) != -1) {
+ $window.alert("Un noeud de même nom existe déjà à ce niveau !");
+ } else {
+ // extend node (in faxtomail collapsed = extended)
+ scope.collapse();
+ // append new node
+ nodeData.children.push(newNode);
+ // update flat map
+ $scope._updateFlatMailFolders();
+ // edition automatique
+ $scope.editMailFolder(newNode);
+ }
}
};
@@ -397,15 +422,21 @@
useCurrentLevelRejectResponseMailAddress: false,
archiveFolder: true
};
- // extend node (in faxtomail collapsed = extended)
- scope.collapse();
- // append new node
- nodeData.hasArchiveFolder = true;
- nodeData.children.push(newNode);
- // edition automatique
- //$scope.editMailFolder(newNode);
- // update flat map
- $scope._updateFlatMailFolders();
+
+ // check if already exists
+ if (nodeData.children.indexOfBy('name', newNode) != -1) {
+ $window.alert("Un noeud de même nom existe déjà à ce niveau !");
+ } else {
+ // extend node (in faxtomail collapsed = extended)
+ scope.collapse();
+ // append new node
+ nodeData.hasArchiveFolder = true;
+ nodeData.children.push(newNode);
+ // update flat map
+ $scope._updateFlatMailFolders();
+ // edition automatique
+ $scope.editMailFolder(newNode);
+ }
}
}
};
@@ -883,7 +914,7 @@
}
}
};
-
+
// change le droit de lecture du groupe
$scope.changeReadRightGroup = function(group) {
var index = $scope.selectedMailFolder.readRightGroups.indexOfByTopiaId(group);
Modified: trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js 2014-07-02 12:00:40 UTC (rev 312)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js 2014-07-02 13:26:03 UTC (rev 313)
@@ -38,12 +38,12 @@
}
/**
- * Même fonction que indexOf mais qui compare par topiaId au lieu des références.
+ * Cherche un element par egalité de champ sur le champ spécifié.
*/
-Array.prototype.indexOfByTopiaId = function(obj) {
+Array.prototype.indexOfBy = function(field, obj) {
var i = this.length;
while (i--) {
- if (this[i].topiaId == obj.topiaId) {
+ if (this[i][field] == obj[field]) {
return i;
}
}
@@ -51,6 +51,13 @@
};
/**
+ * Même fonction que indexOf mais qui compare par topiaId au lieu des références.
+ */
+Array.prototype.indexOfByTopiaId = function(obj) {
+ return this.indexOfBy('topiaId', obj);
+};
+
+/**
* Method contains par topiaId.
*/
Array.prototype.containsByTopiaId = function(obj) {
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-07-02 12:00:40 UTC (rev 312)
+++ trunk/pom.xml 2014-07-02 13:26:03 UTC (rev 313)
@@ -520,7 +520,7 @@
<dependency>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-core</artifactId>
- <version>1.7.6</version>
+ <version>1.7.5</version> <!-- pb de cache dans la v 1.7.6 -->
<scope>runtime</scope>
</dependency>
1
0
Author: echatellier
Date: 2014-07-02 14:00:40 +0200 (Wed, 02 Jul 2014)
New Revision: 312
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/312
Log:
Update angularjs
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-07-02 10:10:27 UTC (rev 311)
+++ trunk/pom.xml 2014-07-02 12:00:40 UTC (rev 312)
@@ -582,7 +582,7 @@
<dependency>
<groupId>org.nuiton.js</groupId>
<artifactId>nuiton-js-angularjs</artifactId>
- <version>1.2.18-1</version>
+ <version>1.2.19-1</version>
<scope>runtime</scope>
</dependency>
1
0
r311 - in trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing: content/demande util
by echatellier@users.forge.codelutin.com 02 Jul '14
by echatellier@users.forge.codelutin.com 02 Jul '14
02 Jul '14
Author: echatellier
Date: 2014-07-02 12:10:27 +0200 (Wed, 02 Jul 2014)
New Revision: 311
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/311
Log:
G?\195?\169n?\195?\169ration d'une page r?\195?\169capitulatif pour les pieces jointes non imprim?\195?\169es
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/util/FaxToMailUIUtil.java
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-07-02 10:10:11 UTC (rev 310)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIHandler.java 2014-07-02 10:10:27 UTC (rev 311)
@@ -22,20 +22,68 @@
* #L%
*/
+import static org.nuiton.i18n.I18n.t;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.JComponent;
+import javax.swing.JPopupMenu;
+import javax.swing.JTable;
+import javax.swing.JTree;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.table.TableModel;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.validator.swing.SwingValidator;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.io.Charsets;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+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 com.ezware.oxbow.swingbits.table.filter.DistinctColumnItem;
import com.ezware.oxbow.swingbits.table.filter.ITableFilter;
import com.ezware.oxbow.swingbits.table.filter.JTableFilter;
import com.ezware.oxbow.swingbits.table.filter.TableRowFilterSupport;
import com.franciaflex.faxtomail.persistence.entities.Attachment;
import com.franciaflex.faxtomail.persistence.entities.AttachmentFile;
-import com.franciaflex.faxtomail.persistence.entities.AttachmentFileImpl;
import com.franciaflex.faxtomail.persistence.entities.DemandStatus;
import com.franciaflex.faxtomail.persistence.entities.Email;
import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser;
-import com.franciaflex.faxtomail.persistence.entities.MailField;
import com.franciaflex.faxtomail.persistence.entities.History;
import com.franciaflex.faxtomail.persistence.entities.HistoryImpl;
import com.franciaflex.faxtomail.persistence.entities.HistoryType;
+import com.franciaflex.faxtomail.persistence.entities.MailField;
import com.franciaflex.faxtomail.persistence.entities.MailFolder;
import com.franciaflex.faxtomail.services.FaxToMailServiceUtils;
import com.franciaflex.faxtomail.services.service.EmailService;
@@ -49,44 +97,8 @@
import com.franciaflex.faxtomail.ui.swing.util.CloseableUI;
import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil;
import com.franciaflex.faxtomail.ui.swing.util.FolderTreeNode;
+import com.google.common.base.Strings;
-import jaxx.runtime.JAXXUtil;
-import jaxx.runtime.validator.swing.SwingValidator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-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.util.pagination.PaginationParameter;
-
-import javax.swing.*;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.table.TableModel;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-
-import java.awt.*;
-import java.awt.event.MouseEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n.t;
-
/**
* Handler of UI {@link com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUIHandler}.
*
@@ -501,8 +513,7 @@
boolean take = Boolean.TRUE.equals(selectedFolder.getPrintActionEqualTakeAction());
FaxToMailUser currentUser = getContext().getCurrentUser();
- List<AttachmentFile> nonPrintedAttachment = new ArrayList<AttachmentFile>();
- //TODO kmorin 20140606 print a result page and maybe a page to separate the demands
+ Map<Email, Collection<AttachmentFile>> nonPrintedAttachment = new HashMap<Email, Collection<AttachmentFile>>();
List<DemandeUIModel> currentEmails = model.getCurrentEmails();
for (DemandeUIModel demandeUIModel : currentEmails) {
if (take) {
@@ -518,7 +529,7 @@
for (Attachment attachment : demandeUIModel.getAttachment()) {
- // force lasy loading
+ // force lazy loading
FaxToMailUIUtil.forceAttachmentFileLoading(getContext(), attachment);
AttachmentFile attachmentFile = attachment.getEditedFile();
@@ -529,17 +540,53 @@
if (printable) {
FaxToMailUIUtil.print(attachmentFile, true);
} else {
- nonPrintedAttachment.add(attachmentFile);
+
+ Collection<AttachmentFile> emailAttachments = nonPrintedAttachment.get(email);
+ if (emailAttachments == null) {
+ emailAttachments = new ArrayList<AttachmentFile>();
+ nonPrintedAttachment.put(email, emailAttachments);
+ }
+ emailAttachments.add(attachmentFile);
}
}
}
-
- // generate a new page with non printed attachment
- /*for () {
-
- }*/
+
+ // print another page for non printed attachments
+ if (MapUtils.isNotEmpty(nonPrintedAttachment)) {
+ InputStream errorPageStream = generateErrorPageStream(nonPrintedAttachment);
+ FaxToMailUIUtil.print(errorPageStream, true);
+ }
}
+ /**
+ * Retourne un flux de données qui correspond à une page de récapitulatif des pièces jointes
+ * non imprimées.
+ *
+ * @param nonPrintedAttachment not printed attachment list
+ * @return input stream with content
+ */
+ protected InputStream generateErrorPageStream(Map<Email, Collection<AttachmentFile>> nonPrintedAttachment) {
+
+ // generate text content
+ StringBuilder builder = new StringBuilder();
+ builder.append("\nLes pièces-jointes suivantes n'ont pas pu être imprimées:\n");
+
+ for (Map.Entry<Email, Collection<AttachmentFile>> entry : nonPrintedAttachment.entrySet()) {
+ Email email = entry.getKey();
+ Collection<AttachmentFile> attachments = entry.getValue();
+
+ builder.append(" * " + Strings.nullToEmpty(email.getCompanyReference()) + " - " + Strings.nullToEmpty(email.getObject()) + " : \n");
+ for (AttachmentFile attachmentFile : attachments) {
+ builder.append(" - " + attachmentFile.getFilename() + "\n");
+ }
+ }
+
+ // convert text content to inputstream
+ byte[] content = builder.toString().getBytes(Charsets.UTF_8);
+ InputStream is = new ByteArrayInputStream(content);
+ return is;
+ }
+
public void reply() {
DemandeUIModel demand = getModel().getCurrentEmails().get(0);
getContext().setCurrentEmail(demand);
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-07-02 10:10:11 UTC (rev 310)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-07-02 10:10:27 UTC (rev 311)
@@ -31,9 +31,9 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URI;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -64,14 +64,11 @@
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
-import com.google.common.collect.Lists;
-
import jaxx.runtime.JAXXObject;
import jaxx.runtime.JAXXUtil;
import org.apache.commons.collections4.CollectionUtils;
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.StringUtils;
@@ -86,7 +83,6 @@
import com.franciaflex.faxtomail.persistence.entities.Attachment;
import com.franciaflex.faxtomail.persistence.entities.AttachmentFile;
-import com.franciaflex.faxtomail.persistence.entities.AttachmentFileImpl;
import com.franciaflex.faxtomail.persistence.entities.ExtensionCommand;
import com.franciaflex.faxtomail.persistence.entities.MailFolder;
import com.franciaflex.faxtomail.services.service.ConfigurationService;
@@ -95,6 +91,7 @@
import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIHandler;
import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel;
import com.franciaflex.faxtomail.ui.swing.content.demande.RangeRowModel;
+import com.google.common.collect.Lists;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -380,14 +377,39 @@
return desktop;
}
+ /**
+ * Imprime un attachment file.
+ *
+ * @param attachmentFile
+ * @param defaultPrinter if {@code true}, do not display print dialog and print with default printer
+ */
public static void print(AttachmentFile attachmentFile, boolean defaultPrinter) {
FileInputStream textStream = null;
try {
textStream = new FileInputStream(attachmentFile.getFile());
+ print(textStream, defaultPrinter);
+ } catch (IOException e) {
+ throw new ApplicationTechnicalException(
+ t("jaxx.application.error.cannot.print"), e);
+ } finally {
+ IOUtils.closeQuietly(textStream);
+ }
+ }
+
+ /**
+ * Imprime un attachment file.
+ *
+ * @param inputStream stream to print
+ * @param defaultPrinter if {@code true}, do not display print dialog and print with default printer
+ */
+ public static void print(InputStream inputStream, boolean defaultPrinter) {
+
+ try {
+
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
- Doc mydoc = new SimpleDoc(textStream, flavor, null);
+ Doc mydoc = new SimpleDoc(inputStream, flavor, null);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
@@ -411,7 +433,7 @@
} else {
if (services.length == 0) {
- if(defaultService == null) {
+ if (defaultService == null) {
throw new ApplicationBusinessException(t("jaxx.application.error.noPrinter"));
} else {
@@ -431,14 +453,10 @@
}
}
- } catch (PrintException | IOException e) {
-
+ } catch (PrintException e) {
throw new ApplicationTechnicalException(
t("jaxx.application.error.cannot.print"), e);
- } finally {
- IOUtils.closeQuietly(textStream);
}
-
}
public static String getEditedFileName(String originalFileName) {
1
0
r310 - in trunk: . faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/job
by echatellier@users.forge.codelutin.com 02 Jul '14
by echatellier@users.forge.codelutin.com 02 Jul '14
02 Jul '14
Author: echatellier
Date: 2014-07-02 12:10:11 +0200 (Wed, 02 Jul 2014)
New Revision: 310
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/310
Log:
Update html2image
Modified:
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/job/MailFilterJob.java
trunk/pom.xml
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-07-02 09:05:42 UTC (rev 309)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/job/MailFilterJob.java 2014-07-02 10:10:11 UTC (rev 310)
@@ -25,7 +25,8 @@
*/
import static org.nuiton.i18n.I18n.t;
-import gui.ava.html.image.generator.HtmlImageGenerator;
+import gui.ava.html.Html2Image;
+import gui.ava.html.renderer.ImageRenderer;
import java.io.File;
import java.io.FileInputStream;
@@ -57,7 +58,6 @@
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;
-import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FileUtils;
@@ -70,7 +70,6 @@
import org.nuiton.util.StringUtil;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
-import org.xml.sax.SAXException;
import com.franciaflex.faxtomail.persistence.entities.Attachment;
import com.franciaflex.faxtomail.persistence.entities.AttachmentFile;
@@ -674,11 +673,11 @@
log.debug("Mapping attachment id " + key + " to file " + file.getAbsolutePath());
}
}
-
- HtmlImageGenerator imageGenerator = new HtmlImageGenerator();
- imageGenerator.loadHtml(content);
- imageGenerator.saveAsImage(target);
-
+
+ Html2Image image = Html2Image.fromHtml(content);
+ ImageRenderer imageRenderer = image.getImageRenderer();
+ imageRenderer.saveImage(target);
+
// convert content to blob
EmailService emailService = serviceContext.newService(EmailService.class);
AttachmentFile attachmentFileNew = emailService.getAttachmentFileFromStream(new FileInputStream(target));
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-07-02 09:05:42 UTC (rev 309)
+++ trunk/pom.xml 2014-07-02 10:10:11 UTC (rev 310)
@@ -629,7 +629,7 @@
<dependency>
<groupId>gui.ava</groupId>
<artifactId>html2image</artifactId>
- <version>0.9</version>
+ <version>2.0.1</version>
</dependency>
</dependencies>
1
0
r309 - trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin
by echatellier@users.forge.codelutin.com 02 Jul '14
by echatellier@users.forge.codelutin.com 02 Jul '14
02 Jul '14
Author: echatellier
Date: 2014-07-02 11:05:42 +0200 (Wed, 02 Jul 2014)
New Revision: 309
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/309
Log:
Add doc about filters
Modified:
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-07-02 08:57:43 UTC (rev 308)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-07-02 09:05:42 UTC (rev 309)
@@ -916,6 +916,8 @@
<div class="form-group">
<label for="filterField">Filtre</label>
<input type="text" class="form-control" id="folderField" ng-model="newFilter.expression">
+ <p class="help-block">Le fitre s'applique à l'adresse de reception de l'email.
+ Il peut commencer ou se terminer par <code>%</code> pour respectivement appliquer le filtre à la fin ou au début de l'adresse de réception</p>
</div>
<div class="form-group">
<label for="folderField">Dossier</label>
1
0
02 Jul '14
Author: echatellier
Date: 2014-07-02 10:57:43 +0200 (Wed, 02 Jul 2014)
New Revision: 308
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/308
Log:
Refactor email details pdf generation.
Move code test service module.
Add unit test.
Added:
trunk/faxtomail-service/src/main/resources/pdf/
trunk/faxtomail-service/src/main/resources/pdf/demande.odt
Removed:
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/ComputeDemandeContent.java
trunk/faxtomail-ui-swing/src/main/resources/odt/
trunk/faxtomail-ui-swing/src/main/resources/pdf/
Modified:
trunk/faxtomail-service/pom.xml
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailDecorator.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java
trunk/faxtomail-service/src/main/resources/pdf/demande.pdf
trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/EmailServiceTest.java
trunk/faxtomail-ui-swing/pom.xml
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/print/AttachmentToPrintChooserUIHandler.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java
trunk/pom.xml
Modified: trunk/faxtomail-service/pom.xml
===================================================================
--- trunk/faxtomail-service/pom.xml 2014-07-02 08:29:20 UTC (rev 307)
+++ trunk/faxtomail-service/pom.xml 2014-07-02 08:57:43 UTC (rev 308)
@@ -161,6 +161,11 @@
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.pdfbox</groupId>
+ <artifactId>pdfbox</artifactId>
+ </dependency>
</dependencies>
<build>
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailDecorator.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailDecorator.java 2014-07-02 08:29:20 UTC (rev 307)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailDecorator.java 2014-07-02 08:57:43 UTC (rev 308)
@@ -46,10 +46,9 @@
import java.util.concurrent.ExecutionException;
/**
- * TODO
+ * Faxtomail decorator.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since TODO
*/
public class FaxToMailDecorator<O> extends MultiJXPathDecorator<O> implements Cloneable {
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-07-02 08:29:20 UTC (rev 307)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-07-02 08:57:43 UTC (rev 308)
@@ -47,8 +47,6 @@
import javax.activation.FileDataSource;
import javax.mail.MessagingException;
-import com.franciaflex.faxtomail.persistence.entities.Range;
-
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.io.IOUtils;
@@ -60,6 +58,10 @@
import org.apache.commons.mail.EmailConstants;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.MultiPartEmail;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
+import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
+import org.apache.pdfbox.pdmodel.interactive.form.PDField;
import org.nuiton.topia.persistence.TopiaEntities;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -89,12 +91,14 @@
import com.franciaflex.faxtomail.persistence.entities.MailField;
import com.franciaflex.faxtomail.persistence.entities.MailFolder;
import com.franciaflex.faxtomail.persistence.entities.MailFolderTopiaDao;
+import com.franciaflex.faxtomail.persistence.entities.Range;
import com.franciaflex.faxtomail.persistence.entities.RangeRow;
import com.franciaflex.faxtomail.persistence.entities.RangeRowTopiaDao;
import com.franciaflex.faxtomail.persistence.entities.Reply;
import com.franciaflex.faxtomail.persistence.entities.ReplyTopiaDao;
import com.franciaflex.faxtomail.services.FaxToMailServiceSupport;
import com.google.common.base.Function;
+import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
@@ -806,4 +810,95 @@
ediReturnDao.deleteAll(ediReturns);
getPersistenceContext().commit();
}
+
+ /**
+ * Generate email details as PDF and return it as an printable attachment.
+ *
+ * @param email email
+ * @return attachment filled with pdf content
+ */
+ public AttachmentFile getEmailDetailAsAttachment(Email email) {
+ Map<String, String> pdfFieldValues = Maps.newHashMap();
+ InputStream emptyPage = null;
+ PDDocument resultDocument;
+
+ AttachmentFile result = null;
+
+ try {
+
+ emptyPage = getClass().getResourceAsStream("/pdf/demande.pdf");
+ resultDocument = PDDocument.load(emptyPage);
+ /*SetField fields = new SetField();
+ if (log.isTraceEnabled()) {
+ log.trace("fields in document are:");
+ PrintFields printFields = new PrintFields();
+ printFields.printFields(resultDocument);
+ }*/
+
+ loadDocumentDedails(pdfFieldValues, email);
+
+
+ if (log.isDebugEnabled()) {
+ log.debug("will fill form document:\n" + pdfFieldValues);
+ }
+
+ for (Map.Entry<String, String> field : pdfFieldValues.entrySet()) {
+ String fieldName = field.getKey();
+ String fieldValue = field.getValue();
+ setField(resultDocument, fieldName, fieldValue);
+ }
+
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ resultDocument.save(out);
+ resultDocument.close();
+
+ result = new AttachmentFileImpl();
+ result.setContent(out.toByteArray());
+ result.setFilename("demand_details.pdf");
+ result.getFile();
+
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("", e);
+ }
+ } finally {
+ IOUtils.closeQuietly(emptyPage);
+ }
+ return result;
+ }
+
+ protected void loadDocumentDedails(Map<String, String> pdfFieldValues, Email email) {
+ setField(pdfFieldValues, "demand", email.getObject());
+ setField(pdfFieldValues, "receivedDate", DateFormatUtils.format(email.getReceptionDate(), "dd/MM/yyyy"));
+ setField(pdfFieldValues, "sender", email.getSender());
+ setField(pdfFieldValues, "object", email.getObject());
+ setField(pdfFieldValues, "clientCode", email.getClient() == null ? "" : email.getClient().getCode());
+ setField(pdfFieldValues, "demandType", email.getDemandType() == null ? "" : email.getDemandType().getLabel());
+ setField(pdfFieldValues, "priority", email.getPriority() == null ? "" : email.getPriority().getLabel());
+ setField(pdfFieldValues, "projectReference", email.getProjectReference());
+ setField(pdfFieldValues, "companyReference", email.getCompanyReference());
+ setField(pdfFieldValues, "etatAttente", email.getEtatAttente() == null ? "" : email.getEtatAttente().getLabel());
+ setField(pdfFieldValues, "status", email.getDemandStatus() == null ? "" : email.getDemandStatus().getLabel());
+ setField(pdfFieldValues, "takenBy", email.getTakenBy() == null ? "" : (email.getTakenBy().getLogin() + " " + email.getTakenBy().getFirstName() + " " + email.getTakenBy().getLastName()));
+ }
+
+ protected void setField(Map<String, String> pdfFieldValues, String fieldName, String... value) {
+ if (value == null) {
+ pdfFieldValues.put(fieldName, "");
+ } else {
+ pdfFieldValues.put(fieldName, Joiner.on(" ").skipNulls().join(value));
+ }
+ }
+
+ protected void setField( PDDocument pdfDocument, String name, String value ) throws IOException {
+ PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
+ PDAcroForm acroForm = docCatalog.getAcroForm();
+ PDField field = acroForm.getField( name );
+ if ( field != null ) {
+ field.setValue( value );
+ } else if (log.isWarnEnabled()) {
+ log.warn("Can't find field " + name + " in pdf form");
+ }
+ }
}
Copied: trunk/faxtomail-service/src/main/resources/pdf/demande.odt (from rev 306, trunk/faxtomail-ui-swing/src/main/resources/odt/demande.odt)
===================================================================
(Binary files differ)
Modified: trunk/faxtomail-service/src/main/resources/pdf/demande.pdf
===================================================================
(Binary files differ)
Modified: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/EmailServiceTest.java
===================================================================
--- trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/EmailServiceTest.java 2014-07-02 08:29:20 UTC (rev 307)
+++ trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/EmailServiceTest.java 2014-07-02 08:57:43 UTC (rev 308)
@@ -33,6 +33,7 @@
import org.nuiton.util.pagination.PaginationParameter;
import org.nuiton.util.pagination.PaginationResult;
+import com.franciaflex.faxtomail.persistence.entities.AttachmentFile;
import com.franciaflex.faxtomail.persistence.entities.DemandStatus;
import com.franciaflex.faxtomail.persistence.entities.Email;
import com.franciaflex.faxtomail.persistence.entities.EmailFilter;
@@ -108,4 +109,21 @@
emails = service.search(filter, getCurrentUser(), paginationParameter);
Assert.assertEquals(0, emails.getCount());
}
+
+ /**
+ * Generate email detail as pdf test.
+ */
+ @Test
+ public void testEmailDetailsPdf() {
+
+ // select a random test email
+ PaginationParameter paginationParameter = PaginationParameter.of(0, 1);
+ EmailFilter filter = new EmailFilter();
+ PaginationResult<Email> emails = service.search(filter, getCurrentUser(), paginationParameter);
+ Email testEmail = emails.getElements().get(0);
+
+ // test pdf generation
+ AttachmentFile attachmentFile = service.getEmailDetailAsAttachment(testEmail);
+ Assert.assertNotNull(attachmentFile);
+ }
}
Modified: trunk/faxtomail-ui-swing/pom.xml
===================================================================
--- trunk/faxtomail-ui-swing/pom.xml 2014-07-02 08:29:20 UTC (rev 307)
+++ trunk/faxtomail-ui-swing/pom.xml 2014-07-02 08:57:43 UTC (rev 308)
@@ -283,11 +283,6 @@
<artifactId>activation</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.pdfbox</groupId>
- <artifactId>pdfbox</artifactId>
- </dependency>
-
</dependencies>
<!-- TODO -->
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-07-02 08:29:20 UTC (rev 307)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeListUIHandler.java 2014-07-02 08:57:43 UTC (rev 308)
@@ -38,11 +38,11 @@
import com.franciaflex.faxtomail.persistence.entities.HistoryType;
import com.franciaflex.faxtomail.persistence.entities.MailFolder;
import com.franciaflex.faxtomail.services.FaxToMailServiceUtils;
+import com.franciaflex.faxtomail.services.service.EmailService;
import com.franciaflex.faxtomail.ui.swing.actions.ArchiveFromListAction;
import com.franciaflex.faxtomail.ui.swing.actions.ComputeQuantitiesByRangeAction;
import com.franciaflex.faxtomail.ui.swing.actions.LoadFolderEmailsAction;
import com.franciaflex.faxtomail.ui.swing.actions.SaveDemandeFromListAction;
-import com.franciaflex.faxtomail.ui.swing.content.print.ComputeDemandeContent;
import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUI;
import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUIModel;
import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailDemandListHandler;
@@ -501,6 +501,7 @@
boolean take = Boolean.TRUE.equals(selectedFolder.getPrintActionEqualTakeAction());
FaxToMailUser currentUser = getContext().getCurrentUser();
+ List<AttachmentFile> nonPrintedAttachment = new ArrayList<AttachmentFile>();
//TODO kmorin 20140606 print a result page and maybe a page to separate the demands
List<DemandeUIModel> currentEmails = model.getCurrentEmails();
for (DemandeUIModel demandeUIModel : currentEmails) {
@@ -508,12 +509,12 @@
demandeUIModel.setTakenBy(currentUser);
}
- final AttachmentFile demandFile = new AttachmentFileImpl();
- demandFile.setFilename("demand_details");
- ComputeDemandeContent generateDemandeContent = new ComputeDemandeContent();
- byte[] demandContent = generateDemandeContent.getDocumentContent(demandeUIModel);
- demandFile.setContent(demandContent);
- FaxToMailUIUtil.print(demandFile, true);
+ // generate details as pdf
+ EmailService emailService = getContext().getEmailService();
+ Email email = demandeUIModel.toEntity();
+ final AttachmentFile demandDetailAttachment = emailService.getEmailDetailAsAttachment(email);
+ // print details
+ FaxToMailUIUtil.print(demandDetailAttachment, true);
for (Attachment attachment : demandeUIModel.getAttachment()) {
@@ -528,10 +529,15 @@
if (printable) {
FaxToMailUIUtil.print(attachmentFile, true);
} else {
- //TODO kmorin 20140629 add to errors
+ nonPrintedAttachment.add(attachmentFile);
}
}
}
+
+ // generate a new page with non printed attachment
+ /*for () {
+
+ }*/
}
public void reply() {
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/AttachmentToPrintChooserUIHandler.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/AttachmentToPrintChooserUIHandler.java 2014-07-02 08:29:20 UTC (rev 307)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/AttachmentToPrintChooserUIHandler.java 2014-07-02 08:57:43 UTC (rev 308)
@@ -24,27 +24,33 @@
* #L%
*/
+import static org.nuiton.i18n.I18n.t;
+
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.List;
+
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.validator.swing.SwingValidator;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import com.franciaflex.faxtomail.persistence.entities.Attachment;
import com.franciaflex.faxtomail.persistence.entities.AttachmentFile;
-import com.franciaflex.faxtomail.persistence.entities.AttachmentFileImpl;
+import com.franciaflex.faxtomail.persistence.entities.Email;
+import com.franciaflex.faxtomail.services.service.EmailService;
import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel;
import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailUIHandler;
import com.franciaflex.faxtomail.ui.swing.util.Cancelable;
import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil;
import com.google.common.collect.Lists;
-import jaxx.runtime.JAXXUtil;
-import jaxx.runtime.validator.swing.SwingValidator;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import javax.swing.*;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n.t;
-
/**
* @author Kevin Morin (Code Lutin)
* @since x.x
@@ -65,22 +71,20 @@
ui.getAttachmentPanel().add(checkBox);
// add demand details
- final AttachmentFile demandFile = new AttachmentFileImpl();
- demandFile.setFilename("demand_details");
- ComputeDemandeContent generateDemandeContent = new ComputeDemandeContent();
- byte[] demandContent = generateDemandeContent.getDocumentContent(demand);
- demandFile.setContent(demandContent);
- getModel().addAttachmentToPrint(demandFile);
+ EmailService emailService = getContext().getEmailService();
+ Email email = getModel().getDemand().toEntity();
+ final AttachmentFile demandDetailAttachment = emailService.getEmailDetailAsAttachment(email);
// add attached files
+ getModel().addAttachmentToPrint(demandDetailAttachment);
checkBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
log.info("state changed " + e.getStateChange());
if (e.getStateChange() == ItemEvent.SELECTED) {
- getModel().addAttachmentToPrint(demandFile);
+ getModel().addAttachmentToPrint(demandDetailAttachment);
} else {
- getModel().removeAttachmentToPrint(demandFile);
+ getModel().removeAttachmentToPrint(demandDetailAttachment);
}
}
});
@@ -179,6 +183,4 @@
closeDialog();
}
}
-
-
}
Deleted: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/ComputeDemandeContent.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/ComputeDemandeContent.java 2014-07-02 08:29:20 UTC (rev 307)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/ComputeDemandeContent.java 2014-07-02 08:57:43 UTC (rev 308)
@@ -1,136 +0,0 @@
-package com.franciaflex.faxtomail.ui.swing.content.print;
-
-/*
- * #%L
- * FaxToMail :: UI
- * $Id:$
- * $HeadURL:$
- * %%
- * Copyright (C) 2014 Franciaflex, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel;
-import com.google.common.base.Joiner;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.io.Closeables;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.examples.fdf.PrintFields;
-import org.apache.pdfbox.examples.fdf.SetField;
-import org.apache.pdfbox.pdmodel.PDDocument;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by davidcosse on 27/06/14.
- */
-public class ComputeDemandeContent {
-
- private static final Log log = LogFactory.getLog(ComputeDemandeContent.class);
- protected Map<String, String> pdfFieldValues;
- protected DateFormat dayFormat = new SimpleDateFormat("dd/MM/yyyy");
-
-
- public byte[] getDocumentContent(DemandeUIModel demand) {
- pdfFieldValues = Maps.newHashMap();
- List<InputStream> streams = Lists.newArrayList();
- PDDocument resultDocument;
-
- byte[] result = null;
-
- try {
-
- InputStream emptyPage = getClass().getResourceAsStream("/pdf/demande.pdf");
- streams.add(emptyPage);
- resultDocument = PDDocument.load(emptyPage);
- SetField fields = new SetField();
- if (log.isTraceEnabled()) {
- log.trace("fields in document are:");
- PrintFields printFields = new PrintFields();
- printFields.printFields(resultDocument);
- }
-
- loadDocumentDedails(demand);
-
-
- if (log.isDebugEnabled()) {
- log.debug("will fill form document:\n" + pdfFieldValues);
- }
-
- for (Map.Entry<String, String> field : pdfFieldValues.entrySet()) {
- String fieldName = field.getKey();
- String fieldValue = field.getValue();
- fields.setField(resultDocument, fieldName, fieldValue);
- }
-
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- resultDocument.save(out);
- resultDocument.close();
-
- result = out.toByteArray();
-
-
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("", e);
- }
- } finally {
- for (InputStream is : streams) {
- try {
- Closeables.close(is, false);
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("An exception occurred", e);
- }
- }
- }
- }
- return result;
- }
-
- protected void loadDocumentDedails(DemandeUIModel demand) {
- setField("demand", demand.getObject());
- setField("receivedDate", dayFormat.format(demand.getReceptionDate()));
- setField("sender", demand.getSender());
- setField("object", demand.getObject());
- setField("clientCode", demand.getClientCode());
- setField("demandType", (demand.getDemandType() == null) ? "" : demand.getDemandType().getLabel());
- setField("priority", (demand.getPriority() == null) ? "" : demand.getPriority().getLabel());
- setField("projectReference", demand.getProjectReference());
- setField("companyReference", demand.getCompanyReference());
- setField("etatAttente", (demand.getEtatAttente() == null) ? "" : demand.getEtatAttente().getLabel());
- setField("status", (demand.getDemandStatus() == null) ? "" : demand.getDemandStatus().getLabel());
- setField("takenBy", (demand.getTakenBy() == null) ? "" : (demand.getTakenBy().getLogin() + " " + demand.getTakenBy().getFirstName() + " " + demand.getTakenBy().getLastName()));
- }
-
- protected void setField(String fieldName, String... value) {
- if (value == null) {
- pdfFieldValues.put(fieldName, "");
- } else {
- pdfFieldValues.put(fieldName, Joiner.on(" ").skipNulls().join(value));
- }
- }
-}
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java 2014-07-02 08:29:20 UTC (rev 307)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java 2014-07-02 08:57:43 UTC (rev 308)
@@ -71,7 +71,6 @@
protected static final ExclusionStrategy EXCLUSION_STRATEGY = new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes f) {
- // TODO AThimel 06/08/13 Maybe another Multimap implementation will do the job ?
Class<?> declaringClass = f.getDeclaringClass();
String attributeName = f.getName();
boolean result = GSON_EXCLUSIONS.containsEntry(declaringClass, attributeName);
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-07-02 08:29:20 UTC (rev 307)
+++ trunk/pom.xml 2014-07-02 08:57:43 UTC (rev 308)
@@ -135,7 +135,6 @@
<maven.compiler.target>1.7</maven.compiler.target>
<signatureArtifactId>java17</signatureArtifactId>
<signatureVersion>1.0</signatureVersion>
- <pdfboxVersion>1.6.0</pdfboxVersion> <!-- Do not upgrade to version 1.7.x or 1.8.x because some classes are missing -->
</properties>
<repositories>
@@ -487,12 +486,6 @@
</dependency>
<dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-web</artifactId>
- <version>${shiroVersion}</version>
- </dependency>
-
- <dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
@@ -630,7 +623,7 @@
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
- <version>${pdfboxVersion}</version>
+ <version>1.8.6</version>
</dependency>
<dependency>
1
0
r307 - trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities
by echatellier@users.forge.codelutin.com 02 Jul '14
by echatellier@users.forge.codelutin.com 02 Jul '14
02 Jul '14
Author: echatellier
Date: 2014-07-02 10:29:20 +0200 (Wed, 02 Jul 2014)
New Revision: 307
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/307
Log:
Oula, la securit?\195?\169 devait pas bien fonctionner :)
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-07-01 15:06:25 UTC (rev 306)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java 2014-07-02 08:29:20 UTC (rev 307)
@@ -50,9 +50,8 @@
Map<String, Object> args = new HashMap<>();
// apply security
- //query.append(" WHERE E." + Email.PROPERTY_MAIL_FOLDER + " in (:readMailFolders)");
- //args.put("readMailFolders", readMailFolders);
- query.append(" WHERE 1 = 1");
+ query.append(" WHERE E." + Email.PROPERTY_MAIL_FOLDER + " in (:readMailFolders)");
+ args.put("readMailFolders", readMailFolders);
// email minReceptionDate
if (emailFilter.getMinReceptionDate() != null) {
1
0
01 Jul '14
Author: echatellier
Date: 2014-07-01 17:06:25 +0200 (Tue, 01 Jul 2014)
New Revision: 306
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/306
Log:
Clean dead code.
Clean i18n files.
Fix send mail with xfce.
Modified:
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.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/content/MainUI.jaxx
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUIHandler.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/ButtonAttachment.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/history/HistoryListUIHandler.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/ButtonDemandReplies.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/AttachmentToPrintChooserUIHandler.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java
trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-07-01 14:08:48 UTC (rev 305)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-07-01 15:06:25 UTC (rev 306)
@@ -97,7 +97,6 @@
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
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-07-01 14:08:48 UTC (rev 305)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java 2014-07-01 15:06:25 UTC (rev 306)
@@ -54,10 +54,7 @@
import com.itextpdf.text.pdf.ColumnText;
import com.itextpdf.text.pdf.PdfAction;
import com.itextpdf.text.pdf.PdfContentByte;
-import com.itextpdf.text.pdf.PdfDictionary;
import com.itextpdf.text.pdf.PdfGState;
-import com.itextpdf.text.pdf.PdfName;
-import com.itextpdf.text.pdf.PdfNumber;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import com.itextpdf.text.pdf.PdfWriter;
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUI.jaxx
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUI.jaxx 2014-07-01 14:08:48 UTC (rev 305)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUI.jaxx 2014-07-01 15:06:25 UTC (rev 306)
@@ -55,17 +55,6 @@
<JMenuItem id='menuFileExit' onActionPerformed="this.dispose()"/>
</JMenu>
- <!--<JMenu id='menuHelp'>-->
- <!--<JMenuItem id='menuShowHelp'-->
- <!--onActionPerformed="handler.showHelp()"/>-->
- <!--<JMenuItem id='menuHelpSite'-->
- <!--onActionPerformed='handler.gotoSite()'/>-->
- <!--<JMenuItem id='menuHelpAbout'/>-->
- <!--<JMenu id='menuChangeLocale'>-->
- <!--<JMenuItem id='menuChangeLocaleUK'/>-->
- <!--<JMenuItem id='menuChangeLocaleFR'/>-->
- <!--</JMenu>-->
- <!--</JMenu>-->
</JMenuBar>
<JToolBar id='bottomBar'>
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUIHandler.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUIHandler.java 2014-07-01 14:08:48 UTC (rev 305)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUIHandler.java 2014-07-01 15:06:25 UTC (rev 306)
@@ -25,7 +25,6 @@
import com.franciaflex.faxtomail.ui.swing.FaxToMailScreen;
import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext;
import com.franciaflex.faxtomail.ui.swing.RunFaxToMail;
-import com.franciaflex.faxtomail.ui.swing.content.config.FaxToMailConfigUI;
import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeListUI;
import com.franciaflex.faxtomail.ui.swing.content.demande.DemandesUI;
import com.franciaflex.faxtomail.ui.swing.content.search.SearchUI;
@@ -142,13 +141,6 @@
}
});
- // installation layer de blocage en mode busy
-// SwingUtil.setLayerUI(ui.getBody(), ui.getBusyBlockLayerUI());
-//
- //FIXME-TC See why this binding is not setted ?
-// ui.applyDataBinding(MainUI.BINDING_MENU_CHANGE_LOCALE_FR_ENABLED);
-// ui.applyDataBinding(MainUI.BINDING_MENU_CHANGE_LOCALE_UK_ENABLED);
-
// Init SwingSession
SwingSession swingSession = getContext().getSwingSession();
swingSession.add(ui);
@@ -239,34 +231,16 @@
public void changeLocale(Locale locale) {
-// // change locale (and save configuration)
+ // change locale (and save configuration)
getModel().setLocale(locale);
-//
-// // change i18n locale
+
+ // change i18n locale
I18n.setDefaultLocale(getConfig().getI18nLocale());
-//
-// // reload decorator service (TODO Check if this is necessary)
-// getContext().reloadDecoratorService();
-//
-// // close reload
+
+ // close reload
reloadUI();
}
-// public void gotoSite() {
-// FaxToMailApplicationConfig config = context.getConfig();
-//
-// URL siteURL = config.getSiteUrl();
-//
-// if (log.isDebugEnabled()) {
-// log.debug("goto " + siteURL);
-// }
-// TuttiUIUtil.openLink(siteURL);
-// }
-
-// public void showHelp() {
-// getModel().showHelp(ui, ui.getBroker(), null);
-// }
-
@Override
public final void showInformationMessage(String message) {
ui.getStatus().setStatus("<html><body>" + message + "</body></html>");
@@ -368,16 +342,6 @@
break;
}
-// JButton showHelp = ui.getShowHelp();
-// if (rightDecoration == null) {
-// rightDecoration = new JToolBar();
-// rightDecoration.setFloatable(false);
-// rightDecoration.setOpaque(false);
-// rightDecoration.setBorderPainted(false);
-// } else {
-// rightDecoration.remove(showHelp);
-// }
-// rightDecoration.add(showHelp, 0);
this.currentBody = screenUI;
getContext().getSwingSession().add(currentBody, true);
ui.getBody().setTitle(screenTitle);
@@ -391,75 +355,10 @@
public void changeTitle() {
- String title = getTitle();
-
ui.setTitle(t("faxtomail.main.title.application",
- getConfig().getVersion(),
-// "0.1",
- title));
+ getConfig().getVersion()));
}
- protected String getTitle() {
-
-
- String title;
-
-// if (context.isDbLoaded()) {
-//
-// if (context.isProgramFilled()) {
-//
-// // selected program
-//
-// Program program = getDataContext().getProgram();
-//
-// title = _("tutti.main.title.selectedProgram", program.getName()) + " / ";
-//
-// if (context.isCruiseFilled()) {
-//
-// // selected cruise
-// Cruise cruise = getDataContext().getCruise();
-//
-// if (cruise != null) {
-// title += _("tutti.main.title.selectedCruise", cruise.getName());
-// }
-// } else {
-//
-// // no selected cruise
-//
-// title += _("tutti.main.title.noSelectedCruise");
-// }
-//
-// } else {
-//
-// // no program selected (so neither cruise)
-//
-// title = _("tutti.main.title.noSelectedProgram");
-//
-// }
-//
-// title += " / ";
-//
-// if (context.isProtocolFilled()) {
-//
-// // selected protocol
-// TuttiProtocol protocol = getDataContext().getProtocol();
-//
-// title += _("tutti.main.title.selectedProtocol", protocol.getName());
-// } else {
-//
-// // no selected protocol
-//
-// title += _("tutti.main.title.noSelectedProtocol");
-// }
-// } else {
-
- // no db loaded
-
- title = t("faxtomail.main.title.nodb");
-// }
- return title;
- }
-
public void setBodyTitle(String title) {
ui.getBody().setTitle(title);
}
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/ButtonAttachment.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/ButtonAttachment.java 2014-07-01 14:08:48 UTC (rev 305)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/ButtonAttachment.java 2014-07-01 15:06:25 UTC (rev 306)
@@ -35,6 +35,7 @@
import java.util.List;
import static org.nuiton.i18n.I18n.t;
+import static org.nuiton.i18n.I18n.n;
/**
* Button to edit attachments.
@@ -68,7 +69,7 @@
};
public ButtonAttachment(AttachmentModelAware model) {
- this("faxtomail.attachmentEditor.text", model);
+ this(n("faxtomail.attachmentEditor.text"), model);
}
public ButtonAttachment(String textKey, AttachmentModelAware model) {
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/history/HistoryListUIHandler.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/history/HistoryListUIHandler.java 2014-07-01 14:08:48 UTC (rev 305)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/history/HistoryListUIHandler.java 2014-07-01 15:06:25 UTC (rev 306)
@@ -126,7 +126,7 @@
}
historyAsString.append("\n");
}
- FaxToMailUIUtil.mail(t("faxtomail.demande.history.send.subject", getModel().getTitle()), historyAsString.toString());
+ FaxToMailUIUtil.email(t("faxtomail.demande.history.send.subject", getModel().getTitle()), historyAsString.toString());
}
};
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/ButtonDemandReplies.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/ButtonDemandReplies.java 2014-07-01 14:08:48 UTC (rev 305)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/ButtonDemandReplies.java 2014-07-01 15:06:25 UTC (rev 306)
@@ -36,6 +36,7 @@
import java.util.Collection;
import static org.nuiton.i18n.I18n.t;
+import static org.nuiton.i18n.I18n.n;
/**
* Button to edit attachments.
@@ -56,7 +57,7 @@
};
public ButtonDemandReplies(DemandeUIModel model) {
- this("faxtomail.demandReplies.text", model);
+ this(n("faxtomail.demandReplies.text"), model);
}
public ButtonDemandReplies(String textKey, DemandeUIModel model) {
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/AttachmentToPrintChooserUIHandler.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/AttachmentToPrintChooserUIHandler.java 2014-07-01 14:08:48 UTC (rev 305)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/print/AttachmentToPrintChooserUIHandler.java 2014-07-01 15:06:25 UTC (rev 306)
@@ -54,9 +54,6 @@
private static final Log log = LogFactory.getLog(AttachmentToPrintChooserUIHandler.class);
-
-
-
@Override
public void afterInit(AttachmentToPrintChooserUI attachmentToPrintChooserUI) {
initUI(attachmentToPrintChooserUI);
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel.java 2014-07-01 14:08:48 UTC (rev 305)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIModel.java 2014-07-01 15:06:25 UTC (rev 306)
@@ -197,9 +197,7 @@
}
public void setValid(boolean valid) {
- log.info("set valid " + valid);
Object oldValue = isValid();
- log.info("oldValue " + oldValue);
this.valid = valid;
firePropertyChange(PROPERTY_VALID, oldValue, valid);
}
@@ -207,9 +205,13 @@
// Do not remove the unused parameter, it is just for the validation
// to bind the totalAttachmentLength property
public boolean isAttachmentSizeValid(long totalAttachmentLength) {
- log.info(this.totalAttachmentLength + ", " + maxAttachmentLength + ", " + (this.totalAttachmentLength < maxAttachmentLength));
+ if (log.isDebugEnabled()) {
+ log.debug(this.totalAttachmentLength + ", " + maxAttachmentLength + ", " + (this.totalAttachmentLength < maxAttachmentLength));
+ }
boolean valid = maxAttachmentLength == 0 || this.totalAttachmentLength < maxAttachmentLength;
- log.info(valid);
+ if (log.isDebugEnabled()) {
+ log.debug(valid);
+ }
return valid;
}
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-07-01 14:08:48 UTC (rev 305)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-07-01 15:06:25 UTC (rev 306)
@@ -31,6 +31,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -64,6 +65,7 @@
import javax.swing.tree.TreePath;
import com.google.common.collect.Lists;
+
import jaxx.runtime.JAXXObject;
import jaxx.runtime.JAXXUtil;
@@ -488,4 +490,23 @@
DesktopUtil.open(file);
}
}
+
+ /**
+ * Send email.
+ *
+ * @param subject
+ * @param body
+ */
+ public static void email(String subject, String body) {
+
+ try {
+ URI mailtoURI = new URI("mailto", null, null, "subject=" + subject + "&body=" + body, null);
+ DesktopUtil.mail(mailtoURI);
+
+ } catch (Exception e) {
+
+ throw new ApplicationTechnicalException(
+ t("jaxx.application.error.cannot.mail"), e);
+ }
+ }
}
Modified: trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties
===================================================================
--- trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties 2014-07-01 14:08:48 UTC (rev 305)
+++ trunk/faxtomail-ui-swing/src/main/resources/i18n/faxtomail-ui-swing_fr_FR.properties 2014-07-01 15:06:25 UTC (rev 306)
@@ -8,13 +8,6 @@
faxtomail.action.attachment.edit.tip=Edition du fichier %s
faxtomail.action.attachment.open.tip=Ouverture du fichier %s
faxtomail.action.computeQuantitiesByRange.tip=Calculer les quantités par gamme
-faxtomail.action.configuration=Configuration
-faxtomail.action.configuration.mnemonic=
-faxtomail.action.configuration.tip=Menu configuration
-faxtomail.action.demandeList=Gestion des fax
-faxtomail.action.demandeList.tip=Gestion des fax
-faxtomail.action.exit=Quitter
-faxtomail.action.exit.tip=Quitter l'application
faxtomail.action.generateAnnotatedAttachment.tip=Générer le pdf annoté
faxtomail.action.goto.demand.tip=Aller au détail de l'élément
faxtomail.action.goto.demandList.tip=Aller à la liste des éléments
@@ -30,9 +23,6 @@
faxtomail.action.transmit.tip=Déplacer l'élément
faxtomail.alert.alreadyLockedBy.message=L'élément est déjà vérrouillé par %s, vous ne pouvez pas l'ouvrir.
faxtomail.alert.alreadyLockedBy.title=Document déjà vérrouillé
-faxtomail.alert.alreadyTakenBy.button.quit=Quitter
-faxtomail.alert.alreadyTakenBy.button.take=Prendre
-faxtomail.alert.alreadyTakenBy.button.view=Visualiser
faxtomail.alert.alreadyTakenBy.help=Voulez-vous le prendre ?<ul><li><strong>Annuler</strong> pour ne retourner à la liste</li><li><strong>Non</strong> pour visualiser l'élément en lecture seule</li><li><strong>Oui</strong> pour le prendre</li></ul>
faxtomail.alert.alreadyTakenBy.message=L'élément est déjà pris par %s.
faxtomail.alert.alreadyTakenBy.title=Document déjà pris
@@ -47,18 +37,12 @@
faxtomail.attachmentEditor.action.edit.tip=Editer la pièce jointe
faxtomail.attachmentEditor.action.open.tip=Ouvrir la pièce jointe
faxtomail.attachmentEditor.action.remove.tip=Supprimer la pièce jointe
-faxtomail.attachmentEditor.action.save.tip=Enregistrer la pièce jointe en local
faxtomail.attachmentEditor.action.tip=Pièces jointes
faxtomail.attachmentEditor.attachments.empty=Aucune pièce jointe
faxtomail.attachmentEditor.deleteAttachment.message=Êtes-vous sûr de vouloir supprimer la pièce-jointe %s ?
faxtomail.attachmentEditor.deleteAttachment.title=Suppression de pièce-jointe
faxtomail.attachmentEditor.field.file=Fichier
-faxtomail.attachmentEditor.fileNotFound=Le fichier %s de la pièce jointe n'a pas été trouvé
faxtomail.attachmentEditor.none.tip=Aucune pièce-jointe
-faxtomail.attachmentEditor.saveAttachment.button=Enregistrer
-faxtomail.attachmentEditor.saveAttachment.error.message=Erreur lors de l'enregistrement de la pièce jointe %1s dans le fichier %2s
-faxtomail.attachmentEditor.saveAttachment.success.message=Le fichier %s a été sauvegardé sur votre machine
-faxtomail.attachmentEditor.saveAttachment.title=Enregistrer la pièce-jointe
faxtomail.attachmentEditor.text=Pièces jointes (%s)
faxtomail.attachmentEditor.title=Pièces jointes
faxtomail.chooseAttachmentToPrint.action.cancel=Annuler
@@ -77,11 +61,8 @@
faxtomail.common.by.label=par
faxtomail.common.none.label=Sans
faxtomail.common.on.label=le
-faxtomail.config.application=
-faxtomail.config.title=
faxtomail.demand.title=Détail
faxtomail.demandGroup.action.tip=Éléments groupés avec l'élément courant
-faxtomail.demandGroup.empty=Aucune demande groupée
faxtomail.demandGroup.text=Groupe (%s)
faxtomail.demandGroup.title=Groupe
faxtomail.demandReplies.action.open.tip=Visualiser la réponse
@@ -102,7 +83,6 @@
faxtomail.demande.client.label=Code client
faxtomail.demande.clientBrand.label=Marque
faxtomail.demande.clientCode.label=Client
-faxtomail.demande.commandNumber.label=Numéro de commande
faxtomail.demande.comment.label=Message
faxtomail.demande.companyReference.label=Notre référence
faxtomail.demande.demandStatus.label=Statut
@@ -121,7 +101,6 @@
faxtomail.demande.lastAttachmentOpening.label=Dernière ouverture de pièce-jointe
faxtomail.demande.lastModified.label=Dernière modification
faxtomail.demande.localReference.label=Référence
-faxtomail.demande.mailBody.label=Corps du mail
faxtomail.demande.mailFolder.label=Dossier
faxtomail.demande.object.label=Objet
faxtomail.demande.print.button.label=Imprimer
@@ -147,8 +126,6 @@
faxtomail.demande.transmit.button.label=Déplacer
faxtomail.demandeList.action.archive=Archiver
faxtomail.demandeList.action.archive.tip=Archiver l'élément
-faxtomail.demandeList.action.attachment=Ajouter une pièce-jointe
-faxtomail.demandeList.action.attachment.tip=Ajouter une pièce-jointe
faxtomail.demandeList.action.computeQuantitiesByRange=Calculer les quantités par gamme
faxtomail.demandeList.action.computeQuantitiesByRange.tip=Calculer les quantités par gamme
faxtomail.demandeList.action.newDemand=Créer une nouvelle demande
@@ -213,24 +190,16 @@
faxtomail.historyList.action.tip=Historique
faxtomail.historyList.text=Historique (%s)
faxtomail.historyList.title=Historique
-faxtomail.i18n.deleteCache.error=
-faxtomail.i18n.mkDir.error=
-faxtomail.main.action.configuration=Configuration
-faxtomail.main.action.configuration.mnemonic=
-faxtomail.main.action.configuration.tip=Menu configuration
faxtomail.main.action.demandeList=Gestion des fax
faxtomail.main.action.demandeList.tip=Gestion des fax
faxtomail.main.action.exit=Quitter
faxtomail.main.action.exit.tip=Quitter l'application
-faxtomail.main.action.goto.previousScreen.tip=
faxtomail.main.action.recherche=Recherche
faxtomail.main.action.recherche.tip=Recherche de demandes archivées
-faxtomail.main.action.reloadFaxToMail=
faxtomail.main.menu.file=Fichier
faxtomail.main.menu.file.tip=Menu fichier
faxtomail.main.title.application=FaxToMail
faxtomail.main.title.applicationName=FaxToMail
-faxtomail.main.title.nodb=
faxtomail.pdfEditor.action.cancel=Annuler
faxtomail.pdfEditor.action.cancel.tip=Ne pas enregistrer les changements et fermer
faxtomail.pdfEditor.action.validate=Enregistrer
@@ -300,16 +269,8 @@
faxtomail.validator.error.email.priority.required=
faxtomail.validator.error.email.projectReference.required=Référence chantier requise
faxtomail.validator.error.email.rangeRow.required=Tableau des gammes requis
-faxtomail.validator.error.reply.from.email=
-faxtomail.validator.error.reply.from.invalidDomain=
-faxtomail.validator.error.reply.from.required=
-faxtomail.validator.error.reply.to.email=
-faxtomail.validator.error.reply.to.required=
-faxtomail.validator.error.reply.totalAttachmentLength.required=
jaxx.application.error.cannot.print=
jaxx.application.error.desktop.not.supported=
jaxx.application.error.desktop.print.not.supported=
jaxx.application.error.noPrinter=
swing.error.cannot.copy.file=
-swing.error.cannot.open.file=
-test=
1
0
r305 - trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/job
by echatellier@users.forge.codelutin.com 01 Jul '14
by echatellier@users.forge.codelutin.com 01 Jul '14
01 Jul '14
Author: echatellier
Date: 2014-07-01 16:08:48 +0200 (Tue, 01 Jul 2014)
New Revision: 305
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/305
Log:
Add try/catch (error) if html content can't converted to image
Modified:
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/job/MailFilterJob.java
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-07-01 13:42:59 UTC (rev 304)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/job/MailFilterJob.java 2014-07-01 14:08:48 UTC (rev 305)
@@ -25,6 +25,7 @@
*/
import static org.nuiton.i18n.I18n.t;
+import gui.ava.html.image.generator.HtmlImageGenerator;
import java.io.File;
import java.io.FileInputStream;
@@ -58,16 +59,6 @@
import javax.mail.internet.MimeUtility;
import javax.xml.parsers.ParserConfigurationException;
-import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser;
-import com.franciaflex.faxtomail.persistence.entities.MailFilter;
-
-import com.franciaflex.faxtomail.services.FaxToMailServiceUtils;
-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.image.generator.HtmlImageGenerator;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
@@ -79,6 +70,7 @@
import org.nuiton.util.StringUtil;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
+import org.xml.sax.SAXException;
import com.franciaflex.faxtomail.persistence.entities.Attachment;
import com.franciaflex.faxtomail.persistence.entities.AttachmentFile;
@@ -90,14 +82,21 @@
import com.franciaflex.faxtomail.persistence.entities.EmailAccount;
import com.franciaflex.faxtomail.persistence.entities.EmailImpl;
import com.franciaflex.faxtomail.persistence.entities.ExtensionCommand;
+import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser;
+import com.franciaflex.faxtomail.persistence.entities.MailFilter;
import com.franciaflex.faxtomail.persistence.entities.MailFolder;
import com.franciaflex.faxtomail.services.DecoratorService;
import com.franciaflex.faxtomail.services.FaxToMailServiceContext;
+import com.franciaflex.faxtomail.services.FaxToMailServiceUtils;
import com.franciaflex.faxtomail.services.service.ClientService;
import com.franciaflex.faxtomail.services.service.ConfigurationService;
import com.franciaflex.faxtomail.services.service.EmailService;
import com.franciaflex.faxtomail.services.service.MailFolderService;
-import org.xml.sax.SAXException;
+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;
/**
* @author Kevin Morin (Code Lutin)
@@ -221,7 +220,7 @@
List<String> modifiedProperties = new ArrayList<>();
- if (log.isDebugEnabled()){
+ if (log.isDebugEnabled()) {
log.debug("Object: " + message.getSubject());
}
@@ -243,7 +242,7 @@
String recipient = address.toString();
- // some reciepient are like "toto tutu<toto.tutu73(a)gmail.com>"
+ // some recipient are like "toto tutu<toto.tutu73(a)gmail.com>"
// the regex is to extract email address from it
recipient = recipient.replaceFirst("^.*<(.*)>$", "$1");
recipient = recipient.toLowerCase();
@@ -377,8 +376,13 @@
if (message.isMimeType("multipart/*")) {
String htmlContent = decomposeMultipartEmail(attachments, message, email, emailService);
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.fileName"));
- attachments.add(attachment);
+ if (attachment != null) {
+ attachments.add(attachment);
+ }
}
} else {
@@ -537,7 +541,7 @@
/**
* Convert attachment to pdf.
*
- * @param attachment attchment to convert
+ * @param attachment attachment to convert
* @param extensionCommand command
* @return
* @throws IOException
@@ -594,13 +598,13 @@
}
// cleanup
- //file.delete();
- //outfile.delete();
+ file.delete();
+ outfile.delete();
return attachment;
}
- public Attachment convertTextToPdf(String content, String name) throws IOException, DocumentException {
+ protected Attachment convertTextToPdf(String content, String name) throws IOException, DocumentException {
File target = File.createTempFile("faxtomail-", ".tmp");
target.deleteOnExit();
@@ -626,52 +630,73 @@
attachment.setOriginalFile(attachmentFileNew);
attachment.setOriginalFileName(name);
attachment.setAddedByUser(false);
+
+ target.delete();
return attachment;
}
- public Attachment convertHTMLToPdf(List<Attachment> attachments, String content, String name) throws IOException, ParserConfigurationException, SAXException, 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
+ */
+ protected Attachment convertHTMLToPdf(List<Attachment> attachments, String content, String name) throws IOException {
File target = File.createTempFile("faxtomail-", ".png");
target.deleteOnExit();
- content = content.replaceAll("<meta (.*?)>(</meta>)?", "");
- for (Attachment attachment : attachments) {
- String key = attachment.getContentId();
- if (key == null) {
- key = attachment.getOriginalFileName();
+ Attachment result = null;
+ 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();
+
+ // 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());
+ }
}
-
- // get file content
- AttachmentFile attachmentFile = attachment.getOriginalFile();
- File file = attachmentFile.getFile();
-
- // replace the inline attachments with the extracted attachment file url
- // match les patterns:
- // <td background="cid:bg.gif" height="52">
- // <img border=0 src="cid:bg.gif" />
- // <img src='cid:5e9ef859-ea65-4f9b-a9fa-30d4a2c5837c'
- content = content.replaceAll("(\\w+)=([\"'])cid:" + Pattern.quote(key) + "([\"'])", "$1=$2file://" + file.getAbsolutePath() + "$3");
-
- if (log.isDebugEnabled()) {
- log.debug("Mapping attachment id " + key + " to file " + file.getAbsolutePath());
+
+ HtmlImageGenerator imageGenerator = new HtmlImageGenerator();
+ imageGenerator.loadHtml(content);
+ imageGenerator.saveAsImage(target);
+
+ // convert content to blob
+ EmailService emailService = serviceContext.newService(EmailService.class);
+ AttachmentFile attachmentFileNew = emailService.getAttachmentFileFromStream(new FileInputStream(target));
+ attachmentFileNew.setFilename(name + ".png");
+
+ result = new AttachmentImpl();
+ result.setOriginalFile(attachmentFileNew);
+ result.setOriginalFileName(name);
+ 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 image", er);
}
}
- HtmlImageGenerator imageGenerator = new HtmlImageGenerator();
- imageGenerator.loadHtml(content);
- imageGenerator.saveAsImage(target);
+ target.delete();
- // convert content to blob
- EmailService emailService = serviceContext.newService(EmailService.class);
- AttachmentFile attachmentFileNew = emailService.getAttachmentFileFromStream(new FileInputStream(target));
- attachmentFileNew.setFilename(name + ".png");
-
- Attachment attachment = new AttachmentImpl();
- attachment.setOriginalFile(attachmentFileNew);
- attachment.setOriginalFileName(name);
- attachment.setAddedByUser(false);
-
- return attachment;
+ return result;
}
}
1
0