[Schmitzm-commits] r2412 - in trunk/schmitzm-core/src/main: java/de/schmitzm/net/mail resources/de/schmitzm/net/mail/resource/locales
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Wed Mar 4 10:34:35 CET 2015
Author: mojays
Date: 2015-03-04 10:34:35 +0100 (Wed, 04 Mar 2015)
New Revision: 2412
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/net/mail/MailUtil.java
trunk/schmitzm-core/src/main/resources/de/schmitzm/net/mail/resource/locales/MailResourceBundle.properties
trunk/schmitzm-core/src/main/resources/de/schmitzm/net/mail/resource/locales/MailResourceBundle_de.properties
Log:
MailUtil: check for total size of desktop mail
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/net/mail/MailUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/net/mail/MailUtil.java 2015-03-04 09:34:00 UTC (rev 2411)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/net/mail/MailUtil.java 2015-03-04 09:34:35 UTC (rev 2412)
@@ -80,7 +80,13 @@
public static final int MAX_DESKTOP_MAIL_BODY_SIZE = 1500;
- /**
+ /**
+ * Maximale Gesamt-Laenge einer Desktop-Mail, falls dieser mit mailto:// - URL
+ * verschickt wird.
+ */
+ public static final int MAX_DESKTOP_MAIL_SIZE = 1900;
+
+ /**
* Use a {@link Mailer} instance if you youse this method often.
*
* @param recipientsAddress
@@ -348,12 +354,26 @@
// add TO addresses at the beginning
if ( !StringUtils.isBlank(mailDestAddr) )
uriMailStr = mailDestAddr + uriMailStr;
-
+
+ // check total length
+ if ( uriMailStr.length() > MAX_DESKTOP_MAIL_SIZE ) {
+ // try to cut body (at the end)
+ if (uriMailStr.length() - mailBody.length() <= MAX_DESKTOP_MAIL_SIZE)
+ uriMailStr = uriMailStr.substring(0, MAX_DESKTOP_MAIL_SIZE)
+ + "...\n[...]";
+ else
+ // recipients (+ subject) to long
+ throw new Exception(RESOURCE.getString("MailUtil.DesktopMail.SizeError"));
+ }
+
+
URI uriMailTo = new URI("mailto", uriMailStr, null);
Desktop.getDesktop().mail(uriMailTo);
+ //System.out.println(uriMailStr);
} catch (Exception err) {
- ExceptionDialog.show(null, err, null,
- RESOURCE.getString("MailUtil.DesktopMail.CreationError"));
+ ExceptionDialog.show(null, err,
+ RESOURCE.getString("MailUtil.DesktopMail.CreationError"),
+ err.getLocalizedMessage() );
}
}
Modified: trunk/schmitzm-core/src/main/resources/de/schmitzm/net/mail/resource/locales/MailResourceBundle.properties
===================================================================
--- trunk/schmitzm-core/src/main/resources/de/schmitzm/net/mail/resource/locales/MailResourceBundle.properties 2015-03-04 09:34:00 UTC (rev 2411)
+++ trunk/schmitzm-core/src/main/resources/de/schmitzm/net/mail/resource/locales/MailResourceBundle.properties 2015-03-04 09:34:35 UTC (rev 2412)
@@ -34,6 +34,7 @@
# ---------------------------------------------------------------
MailUtil.DesktopMail.NotSupported=Mailing is not supported on your operating system!
-MailUtil.DesktopMail.CreationError=Error during creation of exception mail
+MailUtil.DesktopMail.CreationError=Error during creation of mail
+MailUtil.DesktopMail.SizeError=To many recipients for desktop mail!
MailUtil.DesktopBrowser.NotSupported=Opening an URL in browser is not supported on your operating system!
MailUtil.DesktopBrowser.BrowseError=Error during browsing the URL
Modified: trunk/schmitzm-core/src/main/resources/de/schmitzm/net/mail/resource/locales/MailResourceBundle_de.properties
===================================================================
--- trunk/schmitzm-core/src/main/resources/de/schmitzm/net/mail/resource/locales/MailResourceBundle_de.properties 2015-03-04 09:34:00 UTC (rev 2411)
+++ trunk/schmitzm-core/src/main/resources/de/schmitzm/net/mail/resource/locales/MailResourceBundle_de.properties 2015-03-04 09:34:35 UTC (rev 2412)
@@ -59,6 +59,7 @@
# ----------------------------------------------------
MailUtil.DesktopMail.NotSupported=Mailen wird von Ihrem Betriebssystem leider nicht unterst\u00FCtzt.
-MailUtil.DesktopMail.CreationError=Fehler beim Erstellen der Fehler-Mail
+MailUtil.DesktopMail.CreationError=Fehler beim Erstellen der Mail
+MailUtil.DesktopMail.SizeError=Zu viele Empf\u00E4nger f\u00FCr eine Desktop-Mail!
MailUtil.DesktopBrowser.NotSupported=Das \u00D6ffnen einer URL im Browser wird von Ihrem Betriebssystem leider nicht unterst\u00FCtzt.
MailUtil.DesktopBrowser.BrowseError=Fehler beim \u00D6ffnen der URL im Browser
More information about the Schmitzm-commits
mailing list