@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};
 }
Ejemplo n.º 2
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 void parseBrowserResponse(
      HttpServletRequest httpRequest, ExecutorResponse executorResponse) {
    ShareAddressResponse response = (ShareAddressResponse) executorResponse;
    int status = response.getStatus();
    boolean isRGC = response.isRGC();
    String resultText = "N";
    if (status == ExecutorResponse.STATUS_OK) {
      resultText = "Y";
    }
    TxNode node = new TxNode();
    node.addMsg(resultText);
    if (isRGC) {
      Stop stop = response.getAddress();
      JSONObject stopJo = new JSONObject();
      try {
        stopJo.put("firstLine", stop.firstLine);
        stopJo.put("city", stop.city);
        stopJo.put("state", stop.state);
        stopJo.put("country", stop.country);
        stopJo.put("lon", stop.lon);
        stopJo.put("zip", stop.zip);
        stopJo.put("lat", stop.lat);
        stopJo.put("lon", stop.lon);
        stopJo.put("label", stop.label);
      } catch (JSONException e) {
        // TODO Auto-generated catch block
        logger.error("JSONException occured when we want to put a string into it");
        logger.error("cause:" + e.getCause() + ",message:" + e.getMessage());
      }

      node.addMsg(stopJo.toString());
    }
    httpRequest.setAttribute("node", node);

    // TODO save audio
  }
  protected ActionForward doAction(
      ActionMapping mapping, HttpServletRequest request, HttpServletResponse response) {
    try {
      DataHandler handler =
          (DataHandler) request.getAttribute(BrowserFrameworkConstants.CLIENT_INFO);
      Long userId = PoiUtil.getUserId(handler);
      TnContext tc = PoiUtil.getTnContext(handler);
      TxNode body = handler.getAJAXBody();
      String joString = body.msgAt(0);
      JSONObject jo = new JSONObject(joString);
      String firstName = jo.getString("firstName");
      String lastName = jo.getString("lastName");
      String email = jo.getString("email");
      if (null != email) {
        email = email.toLowerCase();
      }

      TxNode node = new TxNode();
      node.addMsg(firstName);
      node.addMsg(lastName);
      node.addMsg(email);

      if (email.equals("")) {
        email = null;
      }

      TelepersonalizationFacade.updateUserProfile(
          userId.toString(), firstName, lastName, email, -1, -1, true, tc);

      /*
      TelePersonalize telePersonalize = new TelePersonalize();
      telePersonalize.updateUserInfo(userId.toString(), firstName, lastName, email,
              -1, -1, false, tc.toContextString());*/

      request.setAttribute("node", node);
      return mapping.findForward("success");
    } catch (Exception e) {
      ActionMessages msgs = new ActionMessages();
      msgs.add("UpdateUserInfofailed", new ActionMessage("errors.UpdateUserInfo.failed"));
      addErrors(request, msgs);
      return mapping.findForward("failure");
    }
  }
  @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};
  }
Ejemplo n.º 6
0
  public void testDoEndTagInfo()
      throws JspException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException {
    TxNode root = new TxNode();
    root.addValue(1);

    tst.setQuestionsTxNodeName("SurveyNodeName");
    TxNode node = new TxNode();
    node.addValue(1);
    node.addMsg("INFO");
    node.addMsg("Why did you decide not to subscribe to Premium Navigation?");
    node.addMsg("1");
    TxNode childNode = new TxNode();
    childNode.addMsg("Don't need these features");
    childNode.addMsg("Price is too high");

    node.addChild(childNode);
    root.addChild(node);
    IMocksControl RequestControl = EasyMock.createControl();

    HttpServletRequest request = RequestControl.createMock(HttpServletRequest.class);
    EasyMock.expect(request.getAttribute(tst.getQuestionsTxNodeName())).andReturn(root).anyTimes();
    RequestControl.replay();

    IMocksControl pageContextControl = EasyMock.createControl();
    javax.servlet.jsp.PageContext pageContext =
        pageContextControl.createMock(javax.servlet.jsp.PageContext.class);
    EasyMock.expect(pageContext.getRequest()).andReturn(request).anyTimes();

    IMocksControl JspWritersControl = EasyMock.createControl();
    JspWriter jspwriter = JspWritersControl.createMock(JspWriter.class);
    EasyMock.expect(pageContext.getOut()).andReturn(jspwriter);
    pageContextControl.replay();

    tst.setPageContext(pageContext);
    tst.setPageNumber(1);

    tst.doEndTag();

    String strActual = ((StringBuilder) getValue(tst, "outputText")).toString();

    assertEquals("", strActual);
  }