From 878e067683780fdeb93882a5c8b1ce62512b67cd Mon Sep 17 00:00:00 2001 From: Vova Perebykivskiy Date: Tue, 10 Nov 2015 11:56:42 +0200 Subject: [PATCH] Add possibility to disable E-mail sending with Maven compiler option. --- HACKING.rst | 3 ++ .../business/common/Configuration.java | 42 +++++++++++++------ .../libreplan-business-spring-config.xml | 3 ++ .../org/libreplan/importers/SendEmail.java | 12 +++--- pom.xml | 1 + 5 files changed, 42 insertions(+), 19 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index b6aec7557..4e2d7efdf 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -506,6 +506,9 @@ example: mvn -Ddefault.passwordsControl=false -Ddefault.exampleUsersDisabled=false clean install +* Set *default.emailSendingDisabled* to true:: + + mvn -Ddefault.emailSendingDisabled=true clean install Tests ----- diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/Configuration.java b/libreplan-business/src/main/java/org/libreplan/business/common/Configuration.java index 80c084ffd..680de01af 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/common/Configuration.java +++ b/libreplan-business/src/main/java/org/libreplan/business/common/Configuration.java @@ -26,16 +26,19 @@ import org.apache.commons.lang.BooleanUtils; /** * This is a singleton that contains the compilation options passed from Maven. * - * Currently we have two options: + * Currently we have three options: * * * @author Susana Montes Pedreira * @author Manuel Rego Casasnovas + * @author Vova Perebykivskiy */ + public class Configuration { private static final Configuration singleton = new Configuration(); @@ -44,6 +47,8 @@ public class Configuration { private Boolean exampleUsersDisabled; + private Boolean emailSendingDisabled; + private Configuration() { } @@ -59,22 +64,13 @@ public class Configuration { return singleton.getDefaultPasswordsControl() != null ? singleton .getDefaultPasswordsControl() : true; } - + public Boolean getDefaultPasswordsControl() { + return defaultPasswordsControl; + } public void setDefaultPasswordsControl(Boolean defaultPasswordsControl) { this.defaultPasswordsControl = defaultPasswordsControl; } - public Boolean getDefaultPasswordsControl() { - return defaultPasswordsControl; - } - - public void setExampleUsersDisabled(Boolean exampleUsersDisabled) { - this.exampleUsersDisabled = exampleUsersDisabled; - } - - public Boolean getExampleUsersDisabled() { - return exampleUsersDisabled; - } /** * Returns the value of example users disabled compilation option @@ -82,5 +78,25 @@ public class Configuration { public static boolean isExampleUsersDisabled() { return BooleanUtils.isNotFalse(singleton.getExampleUsersDisabled()); } + public Boolean getExampleUsersDisabled() { + return exampleUsersDisabled; + } + public void setExampleUsersDisabled(Boolean exampleUsersDisabled) { + this.exampleUsersDisabled = exampleUsersDisabled; + } + + + /** + * Returns the value of E-mail sending disabled compilation option + */ + public static boolean isEmailSendingDisabled(){ + return BooleanUtils.isNotFalse(singleton.getEmailSendingDisabled()); + } + public Boolean getEmailSendingDisabled(){ + return emailSendingDisabled; + } + public void setEmailSendingDisabled(Boolean emailSendingDisabled){ + this.emailSendingDisabled = emailSendingDisabled; + } } diff --git a/libreplan-business/src/main/resources/libreplan-business-spring-config.xml b/libreplan-business/src/main/resources/libreplan-business-spring-config.xml index 6bc5398f3..8323c6d05 100644 --- a/libreplan-business/src/main/resources/libreplan-business-spring-config.xml +++ b/libreplan-business/src/main/resources/libreplan-business-spring-config.xml @@ -146,6 +146,9 @@ ${default.exampleUsersDisabled} + + ${default.emailSendingDisabled} + true true + false UTF-8