[jdk8] pi merge
authorAsier Lostalé <asier.lostale@openbravo.com>
Wed, 18 Jul 2018 10:15:25 +0200
changeset 34307 f2ea92b11b54
parent 34306 24c23f55ecef (current diff)
parent 34298 326f3d73a55e (diff)
child 34308 ae51ebbe1adf
[jdk8] pi merge
build.xml
lib/runtime/mail-1.4.4.jar
--- a/.hgsigs	Mon Jul 16 13:07:51 2018 +0200
+++ b/.hgsigs	Wed Jul 18 10:15:25 2018 +0200
@@ -231,3 +231,4 @@
 9bad88c00b5da708f3e9c1abacd25ea6e6cfd664 0 iEUEABECAAYFAlrXODoACgkQCX/oGf+2qkOblACg0WOwH27TgkH75iKw2Y9tNYxSL8oAl3j0FbjQF6F05ESzZC0l3Uv2Nfg=
 dc2ef98dc38f7c32c888dcf1f1adb37c6afb4d14 0 iEYEABECAAYFAlrxbisACgkQCX/oGf+2qkMMCwCdFeF47f2MY7Pq3cdsyHon64EYekwAoPYllLnhYETGsUEqtiKSxvj9Mgxb
 2121d856284cf0c4f26faef336bd2aa41ada151f 0 iEYEABECAAYFAlr8AykACgkQCX/oGf+2qkPKhQCfeQ+9S16IA3wZMgnoJjRRZRvG8SUAoIgKQPopjsjObnB6Qu1DyNgCByRt
+faeac12b1aad3dc7fb53f8ffda3ada9e3b7deaeb 0 iEYEABECAAYFAls/boQACgkQCX/oGf+2qkNdfACfaNh5oqLf0LzgGAYLmRWa97kbFj4AoL3KPdVDG0Mf6qKcxejAl7Kl12cd
--- a/.hgtags	Mon Jul 16 13:07:51 2018 +0200
+++ b/.hgtags	Wed Jul 18 10:15:25 2018 +0200
@@ -242,3 +242,4 @@
 650aaadd6b6c5fda4f7ad957701face4fa4c3317 3.0PR18Q1.2
 307b23f7635f3e92dd8fc8e7d55d09b7c914384c 3.0PR18Q2
 63c5e173ffdca0828d75476e5a48e2fae42ad9e9 3.0PR18Q1.3
+3f281a901fbbde5103faebca4df0c22b94ac5535 3.0PR18Q2.1
--- a/legal/Licensing.txt	Mon Jul 16 13:07:51 2018 +0200
+++ b/legal/Licensing.txt	Wed Jul 18 10:15:25 2018 +0200
@@ -203,8 +203,7 @@
   License Agreement available at:
   http://fisheye.jboss.org/browse/Hibernate/jpa-api/tags/hibernate-jpa-2.0-api-1.0.0.Final/license.txt?r=16109&r=16109
 
-# jaxrpc.jar 
-# mail-1.4.4.jar 
+# jaxrpc.jar
 All files under the corresponding Sun Binary Code License. This is not free
 software, but provided under license from Sun Microsystems.
 
@@ -276,6 +275,7 @@
 # javax.activation-api-1.2.0.jar
 # jaxb-api-2.2.12.jar
 # jaxb-impl-2.2.6.jar
+# javax.mail-1.6.1.jar
 Under the CDDL license version 1.1 (license available at https://spdx.org/licenses/CDDL-1.1.html 
 or in the file CDDL-1.1.txt in this folder)
 
Binary file lib/runtime/javax.mail-1.6.1.jar has changed
Binary file lib/runtime/mail-1.4.4.jar has changed
--- a/src-db/database/model/tables/C_POC_CONFIGURATION.xml	Mon Jul 16 13:07:51 2018 +0200
+++ b/src-db/database/model/tables/C_POC_CONFIGURATION.xml	Wed Jul 18 10:15:25 2018 +0200
@@ -61,6 +61,10 @@
         <default><![CDATA[25]]></default>
         <onCreateDefault><![CDATA[25]]></onCreateDefault>
       </column>
+      <column name="SMTPTIMEOUT" primaryKey="false" required="false" type="DECIMAL" size="10,0" autoIncrement="false">
+        <default><![CDATA[600]]></default>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="C_POC_CONFIGURATION_AD_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Mon Jul 16 13:07:51 2018 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Wed Jul 18 10:15:25 2018 +0200
@@ -373199,6 +373199,45 @@
 <!--DD50B83DF5FDEED7E040007F01006467-->  <EM_OBUIAPP_PROCESS_ID><![CDATA[AB810AFFC62E4FC199C8C422A18B2533]]></EM_OBUIAPP_PROCESS_ID>
 <!--DD50B83DF5FDEED7E040007F01006467--></AD_COLUMN>
 
