Esempio n. 1
0
  /**
   * A common method that contains the code to deal with exceptions
   *
   * @param request
   * @param e
   * @return Returns a string
   */
  protected String handleException(HttpServletRequest request, Exception e) {

    if (e != null && e.getClass().getName().equals("com.konakart.app.KKException")) {
      KKException ex = (KKException) e;

      switch (ex.getCode()) {
        case KKException.KK_STORE_DELETED:
          if (appEng != null) {
            addActionError(appEng.getMsg("unavailable.deleted"));
          }
          return new String("Unavailable");
        case KKException.KK_STORE_DISABLED:
          if (appEng != null) {
            addActionError(appEng.getMsg("unavailable.disabled"));
          }
          return new String("Unavailable");
        case KKException.KK_STORE_UNDER_MAINTENANCE:
          if (appEng != null) {
            addActionError(appEng.getMsg("unavailable.maintenance"));
          }
          return new String("Unavailable");
      }
    }

    Long time = System.currentTimeMillis();
    log.error("A customer has received the following exception ( ref: " + time + " )", e);
    if (appEng != null) {
      addActionError(Long.toString(time));
    }
    return new String("Exception");
  }
Esempio n. 2
0
  /**
   * Sets the variable kkAppEng to the KKAppEng instance saved in the session. If cannot be found,
   * then it is instantiated and attached.
   *
   * @param request
   * @param response
   * @return Returns a KonaKart client engine instance
   * @throws KKException
   * @throws KKAppException
   */
  protected KKAppEng getKKAppEng(HttpServletRequest request, HttpServletResponse response)
      throws KKAppException, KKException {
    HttpSession session = request.getSession();
    KKAppEng kkAppEng = (KKAppEng) session.getAttribute(KKAppEng.KONAKART_KEY);
    if (kkAppEng == null) {
      if (log.isInfoEnabled()) {
        log.info("KKAppEng not found on the session");
      }

      String storeIdForNewEngine = getStoreIdFromRequest(request);

      StoreInfo si = new StoreInfo();
      si.setStoreId(storeIdForNewEngine);
      kkAppEng = new KKAppEng(si, session);

      if (log.isInfoEnabled()) {
        log.info("Set KKAppEng on the session for storeId " + si.getStoreId());
      }

      /*
       * Add KKAppEng to the struts and the HTTP sessions. In order for the struts jsp tags to
       * see it, it has to be added to the struts session as well.
       */
      session.setAttribute(KKAppEng.KONAKART_KEY, kkAppEng);
      strutsSession.put(KKAppEng.KONAKART_KEY, kkAppEng);

      String customerUuid = manageCookies(request, response, kkAppEng);
      if (customerUuid != null) {
        // Get the locale from the cookie
        String savedLocale = getKKCookie(customerUuid, CUSTOMER_LOCALE, kkAppEng);
        if (savedLocale != null) {
          // Set the engine with the new locale
          kkAppEng.setLocale(savedLocale);
        }
      }

      // Insert event
      insertCustomerEvent(kkAppEng, ACTION_NEW_CUSTOMER_VISIT);
    }

    kkAppEng.setPageTitle(kkAppEng.getMsg("seo.default.title"));
    kkAppEng.setMetaDescription(kkAppEng.getMsg("seo.default.meta.description"));
    kkAppEng.setMetaKeywords(kkAppEng.getMsg("seo.default.meta.keywords"));

    /* Save a copy in the base action */
    appEng = kkAppEng;

    /* Used by the JSP */
    jspEng = kkAppEng;

    return kkAppEng;
  }
  public String execute() {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpServletResponse response = ServletActionContext.getResponse();

    try {
      int custId;

      KKAppEng kkAppEng = this.getKKAppEng(request, response);

      custId = this.loggedIn(request, response, kkAppEng, null);

      // Force the user to login if configured to do so
      if (custId < 0 && kkAppEng.isForceLogin()) {
        return KKLOGIN;
      }

      // Ensure we are using the correct protocol. Redirect if not.
      String redirForward = checkSSL(kkAppEng, request, custId, /* forceSSL */ false);
      if (redirForward != null) {
        setupResponseForSSLRedirect(response, redirForward);
        return null;
      }

      kkAppEng.getNav().set(kkAppEng.getMsg("header.advanced.navigation"), request);
      return SUCCESS;

    } catch (Exception e) {
      return super.handleException(request, e);
    }
  }
Esempio n. 4
0
 /**
  * Gets the text from the message catalog using place holders
  *
  * @param key
  * @param args
  * @return Gets the text from the message catalog
  */
 protected String getMsg(String key, String[] args) {
   return eng.getMsg(key, args);
 }
