NIH | National Cancer Institute | NCI Wiki  

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Scrollbar
iconsfalse

Page info
title
title

Section
Column
width75%
Panel
titleContents of this Page
Table of Contents
minLevel2
Column
Align
alignright
Include Page
Menu LexEVS 6.0 CTS2 to Include
Menu LexEVS 6.0 CTS2 to Include

...

{scrollbar:icons=false}
Code Block
package org.lexevs.alert;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import org.LexGrid.LexBIG.Extensions.Generic.GenericExtension;
import org.lexevs.dao.database.service.event.DatabaseServiceEventListener;
import org.lexevs.dao.database.service.event.codingscheme.CodingSchemeUpdateEvent;
import org.lexevs.dao.database.service.listener.DefaultServiceEventListener;

public class MailAlertExtension extends DefaultServiceEventListener implements GenericExtension, DatabaseServiceEventListener{

	private static final long serialVersionUID = 6752732957279346146L;

	public static void main(String[] args) {
		MailAlertExtension ext = new MailAlertExtension();
		ext.onCodingSchemeUpdate(null);
	}
	
	public boolean onCodingSchemeUpdate(CodingSchemeUpdateEvent event) {
		try {
			
			Properties props = System.getProperties();
			props.put("mail.smtp.host", "your.host.org");
			props.put("mail.smtp.port", "25");

			Session session = Session.getDefaultInstance(props,null);

			Message msg = new MimeMessage(session);

			msg.setFrom(new InternetAddress("user@your.host.org"));

			msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse("NotifiedUser", false));

			msg.setSubject("Coding Scheme Change");
			msg.setText("Coding Scheme:" + event.getOriginalCodingScheme().getCodingSchemeURI() + " has changed.");

			Transport.send(msg);
		} catch(Exception e) {
			throw new RuntimeException(e);
		}
		
		return true;
	}

	public String getDescription() {
		return "An Email alerting Extension";
	}

	public String getName() {
		return "MailAlertExtension";
	}

	public String getProvider() {
		return "LexEVS Team";
	}

	public String getVersion() {
		return "1.0";
	}
}
Wiki Markup
Scrollbar
iconsfalse