+<!--DD8B47B6ECF745C0B401A06D37047AAA--><AD_COLUMN>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <AD_COLUMN_ID><![CDATA[DD8B47B6ECF745C0B401A06D37047AAA]]></AD_COLUMN_ID>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <NAME><![CDATA[Smtp Connection Timeout]]></NAME>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <DESCRIPTION><![CDATA[Timeout used in SMTP server communication]]></DESCRIPTION>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <HELP><![CDATA[SMTP server communication timeout defined in seconds. After this timeout the email send process will stop.]]></HELP>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <COLUMNNAME><![CDATA[SmtpTimeout]]></COLUMNNAME>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <AD_TABLE_ID><![CDATA[1000500000]]></AD_TABLE_ID>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <AD_REFERENCE_ID><![CDATA[11]]></AD_REFERENCE_ID>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <FIELDLENGTH><![CDATA[10]]></FIELDLENGTH>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <DEFAULTVALUE><![CDATA[600]]></DEFAULTVALUE>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <SEQNO><![CDATA[180]]></SEQNO>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <AD_ELEMENT_ID><![CDATA[A9108AC54B3A4E14AF83D86DF60069FA]]></AD_ELEMENT_ID>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <POSITION><![CDATA[16]]></POSITION>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--DD8B47B6ECF745C0B401A06D37047AAA-->  <ALLOWED_CROSS_ORG_LINK><![CDATA[N]]></ALLOWED_CROSS_ORG_LINK>
+<!--DD8B47B6ECF745C0B401A06D37047AAA--></AD_COLUMN>
+
 <!--DD9A479969A747D1972E40FDB96D7DE7--><AD_COLUMN>
 <!--DD9A479969A747D1972E40FDB96D7DE7-->  <AD_COLUMN_ID><![CDATA[DD9A479969A747D1972E40FDB96D7DE7]]></AD_COLUMN_ID>
 <!--DD9A479969A747D1972E40FDB96D7DE7-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_ELEMENT.xml	Mon Jul 16 13:07:51 2018 +0200
+++ b/src-db/database/sourcedata/AD_ELEMENT.xml	Wed Jul 18 10:15:25 2018 +0200
@@ -31296,6 +31296,20 @@
 <!--A7FC44EFCAFC41CB9971C834BB3A09D7-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--A7FC44EFCAFC41CB9971C834BB3A09D7--></AD_ELEMENT>
 
+<!--A9108AC54B3A4E14AF83D86DF60069FA--><AD_ELEMENT>
+<!--A9108AC54B3A4E14AF83D86DF60069FA-->  <AD_ELEMENT_ID><![CDATA[A9108AC54B3A4E14AF83D86DF60069FA]]></AD_ELEMENT_ID>
+<!--A9108AC54B3A4E14AF83D86DF60069FA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--A9108AC54B3A4E14AF83D86DF60069FA-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--A9108AC54B3A4E14AF83D86DF60069FA-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--A9108AC54B3A4E14AF83D86DF60069FA-->  <COLUMNNAME><![CDATA[SmtpTimeout]]></COLUMNNAME>
+<!--A9108AC54B3A4E14AF83D86DF60069FA-->  <NAME><![CDATA[Smtp Connection Timeout]]></NAME>
+<!--A9108AC54B3A4E14AF83D86DF60069FA-->  <PRINTNAME><![CDATA[Smtp Connection Timeout]]></PRINTNAME>
+<!--A9108AC54B3A4E14AF83D86DF60069FA-->  <DESCRIPTION><![CDATA[Timeout used in SMTP server communication]]></DESCRIPTION>
+<!--A9108AC54B3A4E14AF83D86DF60069FA-->  <HELP><![CDATA[SMTP server communication timeout defined in seconds. After this timeout the email send process will stop.]]></HELP>
+<!--A9108AC54B3A4E14AF83D86DF60069FA-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--A9108AC54B3A4E14AF83D86DF60069FA-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--A9108AC54B3A4E14AF83D86DF60069FA--></AD_ELEMENT>
+
 <!--A92C853AF2C011DD81C5001D09C4A2FE--><AD_ELEMENT>
 <!--A92C853AF2C011DD81C5001D09C4A2FE-->  <AD_ELEMENT_ID><![CDATA[A92C853AF2C011DD81C5001D09C4A2FE]]></AD_ELEMENT_ID>
 <!--A92C853AF2C011DD81C5001D09C4A2FE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_FIELD.xml	Mon Jul 16 13:07:51 2018 +0200
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Wed Jul 18 10:15:25 2018 +0200
@@ -291764,6 +291764,36 @@
 <!--C7D7251DF056400BB756B611D3A48264-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--C7D7251DF056400BB756B611D3A48264--></AD_FIELD>
 
