Skip to content
Snippets Groups Projects
Commit 9d893948 authored by kohleman's avatar kohleman
Browse files

added: sending email to admin when tracker fails

SVN: 23443
parent bc38abc7
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,10 @@ public class Parameters ...@@ -37,6 +37,10 @@ public class Parameters
private static final String PERMLINK_URL = "permlink-url"; private static final String PERMLINK_URL = "permlink-url";
private static final String TRACKING_ADMIN_EMAIL = "tracking-admin-email";
private static final String NOTIFICATION_EMAIL_FROM = "notification-email-from";
private final String openbisUser; private final String openbisUser;
private final String openbisPassword; private final String openbisPassword;
...@@ -47,6 +51,10 @@ public class Parameters ...@@ -47,6 +51,10 @@ public class Parameters
private final IMailClient mailClient; private final IMailClient mailClient;
private final String adminEmail;
private final String notificationEmail;
public Parameters(Properties props) public Parameters(Properties props)
{ {
this.openbisUser = getMandatoryProperty(props, OPENBIS_USER); this.openbisUser = getMandatoryProperty(props, OPENBIS_USER);
...@@ -54,6 +62,8 @@ public class Parameters ...@@ -54,6 +62,8 @@ public class Parameters
this.openbisServerURL = getMandatoryProperty(props, OPENBIS_SERVER_URL); this.openbisServerURL = getMandatoryProperty(props, OPENBIS_SERVER_URL);
this.permlinkURL = PropertyUtils.getProperty(props, PERMLINK_URL, openbisServerURL); this.permlinkURL = PropertyUtils.getProperty(props, PERMLINK_URL, openbisServerURL);
this.mailClient = new MailClient(props); this.mailClient = new MailClient(props);
this.adminEmail = PropertyUtils.getProperty(props, TRACKING_ADMIN_EMAIL);
this.notificationEmail = PropertyUtils.getProperty(props, NOTIFICATION_EMAIL_FROM);
} }
public String getOpenbisUser() public String getOpenbisUser()
...@@ -80,4 +90,15 @@ public class Parameters ...@@ -80,4 +90,15 @@ public class Parameters
{ {
return permlinkURL; return permlinkURL;
} }
public String getAdminEmail()
{
return adminEmail;
}
public String getNotificationEmail()
{
return notificationEmail;
}
} }
...@@ -20,6 +20,8 @@ import java.io.File; ...@@ -20,6 +20,8 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
...@@ -30,6 +32,7 @@ import ch.ethz.bsse.cisd.dsu.tracking.email.IEntityTrackingEmailGenerator; ...@@ -30,6 +32,7 @@ import ch.ethz.bsse.cisd.dsu.tracking.email.IEntityTrackingEmailGenerator;
import ch.ethz.bsse.cisd.dsu.tracking.utils.LogUtils; import ch.ethz.bsse.cisd.dsu.tracking.utils.LogUtils;
import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
import ch.systemsx.cisd.common.logging.LogInitializer; import ch.systemsx.cisd.common.logging.LogInitializer;
import ch.systemsx.cisd.common.mail.EMailAddress;
import ch.systemsx.cisd.common.mail.IMailClient; import ch.systemsx.cisd.common.mail.IMailClient;
import ch.systemsx.cisd.common.spring.HttpInvokerUtils; import ch.systemsx.cisd.common.spring.HttpInvokerUtils;
import ch.systemsx.cisd.common.utilities.PropertyUtils; import ch.systemsx.cisd.common.utilities.PropertyUtils;
...@@ -129,13 +132,24 @@ public class TrackingClient ...@@ -129,13 +132,24 @@ public class TrackingClient
private static EnvironmentFailureException createAuthentificationException(Parameters params, private static EnvironmentFailureException createAuthentificationException(Parameters params,
Exception exOrNull) Exception exOrNull)
{ {
List<EMailAddress> adminEmails = new ArrayList<EMailAddress>();
for (String adminEmail : params.getAdminEmail().split(","))
{
adminEmails.add(new EMailAddress(adminEmail.trim()));
}
String exceptionMsg = String exceptionMsg =
(exOrNull == null) ? "" : " Unexpected exception has occured: " (exOrNull == null) ? "" : " Unexpected exception has occured: "
+ exOrNull.getMessage(); + exOrNull.getMessage();
return LogUtils
.environmentError( EnvironmentFailureException ret =
LogUtils.environmentError(
"Cannot authentificate in openBIS as a user '%s'. Check that the password is correct and that openBIS service URL is correct.%s", "Cannot authentificate in openBIS as a user '%s'. Check that the password is correct and that openBIS service URL is correct.%s",
params.getOpenbisUser(), exceptionMsg); params.getOpenbisUser(), exceptionMsg);
IMailClient emailClient = params.getMailClient();
emailClient.sendEmailMessage("[] DSU Tracking client NOT working",
ret.getLocalizedMessage(), null, new EMailAddress(params.getNotificationEmail()),
(EMailAddress[]) adminEmails.toArray());
return ret;
} }
} }
...@@ -17,6 +17,9 @@ notification-email-reply-to = <admin@address.ch> ...@@ -17,6 +17,9 @@ notification-email-reply-to = <admin@address.ch>
# subject of all the notification emails # subject of all the notification emails
notification-email-subject = Status report of your sequencing order notification-email-subject = Status report of your sequencing order
# if the tracking client fails an email will be sent out to these recipients
tracking-admin-email = <admin1@address.ch>, <admin2@address.ch>
# Recipients that will receive notifications when entity connected with sequencing sample # Recipients that will receive notifications when entity connected with sequencing sample
# with certain AFFILIATION value. Property key should contain affiliation vocabulary term code # with certain AFFILIATION value. Property key should contain affiliation vocabulary term code
# with '-affiliation-notification-email-contact' suffix, e.g. for 'FMI' affiliation: # with '-affiliation-notification-email-contact' suffix, e.g. for 'FMI' affiliation:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment