Ejemplo n.º 1
0
  public ActionForward doAction(
      ActionMapping mapping, HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    DataHandler handler = (DataHandler) request.getAttribute(BrowserFrameworkConstants.CLIENT_INFO);

    // get values for current location lat and lon, and also distUnit
    TxNode node = (TxNode) handler.getParameter("anchorLat");
    long anchorLat = node != null ? node.valueAt(0) : -1;

    node = (TxNode) handler.getParameter("anchorLon");
    long anchorLon = node != null ? node.valueAt(0) : -1;

    node = (TxNode) handler.getParameter("distUnit");
    long distUnit = node != null ? node.valueAt(0) : 1;

    logger.debug("Lat:" + anchorLat + " Lon:" + anchorLon + "Dist Unit:" + distUnit);

    // convert distUnit to mi or km
    String scale = "mi";
    if (distUnit != Constant.DUNIT_MILES) {
      scale = "km";
    }

    // set attributes for anchor lat, lon, distUnit and scale
    request.setAttribute("anchorLat", anchorLat);
    request.setAttribute("anchorLon", anchorLon);
    request.setAttribute("distUnit", distUnit);
    request.setAttribute("scale", scale);

    try {
      logger.debug("ShareMovie... before");
      ExecutorRequest[] executorRequests = requestParser.parse(request);

      ShareMovieResponse executorResponse = new ShareMovieResponse();

      if (executorRequests != null && executorRequests.length > 0) {
        ExecutorDispatcher ac = ExecutorDispatcher.getInstance();
        ac.execute(executorRequests[0], executorResponse, new ExecutorContext());
      }

      if (executorResponse.getStatus() == ExecutorResponse.STATUS_FAIL) {
        request.setAttribute("errorCode", new Long(-1));
        request.setAttribute("errorMsg", executorResponse.getErrorMessage());
        return mapping.findForward("failure");
      }

      responseFormatter.format(request, new ExecutorResponse[] {executorResponse});
      logger.debug("ShareMovie... after");
      return mapping.findForward("success");
    } catch (Exception e) {
      ActionMessages msgs = new ActionMessages();
      msgs.add("loginfailed", new ActionMessage("errors.movie.failed"));
      addErrors(request, msgs);
      return mapping.findForward("failure");
    }
  }
 @Override
 public ExecutorRequest[] parse(Object object) throws ExecutorException {
   SentAddressRequest request = new SentAddressRequest();
   TxNode node = (TxNode) object;
   request.setUserId(node.valueAt(0));
   return new ExecutorRequest[] {request};
 }
  @Override
  public ExecutorRequest[] parse(Object object) throws ExecutorException {
    TxNode node = (TxNode) object;
    BannerAdsRequest request = new BannerAdsRequest();

    request.setExecutorType(node.msgAt(0));
    request.setPageId(node.msgAt(1));
    request.setKeyWord(node.msgAt(2));
    request.setSearchId(node.msgAt(3));
    request.setPageIndex((int) node.valueAt(3));

    Location location = getLocation(node.valueAt(1), node.valueAt(2));
    request.setLoc(location);
    if (TYPE_CURRENT_LOCATION == node.valueAt(3)) {
      request.setCurLoc(location);
    }

    double width = node.valueAt(5);
    double height = node.valueAt(6);
    // FIXME: what is the real configuration?
    final int preferredWidth = (int) (width * 0.95);
    int preferredHeight = (int) (height / 4);

    ImageSizeType maxSize = new ImageSizeType();
    maxSize.setHeight(preferredHeight);
    maxSize.setWidth(preferredWidth);
    request.setMaxSize(maxSize);

    ImageSizeType minSize = new ImageSizeType();
    minSize.setWidth((int) (width / 2));
    minSize.setHeight((int) (height * 0.04));

    request.setMinSize(minSize);

    return new ExecutorRequest[] {request};
  }