+<!--C7F62311B91C40F89D27D69E8B48638A--><AD_FIELD>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <AD_FIELD_ID><![CDATA[C7F62311B91C40F89D27D69E8B48638A]]></AD_FIELD_ID>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <NAME><![CDATA[Smtp Connection Timeout]]></NAME>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <DESCRIPTION><![CDATA[Timeout used in SMTP server communication]]></DESCRIPTION>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <HELP><![CDATA[SMTP server communication timeout defined in seconds. After this timeout the email send process will stop.]]></HELP>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <AD_TAB_ID><![CDATA[1000500000]]></AD_TAB_ID>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <AD_COLUMN_ID><![CDATA[DD8B47B6ECF745C0B401A06D37047AAA]]></AD_COLUMN_ID>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <AD_FIELDGROUP_ID><![CDATA[1000500000]]></AD_FIELDGROUP_ID>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <DISPLAYLENGTH><![CDATA[10]]></DISPLAYLENGTH>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <SEQNO><![CDATA[90]]></SEQNO>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <GRID_SEQNO><![CDATA[90]]></GRID_SEQNO>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--C7F62311B91C40F89D27D69E8B48638A-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--C7F62311B91C40F89D27D69E8B48638A--></AD_FIELD>
+
 <!--C81180C829FD44D48C9D04D09DA96A39--><AD_FIELD>
 <!--C81180C829FD44D48C9D04D09DA96A39-->  <AD_FIELD_ID><![CDATA[C81180C829FD44D48C9D04D09DA96A39]]></AD_FIELD_ID>
 <!--C81180C829FD44D48C9D04D09DA96A39-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/costing/LandedCostProcess.java	Mon Jul 16 13:07:51 2018 +0200
+++ b/src/org/openbravo/costing/LandedCostProcess.java	Wed Jul 18 10:15:25 2018 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2014-2017 Openbravo SLU
+ * All portions are Copyright (C) 2014-2018 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -114,6 +114,7 @@
       landedCost.setDocumentStatus("CO");
       landedCost.setProcessed(Boolean.TRUE);
       OBDal.getInstance().save(landedCost);