Esempio n. 5
0
 /**
  * Gets the text from the message catalog
  *
  * @param key
  * @param arg0
  * @param arg1
  * @param arg2
  * @return Gets the text from the message catalog
  */
 protected String getMsg(String key, String arg0, String arg1, String arg2) {
   return eng.getMsg(key, arg0, arg1, arg2);
 }
Esempio n. 6
0
 /**
  * Gets the text from the message catalog
  *
  * @param key
  * @param arg0
  * @return Gets the text from the message catalog
  */
 protected String getMsg(String key, String arg0) {
   return eng.getMsg(key, arg0);
 }
Esempio n. 7
0
 /**
  * Gets the text from the message catalog
  *
  * @param key
  * @return Gets the text from the message catalog
  */
 protected String getMsg(String key) {
   return eng.getMsg(key);
 }
  public String execute() {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpServletResponse response = ServletActionContext.getResponse();

    try {
      int custId;

      KKAppEng kkAppEng = this.getKKAppEng(request, response);

      custId = this.loggedIn(request, response, kkAppEng, null);

      // Check to see whether the user is logged in since this is required to create a gift
      // registry
      custId = this.loggedIn(request, response, kkAppEng, "CreateGiftRegistry");
      if (custId < 0) {
        return KKLOGIN;
      }

      // If it is a temporary customer, then he needs to register to create a gift registry
      if (kkAppEng.getCustomerMgr().getCurrentCustomer() != null
          && kkAppEng.getCustomerMgr().getCurrentCustomer().getType()
              == com.konakart.bl.CustomerMgr.CUST_TYPE_NON_REGISTERED_CUST) {
        return KKLOGIN;
      }

      // Ensure we are using the correct protocol. Redirect if not.
      String redirForward = checkSSL(kkAppEng, request, custId, /* forceSSL */ false);
      if (redirForward != null) {
        setupResponseForSSLRedirect(response, redirForward);
        return null;
      }

      /*
       * Create the gift registry
       */
      WishListIf wl = new WishList();
      wl.setAddressId(getAddressId());
      wl.setCustom1(escapeFormInput(getCustom1()));
      wl.setCustom2(escapeFormInput(getCustom2()));
      wl.setCustom3(escapeFormInput(getCustom3()));
      wl.setCustom4(escapeFormInput(getCustom4()));
      wl.setCustom5(escapeFormInput(getCustom5()));
      wl.setCustomer1FirstName(escapeFormInput(getFirstName1()));
      wl.setCustomer1LastName(escapeFormInput(getLastName1()));
      wl.setCustomerFirstName(escapeFormInput(getFirstName()));
      wl.setCustomerLastName(escapeFormInput(getLastName()));
      wl.setCustomerId(custId);
      wl.setLinkUrl(escapeFormInput(getLinkURL()));
      wl.setListType(getListType());
      wl.setName(escapeFormInput(getRegistryName()));
      if (getPublicWishList() != null && getPublicWishList().equalsIgnoreCase("true")) {
        wl.setPublicWishList(true);
      } else {
        wl.setPublicWishList(false);
      }
      // Set the event date
      if (getEventDateString() != null && !getEventDateString().equals("")) {
        SimpleDateFormat sdf = new SimpleDateFormat(kkAppEng.getMsg("date.format"));
        Date d = sdf.parse(getEventDateString());
        if (d != null) {
          GregorianCalendar gc = new GregorianCalendar();
          gc.setTime(d);
          wl.setEventDate(gc);
        }
      }

      // Add the item
      wishListId = kkAppEng.getWishListMgr().createWishList(wl);
      // Refresh the customer's wish list
      kkAppEng.getWishListMgr().fetchCustomersWishLists();

      return SUCCESS;

    } catch (Exception e) {
      return super.handleException(request, e);
    }
  }
  public void _jspService(
      final javax.servlet.http.HttpServletRequest request,
      final javax.servlet.http.HttpServletResponse response)
      throws java.io.IOException, javax.servlet.ServletException {

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write('\r');
      out.write('\n');
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      com.konakart.al.KKAppEng kkEng =
          (com.konakart.al.KKAppEng) session.getAttribute("konakartKey");
      out.write("\r\n");
      out.write("\t\t    \t\r\n");
      //  kk:carousel
      com.konakart.kktags.CarouselTag _jspx_th_kk_005fcarousel_005f0 =
          (com.konakart.kktags.CarouselTag)
              _005fjspx_005ftagPool_005fkk_005fcarousel_0026_005fwidth_005ftitle_005fprods_005fnobody
                  .get(com.konakart.kktags.CarouselTag.class);
      _jspx_th_kk_005fcarousel_005f0.setPageContext(_jspx_page_context);
      _jspx_th_kk_005fcarousel_005f0.setParent(null);
      // /WEB-INF/jsp/FeaturedProductsBody.jsp(23,0) name = prods type = null reqTime = true
      // required = true fragment = false deferredValue = false expectedTypeName = null
      // deferredMethod = false methodSignature = null
      _jspx_th_kk_005fcarousel_005f0.setProds(kkEng.getProductMgr().getCustomProducts1());
      // /WEB-INF/jsp/FeaturedProductsBody.jsp(23,0) name = title type = null reqTime = true
      // required = true fragment = false deferredValue = false expectedTypeName = null
      // deferredMethod = false methodSignature = null
      _jspx_th_kk_005fcarousel_005f0.setTitle(kkEng.getMsg("featured.products.body.title"));
      // /WEB-INF/jsp/FeaturedProductsBody.jsp(23,0) name = width type = null reqTime = true
      // required = true fragment = false deferredValue = false expectedTypeName = null
      // deferredMethod = false methodSignature = null
      _jspx_th_kk_005fcarousel_005f0.setWidth(kkEng.getContentClass());
      int _jspx_eval_kk_005fcarousel_005f0 = _jspx_th_kk_005fcarousel_005f0.doStartTag();
      if (_jspx_th_kk_005fcarousel_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
        _005fjspx_005ftagPool_005fkk_005fcarousel_0026_005fwidth_005ftitle_005fprods_005fnobody
            .reuse(_jspx_th_kk_005fcarousel_005f0);
        return;
      }
      _005fjspx_005ftagPool_005fkk_005fcarousel_0026_005fwidth_005ftitle_005fprods_005fnobody.reuse(
          _jspx_th_kk_005fcarousel_005f0);
      out.write("\r\n");
      out.write("\r\n");
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try {
            out.clearBuffer();
          } catch (java.io.IOException e) {
          }
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
  public String execute() {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpServletResponse response = ServletActionContext.getResponse();

    try {
      int custId;

      KKAppEng kkAppEng = this.getKKAppEng(request, response);

      custId = this.loggedIn(request, response, kkAppEng, "EditCustomer");

      // Check to see whether the user is logged in
      if (custId < 0) {
        return KKLOGIN;
      }

      // Ensure we are using the correct protocol. Redirect if not.
      String redirForward = checkSSL(kkAppEng, request, custId, /* forceSSL */ false);
      if (redirForward != null) {
        setupResponseForSSLRedirect(response, redirForward);
        return null;
      }

      // Copy the inputs from the form to a customer object
      CustomerIf cust = new Customer();
      cust.setGender(escapeFormInput(getGender()));
      cust.setFirstName(escapeFormInput(getFirstName()));
      cust.setLastName(escapeFormInput(getLastName()));
      cust.setEmailAddr(escapeFormInput(getEmailAddr()));
      cust.setFaxNumber(escapeFormInput(getFaxNumber()));
      cust.setTelephoneNumber(escapeFormInput(getTelephoneNumber()));
      cust.setTelephoneNumber1(escapeFormInput(getTelephoneNumber1()));
      cust.setId(kkAppEng.getCustomerMgr().getCurrentCustomer().getId());
      cust.setCustom1(escapeFormInput(getCustomerCustom1()));

      CustomerIf currentCustomer = kkAppEng.getCustomerMgr().getCurrentCustomer();
      if (currentCustomer != null) {
        cust.setType(currentCustomer.getType());
      }

      // Set the date
      if (getBirthDateString() != null && !getBirthDateString().equals("")) {
        SimpleDateFormat sdf = new SimpleDateFormat(kkAppEng.getMsg("date.format"));
        Date d = sdf.parse(getBirthDateString());
        if (d != null) {
          GregorianCalendar gc = new GregorianCalendar();
          gc.setTime(d);
          cust.setBirthDate(gc);

          // Set the customer tag
          CustomerTag ct = new CustomerTag();
          ct.setValueAsDate(d);
          ct.setName(TAG_BIRTH_DATE);
          kkAppEng.getCustomerTagMgr().insertCustomerTag(ct);
        }
      }

      // Set the IS_MALE customer tag for this customer
      CustomerTag ct = new CustomerTag();
      ct.setName(TAG_IS_MALE);
      ct.setValueAsBoolean(false);
      if (getGender() != null && getGender().equalsIgnoreCase("m")) {
        ct.setValueAsBoolean(true);
      }
      kkAppEng.getCustomerTagMgr().insertCustomerTag(ct);

      // Call the engine registration method
      try {
        kkAppEng.getCustomerMgr().editCustomer(cust);
      } catch (Exception e) {
        addActionError(kkAppEng.getMsg("edit.customer.body.user.exists"));
        return "ApplicationError";
      }

      return SUCCESS;

    } catch (Exception e) {
      return super.handleException(request, e);
    }
  }