/* Manage all messages in TMD, including email and web display
** Class: msgManager
** Author: Yuping Zhu
** Date: 10-27-1999
*/
package ascdb.admin;
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.util.Hashtable;
import javax.servlet.http.*;
public class msgManager {
private Hashtable infoTable = new Hashtable();
public msgManager(){}
public void putHashTable(Hashtable ht)
{
infoTable = ht;
}
public void UserRegisterOk(HttpServletResponse res)
throws IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("");
out.println("
Before your registration can be confirmed ...");
out.println("");
out.println(" Before your registration can be confirmed ...
");
out.println("The one-time registration process is now completed.
");
out.println(HTMLMsg("Register"));
out.println("To access the TMD in the future, you need to choose 'Login as User'. Your current TMD session will be continued until hit 'Logout' if you would like to register for a class at this time. If you Logout now, you will not be able to enter the TMD until you recieve your UserID and Password.");
}
public void UserExist(HttpServletResponse res)
throws IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("");
out.println("Your partial info exist...");
out.println("");
out.println("Partial information already exists for you. Please call " + infoTable.get("admph") + " or toll-free " + infoTable.get("freephone") + " or email " + infoTable.get("TMDemail") + " to recieve your UserID and Password.");
out.println("");
}
public void msgSender(String to, String from,String ccTo, String msgCode,String host)
{
Properties props = new Properties();
props.put("mail.smtp.host", host);
// props.put("mail.debug",new Boolean(false));
Session session = Session.getDefaultInstance(props, null);
session.setDebug(false);
try {
// create a message
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(from)};
InternetAddress[] Toaddress = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, Toaddress);
if (ccTo.length() != 0) {
InternetAddress[] CCaddress = {new InternetAddress(ccTo)};
msg.setRecipients(Message.RecipientType.CC, CCaddress);
}
msg.setReplyTo(address);
msg.setSubject(getSubject(msgCode));
msg.setSentDate(new Date());
// msg.setText("test");
msg.setText(getMsg(msgCode));
Transport.send(msg);
} catch (MessagingException mex) {
System.out.println(mex.getMessage());
}
}
private String getSubject(String code) {
if ((code.compareTo("Student") == 0) || (code.compareTo("Instructor") == 0))
return "New TMD Form Submitted";
else if ((code.compareTo("Sponsor TMD") == 0) || (code.compareTo("Sponsor class") == 0))
return "Sponsor Verification";
else if ((code.compareTo("Register") == 0) || (code.compareTo("Class") ==0))
return "Before your registration can be confirmed ...";
else if (code.compareTo("Approve") == 0)
return "Registration for class " + infoTable.get("course_num")
+ " - " + infoTable.get("start_date");
else if (code.compareTo("Request") == 0)
return "Building Access Request";
else if (code.compareTo("NacNotOnFile") == 0)
return "NAC/Security Clearance not on file";
else if (code.compareTo("NacRegisterConfirmed") == 0)
return "NAC/Security Clearance received and Registration confirmed";
else if (code.compareTo("Reminder") == 0)
return "5-day Reminder";
else if (code.compareTo("RegisterConfirmed") == 0)
return "Register Confirmed";
else
return "No Subject";
}
private String getMsg(String code)
{
String days = new String();
if ((code.compareTo("Student") == 0)|| (code.compareTo("Instructor") == 0))
return "There has a new " + code
+ " form submitted to the TMD. The "
+ code + " is " + infoTable.get("f_name") + " "
+ infoTable.get("l_name");
else if (code.compareTo("Sponsor TMD") == 0)
return "Dear " + infoTable.get("sfname") + " "
+ infoTable.get("slname") + ",\n"
+ infoTable.get("f_name") + " " + infoTable.get("l_name")
+ " is registering with Training Management Database in order to register for classes and has listed you as a sponsor. The information they provided for you is:\nOrganization: " + infoTable.get("org")
+ "\nFirst Name: " + infoTable.get("sfname")
+ "\nLast Name: " + infoTable.get("slname")
+ "\nPhone: " + infoTable.get("sphone")
+ "\nPhone Ext: " + infoTable.get("sext")
+ "\nFAX: " + infoTable.get("sfax")
+ "\nEmail: " + infoTable.get("semail") + "\n"
+ "If any of this information needs to be corrected, please respond to this email and provide the correct information. If you do not wish to send the requested information via email, you may call "
+ infoTable.get("admph") + " or toll-free "
+ infoTable.get("freephone") + ".\nThank you.";
else if (code.compareTo("Sponsor class") == 0)
return "Dear " + infoTable.get("sfname") + " "
+ infoTable.get("slname") + ",\n"
+ infoTable.get("f_name") + " " + infoTable.get("l_name")
+ " would like to attend " + infoTable.get("course_num") + ": "
+ infoTable.get("title") + " " + infoTable.get("start_date")
+ " being hled by the ASC MSRC at Wright - Patterson Air Force Base. They have listed you as their Government Sponsor. Does this person work for you and if so, do you approve their attendance at this training course?\nPLease call " + infoTable.get("admph") + " or " + infoTable.get("freephone")
+ " if you have any questions. We ask you respond as soon as possible.\nThank you.";
else if ((code.compareTo("Register") == 0) || (code.compareTo("Class") == 0))
{
if (code.compareTo("Register") == 0)
days = "one".toString();
else
days = "5".toString();
return "Your request has been mailed to ASC MSRC PET Training Support.\nWe must verify the status of your NAC or Security Clearance before we can grant you computer access. If your Security Officer has not sent your Security Clearance to the ASC/HP Security Officer, "
+ infoTable.get("officer")
+ ", please make sure that they do so imediately.\n"
+ " " + infoTable.get("officer") + "\n"
+ " ASC/HPX\n"
+ " 2435 Fifth Street\n"
+ " Wright Patterson AFB, OH 45433 - 7802\n"
+ " Phone: " + infoTable.get("officerPH") + "\n"
+ " DSN: " + infoTable.get("dsn") + "\n"
+ " Fax: " + infoTable.get("officerFax") + "\n"
+ " Email: " + infoTable.get("officerEmail") + "\n"
+ " The Visit Request form must clearly state the purpose of the visit to be \"Attend a Class\" and the dates of the class.\n"
+ "If you have not recieved a confirmed within "
+ days + " business days containing your UserID and Password, please send an email to ASC MSRC PET Training Support ("
+ infoTable.get("TMDemail") + ") or call "
+ infoTable.get("admph") + " or toll-free "
+ infoTable.get("freephone") + ".\nThank you.";
}
else if (code.compareTo("Approve") == 0)
return "Your registration request for the \""
+ infoTable.get("title") + "\" class, being held "
+ infoTable.get("start_date") + ", has been received and a place is being held for you. The information accessible via the ASC MSRC Web Site:\n\n http://www.asc.hpc.mil\n\ncontains the latest class info as it becomes available. The class will be held in the "
+ infoTable.get("room") + " of building "
+ infoTable.get("building")
+ " located in Area B of Wright-Patterson Air Force Base.\n\nThank you for your interest and we look forward to seeing you "
+ infoTable.get("start_date")
+ ".\n\nThank you!\n -Erin";
else if (code.compareTo("Request") == 0)
return "Jim,\n " + infoTable.get("f_name") + " "
+ infoTable.get("l_name") + " will be attending "
+ infoTable.get("course_num") + ": "
+ infoTable.get("title") + " beginning "
+ infoTable.get("start_date") + " and lasting for "
+ infoTable.get("days") + " days. They have current NAC/Security Clearance Information already in your DB. Please update their Building Access so they may attend class. Please respond to this email completed.\nThank you.\n\n-Erin";
else if (code.compareTo("NacNotOnFile") == 0)
return "Your NAC/Security Clearance is not on file!";
else if (code.compareTo("NacRegisterConfirmed") == 0)
return "Your NAC/Security Clearance is recieved and Registration is confirmed!";
else if (code.compareTo("RegisterConfirmed") == 0)
return "Your Registration is confirmed!";
else if (code.compareTo("Reminder") == 0)
return "Just remind you that the class will be open after 5 days!";
else
return "Nothing !";
}
private String HTMLMsg(String code)
{
String days = new String();
if (code.compareTo("Register") == 0)
days = "one".toString();
else
days = "5".toString();
return "Your request has been mailed to ASC MSRC PET Training Support.
We must verify the status of your NAC or Security Clearance before we can grant you computer access. If your Security Officer has not sent your Security Clearance to the ASC/HP Security Officer, "
+ infoTable.get("officer")
+ ", please make sure that they do so imediately.
"
+ "- " + infoTable.get("officer") + "\n"
+ "
- ASC/HPX"
+ "
- 2435 Fifth Street"
+ "
- Wright Patterson AFB, OH 45433 - 7802"
+ "
- Phone: " + infoTable.get("officerPH") + "\n"
+ "
- DSN: " + infoTable.get("dsn") + "\n"
+ "
- Fax: " + infoTable.get("officerFax") + "\n"
+ "
- Email: " + infoTable.get("officerEmail") + ""
+ "
- The Visit Request form must clearly state the purpose of the visit to be \"Attend a Class\" and the dates of the class.
"
+ "If you have not recieved a confirmed within "
+ days + " business days containing your UserID and Password, please send an email to ASC MSRC PET Training Support ("
+ infoTable.get("TMDemail") + ") or call "
+ infoTable.get("admph") + " or toll-free "
+ infoTable.get("freephone") + ".Thank you.";
}
}