package com.sun.j2ee.blueprints.adventure.web.actions;
import javax.servlet.http.*;
import java.util.Collection;
import javax.naming.*;
import javax.xml.rpc.*;
import com.sun.j2ee.blueprints.waf.controller.Event;
import com.sun.j2ee.blueprints.waf.controller.web.html.*;
import com.sun.j2ee.blueprints.adventure.web.*;
import com.sun.j2ee.blueprints.adventure.web.exceptions.*;
import com.sun.j2ee.blueprints.catalog.*;
public class OrderTrackingHTMLAction extends HTMLActionSupport{
public Event perform(HttpServletRequest request)
throws HTMLActionException {
String orderId = null;
OrderDetails result = null;
orderId = request.getParameter("orderId");
request.setAttribute("orderTrackingId", orderId);
try {
result = this.getOrderDetails(orderId, request);
if (result.getPO() == null) {
throw new OrderNotFoundException("Order Not Found: " + orderId);
}
request.setAttribute("orderDetails", result);
} catch(Exception ex) {
throw new OrderNotFoundException("Handler error calling ordertracking endpoint " + ex);
}
return null;
}
private OrderDetails getOrderDetails(String orderId,
HttpServletRequest request) throws Exception {
Context ic = new InitialContext();
OpcOrderTrackingService opcOrderTrackingSvc =
(OpcOrderTrackingService) ic.lookup("java:comp/env/service/OpcOrderTrackingService");
OrderTrackingIntf port = opcOrderTrackingSvc.getOrderTrackingIntfPort();
String server = (request.getServerPort() != 0) ?
(request.getServerName()+":"+request.getServerPort()) :
(request.getServerName());
((Stub)port)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY,
"http://" + server + "/webservice/OtEndpointBean");
return port.getOrderDetails(orderId);
}
}