1 2 3 package com.sun.j2ee.blueprints.consumerwebsite.actions; 4 5 import javax.servlet.http.*; 6 import java.util.Collection ; 7 import javax.naming.*; 8 import javax.xml.rpc.*; 9 10 import com.sun.j2ee.blueprints.waf.controller.Event; 12 import com.sun.j2ee.blueprints.waf.controller.web.html.*; 13 14 import com.sun.j2ee.blueprints.consumerwebsite.*; 16 17 import com.sun.j2ee.blueprints.catalog.*; 19 20 21 25 public class OrderTrackingHTMLAction extends HTMLActionSupport{ 26 27 33 public Event perform(HttpServletRequest request) throws HTMLActionException { 34 35 String orderId = null; 36 OrderDetails result = null; 37 orderId = request.getParameter("orderId"); 38 request.setAttribute("orderTrackingId", orderId); 40 try { 41 result = this.getOrderDetails(orderId, request); 42 if (result.getPO() == null) { 43 throw new OrderNotFoundException("Order Not Found: " + orderId); 44 } 45 request.setAttribute("orderDetails", result); 47 } catch(OrderNotFoundException ex) { 48 System.out.println("OrderTrackingHTMLAction caught the OrderNotFoundException Service Exception"); 49 throw new com.sun.j2ee.blueprints.consumerwebsite.exceptions.OrderNotFoundException("Action error calling ordertracking endpoint " + ex); 50 } catch(Exception ex) { 51 System.out.println("OrderTrackingHTMLAction caught an Exception"); 52 throw new com.sun.j2ee.blueprints.consumerwebsite.exceptions.OrderNotFoundException("Action error calling ordertracking endpoint " + ex); 53 } 54 return null; 55 } 56 57 60 private OrderDetails getOrderDetails(String orderId, 61 HttpServletRequest request) throws Exception { 62 63 Context ic = new InitialContext(); 64 OpcOrderTrackingService opcOrderTrackingSvc = 65 (OpcOrderTrackingService) ic.lookup("java:comp/env/service/OpcOrderTrackingService"); 66 OrderTrackingIntf port = opcOrderTrackingSvc.getOrderTrackingIntfPort(); 67 String server = (request.getServerPort() != 0) ? 68 (request.getServerName()+":"+request.getServerPort()) : 69 (request.getServerName()); 70 ((Stub)port)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, 71 "http://" + server + "/webservice/OpcOrderTrackingService"); 72 return port.getOrderDetails(orderId); 73 } 74 } 75 | Popular Tags |