From 5712baf9d8ebef314c21599cfc22aa58cb41c726 Mon Sep 17 00:00:00 2001 From: dolfinus Date: Mon, 3 Feb 2020 15:45:34 +0300 Subject: [PATCH] Fix MailSender class methods return values --- CHANGELOG.md | 2 +- .../{Mail.groovy => MailSender.groovy} | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) rename src/org/camunda/latera/bss/connectors/{Mail.groovy => MailSender.groovy} (92%) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa3f5a46..79069e0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ v1.4.1 [unreleased] - [#d58ab24](https://github.com/latera/camunda-ext/commit/d58ab24) Fix hid.Hydra#createEquipment method - [#19c0746](https://github.com/latera/camunda-ext/commit/19c0746) Fix helpers.Hydra#fetchSubscription method - [#12](https://github.com/latera/camunda-ext/pull/12) Fix helpers.Hydra#parseRegion method - +- [#19](https://github.com/latera/camunda-ext/pull/19) Fix MailSender class methods return values v1.4 [2020-01-13] ------------------- ### Breaking changes diff --git a/src/org/camunda/latera/bss/connectors/Mail.groovy b/src/org/camunda/latera/bss/connectors/MailSender.groovy similarity index 92% rename from src/org/camunda/latera/bss/connectors/Mail.groovy rename to src/org/camunda/latera/bss/connectors/MailSender.groovy index 8a537840..39a95dad 100644 --- a/src/org/camunda/latera/bss/connectors/Mail.groovy +++ b/src/org/camunda/latera/bss/connectors/MailSender.groovy @@ -73,7 +73,7 @@ class MailSender { this.setFrom(user) } - MailSender getHost() { + String getHost() { return this.host } @@ -83,7 +83,7 @@ class MailSender { return this } - MailSender getPort() { + Integer getPort() { return this.port } @@ -97,7 +97,7 @@ class MailSender { return setPort(port.toInteger()) } - MailSender getUser() { + String getUser() { return this.user } @@ -135,10 +135,10 @@ class MailSender { return this } - MailSender addFile(CharSequence filename, Object datasource){ + MailSender addFile(CharSequence name, Object datasource) { MimeBodyPart part = new MimeBodyPart() part.setDataHandler(new DataHandler(datasource, 'application/octet-stream')) - part.setFileName(filename.toString()) + part.setFileName(MimeUtility.encodeText(name, 'UTF-8', null)) multipart.addBodyPart(part) return this } @@ -152,15 +152,20 @@ class MailSender { return this } - void send(){ + Boolean send() { + Boolean result = true Transport transport = session.getTransport('smtp') transport.connect(host, port, user, password) try { message.setContent(multipart) transport.sendMessage(message, message.getAllRecipients()) - } - finally { + } catch (Exception e) { + logger.error(e) + result = false + } finally { transport.close() } + + return result } }