This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository faxtomail. See https://gitlab.nuiton.org/codelutin/faxtomail.git commit 229bcfeede64aaffc409899d8994a7648f6bcc75 Author: jcouteau <couteau@codelutin.com> Date: Thu Jun 14 14:52:21 2018 +0200 Fix SQL Server Generated Pages ? --- faxtomail-persistence/pom.xml | 7 ++++++- .../src/main/xmi/faxtomail.properties | 8 +++++++- faxtomail-persistence/src/main/xmi/faxtomail.zargo | Bin 36986 -> 36985 bytes .../services/service/EmailServiceImpl.java | 8 ++------ .../faxtomail/ui/swing/util/FaxToMailUIUtil.java | 20 ++++++++------------ pom.xml | 7 +++++++ 6 files changed, 30 insertions(+), 20 deletions(-) diff --git a/faxtomail-persistence/pom.xml b/faxtomail-persistence/pom.xml index 02bcac53..4a82e533 100644 --- a/faxtomail-persistence/pom.xml +++ b/faxtomail-persistence/pom.xml @@ -53,9 +53,14 @@ <artifactId>hibernate-c3p0</artifactId> </dependency> - <dependency> + <!--dependency> <groupId>net.sourceforge.jtds</groupId> <artifactId>jtds</artifactId> + </dependency--> + + <dependency> + <groupId>com.microsoft.sqlserver</groupId> + <artifactId>mssql-jdbc</artifactId> </dependency> <dependency> diff --git a/faxtomail-persistence/src/main/xmi/faxtomail.properties b/faxtomail-persistence/src/main/xmi/faxtomail.properties index 1927ed96..1c10a5be 100644 --- a/faxtomail-persistence/src/main/xmi/faxtomail.properties +++ b/faxtomail-persistence/src/main/xmi/faxtomail.properties @@ -135,4 +135,10 @@ com.franciaflex.faxtomail.persistence.entities.BrandsForDomain.attribute.domainN # SigningForDomain com.franciaflex.faxtomail.persistence.entities.SigningForDomain.attribute.domainName.tagvalue.notNull=true -com.franciaflex.faxtomail.persistence.entities.SigningForDomain.attribute.domainName.stereotype=unique \ No newline at end of file +com.franciaflex.faxtomail.persistence.entities.SigningForDomain.attribute.domainName.stereotype=unique + +# GeneratedPDFPage +com.franciaflex.faxtomail.persistence.entities.GeneratedPDFPage.attribute.page.tagvalue.notNull=true +# il faut mettre une valeur > a 8000 pour que la mapping genere un type varbinary(max) +com.franciaflex.faxtomail.persistence.entities.GeneratedPDFPage.attribute.page.tagValue.hibernateAttributeType=binary +com.franciaflex.faxtomail.persistence.entities.GeneratedPDFPage.attribute.page.tagvalue.length=9999999 \ No newline at end of file diff --git a/faxtomail-persistence/src/main/xmi/faxtomail.zargo b/faxtomail-persistence/src/main/xmi/faxtomail.zargo index 1d3e2e80..0b3dda75 100644 Binary files a/faxtomail-persistence/src/main/xmi/faxtomail.zargo and b/faxtomail-persistence/src/main/xmi/faxtomail.zargo differ diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java index 31d635a7..55ecaa49 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java @@ -105,8 +105,6 @@ import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimeUtility; -import javax.sql.rowset.serial.SerialBlob; -import javax.sql.rowset.serial.SerialException; import java.awt.image.BufferedImage; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; @@ -121,7 +119,6 @@ import java.io.UnsupportedEncodingException; import java.io.Writer; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import java.sql.Blob; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -2353,13 +2350,12 @@ public class EmailServiceImpl extends FaxToMailServiceSupport implements EmailSe ImageIO.write(image, "png", baos); baos.flush(); - Blob pageBlob = new SerialBlob(baos.toByteArray()); - generatedPDFPage.setPage(pageBlob); + generatedPDFPage.setPage(baos.toByteArray()); attachment.addGeneratedPDFPages(generatedPDFPage); //generatedPDFPage = dao.create(generatedPDFPage); //getPersistenceContext().getAttachmentDao().update(attachment); - } catch (IOException | SQLException e) { + } catch (IOException e) { log.error("Error while writing image", e); } diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java index 00a8ea35..7842757f 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java @@ -1036,18 +1036,14 @@ public final class FaxToMailUIUtil extends ApplicationUIUtil { if (pages != null && !pages.isEmpty()) { //Got pre-generated pages for (GeneratedPDFPage page : pages) { - try { - InputStream in = page.getPage().getBinaryStream(); - BufferedImage pageImage = ImageIO.read(in); - JImagePanel imagePanel = new JImagePanel(); - imagePanel.setScaleImageToFitPanel(true); - imagePanel.setImage(pageImage); - imagePanel.setAlignmentX(Component.LEFT_ALIGNMENT); - box.add(imagePanel); - box.add(Box.createVerticalStrut(3)); - } catch (SQLException eee) { - log.error("Could not print generated PDF page", eee); - } + InputStream in = new ByteArrayInputStream(page.getPage()); + BufferedImage pageImage = ImageIO.read(in); + JImagePanel imagePanel = new JImagePanel(); + imagePanel.setScaleImageToFitPanel(true); + imagePanel.setImage(pageImage); + imagePanel.setAlignmentX(Component.LEFT_ALIGNMENT); + box.add(imagePanel); + box.add(Box.createVerticalStrut(3)); } } else { //No pre-generated pages - old school on the fly generation diff --git a/pom.xml b/pom.xml index 7207e169..2019f9a1 100644 --- a/pom.xml +++ b/pom.xml @@ -216,6 +216,13 @@ <scope>runtime</scope> </dependency> + <dependency> + <groupId>com.microsoft.sqlserver</groupId> + <artifactId>mssql-jdbc</artifactId> + <version>6.2.0.jre7</version> + <scope>runtime</scope> + </dependency> + <!-- librairies utils --> <dependency> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.