head 1.29; access; symbols ChronicleBooks-TomcatApacheRelease:1.4; locks; strict; comment @# @; 1.29 date 2003.05.13.03.42.46; author erik; state Exp; branches; next 1.28; 1.28 date 2003.05.09.20.35.11; author erik; state Exp; branches; next 1.27; 1.27 date 2003.02.03.20.01.48; author erik; state Exp; branches; next 1.26; 1.26 date 2002.10.31.17.59.15; author erik; state Exp; branches; next 1.25; 1.25 date 2002.09.18.17.48.53; author mike; state Exp; branches; next 1.24; 1.24 date 2002.09.16.22.58.42; author mike; state Exp; branches; next 1.23; 1.23 date 2002.05.02.20.42.49; author mike; state Exp; branches; next 1.22; 1.22 date 2002.05.02.18.00.02; author mike; state Exp; branches; next 1.21; 1.21 date 2002.05.02.00.27.54; author mike; state Exp; branches; next 1.20; 1.20 date 2002.04.09.20.30.34; author mike; state Exp; branches; next 1.19; 1.19 date 2002.04.04.22.30.26; author mike; state Exp; branches; next 1.18; 1.18 date 2002.02.12.20.23.24; author mike; state Exp; branches; next 1.17; 1.17 date 2002.02.12.01.38.28; author mike; state Exp; branches; next 1.16; 1.16 date 2002.02.01.20.39.28; author mike; state Exp; branches; next 1.15; 1.15 date 2002.02.01.20.00.21; author mike; state Exp; branches; next 1.14; 1.14 date 2001.12.20.02.05.24; author mike; state Exp; branches; next 1.13; 1.13 date 2001.12.18.19.17.32; author mike; state Exp; branches; next 1.12; 1.12 date 2001.12.18.01.25.11; author mike; state Exp; branches; next 1.11; 1.11 date 2001.12.13.20.58.56; author alon; state Exp; branches; next 1.10; 1.10 date 2001.12.13.20.30.49; author alon; state Exp; branches; next 1.9; 1.9 date 2001.12.05.23.35.15; author mike; state Exp; branches; next 1.8; 1.8 date 2001.12.05.21.00.25; author mike; state Exp; branches; next 1.7; 1.7 date 2001.12.05.02.40.48; author mike; state Exp; branches; next 1.6; 1.6 date 2001.12.05.00.29.13; author mike; state Exp; branches; next 1.5; 1.5 date 2001.12.04.01.32.32; author alon; state Exp; branches; next 1.4; 1.4 date 2001.11.13.00.18.44; author sara; state Exp; branches; next 1.3; 1.3 date 2001.11.08.23.48.05; author alon; state Exp; branches; next 1.2; 1.2 date 2001.10.30.22.05.51; author alon; state Exp; branches; next 1.1; 1.1 date 2001.10.23.23.32.17; author sara; state Exp; branches; next ; desc @@ 1.29 log @*** empty log message *** @ text @import java.io.*; import java.util.*; import java.text.SimpleDateFormat; import javax.servlet.*; import javax.servlet.http.*; import javax.mail.internet.*; import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.xml.parsers.*; import org.apache.xalan.xslt.*; import org.w3c.dom.*; import com.posttool.hierarchy.*; import com.posttool.Chronicle.*; import com.posttool.util.XSL.*; import com.posttool.dbManager.DataClass; import com.posttool.util.DataClassFactory; import com.chronicle.util.Sequence; import com.chronicle.xsl.*; /** * this is pretty much all of the form processing for Chronicle. * Creation date: (1/11/2001 8:58:52 PM) * Modified regularly until (4/24/2001 9:34:33 AM) * @@author: */ public class processForm extends javax.servlet.http.HttpServlet { private static org.apache.log4j.Category log = org.apache.log4j.Category.getInstance(processForm.class.getName()); int count, postcardCount; private static ResourceBundle labels = null; private final static String locBundle = "com.posttool.Chronicle.LocalStrings", resBundle = "com.posttool.Chronicle.taskManager"; private static Locale currentLocale = Locale.getDefault(); private static ResourceBundle appContext = null; private static ResourceBundle messages = null; private static String baseURL = "/Chronicle/servlet/at/"; static { Locale currentlocale = Locale.getDefault(); labels = ResourceBundle.getBundle("com.posttool.Chronicle.LocalStrings", currentlocale); messages = ResourceBundle.getBundle("Messages", currentlocale); } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public boolean addFavorite(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); if (user == null) { // this is a problem, i think. perhaps the session timed out? log.warn("Trying to add a favorite with no user logged in"); actionInfo.message = "I could not add the item to your favorites " + "because you do not appear to be logged in."; synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } return false; } Favorites fav = new Favorites(); fav.makeFromRequest(request, false); fav.Email = user.Email; boolean success = fav.DBInsert(); actionInfo.message = "The item was added to your list of favorites."; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // return success; } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public void addressDelete(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo)session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // AddressBook addressBook = new AddressBook(); String key1 = (String) request.getParameter("k1"); String key2 = (String) request.getParameter("k2"); addressBook.DBDelete("Email = \""+user.Email+"\" and "+ "EntryFirst = \""+key1+"\" and "+ "EntryLast = \""+key2+"\""); actionInfo.message = ""; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public void addressInsert(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo)session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // AddressBook addressBook = new AddressBook(); addressBook.makeFromRequest(request,false); addressBook.Email = user.Email; addressBook.DBInsert(); actionInfo.message = ""; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // } /** * Hello. */ public void addressItem(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // String addressId = (String) request.getParameter("address"); Point p = new Point(); DataAssociation da = new DataAssociation(); Vector v = new Vector(); v.add(da); p.dataAssociation = v; p.id = "address_book"; p.displayName = "Address Book"; p.masterPage = "blankMasterPage"; p.subStructure = "blankSubStructure"; da.table = "AddressBook"; da.tableTemplate = "Address"; da.whereClause = "select * from AddressBook where EntryName = \""+addressId+"\""; da.orderBy = "EntryName"; da.direction = ""; da.subStructureBucket = "report"; da.perPage = "1"; // HttpSession session = request.getSession(true); String[] address = { "address", addressId }; synchronized (session.getId().intern()) { session.setAttribute("address", address); } // ClientInfo clientInfo = new ClientInfo(); clientInfo.addPointToSession("pop",p, session); } /** * Hello. */ public void addressReport(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo)session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // // String letter = (String) request.getParameter("letter"); Point p = new Point(); DataAssociation da = new DataAssociation(); DataAssociation pi = new DataAssociation(); DataAssociation pc = new DataAssociation(); Vector v = new Vector(); v.add(da); v.add(pi); v.add(pc); p.dataAssociation = v; p.id = "address_book"; p.displayName = "Address Book"; p.masterPage = "blankMasterPage"; p.subStructure = "blankSubStructure"; da.table = "AddressBook"; da.tableTemplate = "Address"; da.whereClause = "select * from AddressBook where " +"Email = \"" + user.Email +"\" AND " +"EntryLast like \""+letter+"%\""; da.orderBy = "EntryLast, EntryFirst"; da.direction = ""; da.subStructureBucket = "report"; da.perPage = "33"; // pi.name = "personalImage"; pi.table = "PersonalImage"; pi.whereClause = "( ( Email eq \"_session.Email\" ) and ( ImageType is \"Address\" ) )"; pi.orderBy = "PersonalImage.Email"; pi.tableTemplate="none"; pi.subStructureBucket="report"; // pc.table ="Postcard"; pc.whereClause="( ( ISBN eq \"_personalImage.ISBN\" ) )"; pc.orderBy="Postcard.ISBN"; pc.tableTemplate="blankPC"; pc.subStructureBucket="report"; String[] address = { "letter", letter }; synchronized (session.getId().intern()) { session.setAttribute("address", address); } // ClientInfo clientInfo = new ClientInfo(); clientInfo.addPointToSession("pop",p, session); // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // } /** * Hello. */ public void addressSearch(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo)session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // // String searchField = (String) request.getParameter("searchField"); String search = "%" + searchField.replace(' ', '%') + "%"; Point p = new Point(); DataAssociation da = new DataAssociation(); DataAssociation pi = new DataAssociation(); DataAssociation pc = new DataAssociation(); Vector v = new Vector(); v.add(da); v.add(pi); v.add(pc); p.dataAssociation = v; p.id = "address_book"; p.displayName = "Address Book"; p.masterPage = "blankMasterPage"; p.subStructure = "blankSubStructure"; // da.table = "AddressBook"; da.tableTemplate = "Address"; da.whereClause = "select * from AddressBook where " + "Email = \"" + user.Email +"\" AND (" + "EntryFirst like \"" + search+ "\" or " + "EntryLast like \"" + search + "\" or " + "Address1 like \"" + search + "\" or " + "Address2 like \"" + search + "\" or " + "City like \"" + search + "\" or " + "State like \"" + search + "\" or " + "ZipCode like \"" + search + "\" or " + "EntryEmail like \"" + search + "\" or " + "HomePhone like \"" + search + "\" or " + "WorkPhone like \"" + search + "\" )"; da.orderBy = "EntryLast, EntryFirst"; da.direction = ""; da.subStructureBucket = "report"; da.perPage = "33"; // pi.name = "personalImage"; pi.table = "PersonalImage"; pi.whereClause = "( ( Email eq \"_session.Email\" ) and ( ImageType is \"Address\" ) )"; pi.orderBy = "PersonalImage.Email"; pi.tableTemplate="none"; pi.subStructureBucket="report"; // pc.table ="Postcard"; pc.whereClause="( ( ISBN eq \"_personalImage.ISBN\" ) )"; pc.orderBy="Postcard.ISBN"; pc.tableTemplate="blankPC"; pc.subStructureBucket="report"; // String[] address = { "search", searchField }; synchronized (session.getId().intern()) { session.setAttribute("address", address); } // ClientInfo clientInfo = new ClientInfo(); clientInfo.addPointToSession("pop",p, session); // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public void addressUpdate(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo)session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // ' AddressBook addressBook = new AddressBook(); String key1 = (String) request.getParameter("k1"); String key2 = (String) request.getParameter("k2"); Hashtable originalKeys = new Hashtable(); originalKeys.put("Email",user.Email); originalKeys.put("EntryFirst",key1); originalKeys.put("EntryLast",key2); addressBook.makeFromRequest(request,false); addressBook.Email = user.Email; addressBook.DBUpdate(originalKeys); actionInfo.message = ""; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public Orders cart_AccountToOrder(RegUserAccount acct, Orders order) { order.Email = acct.Email; order.ShipName = acct.ShipName; order.ShipAddress1 = acct.ShipAddress1; order.ShipAddress2 = acct.ShipAddress2; order.ShipCity = acct.ShipCity; order.ShipState = acct.ShipState; order.ShipZipCode = acct.ShipZipCode; order.ShipCountry = acct.ShipCountry; order.ShipTelephone = acct.ShipTelephone; order.ShipMethod = acct.ShipMethod; order.BillName = acct.BillName; order.BillAddress1 = acct.BillAddress1; order.BillAddress2 = acct.BillAddress2; order.BillCity = acct.BillCity; order.BillState = acct.BillState; order.BillZipCode = acct.BillZipCode; order.BillCountry = acct.BillCountry; order.BillTelephone = acct.BillTelephone; order.CardHolder = acct.CardHolder; order.CardNumber = acct.CardNumber; order.CardType = acct.CardType; order.ExpDateMM = acct.ExpDateMM; order.ExpDateYY = acct.ExpDateYY; return order; } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public AddressBook cart_OrderToAddress(Orders order, AddressBook address, RegUsers user) { // address.Email = user.Email; int space = order.ShipName.indexOf(" "); if (space != -1) { address.EntryFirst = order.ShipName.substring(0, space).trim(); address.EntryLast = order.ShipName.substring(space).trim(); } else { address.EntryLast = order.ShipName; } address.Address1 = order.ShipAddress1; address.Address2 = order.ShipAddress2; address.City = order.ShipCity; address.State = order.ShipState; address.Country = order.ShipCountry; address.ZipCode = order.ShipZipCode; address.HomePhone = order.ShipTelephone; return address; } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public RegUserAccount cart_OrderToRegUserAccount(Orders order, RegUserAccount acct, RegUsers user) { acct.Email = user.Email; // acct.ShipName = order.ShipName; acct.ShipAddress1 = order.ShipAddress1; acct.ShipAddress2 = order.ShipAddress2; acct.ShipCity = order.ShipCity; acct.ShipState = order.ShipState; acct.ShipCountry = order.ShipCountry; acct.ShipZipCode = order.ShipZipCode; acct.ShipTelephone = order.ShipTelephone; // acct.BillName = order.BillName; acct.BillAddress1 = order.BillAddress1; acct.BillAddress2 = order.BillAddress2; acct.BillCity = order.BillCity; acct.BillState = order.BillState; acct.BillCountry = order.BillCountry; acct.BillZipCode = order.BillZipCode; acct.BillTelephone = order.BillTelephone; // acct.CardHolder = order.CardHolder; acct.CardNumber = order.CardNumber; acct.CardType = order.CardType; acct.ExpDateMM = order.ExpDateMM; acct.ExpDateYY = order.ExpDateYY; return acct; } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public void cartAdd(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); String client = (String) session.getAttribute("client"); Cart cart = new Cart(); cart.makeFromRequest(request, false); boolean isOk = cart.DBInsert(); if (isOk) { //actionInfo.redirect = ""; actionInfo.message += "Item added to cart. "; } else { // back to the page you were on //actionInfo.redirect = ""; String sclink = "shopping cart"; if ("HTML".equals(client)) { sclink = "" + sclink + ""; } actionInfo.message += "You already have that in your cart. To purchase additional " + "copies, go to your " + sclink + ", change quantity and click \"update\"."; if ("HTML".equals(client)) { actionInfo.message = "" + actionInfo.message + ""; } } synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public boolean cartCheckout(HttpServletRequest request, HttpServletResponse response) { log.debug("In processForm.cartCheckout"); // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); String status = ""; // this will capture the form at hand // or pickup a registered user's account preferences Orders order = (Orders) session.getAttribute("Orders"); if (order == null) order = new Orders(); order.makeFromRequest(request, false); synchronized (session.getId().intern()) { session.setAttribute("Orders", order); } if (actionInfo.redirect.indexOf("shipping") > -1 && request.getParameter("ShipName") != null) { log.debug("Redirect has 'shipping' and ShipName is not null"); actionInfo.redirect = "history(u);billing"; } if (actionInfo.redirect.indexOf("billing") > -1 && request.getParameter("ExpDateMM") != null) { log.debug("Redirect has 'billing' and ExpDateMM is not null"); actionInfo.redirect = "history(u);confirm"; } /* registered users can save the shipping address to their personal * address book. new users (who register from checkout) cannot save the * the first address because it will be used as the reg user address. */ String saveAddress = (String) request.getParameter("saveAddress"); if (saveAddress != null && saveAddress.equals("checked")) { AddressBook address = new AddressBook(); address = cart_OrderToAddress(order, address, user); boolean inserted = address.DBInsert(); if (!inserted) status += "Chckout Error. Cannot transfer shipping address to personal address book. "; } /* */ if (status.equals("")) status = "Your order information has been updated. "; actionInfo.message += status; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // return true; } /** * Transfer cart contents to order contents. * Return true if no error occurs, false otherwise. */ public boolean cartOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException { // the order, the user info and the card information HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); String client = (String) session.getAttribute("client"); Orders order = (Orders) session.getAttribute("Orders"); RegUserAccount account = (RegUserAccount) session.getAttribute("RegUserAccount"); // is anything null? if (user == null || account == null || order == null) { actionInfo.redirect = "history(u);login"; actionInfo.message = "Order Error: Please log in."; synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } log.warn("Something is null. User must log in again."); return false; } // connect the order to this user if (order.CardHolder == null || order.CardHolder.equals("CardHolder")) { log.debug("Set order card holder to order ship name"); order.CardHolder = order.ShipName; } // Get next order id // this is in place of the old post tool solution where // id's were maintained in a file by this code int id; try { id = Sequence.nextOrderId(); } catch (java.sql.SQLException e) { log.error("error getting next order id", e); throw new ServletException(e); } log.debug("Set order id and email"); order.OrderID = id; order.Email = user.Email; synchronized (session.getId().intern()) { session.setAttribute("Orders", order); } // and insert log.debug("Insert order in to database"); boolean inserted = order.DBInsert(); if (! inserted) { log.error("Could not insert order: " + order.OrderID); actionInfo.message += "Order Error: Invalid invoice number for order. "; } // copy from the cart to orderItems Cart cart = new Cart(); log.debug("Select items from cart"); int cartItems = cart.DBSelect("Email = \"" + user.Email + "\""); OrderItems orderItem = new OrderItems(); log.debug("There are " + cartItems + " in the cart"); for (int i = 0; i < cartItems; i++) { log.debug("Select row from cart table"); cart.DBSelectRow(i); orderItem.OrderID = order.OrderID; orderItem.ISBN = cart.ISBN; orderItem.Quantity = toInt(cart.Quantity); log.debug("Insert into order table (" + orderItem.ISBN + ", " + orderItem.Quantity + ")"); inserted = orderItem.DBInsert(); if (! inserted) { log.error("Count not insert order item: " + orderItem.ISBN); actionInfo.message += "Order Error: Cannot transfer from cart to orderItems. "; } } // delete the cart log.debug("Delete cart"); cart.DBDelete("Email = \"" + user.Email + "\""); // transfer the order info is the savePrefs is checked String savePrefs = (String) request.getParameter("savePrefs"); if (savePrefs != null) { log.debug("Update user account information"); account = cart_OrderToRegUserAccount(order, account, user); account.DBUpdate(); } synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } return (actionInfo.message.equals("")); } /** * This method DOESN'T DO ANYTHING!! */ public void cartOrderEmail(HttpServletRequest request, RegUsers user, Orders order) { log.warn("This method doesn't do anything! Nobody should be calling me!"); String m = ""; m += "Dear " + order.BillName + ",\n\n"; m += "Thank you for ordering from chroniclebooks.com!\n"; m += "In accordance with your order (Order #" + order.OrderID + "), we have shipped\n"; m += "Quantity ISBN Title\n"; m += "--------------------------------------------------------------------\n"; //5 . . . 0811831434 . . . . Paper Palm int total = 0; // loop through items // didn't do this yet, i just noticed that this was already being done.... // // total += qty * unitPrice; // if (! order.ShipAddress1.equals("")) { m += "to " + order.ShipName + "\n"; m += "" + order.ShipAddress1 + "\n"; if (! order.ShipAddress2.equals("")) m += "" + order.ShipAddress2 + "\n"; m += "" + order.ShipState + " " + order.ShipZipCode + "\n"; } else { m += "to " + order.BillName + "\n"; m += "" + order.BillAddress1 + "\n"; if (! order.BillAddress2.equals("")) m += "" + order.BillAddress2 + "\n"; m += "" + order.BillState + " " + order.BillZipCode + "\n"; } String last4digits = order.CardNumber.substring(order.CardNumber.length() - 4); m += "and have charged credit card number XXXX-XXXX-XXXX-" + last4digits + "\n"; m += "[note-only last four digits printed for your security] "; m += "in the amount of $" + total + ".\n"; m += "Should you wish to check the status of this order, please visit"; m += "Order Status.\n"; m += "If you have questions about your order, "; m += "contact order_inquiries@@chroniclebooks.com\n\n"; m += "Your order should arrive in 10-12 business days.\n"; m += "Thanks again for your order, and be sure to visit www.chroniclebooks.com"; m += "again soon!\n"; m += "Chronicle Books Customer Service.\n"; m += "800-722-6657\n"; m += "order_inquiries@@chroniclebooks.com\n\n"; } /** * Handles placing an order */ public boolean cartOrderResponse(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); Orders order = (Orders) session.getAttribute("Orders"); // delete the user if no password was ever specified- // a new user with this email has no history (see userInserNew) String client = (String) session.getAttribute("client"); if (actionInfo.message.equals("")) { actionInfo.message = "Your order has been submitted with an Order Id of " + order.OrderID + ". "; // Hack additional parameter for fl.pl to switch on. actionInfo.fh = "home"; // cartOrderEmail doesn't do anything, so we won't call it -mike // cartOrderEmail(request, user, order); String ccs = "contact customer service"; // Flash checkout uses HTML confirmation page, too if (client.equals("HTML") || client.equals("Flash")) { ccs = "" + ccs + ""; } if (user.CatSection.equals("Temp")) { // temp user goes byebye actionInfo.message += "Your order should arrive 7-10 days after it is processed. If you have any questions, " + ccs + "."; user.DBDelete("Email = \"" + user.Email + "\""); synchronized (session.getId().intern()) { session.removeAttribute("RegUsers"); } synchronized (session.getId().intern()) { session.removeAttribute("RegUserAccount"); } synchronized (session.getId().intern()) { session.removeAttribute("Orders"); } synchronized (session.getId().intern()) { session.removeAttribute("secure"); } actionInfo.redirect = "history(u);message"; synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } sendJSResponse(request, response, client, true, false, false, false); // update parent, close window, no cookie. return true; } else { String yourcb = "Your Chronicle Books"; // Flash checkout uses HTML confirmation page, too if (client.equals("HTML")) { yourcb = "" + yourcb + ""; } else if (client.equals("Flash")) { yourcb = "" + yourcb + ""; } actionInfo.message += "You may cancel this order from account maintenance anytime before it is shipped or " + "view the status of this order using " + yourcb + ". Your order should arrive " + "7-10 days after it is processed. If you have any questions, " + ccs + "."; synchronized (session.getId().intern()) { session.setAttribute("whichTree", "adults"); } if (client.equals("HTML") || client.equals("Flash")) { actionInfo.message = "" + actionInfo.message + ""; } if (user != null) actionInfo.redirect = "history(u);your"; else actionInfo.redirect = "history(u);message"; synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } // synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } sendJSResponse(request, response, client, true, false, false, true); // switch parent window to adults return true; } } else { // copy from the cart to orderItems OrderItems oi = new OrderItems(); int oiCount = oi.DBSelect("OrderID = \"" + order.OrderID + "\""); Cart cart = new Cart(); for (int i = 0; i < oiCount; i++) { oi.DBSelectRow(i); cart.ISBN = oi.ISBN; cart.Quantity = oi.Quantity + ""; cart.Email = user.Email; boolean inserted = cart.DBInsert(); if (! inserted) actionInfo.message += "Order Error: Cannot transfer cart. "; } oi.DBDelete("OrderID = \"" + order.OrderID + "\""); // remove the order int ordersDeleted = order.DBDelete(); actionInfo.message = "There were problems placing the order (id: " + order.OrderID + "). " + actionInfo.message; actionInfo.redirect = "history(u);message"; synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } return false; } } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public void cartUpdate(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); boolean isOk = true; Cart cart = new Cart(); Vector rows = requestAsRows(request, cart); if (rows.isEmpty()) { log.warn("Nothing to update the cart with in the request"); } else { log.debug("Updating the cart with " + rows.size() + " rows"); Hashtable newRow = (Hashtable) rows.elementAt(0); // get one row in order to get the email address Hashtable oldRow = null; String newISBN = null; log.debug("Reading cart in from database"); cart.DBSelect( "ISBN", "Catalog", "Email = \"" + newRow.get("Email") + "\" " + " ORDER BY Catalog.Title"); for (int i = 0; i < rows.size(); i++) { log.debug("Getting item from request: " + i); newRow = (Hashtable) rows.elementAt(i); newISBN = (String) newRow.get("ISBN"); log.debug("Reading cart item in from database: " + newISBN); boolean couldFind = cart.DBSelectRow(newISBN); if (! couldFind) { log.error("Could not find item in cart: " + newISBN); isOk = false; break; } oldRow = cart.toHash(); log.debug("old row: " + oldRow); log.debug("new row: " + newRow); if (toInt((String) newRow.get("Quantity")) == 0) { log.debug("Quantity is zero, deleting item from cart: " + newISBN); int rowsGone = cart.DBDelete(); if (rowsGone > 1) { log.error(rowsGone + " rows were deleted from the cart (should be 1) for item: " + newISBN); isOk = false; break; } } else if (toInt((String) newRow.get("Quantity")) == toInt((String) oldRow.get("Quantity"))) { log.debug("Nothing has changed for item: " + newRow.get("ISBN")); } else { log.debug("Updating cart for item: " + newRow.get("ISBN")); isOk = cart.DBUpdate(oldRow, newRow); if (! isOk) { log.error("Unable to update cart with item: " + newRow.get("ISBN")); break; } } } } if (isOk) { // forward log.debug("Shopping cart successfully updated."); if (actionInfo.redirect == null) actionInfo.redirect = ""; actionInfo.message = "Your shopping cart has been updated."; } else { // back to the page you were on (with some message) log.debug("Error updating cart. Redirecting user back to same page."); actionInfo.redirect = ""; actionInfo.message = "There was a problem updating your shopping cart."; } synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } // synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public boolean cartUserUpdate(String userEmail, String id, HttpServletRequest request) { Cart cart = new Cart(); int itemsInCart = cart.DBSelect("Email = \"" + id + "\""); for (int i = 0; i < itemsInCart; i++) { cart.DBSelectRow(i); Hashtable row = cart.toHash(); cart.Email = userEmail; boolean isOk = cart.DBUpdate(row); if (!isOk) return false; } return true; } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public boolean cartUserUpdate(String userEmail, HttpServletRequest request) { String id = (String) request.getParameter("cartConnect"); return cartUserUpdate(userEmail, id, request); } /** * Verify credit card -mike */ public boolean cartVerifyCC(HttpServletRequest request, HttpServletResponse response) { boolean isOk = true; // the order, the user info and the card information HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); Orders order = (Orders) session.getAttribute("Orders"); RegUserAccount account = (RegUserAccount) session.getAttribute("RegUserAccount"); taskCheckCredit tcc = new taskCheckCredit(); String result = tcc.check(order.OrderID); if (result.equals("OK")) { isOk = true; } else if (result.equals("NoCredit")) { actionInfo.message = "The credit card you submitted has been declined by VeriSign, our " + "online credit card verification service. Please try another card if you " + "wish, and contact your credit card company if you feel there is an error " + "with your card. To place your order by phone, call our Customer Service " + "Department at: 800-722-6657, and to report ordering problems, email us." + "

" + "Click here to adjust your entry or try another card.

" + actionInfo.message; isOk = false; } else if (result.equals("Failure")) { actionInfo.message = "We could not get authorization for the credit card number you submitted. " + "Please check to make sure you have entered the card number and expiration " + "date correctly or try another credit card. To place your order by phone, " + "call our Customer Service Department at: 800-722-6657, and to report " + "ordering problems, email us." + "

" + "Click here to adjust your entry or try another card.

" + actionInfo.message; isOk = false; } else { // NOTE: this message is the same as Failure above, but only because I didn't have anything // else to put here. We should probably come up with a more robust error reporting scheme. // -mike log.error("Got an unknown response from taskCheckCredit.check(). Sending failure message."); actionInfo.message = "We could not get authorization for the credit card number you submitted. " + "Please check to make sure you have entered the card number and expiration " + "date correctly or try another credit card. To place your order by phone, " + "call our Customer Service Department at: 800-722-6657, and to report " + "ordering problems, email us." + "

" + "Click here to adjust your entry or try another card.

" + actionInfo.message; isOk = false; } synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } return isOk; } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public void dateChange(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // actionInfo.redirect = (String) request.getParameter("redirect"); if (actionInfo.redirect == null) actionInfo.redirect = "day;history(pop);"; String dateChange = (String) request.getParameter("date"); Date date = (Date) session.getAttribute("Date"); if (date == null) { date = new Date(); } GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date); if (dateChange.length() == 10) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); try { date = dateFormat.parse(dateChange); synchronized (session.getId().intern()) { session.setAttribute("Date", date); } cal.setTime(date); } catch (Exception e) { } } else if (dateChange.indexOf("30") == -1) { int d = toInt(dateChange); int m = cal.get(java.util.Calendar.DAY_OF_YEAR); int y = cal.get(java.util.Calendar.YEAR); if (m + d < 0) { cal.set(java.util.Calendar.YEAR, y - 1); cal.set(java.util.Calendar.DAY_OF_YEAR, 365 + (m + d)); } else if (m + d > 365) { cal.set(java.util.Calendar.YEAR, y + 1); cal.set(java.util.Calendar.DAY_OF_YEAR, (m + d) - 366); } else { cal.set(java.util.Calendar.DAY_OF_YEAR, m + d); } if (d == 7 || d == -7) actionInfo.redirect = "week"; } else { int d = 1; if (dateChange.indexOf("-") > -1) d = -1; int m = cal.get(java.util.Calendar.MONTH); int y = cal.get(java.util.Calendar.YEAR); if (m == 0 && d == -1) { cal.set(java.util.Calendar.YEAR, y - 1); cal.set(java.util.Calendar.MONTH, 11); } else if (m == 11 && d == 1) { cal.set(java.util.Calendar.YEAR, y + 1); cal.set(java.util.Calendar.MONTH, 0); } else { cal.set(java.util.Calendar.MONTH, m + d); } actionInfo.redirect = "month"; } date = cal.getTime(); synchronized (session.getId().intern()) { session.setAttribute("Date", date); } actionInfo.message = ""; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public void dateDelete(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // boolean isOk = true; PersonalCalendar cal = new PersonalCalendar(); cal.makeFromRequest(request,false); cal.Email = user.Email; int d = cal.DBDelete(); if (d==1){ // forward actionInfo.redirect ="day;history(pop);"; actionInfo.message = ""; } else { // back to the page you were on (with some message) actionInfo.redirect = ""; actionInfo.message = "There are "+d+" event(s) at that time."; } // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public void dateInsert(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // Date date = (Date) session.getAttribute("Date"); if (date == null) { date = new Date(); } String hour = (String) request.getParameter("hour"); String newEvent = (String) request.getParameter("new"); // adjust date SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date); cal.set(java.util.Calendar.HOUR_OF_DAY, toInt(hour)); date = cal.getTime(); synchronized (session.getId().intern()) { session.setAttribute("Date", date); } // write record if (newEvent != null) { PersonalCalendar dcal = new PersonalCalendar(); dcal.Email = user.Email; dcal.Date = dateFormat.format(date); dcal.Time = hour; dcal.EventDescription = "A new event."; dcal.DBInsert(); // when does "A new event." get cleaned up? } actionInfo.redirect = "go(edit_cal," + hour + ");history(pop);"; actionInfo.message = ""; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public void dateUpdate(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // Date date = (Date) session.getAttribute("Date"); if (date == null) { date = new Date(); } // adjust date SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTime(date); int hour = gcal.get(java.util.Calendar.HOUR_OF_DAY); String CalendarHour = hour+""; if (hour <10) CalendarHour = "0"+CalendarHour; // PersonalCalendar pcal = new PersonalCalendar(); pcal.Email = user.Email; pcal.DBSelect( "Email = \"" +user.Email + "\" AND Date = \"" + dateFormat.format(date) + "\" AND Time = \"" + CalendarHour + "\""); Hashtable row = pcal.toHash(); pcal.makeFromRequest(request,false); pcal.Email = user.Email; pcal.DBUpdate(row); // try { date =dateFormat.parse(pcal.Date); } catch (Exception e) { } if (date != null) { // forward synchronized (session.getId().intern()) { session.setAttribute("Date", date); } actionInfo.redirect = "day;history(pop)"; actionInfo.message = ""; } else { // back to the page you were on (with some message) actionInfo.redirect = ""; actionInfo.message = "There was a problem updating your calendar."; } // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // } /** * Process incoming HTTP GET requests * * @@param request Object that encapsulates the request to the servlet * @@param response Object that encapsulates the response from the servlet */ public void doGet( javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(true); ActionInfo actionInfo = new ActionInfo(); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // actionInfo.message = ""; actionInfo.table = (String) request.getParameter("table"); actionInfo.action = (String) request.getParameter("action"); actionInfo.redirect = (String) request.getParameter("redirect"); if (actionInfo.table == null) { actionInfo.table = ""; } if (actionInfo.action == null) { actionInfo.action = ""; } if (actionInfo.redirect == null) { actionInfo.redirect = ""; } synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } // if (actionInfo.table.equals("PostcardSent")) { sendPostcard(request, response); } // date changes if (request.getParameter("date") != null) { dateChange(request, response); } if (request.getParameter("hour") != null) { dateInsert(request, response); } if (request.getParameter("letter") != null) { addressReport(request, response); actionInfo.redirect = "history(pop);" + actionInfo.redirect; } if (request.getParameter("searchField") != null) { addressSearch(request, response); actionInfo.redirect = "history(pop);" + actionInfo.redirect; } if (request.getParameter("address") != null) { addressItem(request, response); actionInfo.redirect = "history(pop);" + actionInfo.redirect; } String excerpt = (String) request.getParameter("excerpt"); if (excerpt != null) { //System.err.println("Excerpt is: " + excerpt + "."); //System.err.println("Excerpt's length is: " + excerpt.length()); response.sendRedirect( getString("apacheHttp") + "Chronicle/excerpt/" + excerpt + "-e0.html"); return; } // if (request.getParameter("logout") != null) { logout(request,response); } else { synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // if (!response.isCommitted()) { sendRedirect(response, this.baseURL + actionInfo.redirect, actionInfo.message); } } /** * Process incoming HTTP POST requests * * @@param request Object that encapsulates the request to the servlet * @@param response Object that encapsulates the response from the servlet */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(true); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); if (actionInfo == null) { actionInfo = new ActionInfo(); } RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // init actionInfo.message = ""; actionInfo.table = (String) request.getParameter("table"); actionInfo.action = (String) request.getParameter("action"); actionInfo.redirect = (String) request.getParameter("redirect"); log.debug("actionInfo = " + actionInfo); synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } try { interpretCommand(request, response); } catch (Exception e) { log.error("Exception while intrepreting some POST command", e); sendRedirect(response, this.baseURL + "login", "Please log in."); } } /** * ResourceBundle boilerplate - * variety two, with application context */ protected static String getAppContext(String theKey, String theBundle) { String returnValue = ""; if ((appContext = ResourceBundle.getBundle(theBundle, currentLocale)) != null) { try { returnValue = appContext.getString(theKey); } catch (MissingResourceException MRExcp) { /* just leave it alone if not found */ } } return returnValue; } /** * Reads checkbox values and inserts or deletes them from the table based on your id. * Creation date: (2/16/2001 11:31:57 AM) */ public String[] getCheckboxes(HttpServletRequest request) { String[] checkboxValues = null; List l = new LinkedList(); Enumeration e = request.getParameterNames(); while (e.hasMoreElements()) { String a = (String) e.nextElement(); if (a.startsWith("checkbox")) { l.add(request.getParameter(a)); } } checkboxValues = new String[ l.size() ]; for (int i=0; i< l.size(); i++) { checkboxValues[i] = (String) l.get(i); //System.out.println(l.get(i)); } return checkboxValues; } /** * Returns the servlet info string. */ public String getSecurePath(HttpServletRequest request) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); // return getString("tomcatHttps") +this.baseURL.substring(1)+"secure(1);"+ actionInfo.redirect; } /** * Returns the servlet info string. */ public String getServletInfo() { return super.getServletInfo(); } /* Louisburg College 501 North Main Street Louisburg, NC 27549 */ private static String getString(String key) { return labels.getString(key); } /** * do we use it? * Creation date: (2/16/2001 11:31:57 AM) */ public void giftFinder(HttpServletRequest request, HttpServletResponse response) { at pageGen = new at(); } /** * Interpret POST command (from doPOST).
* This method handles EVERY post command there is (i think). * -mike wynholds */ public void interpretCommand( HttpServletRequest request, HttpServletResponse response) throws Exception { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); if (actionInfo.table != null && actionInfo.action != null) { boolean secure = false; // User Registration if (actionInfo.table.equals("RegUsers")) { if (actionInfo.action.equals("Insert")) { // does its own response switchToSecure(request); secure = userInsertNew(request, response); } if (actionInfo.action.equals("Validate")) { // does its own response switchToSecure(request); userValidate(request, response); } if (actionInfo.action.equals("Update")) { secure = userUpdate(request, response); } } // Password table if (actionInfo.table.equals("Password")) { if (actionInfo.action.equals("Update")) { secure = userPasswordPrefs(request, response); } } // Shipping table if (actionInfo.table.equals("Shipping")) { if (actionInfo.action.equals("Update")) { secure = userShippingPrefs(request, response); } } // Billing table if (actionInfo.table.equals("Billing")) { if (actionInfo.action.equals("Update")) { secure = userBillingPrefs(request, response); } } // Checkout Shipping if (actionInfo.table.equals("Orders")) { if (actionInfo.action.equals("toSession")) { secure = cartCheckout(request, response); } if (actionInfo.action.equals("placeOrder")) { // returns whether an error happened or not secure = cartOrder(request, response); if (secure) { secure = cartVerifyCC(request, response); cartOrderResponse(request, response); } } if (actionInfo.action.equals("Delete")) { secure = orderDelete(request, response); } } // Your stuff if (actionInfo.table.equals("Subscriptions")) { secure = yourSubscription(request, response); } if (actionInfo.table.equals("Reminders")) { secure = yourReminders(request, response); } if (actionInfo.table.equals("HomePage")) { secure = yourFavorites(request, response); } // Calendar add/update event if (actionInfo.table.equals("PersonalCalendar")) { if (actionInfo.action.equals("Update")) { dateUpdate(request, response); } } if (actionInfo.table.equals("PersonalCalendar")) { if (actionInfo.action.equals("Delete")) { dateDelete(request, response); } } // Cart Maintenance if (actionInfo.table.equals("Cart")) { // Special Case insert from custom JSPs if (actionInfo.action.equals("InsertHTML")) { synchronized (session.getId().intern()) { session.setAttribute("client", "HTML"); } cartAdd(request, response); } if (actionInfo.action.equals("Insert")) { cartAdd(request, response); } if (actionInfo.action.equals("Update")) { cartUpdate(request, response); } } // Gift Finder if (actionInfo.table.equals("Gift")) { giftFinder(request, response); } // Address Book if (actionInfo.table.equals("AddressBook")) { if (actionInfo.action.equals("Insert")) { addressInsert(request, response); } if (actionInfo.action.equals("Update")) { addressUpdate(request, response); } if (actionInfo.action.equals("Delete")) { addressDelete(request, response); } } // Favorites if (actionInfo.table.equals("Favorites")) { addFavorite(request, response); // secure = true; } // Personal image (for calendar or address book) if (actionInfo.table.equals("PersonalImage")) { setImage(request, response); secure = true; } // Send and preview postcard if (actionInfo.table.equals("PostcardSent")) { sendPostcard(request, response); } // Send non-postcard emails: // - order inquiries // - permission inquiries // - other if (actionInfo.table.equals("SendMail")) { sendMail(request); } boolean secureProtocol = request.getPathInfo().indexOf("secure") > -1; // really should be // boolean correctProtocol = request.getProtocol().startsWith("HTTPS"); if (secure && secureProtocol) { log.debug("Secure redirect to " + getSecurePath(request)); sendRedirect(response, getSecurePath(request), actionInfo.message); } else if (secure && !secureProtocol) { // should we be redirecting them to the current server or just "chronbooks"? log.debug("Redirect to http://www.chronbooks.com (hard-coded)"); sendRedirect(response, "http://www.chronbooks.com", ""); } else { log.debug("Redirect to " + this.baseURL + actionInfo.redirect); sendRedirect(response, this.baseURL + actionInfo.redirect, actionInfo.message); } } else { sendRedirect(response, "/Chronicle/servlet/at/", ""); } } public void killCookie( HttpServletRequest request, HttpServletResponse response) { Cookie c = new Cookie("RegUser", ""); c.setMaxAge(0); // c.setPath("/Chronicle"); response.addCookie(c); } public void logout(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) { // invalidate session HttpSession session = request.getSession(true); String whichtree = (String) session.getAttribute("whichTree"); String client = (String) session.getAttribute("client"); Vector history = (Vector) session.getAttribute("history"); Vector command = (Vector) session.getAttribute("command"); // session.invalidate(); killCookie(request,response); // session = request.getSession(true); synchronized (session.getId().intern()) { session.setAttribute("whichTree",whichtree); } synchronized (session.getId().intern()) { session.setAttribute("historyLevel",""); } synchronized (session.getId().intern()) { session.setAttribute("history", history); } synchronized (session.getId().intern()) { session.setAttribute("command", command); } synchronized (session.getId().intern()) { session.setAttribute("client", client); } } /** * deletes orders from the table based on id. * Creation date: (2/16/2001 11:31:57 AM) */ public boolean orderDelete(HttpServletRequest request, HttpServletResponse response) { String[] checkboxValues = getCheckboxes(request); Orders order = new Orders(); OrderItems items = new OrderItems(); taskCheckCredit tcc = new taskCheckCredit(); for (int i = 0; i < checkboxValues.length; i++) { // order.OrderID = toInt(checkboxValues[i]); items.OrderID = order.OrderID; tcc.voidOrder(order.OrderID); // tcc should kill the order, but in case it don't... order.DBDelete(); items.DBDelete(); } //this.message = ""; return true; } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public Vector requestAsRows(HttpServletRequest request, DataClass dC) { String[] key = dC.getColumns(); Vector rows = new Vector(); boolean stillReading = true; while (stillReading) { Hashtable row = new Hashtable(); for (int i = 0; i < key.length; i++) { String value = request.getParameter(key[i]+(rows.size()+1)); // column1, column2, column... if (value == null) { if (dC.isPrimaryKey(key[i])) { stillReading = false; } } else { row.put(key[i], value); } } if (!row.isEmpty()) rows.add(row); } return rows; } /** * called by userInsert & userValidate & cartOrder * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public void sendJSResponse( HttpServletRequest request, HttpServletResponse response, String client, boolean refreshParent, boolean closeWindow, boolean setCookie, boolean switchParentToAdults) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); Orders order = (Orders) session.getAttribute("Orders"); // ' try { // cannot just redirect, cause we want to set the cookie in the response // if (client == null) client = "HTML"; if (!response.isCommitted()) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(""); out.close(); // //System.out.println(user.Email + "\n" + user.FirstName + "\n" + user.Access + "\n" + user.CatSection); } } catch (Exception e) { System.out.println("Redirection error in processForm.sendRedirect."); //e.printStackTrace(); } } // updated 2001.04.26 18:35:06 // add new text // new postcard URL with part of recipient's address embedded // wrap URL in public void sendMail(PostcardSent pc) throws Exception { MimeMessage pcMessage; // postcardsent as a message javax.mail.Session mailSess = null; String SMTPHost = this.getAppContext("taskSendNews.SMTPHost", resBundle); String SMTPUser = this.getAppContext("taskSendNews.SMTPUser", resBundle); Properties theProps = System.getProperties(); theProps.put("mail.smtp.host", SMTPHost); theProps.put("mail.smtp.user", SMTPUser); log.info("Sending postcard email to " + pc.SentTo); try { // fill in headers mailSess = Session.getDefaultInstance(theProps, null); pcMessage = new MimeMessage(mailSess); pcMessage.setRecipients( Message.RecipientType.TO, InternetAddress.parse(pc.SentTo, false)); pcMessage.setFrom( new InternetAddress( "frontdesk@@chroniclebooks.com", "Chronicle Book Postcards")); pcMessage.setSubject(pc.Subject); pcMessage.setSentDate(new Date()); pcMessage.setReplyTo( new InternetAddress[] { new InternetAddress(pc.SentBy, pc.FromName) }); // What is a better way to get this name? String stylesheetName = "PostcardEmailHTML.xsl"; StylesheetRoot style = StylesheetManager.getStylesheet(stylesheetName); // Now create the DOM element (this is kinda hard-coded at this point) // Looks like this: /* http://www.chroniclebooks.com/ John Smith 12345-john@@y */ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.newDocument(); Element root = doc.createElement("postcard-email"); Element hostElm = doc.createElement("host"); Text hostElmText = doc.createTextNode(getString("tomcatHttp")); hostElm.appendChild(hostElmText); Element fromElm = doc.createElement("from"); Text fromElmText = doc.createTextNode(pc.FromName); fromElm.appendChild(fromElmText); Element idElm = doc.createElement("postcard-id"); Text idElmText = doc.createTextNode(pc.PostcardRequestID); idElm.appendChild(idElmText); root.appendChild(hostElm); root.appendChild(fromElm); root.appendChild(idElm); doc.appendChild(root); log.debug("Postcard DOM: " + doc); // Now do the transform to get the email body String body = StylesheetManager.transform(style, root); // This is the old way (very hard-coded) /* href = getString("tomcatHttp") + "Chronicle/servlet/at/go(postcard," + pc.PostcardRequestID + ")"; theBody = "\n" + pc.FromName + " has sent you an electronic postcard via the Chronicle Books Web Site.\n" + "\n" + "You can pick it up by clicking on the following link:\n" + "\n" + "The Postcard
" + "\n" + "If the link above doesn't work, cut and paste the link below into your browser's address field:\n" + "\n" + href + "\n" + "\n" + "To send your own free email postcard, go to:\n" + getString("tomcatHttp") + "Chronicle/servlet/at/efree.epost\n" + "\n" + "\n" + "Any questions? Please write to "; */ pcMessage.setContent(body, "text/html"); Transport.send(pcMessage); } finally { // clean up mailSess = null; pcMessage = null; theProps = null; } } /** * Sends an email based on information in the request, usually from hidden fields * on the HTML form. It is used for order inquiries, i think. * Not postcards. */ public void sendMail(HttpServletRequest request) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); Orders order = (Orders) session.getAttribute("Orders"); MimeMessage mimeMessage; // postcardsent as a message javax.mail.Session mailSess = null; String SMTPHost = this.getAppContext("taskSendNews.SMTPHost", resBundle); String SMTPUser = this.getAppContext("taskSendNews.SMTPUser", resBundle); Properties theProps = System.getProperties(); theProps.put("mail.smtp.host", SMTPHost); theProps.put("mail.smtp.user", SMTPUser); String MailTo = (String) request.getParameter("MailTo"); String Title = (String) request.getParameter("Title"); String MailFrom = (String) request.getParameter("MailFrom"); String FromName = (String) request.getParameter("FromName"); String Subject = (String) request.getParameter("Subject"); actionInfo.message = (String) request.getParameter("message"); if (MailTo == null) MailTo = ""; if (Title == null) Title = ""; if (MailFrom == null) MailFrom = ""; if (FromName == null) FromName = ""; if (Subject == null) Subject = ""; if (actionInfo.message == null) { actionInfo.message = ""; } String theBody = ""; Enumeration e = request.getParameterNames(); List keyList = new LinkedList(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); if (! ( name.equals("action") || name.equals("table") || name.equals("message") || name.equals("redirect") || name.equals("Title") || name.equals("MailTo") || name.equals("MailFrom") || name.equals("FromName") || name.equals("Subject"))) { keyList.add(name); } } Object[] sortedKeys = keyList.toArray(); Arrays.sort(sortedKeys); for (int i = 0; i < sortedKeys.length; i++) { theBody += sortedKeys[i] + ": " + request.getParameter((String) sortedKeys[i]) + "\n"; } // send the email try { // fill in headers mailSess = Session.getDefaultInstance(theProps, null); mimeMessage = new MimeMessage(mailSess); mimeMessage.setRecipients(Message.RecipientType.TO, InternetAddress.parse(MailTo, false)); mimeMessage.setFrom(new InternetAddress("frontdesk@@chroniclebooks.com", Title)); mimeMessage.setSubject(Subject); mimeMessage.setSentDate(new Date()); mimeMessage.setReplyTo(new InternetAddress[] { new InternetAddress(MailFrom, FromName) }); mimeMessage.setText(theBody); Transport.send(mimeMessage); } catch (Exception ex) { actionInfo.message = ex.getMessage(); log.error("Error sending email", ex); } finally { // clean up mailSess = null; mimeMessage = null; theProps = null; } } // end of method /** * send out a pretty postcard * Creation date: (1/12/2001 9:55:44 AM) * 2001.04.20 17:04:13 - add SentTo to PostcardRequestID * @@param table java.lang.String */ public void sendPostcard( HttpServletRequest request, HttpServletResponse response) throws ServletException { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); Orders order = (Orders) session.getAttribute("Orders"); PostcardSent pc = new PostcardSent(); pc.makeFromRequest(request, false); String send2 = pc.SentTo + "xxxxxx"; // Get next postcard id // this is in place of the old post tool solution where // id's were maintained in a file by this code int id; try { id = Sequence.nextPostcardId(); } catch (java.sql.SQLException e) { log.error("error getting next postcard id", e); throw new ServletException(e); } // will wants the id to be more complex pc.PostcardRequestID = id + "_" + send2.substring(0, 6); // lisa wants returns turned into line breaks in html... String pcMessage = ""; for (int i = 0; i < pc.Message.length(); i++) { char c = pc.Message.charAt(i); if (c == '\n' || c == '\r') { pcMessage += "
\n"; } else if (c > 31 && c < 129) { pcMessage += c; } else { // unknown character? just ignore it? if so, at least // explicitly ignore it. -mike log.warn("Unknown character in postcard text: " + c); } } pc.Message = pcMessage; pc.DBInsert(); if (actionInfo.action.equals("Send")) { // try to send the postcard try { sendMail(pc); actionInfo.message = "Your postcard has been sent."; actionInfo.redirect = "history(i);message"; } catch (Exception e) { log.error("Error sending postcard", e); actionInfo.redirect = "history(i);message"; actionInfo.message = e.getMessage(); } } else { // is this an error case or something real? -mike log.debug("Postcard action: " + actionInfo.action); actionInfo.redirect = "history(i);postcard," + pc.PostcardRequestID; } synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public void sendRedirect(HttpServletResponse response, String uri, String status) { try { if (!response.isCommitted()) { if (!status.equals("")) { status = "?status=" + java.net.URLEncoder.encode(status); } response.sendRedirect(uri + status); } } catch (Exception e) { System.out.println("Redirection error in processForm.sendRedirect."); //e.printStackTrace(); } } /** * The dataclass makes my life easy sometimes. * (and sometimes it makes it more difficult) */ public void setImage(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); Orders order = (Orders) session.getAttribute("Orders"); // ' PersonalImage pi = new PersonalImage(); pi.makeFromRequest(request, false); pi.Email = user.Email; pi.DBDelete(); pi.DBInsert(); String type = pi.ImageType; if (type.equals("Address")) { type += " Book"; } actionInfo.message = "Your " + type.toLowerCase() + " image has been set."; actionInfo.redirect = "history(u);"; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // } /** * because we are now in http, a new context should be set * carrying over just the bare amount of info to connect all the pieces * Creation date: (2/16/2001 11:31:57 AM) */ public void switchToSecure(HttpServletRequest request) { HttpSession session = request.getSession(); synchronized (session.getId().intern()) { session.setAttribute("historyLevel" , "u"); } String firstPage = (String) request.getParameter("myPointId"); String whichTree = (String) request.getParameter("section"); ClientInfo clientInfo = new ClientInfo(); clientInfo.addCommand("go"); clientInfo.addArgument(firstPage); clientInfo.addPointToSession(new Point(firstPage, "history"), session); log.debug("clientInfo = " + clientInfo); synchronized (session.getId().intern()) { session.setAttribute("whichTree", whichTree); } } /** * Insert the method's description here. * Creation date: (1/12/2001 3:35:31 PM) * @@return int * @@param s java.lang.String */ public int toInt(String s) { try { return Integer.parseInt(s); } catch (Exception e) { return -1; } } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public boolean userBillingPrefs( HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // ' synchronized (session.getId().intern()) { session.removeAttribute("Orders"); } RegUserAccount acct = new RegUserAccount(); acct.makeFromRequest(request, false); RegUserAccount storedAcct = new RegUserAccount(); int isOk = storedAcct.DBSelect("Email = \"" + user.Email + "\""); if (isOk == 1) { storedAcct.CardNumber = acct.CardNumber; storedAcct.ExpDateMM = acct.ExpDateMM; storedAcct.ExpDateYY = acct.ExpDateYY; storedAcct.CardType = acct.CardType; storedAcct.BillName = acct.BillName; storedAcct.BillAddress1 = acct.BillAddress1; storedAcct.BillAddress2 = acct.BillAddress2; storedAcct.BillCity = acct.BillCity; storedAcct.BillState = acct.BillState; storedAcct.BillZipCode = acct.BillZipCode; storedAcct.BillCountry = acct.BillCountry; storedAcct.BillTelephone = acct.BillTelephone; storedAcct.DBUpdate(); synchronized (session.getId().intern()) { session.setAttribute("RegUserAccount", storedAcct); } actionInfo.message = "Your billing preferences have been set."; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // return true; } else { // back to the page you were on (with some message) actionInfo.redirect = "history(u);"; actionInfo.message = "Error setting billing preferences."; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // return false; } } /** * Verify that the user has the necessary account information. * Is this for shipping only or both shipping and billing? -mike */ public boolean userHasPrefs(RegUserAccount acct) { if (acct.ShipName == null || acct.ShipName.trim().equals("")) return false; if (acct.ShipAddress1 == null || acct.ShipAddress1.trim().equals("")) return false; if (acct.ShipCity == null || acct.ShipCity.trim().equals("")) return false; if (acct.ShipState == null || acct.ShipState.trim().equals("")) return false; if (acct.ShipZipCode == null || acct.ShipZipCode.trim().equals("")) return false; if (acct.ShipTelephone == null || acct.ShipTelephone.trim().equals("")) return false; if (acct.CardNumber == null || acct.CardNumber.trim().equals("")) return false; if (acct.CardType == null || acct.CardType.trim().equals("")) return false; if (acct.ExpDateMM == null || acct.ExpDateMM.trim().equals("")) return false; if (acct.ExpDateYY == null || acct.ExpDateYY.trim().equals("")) return false; return true; } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public boolean userInsertNew(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // // synchronized (session.getId().intern()) { session.removeAttribute("Orders"); } synchronized (session.getId().intern()) { session.removeAttribute("RegUsers"); } synchronized (session.getId().intern()) { session.removeAttribute("RegUserAccount"); } synchronized (session.getId().intern()) { session.removeAttribute("secure"); } // user = new RegUsers(); user.makeFromRequest(request, false); // is it a temporary user? if (user.Access.equals("")) { user.Access = session.getId(); user.CatSection = "Temp"; } else { user.CatSection = "Adult"; } // boolean cookie = false; String Remember = (String) request.getParameter("Remember"); if (Remember != null && Remember.equals("yes")) { cookie = true; } String client = (String) request.getParameter("client"); // boolean isOk; if (user.CatSection.equals("Temp")) { isOk = user.getTableCount("Email = \"" + user.Email + "\"") == 0; //System.out.println(user.toHash()); } else { isOk = user.DBInsert(); } if (isOk) { boolean cartConnectedFromSession = cartUserUpdate(user.Email, request); // kill connected tables just in case String id = "Email = \"" + user.Email + "\""; Orders orders = new Orders(); OrderHistory history = new OrderHistory(); AddressBook book = new AddressBook(); PersonalCalendar pcal = new PersonalCalendar(); RegUserAccount acct = new RegUserAccount(); // bye orders.DBDelete(id); history.DBDelete(id); book.DBDelete(id); pcal.DBDelete(id); acct.DBDelete(id); // make a dummy default account acct.Email = user.Email; acct.ShipName = user.FirstName + " " + user.LastName; if (!user.CatSection.equals("Temp")) acct.DBInsert(); // save the stuff to session synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } synchronized (session.getId().intern()) { session.setAttribute("RegUserAccount", acct); } // just a flag so that the xsl templates can greet you synchronized (session.getId().intern()) { session.setAttribute("Login", new Login()); } // redirect if (actionInfo.redirect == null) actionInfo.redirect = "history(u);your"; actionInfo.message = "Welcome to Your Chronicle Books."; synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } synchronized (session.getId().intern()) { session.setAttribute("secure", new Date()); } sendJSResponse(request, response, client, cookie, false, cookie, false); return true; } else { // back to the page you were on (with some message) if (actionInfo.redirect.equals("history(u);shipping")) actionInfo.redirect = "history(u);reg_log"; else actionInfo.redirect = "history(u);register"; actionInfo.message = messages.getString("message.login.failed"); synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } return false; } } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public boolean userPasswordPrefs( HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers currentUser = (RegUsers) session.getAttribute("RegUsers"); RegUsers user = new RegUsers(); String Email = currentUser.Email; String Access = request.getParameter("cAccess"); if (Access.equals("")) { int isOk = user.DBSelect("Email=\"" + Email + "\""); if (isOk == 1) { user.FirstName = (String) request.getParameter("FirstName"); user.LastName = (String) request.getParameter("LastName"); user.DBUpdate(); synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } actionInfo.message = "Name updated."; } } else { log.debug("updating user password for " + Email); // get the user... & account information int isOk = user.DBSelect( "Email=\"" + Email + "\" AND Access=ENCODE(\"" + Access + "\", \"dookiedookster\")"); if (isOk == 1) { user.makeFromRequest(request, false); user.DBUpdate(); synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } actionInfo.message = "Name and password updated."; actionInfo.redirect = "history(u);your"; } else { actionInfo.message = "The current password entry is incorrect."; } } // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // return true; } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public boolean userShippingPrefs( HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // ' synchronized (session.getId().intern()) { session.removeAttribute("Orders"); } RegUserAccount acct = new RegUserAccount(); acct.makeFromRequest(request, false); RegUserAccount storedAcct = new RegUserAccount(); int isOk = storedAcct.DBSelect("Email = \"" + user.Email + "\""); if (isOk == 1) { storedAcct.ShipName = acct.ShipName; storedAcct.ShipAddress1 = acct.ShipAddress1; storedAcct.ShipAddress2 = acct.ShipAddress2; storedAcct.ShipCity = acct.ShipCity; storedAcct.ShipState = acct.ShipState; storedAcct.ShipZipCode = acct.ShipZipCode; storedAcct.ShipCountry = acct.ShipCountry; storedAcct.ShipTelephone = acct.ShipTelephone; storedAcct.DBUpdate(); synchronized (session.getId().intern()) { session.setAttribute("RegUserAccount", storedAcct); } actionInfo.message = "Your shipping preferences have been set."; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // return true; } else { // back to the page you were on (with some message) actionInfo.redirect = "history(u);"; actionInfo.message = "Error setting shipping preferences."; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // return false; } } /** * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String */ public boolean userUpdate(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // ' RegUsers oldUserInfo = user; user.makeFromRequest(request, false); user.Email = oldUserInfo.Email; boolean isOk = user.DBUpdate(); if (isOk) { actionInfo.redirect = "history(u);"; actionInfo.message = "Your information has been updated."; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // return true; } else { // what's wrong???? actionInfo.redirect = "history(u);your"; actionInfo.message = "Strange. I cannot seem to update your information. Were you gone for a while?"; // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // return false; } } /** * Validate user logging in and send them to the next page * (i think) -mike wynholds */ public void userValidate(HttpServletRequest request, HttpServletResponse response) throws IOException { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); boolean cookie = false; String Remember = (String) request.getParameter("Remember"); if (Remember != null && Remember.equals("yes")) { cookie = true; } String client = (String) request.getParameter("client"); synchronized (session.getId().intern()) { session.removeAttribute("Orders"); } synchronized (session.getId().intern()) { session.removeAttribute("RegUsers"); } synchronized (session.getId().intern()) { session.removeAttribute("RegUserAccount"); } synchronized (session.getId().intern()) { session.removeAttribute("secure"); } user = new RegUsers(); RegUserAccount acct = new RegUserAccount(); String Email = (String) request.getParameter("Email"); String Access = (String) request.getParameter("Access"); // get the user... & account information int isOk = user.DBSelect("Email=\"" + Email + "\" AND Access=ENCODE(\"" + Access + "\", \"dookiedookster\")"); if (isOk == 1) { isOk = acct.DBSelect("Email=\"" + Email + "\""); } if (isOk == 1) { Orders order = cart_AccountToOrder(acct, new Orders()); // transfer the cart Email to user Email boolean cartConnectedFromSession = cartUserUpdate(user.Email, request); // login is ok, setup the session synchronized (session.getId().intern()) { session.setAttribute("Orders", order); } synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } synchronized (session.getId().intern()) { session.setAttribute("RegUserAccount", acct); } synchronized (session.getId().intern()) { session.setAttribute("secure", new Date()); } log.debug("userValidate: " + user.CatSection); if (user.CatSection.equals("Temp")) { cookie = false; } // set redirect if (actionInfo.redirect == null) { actionInfo.redirect = "history(u);your"; } if (actionInfo.redirect.equals("cart*login")) { log.debug("Cart Login section"); if (userHasPrefs(acct)) { log.debug("Go to confirmation page"); actionInfo.redirect = "history(u);confirm"; } else { log.debug("Go to shipping page"); actionInfo.redirect = "history(u);shipping"; } } // set status message if (cartConnectedFromSession) { actionInfo.message = "Hi, " + user.toHash().get("FirstName") + "."; synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } // synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } sendJSResponse(request, response, client, true, false, cookie, false); } else { // the only real reason that a cart might not be tranferred // is if the item from the session cart has duplicate keys for email & isbn... actionInfo.message = "Hello " + user.toHash().get("FirstName") + ". " + "Did you know you already had a shopping cart from the last " + "time you were here. Check the quantity of each book " + "carefully before confirming the order."; synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } // synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // System.out.println("userValidate: !cartConnected, client="+client); sendJSResponse(request, response, client, true, false, cookie, false); } } else { // back to the page you were on (with some message) if (actionInfo.redirect.equals("cart*login")) { actionInfo.redirect = "history(u);reg_log"; } else { actionInfo.redirect = "history(u);login"; } actionInfo.message = messages.getString("message.login.failed"); synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } // synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // System.out.println("userValidate: no password/email match."); sendJSResponse(request, response, client, false, false, false, false); } } /** * Reads checkbox values and inserts or deletes them from the table based on your id. * Creation date: (2/16/2001 11:31:57 AM) */ public boolean yourFavorites(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // ' String[] checkboxValues = getCheckboxes(request); Favorites fav = new Favorites(); if (actionInfo.action.equals("Insert")) { for (int i = 0; i < checkboxValues.length; i++) { fav.Email = user.Email; fav.Favorite = checkboxValues[i]; fav.FavoriteType = "HomePage"; fav.DBInsert(); } actionInfo.redirect = "history(u);"; actionInfo.message = ""; } else if (actionInfo.action.equals("InsertREG")) { for (int i = 0; i < checkboxValues.length; i++) { fav.Email = user.Email; fav.Favorite = checkboxValues[i]; fav.FavoriteType = "HomePage"; fav.DBInsert(); } actionInfo.message = ""; } else { for (int i = 0; i < checkboxValues.length; i++) { fav.DBDelete( "Email = \"" + user.Email + "\" and Favorite = \"" + checkboxValues[i] + "\" and FavoriteType = \"HomePage\""); } actionInfo.redirect = "history(u);"; actionInfo.message = ""; } // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // return true; } /** * Reads checkbox values and inserts or deletes them from the table based on your id. * Creation date: (2/16/2001 11:31:57 AM) */ public boolean yourReminders(HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // ' String[] checkboxValues = getCheckboxes(request); Reminders rem = new Reminders(); if (actionInfo.action.equals("Insert")) { for (int i = 0; i < checkboxValues.length; i++) { rem.Email = user.Email; rem.ReminderEvent = checkboxValues[i]; rem.DBInsert(); } actionInfo.redirect = "history(u);"; actionInfo.message = ""; } else if (actionInfo.action.equals("InsertREG")) { for (int i = 0; i < checkboxValues.length; i++) { rem.Email = user.Email; rem.ReminderEvent = checkboxValues[i]; rem.DBInsert(); } actionInfo.message = ""; } else { for (int i = 0; i < checkboxValues.length; i++) { rem.Email = user.Email; rem.ReminderEvent = checkboxValues[i]; rem.DBDelete(); } actionInfo.redirect = "history(u);"; actionInfo.message = ""; } // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // return true; } /** * Reads checkbox values and inserts or deletes them from the table based on your id. * Creation date: (2/16/2001 11:31:57 AM) */ public boolean yourSubscription( HttpServletRequest request, HttpServletResponse response) { // unfortunately, this is how i make a global variable for processform // it must be synced at the end of the method for the next method... HttpSession session = request.getSession(); ActionInfo actionInfo = (ActionInfo) session.getAttribute("ActionInfo"); RegUsers user = (RegUsers) session.getAttribute("RegUsers"); // ' String[] checkboxValues = getCheckboxes(request); Subscriptions subs = new Subscriptions(); if (actionInfo.action.equals("Insert")) { for (int i = 0; i < checkboxValues.length; i++) { subs.Email = user.Email; subs.NewsLetter = checkboxValues[i]; subs.DBInsert(); } actionInfo.redirect = "history(u);"; actionInfo.message = ""; } else if (actionInfo.action.equals("InsertREG")) { for (int i = 0; i < checkboxValues.length; i++) { subs.Email = user.Email; subs.NewsLetter = checkboxValues[i]; subs.DBInsert(); } actionInfo.message = ""; } else { for (int i = 0; i < checkboxValues.length; i++) { subs.Email = user.Email; subs.NewsLetter = checkboxValues[i]; subs.DBDelete(); } actionInfo.redirect = "history(u);"; actionInfo.message = ""; } // synchronized (session.getId().intern()) { session.setAttribute("ActionInfo", actionInfo); } synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // return true; } } @ 1.28 log @*** empty log message *** @ text @d2587 16 a2602 8 for (int i = 0; i < checkboxValues.length; i++) { fav.Email = user.Email; fav.Favorite = checkboxValues[i]; fav.FavoriteType = "HomePage"; fav.DBInsert(); } actionInfo.redirect = "history(u);"; actionInfo.message = ""; d2604 10 a2613 10 for (int i = 0; i < checkboxValues.length; i++) { fav.DBDelete( "Email = \"" + user.Email + "\" and Favorite = \"" + checkboxValues[i] + "\" and FavoriteType = \"HomePage\""); } actionInfo.redirect = "history(u);"; actionInfo.message = ""; d2635 14 a2648 7 for (int i = 0; i < checkboxValues.length; i++) { rem.Email = user.Email; rem.ReminderEvent = checkboxValues[i]; rem.DBInsert(); } actionInfo.redirect = "history(u);"; actionInfo.message = ""; d2650 7 a2656 7 for (int i = 0; i < checkboxValues.length; i++) { rem.Email = user.Email; rem.ReminderEvent = checkboxValues[i]; rem.DBDelete(); } actionInfo.redirect = "history(u);"; actionInfo.message = ""; d2680 14 a2693 7 for (int i = 0; i < checkboxValues.length; i++) { subs.Email = user.Email; subs.NewsLetter = checkboxValues[i]; subs.DBInsert(); } actionInfo.redirect = "history(u);"; actionInfo.message = ""; d2695 7 a2701 7 for (int i = 0; i < checkboxValues.length; i++) { subs.Email = user.Email; subs.NewsLetter = checkboxValues[i]; subs.DBDelete(); } actionInfo.redirect = "history(u);"; actionInfo.message = ""; @ 1.27 log @Added redirect to "Your Chronicle Books" upon successful order. @ text @d1507 8 d1524 1 a1524 1 @ 1.26 log @Added fh parameter to the ActionInfo class and changed processForm.java to append this parameter to the redirect location it sends on invocation when the flash movie should be redirected to it's home movie. @ text @d752 5 a756 1 actionInfo.redirect = "history(u);message"; @ 1.25 log @fixed bug 937 - cannot update shopping cart. basically, the update algorithm was not matching up the items that is was updating in the cart. so when there was more than 1 item in the cart, sometimes the system would try to update item 1 with item 2's info. this caused a database exception. now it works fine. as a bonus, it was also updating the database even when nothing in the cart had changed. so now it doesn't. more efficient, and faster. -mike @ text @d695 2 d1703 1 a1703 1 + "\";"); d1705 1 d1735 1 @ 1.24 log @error handling and debug output. -mike @ text @d790 1 a790 1 /** d795 2 a796 1 public void cartUpdate(HttpServletRequest request, HttpServletResponse response) { d802 1 a802 1 // d804 63 a866 23 Cart cart = new Cart(); Vector rows = requestAsRows(request, cart); if (!rows.isEmpty()) { Hashtable newRow = (Hashtable) rows.elementAt(0); cart.DBSelect( "ISBN", "Catalog", "Email = \"" + newRow.get("Email") + "\" " + " ORDER BY Catalog.Title"); for (int i = 0; i < rows.size(); i++) { cart.DBSelectRow(i); Hashtable oldRow = cart.toHash(); newRow = (Hashtable) rows.elementAt(i); if (toInt((String) newRow.get("Quantity")) == 0) { int rowsGone = cart.DBDelete(); if (rowsGone > 1) { isOk = false; break; } } else { if (!(isOk = cart.DBUpdate(oldRow, newRow))) { break; } } d869 3 a871 1 if (isOk) { d873 2 a874 2 if (actionInfo.redirect == null) actionInfo.redirect = ""; d876 3 a878 1 } else { d880 1 d882 1 a882 1 actionInfo.message = "The was a problem updating your shopping cart."; d884 1 a884 1 // d886 1 a886 2 //synchronized (session.getId().intern()) { session.setAttribute("RegUsers", user); } // d888 2 a889 1 /** @ 1.23 log @all session action is sychronized. -mike @ text @d541 1 d548 1 d566 1 d572 1 d574 5 a578 1 if (! inserted) actionInfo.message += "Order Error: Invalid invoice number for order. "; d582 1 d584 1 d586 1 d589 1 d594 2 d597 5 a601 1 if (! inserted) actionInfo.message += "Order Error: Cannot transfer from cart to orderItems. "; d605 1 d612 1 @ 1.22 log @using Messages.properties (for one thing). -mike @ text @d72 1 a72 1 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } d82 2 a83 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d109 2 a110 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d133 2 a134 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d165 1 a165 1 synchronized (session) { session.setAttribute("address", address); } d221 1 a221 1 synchronized (session) { session.setAttribute("address", address); } d226 2 a227 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d291 1 a291 1 synchronized (session) { session.setAttribute("address", address); } d296 2 a297 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d324 2 a325 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d459 2 a460 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d483 1 a483 1 synchronized (session) { session.setAttribute("Orders", order); } d515 2 a516 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d540 1 a540 1 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } d566 1 a566 1 synchronized (session) { session.setAttribute("Orders", order); } d597 1 a597 1 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } d694 4 a697 4 session.removeAttribute("RegUsers"); session.removeAttribute("RegUserAccount"); session.removeAttribute("Orders"); session.removeAttribute("secure"); d700 1 a700 1 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } d724 1 a724 1 synchronized (session) { session.setAttribute("whichTree", "adults"); } d731 2 a732 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } // synchronized (session) { session.setAttribute("RegUsers", user); } d764 1 a764 1 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } d819 2 a820 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d916 1 a916 1 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } d945 1 a945 1 synchronized (session) { session.setAttribute("Date", date); } d982 1 a982 1 synchronized (session) { session.setAttribute("Date", date); } d985 2 a986 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d1017 2 a1018 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d1046 1 a1046 1 synchronized (session) { session.setAttribute("Date", date); } d1060 2 a1061 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d1111 1 a1111 1 synchronized (session) { session.setAttribute("Date", date); } d1120 2 a1121 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d1155 1 a1155 1 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } d1192 1 a1192 1 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } d1194 1 a1194 1 //synchronized (session) { session.setAttribute("RegUsers", user); } d1229 2 a1230 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d1546 5 a1550 5 synchronized (session) { session.setAttribute("whichTree",whichtree); } synchronized (session) { session.setAttribute("historyLevel",""); } synchronized (session) { session.setAttribute("history", history); } synchronized (session) { session.setAttribute("command", command); } synchronized (session) { session.setAttribute("client", client); } d1978 1 a1978 1 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } d2023 2 a2024 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d2037 1 a2037 1 synchronized (session) { session.setAttribute("historyLevel" , "u"); } d2045 1 a2045 1 synchronized (session) { session.setAttribute("whichTree", whichTree); } d2075 1 a2075 1 session.removeAttribute("Orders"); d2094 1 a2094 1 synchronized (session) { session.setAttribute("RegUserAccount", storedAcct); } d2097 2 a2098 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d2106 2 a2107 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d2145 4 a2148 4 session.removeAttribute("Orders"); session.removeAttribute("RegUsers"); session.removeAttribute("RegUserAccount"); session.removeAttribute("secure"); d2196 2 a2197 2 synchronized (session) { session.setAttribute("RegUsers", user); } synchronized (session) { session.setAttribute("RegUserAccount", acct); } d2200 1 a2200 1 synchronized (session) { session.setAttribute("Login", new Login()); } d2205 3 a2207 3 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } synchronized (session) { session.setAttribute("secure", new Date()); } d2220 2 a2221 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d2250 1 a2250 1 synchronized (session) { session.setAttribute("RegUsers", user); } d2263 1 a2263 1 synchronized (session) { session.setAttribute("RegUsers", user); } d2271 2 a2272 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d2290 1 a2290 1 session.removeAttribute("Orders"); d2305 1 a2305 1 synchronized (session) { session.setAttribute("RegUserAccount", storedAcct); } d2308 2 a2309 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } //synchronized (session) { session.setAttribute("RegUsers", user); } d2317 2 a2318 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } synchronized (session) { session.setAttribute("RegUsers", user); } d2343 2 a2344 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } synchronized (session) { session.setAttribute("RegUsers", user); } d2353 2 a2354 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } synchronized (session) { session.setAttribute("RegUsers", user); } d2383 4 a2386 4 session.removeAttribute("Orders"); session.removeAttribute("RegUsers"); session.removeAttribute("RegUserAccount"); session.removeAttribute("secure"); d2408 4 a2411 4 synchronized (session) { session.setAttribute("Orders", order); } synchronized (session) { session.setAttribute("RegUsers", user); } synchronized (session) { session.setAttribute("RegUserAccount", acct); } synchronized (session) { session.setAttribute("secure", new Date()); } d2445 2 a2446 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } // synchronized (session) { session.setAttribute("RegUsers", user); } d2462 2 a2463 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } // synchronized (session) { session.setAttribute("RegUsers", user); } d2483 2 a2484 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } // synchronized (session) { session.setAttribute("RegUsers", user); } d2526 2 a2527 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } synchronized (session) { session.setAttribute("RegUsers", user); } d2562 2 a2563 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } synchronized (session) { session.setAttribute("RegUsers", user); } d2600 2 a2601 2 synchronized (session) { session.setAttribute("ActionInfo", actionInfo); } synchronized (session) { session.setAttribute("RegUsers", user); } @ 1.21 log @synchronized session management stuff. -mike @ text @d43 1 d50 1 d2193 2 a2194 1 acct.DBInsert(); d2198 1 d2202 1 a2202 2 if (actionInfo.redirect == null) actionInfo.redirect = "history(u);your"; d2204 1 a2204 1 // d2208 1 a2208 1 // d2211 3 a2213 1 } else { d2215 5 a2219 10 if (actionInfo.redirect.equals("history(u);shipping")) { actionInfo.redirect = "history(u);reg_log"; } else { actionInfo.redirect = "history(u);register"; } actionInfo.message = "There is already someone with that email address. " + "If you have forgotten your password, please email " + "frontdesk@@chroniclebooks.com."; // d2222 1 a2222 1 // d2481 1 a2481 4 actionInfo.message = "The email address and password you entered do not match.
Try again. " + "If you have forgotten your password, please email " + "frontdesk@@chroniclebooks.com."; @ 1.20 log @comments. -mike @ text @d70 1 a70 1 session.setAttribute("ActionInfo", actionInfo); d80 2 a81 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d107 2 a108 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d131 2 a132 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d163 1 a163 1 session.setAttribute("address", address); d219 1 a219 1 session.setAttribute("address", address); d224 2 a225 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d289 1 a289 1 session.setAttribute("address", address); d294 2 a295 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d322 2 a323 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d457 2 a458 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d481 1 a481 1 session.setAttribute("Orders", order); d513 2 a514 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d538 1 a538 1 session.setAttribute("ActionInfo", actionInfo); d564 1 a564 1 session.setAttribute("Orders", order); d595 1 a595 1 session.setAttribute("ActionInfo", actionInfo); d698 1 a698 1 session.setAttribute("ActionInfo", actionInfo); d722 1 a722 1 session.setAttribute("whichTree", "adults"); d729 2 a730 2 session.setAttribute("ActionInfo", actionInfo); // session.setAttribute("RegUsers", user); d762 1 a762 1 session.setAttribute("ActionInfo", actionInfo); d817 2 a818 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d914 1 a914 1 session.setAttribute("ActionInfo", actionInfo); d943 1 a943 1 session.setAttribute("Date", date); d980 1 a980 1 session.setAttribute("Date", date); d983 2 a984 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d1015 2 a1016 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d1044 1 a1044 1 session.setAttribute("Date", date); d1058 2 a1059 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d1109 1 a1109 1 session.setAttribute("Date", date); d1118 2 a1119 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d1153 1 a1153 1 session.setAttribute("ActionInfo", actionInfo); d1190 1 a1190 1 session.setAttribute("ActionInfo", actionInfo); d1192 1 a1192 1 //session.setAttribute("RegUsers", user); d1227 2 a1228 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d1544 5 a1548 5 session.setAttribute("whichTree",whichtree); session.setAttribute("historyLevel",""); session.setAttribute("history", history); session.setAttribute("command", command); session.setAttribute("client", client); d1976 1 a1976 1 session.setAttribute("ActionInfo", actionInfo); d2021 2 a2022 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d2035 1 a2035 1 session.setAttribute("historyLevel" , "u"); d2043 1 a2043 1 session.setAttribute("whichTree", whichTree); d2092 1 a2092 1 session.setAttribute("RegUserAccount", storedAcct); d2095 2 a2096 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d2104 2 a2105 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d2193 2 a2194 2 session.setAttribute("RegUsers", user); session.setAttribute("RegUserAccount", acct); d2196 1 a2196 1 session.setAttribute("Login", new Login()); d2202 3 a2204 3 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); session.setAttribute("secure", new Date()); d2220 2 a2221 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d2250 1 a2250 1 session.setAttribute("RegUsers", user); d2263 1 a2263 1 session.setAttribute("RegUsers", user); d2271 2 a2272 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d2305 1 a2305 1 session.setAttribute("RegUserAccount", storedAcct); d2308 2 a2309 2 session.setAttribute("ActionInfo", actionInfo); //session.setAttribute("RegUsers", user); d2317 2 a2318 2 session.setAttribute("ActionInfo", actionInfo); session.setAttribute("RegUsers", user); d2343 2 a2344 2 session.setAttribute("ActionInfo", actionInfo); session.setAttribute("RegUsers", user); d2353 2 a2354 2 session.setAttribute("ActionInfo", actionInfo); session.setAttribute("RegUsers", user); d2408 4 a2411 4 session.setAttribute("Orders", order); session.setAttribute("RegUsers", user); session.setAttribute("RegUserAccount", acct); session.setAttribute("secure", new Date()); d2445 2 a2446 2 session.setAttribute("ActionInfo", actionInfo); // session.setAttribute("RegUsers", user); d2462 2 a2463 2 session.setAttribute("ActionInfo", actionInfo); // session.setAttribute("RegUsers", user); d2486 2 a2487 2 session.setAttribute("ActionInfo", actionInfo); // session.setAttribute("RegUsers", user); d2529 2 a2530 2 session.setAttribute("ActionInfo", actionInfo); session.setAttribute("RegUsers", user); d2565 2 a2566 2 session.setAttribute("ActionInfo", actionInfo); session.setAttribute("RegUsers", user); d2603 2 a2604 2 session.setAttribute("ActionInfo", actionInfo); session.setAttribute("RegUsers", user); @ 1.19 log @Flash version of order conf page now has links on it. -mike @ text @d1486 4 a1489 1 // Send order inquiries only (not postcards, i think) @ 1.18 log @order confirmation page doesn't go directly to "your chronicle books" -mike @ text @d678 2 a679 1 if (client.equals("HTML")) d707 1 d712 4 d723 1 a723 1 if (client.equals("HTML")) @ 1.17 log @added email link to order confirmation screen. -mike @ text @d722 1 a722 1 actionInfo.redirect = "history(u);your"; @ 1.16 log @already in shopping cart message. -mike @ text @d677 6 d687 1 a687 2 += "Your order should arrive 7-10 days after it is processed. If you have any questions, " + "contact customer service."; d714 1 a714 1 + "7-10 days after it is processed. If you have any questions, contact customer service."; @ 1.15 log @1. modified order confirmation message, but it still needs to be put on a separate page. 2. now order inquiry email prints message after email is sent. -mike @ text @d420 2 a421 1 public void cartAdd(HttpServletRequest request, HttpServletResponse response) { d428 1 a428 1 // d432 3 a434 1 if (isOk) { d437 3 a439 1 } else { d442 13 a454 1 actionInfo.message += "You already have that in your cart. "; d456 1 a456 2 // //System.out.println(actionInfo.redirect+" "+client); a458 1 // d460 1 d1855 1 a1855 2 mimeMessage.setRecipients(Message.RecipientType.TO, InternetAddress.parse(MailTo, false)); d1859 1 a1859 1 mimeMessage.setReplyTo(new InternetAddress[] { new InternetAddress(MailFrom, FromName)}); @ 1.14 log @basically just formatting. -mike @ text @d63 11 a73 1 // d664 4 d684 6 d691 4 a694 1 += "You may cancel this order from account maintenance anytime before it is shipped. "; d1459 1 a1459 1 // Send and preview postcard d1763 7 a1769 6 // end of method // updated 2001.04.26 18:35:06 // add new text // new postcard URL with part of recipient's address embedded // wrap URL in public void sendMail(HttpServletRequest request) { d1776 1 a1776 1 // ' d1784 3 a1786 3 // String MailTo = (String) request.getParameter("MailTo"); String Title = (String) request.getParameter("Title"); d1789 12 a1800 18 String Subject = (String) request.getParameter("Subject"); //actionInfo.message = (String) request.getParameter("message"); if (MailTo == null) { MailTo = ""; } if (Title == null) { Title = ""; } if (MailFrom == null) { MailFrom = ""; } if (FromName == null) { FromName = ""; } if (Subject == null) { Subject = ""; } if (actionInfo.message == null) { d1803 1 d1807 2 a1808 1 while (e.hasMoreElements()) { d1810 11 a1820 10 if (!(name.equals("action") || name.equals("table") || name.equals("message") || name.equals("redirect") || name.equals("Title") || name.equals("MailTo") || name.equals("MailFrom") || name.equals("FromName") || name.equals("Subject"))) { keyList.add(name); d1825 2 a1826 1 for (int i = 0; i < sortedKeys.length; i++) { d1828 3 a1830 3 + ": " + request.getParameter((String) sortedKeys[i]) + "\n"; d1832 4 a1835 1 try { d1839 2 a1840 3 mimeMessage.setRecipients( Message.RecipientType.TO, InternetAddress.parse(MailTo, false)); d1844 1 a1844 2 mimeMessage.setReplyTo( new InternetAddress[] { new InternetAddress(MailFrom, FromName)}); d1847 8 a1854 4 } catch (Exception Excp) { actionInfo.message = Excp.getMessage(); System.out.println("send failed: "+theBody); } finally { d1856 1 a1856 1 mailSess = null; d1858 1 a1858 1 theProps = null; d1861 1 @ 1.13 log @just added some comments around the XML created to send postcards. -mike @ text @d574 1 a574 3 * Insert the method's description here. * Creation date: (1/12/2001 9:55:44 AM) * @@param table java.lang.String d576 5 a580 4 public void cartOrderEmail( HttpServletRequest request, RegUsers user, Orders order) { d596 2 a597 1 if (!order.ShipAddress1.equals("")) { d600 1 a600