+      OBDal.getInstance().flush();
     } catch (JSONException ignore) {
     } finally {
       OBContext.restorePreviousMode();
--- a/src/org/openbravo/email/EmailEventManager.java	Mon Jul 16 13:07:51 2018 +0200
+++ b/src/org/openbravo/email/EmailEventManager.java	Wed Jul 18 10:15:25 2018 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2013 Openbravo SLU
+ * All portions are Copyright (C) 2013-2018 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -19,7 +19,6 @@
 
 package org.openbravo.email;
 
-import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -34,10 +33,10 @@
 import org.apache.log4j.Logger;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.erpCommon.utility.poc.EmailInfo;
 import org.openbravo.erpCommon.utility.poc.EmailManager;
 import org.openbravo.model.common.enterprise.EmailServerConfiguration;
 import org.openbravo.model.common.enterprise.Organization;
-import org.openbravo.utils.FormatUtilities;
 
 /**
  * This singleton class, is in charge of generating events to send emails.
@@ -86,32 +85,23 @@
     }
 
     try {
-      final String username = mailConfig.getSmtpServerAccount();
-      final String password = FormatUtilities.encryptDecrypt(mailConfig.getSmtpServerPassword(),
-          false);
-      final String connSecurity = mailConfig.getSmtpConnectionSecurity();
-      final int port = mailConfig.getSmtpPort().intValue();
-      final String senderAddress = mailConfig.getSmtpServerSenderAddress();
-      final String host = mailConfig.getSmtpServer();
-      final boolean auth = mailConfig.isSMTPAuthentification();
-
       boolean sent = false;
       for (EmailEventContentGenerator gen : getEmailGenerators(event, data)) {
         sent = true;
         log.debug("sending email for event " + event + " with generator " + gen);
 
+        final EmailInfo email = new EmailInfo.Builder().setSubject(gen.getSubject(data, event))
+          .setContent(gen.getBody(data, event))
+          .setContentType(gen.getContentType())
+          .setAttachments(gen.getAttachments(data, event))
+          .build();
+
         if (gen.isAsynchronous()) {
-          final String subject = gen.getSubject(data, event);
-          final String body = gen.getBody(data, event);
-          final String type = gen.getContentType();
-          final List<File> attachments = gen.getAttachments(data, event);
           Thread thread = new Thread(new Runnable() {
             @Override
             public void run() {
               try {
-                EmailManager.sendEmail(host, auth, username, password, connSecurity, port,
-                    senderAddress, recipient, null, null, null, subject, body, type, attachments,
-                    null, null);
+                EmailManager.sendEmail(mailConfig, email);
               } catch (Exception e) {
                 log.error(e.getMessage(), e);
               }
@@ -119,9 +109,7 @@
           });
           thread.start();
         } else {
-          EmailManager.sendEmail(host, auth, username, password, connSecurity, port, senderAddress,
-              recipient, null, null, null, gen.getSubject(data, event), gen.getBody(data, event),
-              gen.getContentType(), gen.getAttachments(data, event), null, null);
+          EmailManager.sendEmail(mailConfig, email);
         }
       }
       if (!sent) {
--- a/src/org/openbravo/erpCommon/ad_process/AlertProcess.java	Mon Jul 16 13:07:51 2018 +0200
+++ b/src/org/openbravo/erpCommon/ad_process/AlertProcess.java	Wed Jul 18 10:15:25 2018 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008-2017 Openbravo SLU 
+ * All portions are Copyright (C) 2008-2018 Openbravo SLU
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -19,7 +19,6 @@
 
 package org.openbravo.erpCommon.ad_process;
 
-import java.io.File;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -43,6 +42,7 @@
 import org.openbravo.erpCommon.utility.SequenceIdData;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.erpCommon.utility.poc.EmailManager;
+import org.openbravo.erpCommon.utility.poc.EmailInfo;
 import org.openbravo.model.ad.access.RoleOrganization;
 import org.openbravo.model.ad.access.User;
 import org.openbravo.model.ad.access.UserRoles;
@@ -241,7 +241,7 @@
    * @param conn
    * @throws Exception
    */
-  @SuppressWarnings({ "unchecked", "deprecation" })
+  @SuppressWarnings("deprecation")
   private void processAlert(AlertProcessData alertRule, ConnectionProvider conn) throws Exception {
     logger.log("Processing rule " + alertRule.name + "\n");
 
@@ -312,7 +312,8 @@
           // depending on the server), they are sent at the end, once all data is recollected, in
           // order to minimize problems/inconsistencies/NPE if the 'Alerts', 'AlertRecipient',
           // 'User' or 'UserRoles' columns change in the middle of the process.
-          final List<Object[]> emailsToSendList = new ArrayList<Object[]>();
+          final List<EmailInfo> emailsToSendList = new ArrayList<>();
+          EmailServerConfiguration mailConfig = null;
           OBContext.setAdminMode();
           try {
             // Getting the SMTP server parameters
@@ -330,7 +331,6 @@
               // first returned one), then for organization '0' (and use the first returned one) and
               // then for any other of the organization tree where current organization belongs to
               // (and use the first returned one).
-              EmailServerConfiguration mailConfig = null;
 
               for (EmailServerConfiguration currentOrgConfig : mailConfigList) {
                 if (adOrgId.equals(currentOrgConfig.getOrganization().getId())) {
@@ -368,7 +368,7 @@
                   continue;
                 }
 
-                final List<User> usersList = new ArrayList<User>();
+                final List<User> usersList = new ArrayList<>();
                 // If there is a 'Contact' established, take it, if not, take all users for the
                 // selected 'Role'
                 if (currentAlertRecipient.getUserContact() != null) {
@@ -448,29 +448,14 @@
 
                   alreadySentToList.add(targetUserEmail);
 
-                  final String host = mailConfig.getSmtpServer();
-                  final Boolean auth = mailConfig.isSMTPAuthentification();
-                  final String username = mailConfig.getSmtpServerAccount();
-                  final String password = FormatUtilities.encryptDecrypt(
-                      mailConfig.getSmtpServerPassword(), false);
-                  final String connSecurity = mailConfig.getSmtpConnectionSecurity();
-                  final int port = mailConfig.getSmtpPort().intValue();
-                  final String senderAddress = mailConfig.getSmtpServerSenderAddress();
-                  final String recipientTO = targetUserEmail;
-                  final String recipientCC = null;
-                  final String recipientBCC = null;
-                  final String replyTo = null;
-                  final String subject = "[OB Alert] " + alertRule.name;
-                  final String content = Utility.messageBD(conn, "AlertMailHead",
-                      targetUserClientLanguage) + "\n" + finalMessage;
-                  final String contentType = "text/plain; charset=utf-8";
-                  final List<File> attachments = null;
-                  final Date sentDate = new Date();
-                  final List<String> headerExtras = null;
+                  final EmailInfo email = new EmailInfo.Builder()
+                      .setRecipientTO(targetUserEmail)
+                      .setSubject("[OB Alert] " + alertRule.name)
+                      .setContent(
+                          Utility.messageBD(conn, "AlertMailHead", targetUserClientLanguage) + "\n"
+                              + finalMessage).setContentType("text/plain; charset=utf-8")
+                      .setSentDate(new Date()).build();
 
-                  final Object[] email = { host, auth, username, password, connSecurity, port,
-                      senderAddress, recipientTO, recipientCC, recipientBCC, replyTo, subject,
-                      content, contentType, attachments, sentDate, headerExtras };
                   emailsToSendList.add(email);
                 }
               }
@@ -481,16 +466,9 @@
             OBContext.restorePreviousMode();
           }
           // Send all the stored emails
-          for (Object[] emailToSend : emailsToSendList) {
+          for (EmailInfo emailToSend : emailsToSendList) {
             try {
-              EmailManager.sendEmail((String) emailToSend[0],
-                  ((Boolean) emailToSend[1]).booleanValue(), (String) emailToSend[2],
-                  (String) emailToSend[3], (String) emailToSend[4],
-                  ((Number) emailToSend[5]).intValue(), (String) emailToSend[6],
-                  (String) emailToSend[7], (String) emailToSend[8], (String) emailToSend[9],
-                  (String) emailToSend[10], (String) emailToSend[11], (String) emailToSend[12],
-                  (String) emailToSend[13], (List<File>) emailToSend[14], (Date) emailToSend[15],
-                  (List<String>) emailToSend[16]);
+              EmailManager.sendEmail(mailConfig, emailToSend);
             } catch (Exception exception) {
               log4j.error(exception);
               final String exceptionClass = exception.getClass().toString().replace("class ", "");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/utility/poc/EmailInfo.java	Wed Jul 18 10:15:25 2018 +0200
@@ -0,0 +1,179 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2018 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.erpCommon.utility.poc;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * This class contains all info required to generate an email to send. This includes data to
+ * generate the header (recipient, CC, BCC, replyTo, date and extra fields) and the body (subject,
+ * content, contentType and attachments)
+ *
+ * To create a new instance of this class use {@link EmailInfo.Builder}
+ */
+public class EmailInfo {
+  private String recipientTO;
+  private String recipientCC;
+  private String recipientBCC;
+  private String replyTo;
+  private String subject;
+  private String content;
+  private String contentType;
+  private List<File> attachments;
+  private Date sentDate;
+  private List<String> headerExtras;
+
+  private EmailInfo(String recipientTO, String recipientCC, String recipientBCC, String replyTo,
+      String subject, String content, String contentType, List<File> attachments, Date sentDate,
+      List<String> headerExtras) {
+    this.recipientTO = recipientTO;
+    this.recipientCC = recipientCC;
+    this.recipientBCC = recipientBCC;
+    this.replyTo = replyTo;
+    this.subject = subject;
+    this.content = content;
+    this.contentType = contentType;
+    this.attachments = attachments;
+    this.sentDate = sentDate;
+    this.headerExtras = headerExtras;
+  }
+
+  public String getRecipientTO() {
+    return recipientTO;
+  }
+
+  public String getRecipientCC() {
+    return recipientCC;
+  }
+
+  public String getRecipientBCC() {
+    return recipientBCC;
+  }
+
+  public String getReplyTo() {
+    return replyTo;
+  }
+
+  public String getSubject() {
+    return subject;
+  }
+
+  public String getContent() {
+    return content;
+  }
+
+  public String getContentType() {
+    return contentType;
+  }
+
+  public List<File> getAttachments() {
+    return attachments;
+  }
+
+  public Date getSentDate() {
+    return sentDate;
+  }
+
+  public List<String> getHeaderExtras() {
+    return headerExtras;
+  }
+
+  /**
+   * Builder class used to create and initialize a EmailInfo instance.
+   */
+  public static class Builder {
+    private String recipientTO = null;
+    private String recipientCC = null;
+    private String recipientBCC = null;
+    private String replyTo = null;
+    private String subject = null;
+    private String content = null;
+    private String contentType = null;
+    private List<File> attachments = new ArrayList<>();
+    private Date sentDate = null;
+    private List<String> headerExtras = new ArrayList<>();
+
+    public Builder() {
+    }
+
+    public Builder setRecipientTO(String recipientTO) {
+      this.recipientTO = recipientTO;
+      return this;
+    }
+
+    public Builder setRecipientCC(String recipientCC) {
+      this.recipientCC = recipientCC;
+      return this;
+    }
+
+    public Builder setRecipientBCC(String recipientBCC) {
+      this.recipientBCC = recipientBCC;
+      return this;
+    }
+
+    public Builder setReplyTo(String replyTo) {
+      this.replyTo = replyTo;
+      return this;
+    }
+
+    public Builder setSubject(String subject) {
+      this.subject = subject;
+      return this;
+    }
+
+    public Builder setContent(String content) {
+      this.content = content;
+      return this;
+    }
+
+    public Builder setContentType(String contentType) {
+      this.contentType = contentType;
+      return this;
+    }
+
+    public Builder setAttachments(List<File> attachments) {
+      this.attachments = attachments;
+      return this;
+    }
+
+    public Builder setSentDate(Date sentDate) {
+      this.sentDate = sentDate;
+      return this;
+    }
+
+    public Builder setHeaderExtras(List<String> headerExtras) {
+      this.headerExtras = headerExtras;
+      return this;
+    }
+
+    /**
+     * Generates a EmailInfo instance initialized with all fields set using the set* methods.
+     * Otherwise they will be initialized as null or as an empty array for the List<> fields.
+     * 
+     * @return a new EmailInfo instance
+     */
+    public EmailInfo build() {
+      return new EmailInfo(recipientTO, recipientCC, recipientBCC, replyTo, subject, content,
+          contentType, attachments, sentDate, headerExtras);
+    }
+  }
+}
--- a/src/org/openbravo/erpCommon/utility/poc/EmailManager.java	Mon Jul 16 13:07:51 2018 +0200
+++ b/src/org/openbravo/erpCommon/utility/poc/EmailManager.java	Wed Jul 18 10:15:25 2018 +0200
@@ -40,17 +40,63 @@
 import javax.servlet.ServletException;
 
 import org.apache.log4j.Logger;
+import org.openbravo.dal.core.OBContext;
 import org.openbravo.database.ConnectionProvider;
+import org.openbravo.email.EmailUtils;
+import org.openbravo.model.common.enterprise.EmailServerConfiguration;
 import org.openbravo.utils.FormatUtilities;
 
 public class EmailManager {
   private static Logger log4j = Logger.getLogger(EmailManager.class);
-  private static final long SMTP_TIMEOUT = TimeUnit.MINUTES.toMillis(10);
+  private static final Long DEFAULT_SMTP_TIMEOUT = TimeUnit.MINUTES.toMillis(10);
 
+  /**
+   * Sends an email using the given SMTP Server configuration and the email definition contained in
+   * the email parameter.
+   * 
+   * @param conf
+   *          The SMTP Server configuration
+   * @param email
+   *          The data of the email being sent
+   * @throws Exception
+   */
+  public static void sendEmail(EmailServerConfiguration conf, EmailInfo email) throws Exception {
+
+    String decryptedPassword = FormatUtilities.encryptDecrypt(conf.getSmtpServerPassword(), false);
+    Long timeoutMillis = TimeUnit.SECONDS.toMillis(conf.getSmtpConnectionTimeout());
+
+    sendEmail(conf.getSmtpServer(), conf.isSMTPAuthentification(), conf.getSmtpServerAccount(),
+        decryptedPassword, conf.getSmtpConnectionSecurity(), conf.getSmtpPort().intValue(),
+        conf.getSmtpServerSenderAddress(), email.getRecipientTO(), email.getRecipientCC(),
+        email.getRecipientBCC(), email.getReplyTo(), email.getSubject(), email.getContent(),
+        email.getContentType(), email.getAttachments(), email.getSentDate(),
+        email.getHeaderExtras(), timeoutMillis.intValue());
+  }
+
+  /**
+   * @deprecated Use {@link #sendEmail(EmailServerConfiguration, EmailInfo)} instead.
+   */
+  @Deprecated
   public static void sendEmail(String host, boolean auth, String username, String password,
       String connSecurity, int port, String senderAddress, String recipientTO, String recipientCC,
       String recipientBCC, String replyTo, String subject, String content, String contentType,
       List<File> attachments, Date sentDate, List<String> headerExtras) throws Exception {
+
+    EmailServerConfiguration configuration = EmailUtils.getEmailConfiguration(OBContext
+        .getOBContext().getCurrentOrganization());
+    Long timeoutMillis = (configuration != null) ? TimeUnit.SECONDS.toMillis(configuration
+        .getSmtpConnectionTimeout()) : DEFAULT_SMTP_TIMEOUT;
+
+    sendEmail(host, auth, username, password, connSecurity, port, senderAddress, recipientTO,
+        recipientCC, recipientBCC, replyTo, subject, content, contentType, attachments, sentDate,
+        headerExtras, timeoutMillis.intValue());
+  }
+
+  private static void sendEmail(String host, boolean auth, String username, String password,
+      String connSecurity, int port, String senderAddress, String recipientTO, String recipientCC,
+      String recipientBCC, String replyTo, String subject, String content, String contentType,
+      List<File> attachments, Date sentDate, List<String> headerExtras, int smtpServerTimeout)
+      throws Exception {
     String localReplyTo = replyTo;
     String localRecipientTO = recipientTO;
     String localRecipientCC = recipientCC;
@@ -65,10 +111,12 @@
       }
       props.put("mail.transport.protocol", "smtp");
       props.put("mail.smtp.host", host);
-      props.put("mail.smtp.port", port);
+      props.put("mail.smtp.port", String.valueOf(port));
 
-      props.put("mail.smtp.timeout", SMTP_TIMEOUT);
-      props.put("mail.smtp.connectiontimeout", SMTP_TIMEOUT);
+      String timeout = String.valueOf(smtpServerTimeout);
+      props.put("mail.smtp.timeout", timeout);
+      props.put("mail.smtp.connectiontimeout", timeout);
+      props.put("mail.smtp.writetimeout", timeout);
 
       if (localConnSecurity != null) {
         localConnSecurity = localConnSecurity.replaceAll(", *", ",");
--- a/src/org/openbravo/erpCommon/utility/reporting/printing/PrintController.java	Mon Jul 16 13:07:51 2018 +0200
+++ b/src/org/openbravo/erpCommon/utility/reporting/printing/PrintController.java	Wed Jul 18 10:15:25 2018 +0200
@@ -8,7 +8,7 @@
  * either express or implied. See the License for the specific language
  * governing rights and limitations under the License. The Original Code is
  * Openbravo ERP. The Initial Developer of the Original Code is Openbravo SLU All
- * portions are Copyright (C) 2008-2017 Openbravo SLU All Rights Reserved.
+ * portions are Copyright (C) 2008-2018 Openbravo SLU All Rights Reserved.
  * Contributor(s): ______________________________________.
  */
 package org.openbravo.erpCommon.utility.reporting.printing;
@@ -28,8 +28,8 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Vector;
 import java.util.Map.Entry;
-import java.util.Vector;
 import java.util.regex.Matcher;
 
 import javax.servlet.ServletConfig;
@@ -38,6 +38,10 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import net.sf.jasperreports.engine.JRException;
+import net.sf.jasperreports.engine.JasperPrint;
+import net.sf.jasperreports.export.SimplePdfExporterConfiguration;
+
 import org.apache.commons.fileupload.FileItem;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
@@ -58,14 +62,15 @@
 import org.openbravo.erpCommon.utility.SequenceIdData;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.erpCommon.utility.poc.EmailManager;
+import org.openbravo.erpCommon.utility.poc.EmailInfo;
 import org.openbravo.erpCommon.utility.poc.EmailType;
 import org.openbravo.erpCommon.utility.reporting.DocumentType;
 import org.openbravo.erpCommon.utility.reporting.Report;
-import org.openbravo.erpCommon.utility.reporting.Report.OutputTypeEnum;
 import org.openbravo.erpCommon.utility.reporting.ReportManager;
 import org.openbravo.erpCommon.utility.reporting.ReportingException;
 import org.openbravo.erpCommon.utility.reporting.TemplateData;
 import org.openbravo.erpCommon.utility.reporting.TemplateInfo;
+import org.openbravo.erpCommon.utility.reporting.Report.OutputTypeEnum;
 import org.openbravo.erpCommon.utility.reporting.TemplateInfo.EmailDefinition;
 import org.openbravo.exception.NoConnectionAvailableException;
 import org.openbravo.model.ad.system.Language;
@@ -74,13 +79,8 @@
 import org.openbravo.model.common.enterprise.EmailServerConfiguration;
 import org.openbravo.model.common.enterprise.EmailTemplate;
 import org.openbravo.model.common.enterprise.Organization;
-import org.openbravo.utils.FormatUtilities;
 import org.openbravo.xmlEngine.XmlDocument;
 
-import net.sf.jasperreports.engine.JRException;
-import net.sf.jasperreports.engine.JasperPrint;
-import net.sf.jasperreports.export.SimplePdfExporterConfiguration;
-
 @SuppressWarnings("serial")
 public class PrintController extends HttpSecureAppServlet {
   private final Map<String, TemplateData[]> differentDocTypes = new HashMap<String, TemplateData[]>();
@@ -760,46 +760,16 @@
     emailBody = emailBody.replaceAll("@doc_desc@",
         Matcher.quoteReplacement(report.getDocDescription()));
 
-    String host = null;
-    boolean auth = true;
-    String username = null;
-    String password = null;
-    String connSecurity = null;
-    int port = 25;
-
     OBContext.setAdminMode(true);
+    EmailServerConfiguration mailConfig = null;
     try {
-      final EmailServerConfiguration mailConfig = OBDal.getInstance().get(
-          EmailServerConfiguration.class, vars.getStringParameter("fromEmailId"));
-
-      host = mailConfig.getSmtpServer();
-
-      if (!mailConfig.isSMTPAuthentification()) {
-        auth = false;
-      }
-      username = mailConfig.getSmtpServerAccount();
-      password = FormatUtilities.encryptDecrypt(mailConfig.getSmtpServerPassword(), false);
-      connSecurity = mailConfig.getSmtpConnectionSecurity();
-      port = mailConfig.getSmtpPort().intValue();
+      mailConfig = OBDal.getInstance().get(EmailServerConfiguration.class,
+          vars.getStringParameter("fromEmailId"));
     } finally {
       OBContext.restorePreviousMode();
     }
 
-    final String recipientTO = toEmail;
-    final String recipientCC = vars.getStringParameter("ccEmail");
-    final String recipientBCC = vars.getStringParameter("bccEmail");
-    final String replyTo = replyToEmail;
-    final String contentType = "text/plain; charset=utf-8";
-
-    if (log4j.isDebugEnabled()) {
-      log4j.debug("From: " + senderAddress);
-      log4j.debug("Recipient TO (contact email): " + recipientTO);
-      log4j.debug("Recipient CC: " + recipientCC);
-      log4j.debug("Recipient BCC (user email): " + recipientBCC);
-      log4j.debug("Reply-to (sales rep email): " + replyTo);
-    }
-
-    List<File> attachments = new ArrayList<File>();
+    List<File> attachments = new ArrayList<>();
     attachments.add(new File(attachmentFileLocation));
 
     if (object != null) {
@@ -811,10 +781,22 @@
       }
     }
 
+    final EmailInfo email = new EmailInfo.Builder().setRecipientTO(toEmail)
+        .setRecipientCC(vars.getStringParameter("ccEmail"))
+        .setRecipientBCC(vars.getStringParameter("bccEmail")).setReplyTo(replyToEmail)
+        .setSubject(emailSubject).setContent(emailBody).setContentType("text/plain; charset=utf-8")
+        .setAttachments(attachments).setSentDate(new Date()).build();
+
+    if (log4j.isDebugEnabled()) {
+      log4j.debug("From: " + senderAddress);
+      log4j.debug("Recipient TO (contact email): " + email.getRecipientTO());
+      log4j.debug("Recipient CC: " + email.getRecipientCC());
+      log4j.debug("Recipient BCC (user email): " + email.getRecipientBCC());
+      log4j.debug("Reply-to (sales rep email): " + email.getReplyTo());
+    }
+
     try {
-      EmailManager.sendEmail(host, auth, username, password, connSecurity, port, senderAddress,
-          recipientTO, recipientCC, recipientBCC, replyTo, emailSubject, emailBody, contentType,
-          attachments, new Date(), null);
+      EmailManager.sendEmail(mailConfig, email);
     } catch (Exception exception) {
       log4j.error(exception);
       final String exceptionClass = exception.getClass().toString().replace("class ", "");
@@ -841,8 +823,9 @@
         log4j.debug("New email id: " + newEmailId);
 
       EmailData.insertEmail(conn, this, newEmailId, vars.getClient(), report.getOrgId(),
-          vars.getUser(), EmailType.OUTGOING.getStringValue(), replyTo, recipientTO, recipientCC,
-          recipientBCC, Utility.formatDate(new Date(), "yyyyMMddHHmmss"), emailSubject, emailBody,
+          vars.getUser(), EmailType.OUTGOING.getStringValue(), email.getReplyTo(),
+          email.getRecipientTO(), email.getRecipientCC(), email.getRecipientBCC(),
+          Utility.formatDate(new Date(), "yyyyMMddHHmmss"), emailSubject, emailBody,
           report.getBPartnerId(),
           ToolsData.getTableId(this, report.getDocumentType().getTableName()),
           documentData.documentId);