Add possibility to disable E-mail sending with Maven compiler option.
This commit is contained in:
parent
821290f75a
commit
878e067683
5 changed files with 42 additions and 19 deletions
|
|
@ -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
|
||||
-----
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
* <ul>
|
||||
* <li>Enable/Disable the warning changing default password</li>
|
||||
* <li>Enable/Disable default users (such as wsreader, wswriter,
|
||||
* wssubcontracting, manager, hresources, outsourcing and reports)</li>
|
||||
* <li>Enable/Disable E-mail sending functionality</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,6 +146,9 @@
|
|||
<property name="exampleUsersDisabled">
|
||||
<value>${default.exampleUsersDisabled}</value>
|
||||
</property>
|
||||
<property name="emailSendingDisabled">
|
||||
<value>${default.emailSendingDisabled}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="scenarioManager"
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.libreplan.importers;
|
||||
|
||||
import org.libreplan.business.common.Configuration;
|
||||
import org.libreplan.business.common.daos.IConnectorDAO;
|
||||
import org.libreplan.business.common.entities.Connector;
|
||||
import org.libreplan.business.common.entities.ConnectorProperty;
|
||||
|
|
@ -80,13 +81,12 @@ public class SendEmail implements ISendEmail {
|
|||
|
||||
@Override
|
||||
public void sendEmail() {
|
||||
|
||||
if ( !Configuration.isEmailSendingDisabled() ){
|
||||
notifications = emailNotificationModel.getAll();
|
||||
|
||||
for (int i = 0; i < notifications.size(); i++) composeMessageForUser(notifications.get(i));
|
||||
|
||||
deleteAllNotificationsAfterSending();
|
||||
}
|
||||
}
|
||||
|
||||
private void composeMessageForUser(EmailNotification notification){
|
||||
|
||||
|
|
|
|||
1
pom.xml
1
pom.xml
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
<default.passwordsControl>true</default.passwordsControl>
|
||||
<default.exampleUsersDisabled>true</default.exampleUsersDisabled>
|
||||
<default.emailSendingDisabled>false</default.emailSendingDisabled>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue