1 19 20 package com.lutris.airsent.presentation.customer; 21 import com.lutris.airsent.spec.AirSentException; 22 import com.lutris.airsent.presentation.*; 23 24 25 import com.lutris.airsent.spec.customer.Customer; 26 import com.lutris.airsent.spec.delivery.*; 27 import com.lutris.airsent.spec.*; 28 29 import com.lutris.appserver.server.httpPresentation.*; 30 import com.lutris.util.*; 31 import org.w3c.dom.*; 34 import org.w3c.dom.html.*; 35 import org.enhydra.xml.xmlc.XMLObject; 36 import java.util.*; 37 38 41 public class OrderPage4 42 extends BasePO { 43 44 47 private static final int AUTH_LEVEL = AirSentConstants.CUSTOMER_USER; 48 49 55 public int getRequiredAuthLevel() { 56 return AUTH_LEVEL; 57 } 58 59 65 public XMLObject handleDefault() 66 throws HttpPresentationException { 67 68 try { 69 OrderForm orderForm = getSessionData().getOrderForm(); 70 if (orderForm == null) { 71 System.err.println("ERROR: no order form"); 72 throw new ClientPageRedirectException(AirSentConstants.ORDERSTEP1_PO); 73 } 74 return showPage4(null, orderForm); 75 } catch (Exception e) { 76 throw new AirSentPresentationException("System error finding user", e); 77 } 78 } 79 80 87 private XMLObject showPage4(String errorMsg, OrderForm orderForm) 88 throws AirSentPresentationException { 89 90 ConfirmationHTML page = (ConfirmationHTML) myComms.xmlcFactory.create(ConfirmationHTML.class); 91 if (null != errorMsg || null != (errorMsg = getSessionData().getAndClearUserMessage())) { 92 page.setTextErrorText(errorMsg); 93 } else { 94 page.getElementErrorText().getParentNode().removeChild(page.getElementErrorText()); 95 } 96 97 try { 98 page.setTextPickupname(orderForm.getPickUpName()); 99 page.setTextPickupaddress(orderForm.getPickUpAddress1()); 100 page.setTextPickupphone(orderForm.getPickUpPhone()); 101 page.setTextDropoffname(orderForm.getDropOffName()); 102 page.setTextDropoffaddress(orderForm.getDropOffAddress1()); 103 page.setTextDropoffphone(orderForm.getDropOffPhone()); 104 105 if (orderForm.getUrgent() == true) { 106 page.getElementPickupurgent().setSrc(AirSentConstants.URGENT_IMAGE); 107 page.getElementDropoffurgent().setSrc(AirSentConstants.URGENT_IMAGE); 108 } else { 109 page.getElementPickupurgent().setSrc(AirSentConstants.BLANK_IMAGE); 110 page.getElementDropoffurgent().setSrc(AirSentConstants.BLANK_IMAGE); 111 } 112 113 114 if (orderForm.getFragile() == true) { 115 page.getElementPickupfragile().setSrc(AirSentConstants.URGENT_IMAGE); 116 page.getElementDropofffragile().setSrc(AirSentConstants.URGENT_IMAGE); 117 } else { 118 page.getElementPickupfragile().setSrc(AirSentConstants.BLANK_IMAGE); 119 page.getElementDropofffragile().setSrc(AirSentConstants.BLANK_IMAGE); 120 } 121 page.setTextPickupdescription(orderForm.getDescription()); 122 page.setTextDropoffdescription(orderForm.getDescription()); 123 124 125 126 }catch(NullPointerException e){ 128 129 ConfirmationHTML defaultPage = (ConfirmationHTML) myComms.xmlcFactory.create(ConfirmationHTML.class); 130 defaultPage.setTextErrorText("This is a default HTML page"); 131 return defaultPage; 132 } catch (Exception ex) { 133 throw new AirSentPresentationException("Error in confimation", ex); 134 } 135 return page; 136 } 137 138 144 public XMLObject handleOrder4() 145 throws AirSentPresentationException { 146 try { 147 OrderForm orderForm = getSessionData().getOrderForm(); 148 if (orderForm == null) { 149 System.err.println("ERROR: no order form"); 150 throw new ClientPageRedirectException(AirSentConstants.ORDERSTEP1_PO); 151 } 152 Customer customer = getSessionData().getCustomer(); 153 HomeManager hf = getApplication().getHomeManager(); 154 DeliveryManager df = hf.getDeliveryManager(); 155 Delivery delivery = df.create(customer, orderForm); 156 delivery.save(); 157 if (orderForm.getOrderId() == null) { 158 getSessionData().setUserMessage("Thanks for your order! Your order # is:" + delivery.getHandle()); 159 } else { 160 getSessionData().setUserMessage("Your changes to order #:" + delivery.getHandle() + " have been saved."); 161 } 162 getSessionData().setOrderForm(null); 163 throw new ClientPageRedirectException(AirSentConstants.ORDERSTEP1_PO); 164 }catch(NullPointerException e){ 166 throw new ClientPageRedirectException(AirSentConstants.ORDERSTEP1_PO); 167 168 } catch (AirSentException ex) { 169 throw new AirSentPresentationException("Exception logging in order: ", ex); 170 } 171 } 172 173 179 public XMLObject handleCancel() { 180 getSessionData().setOrderForm(null); 181 throw new ClientPageRedirectException(AirSentConstants.ORDERSTEP1_PO); 182 } 183 } 184 185 186 187 | Popular Tags |