Example #1
0
  /* (non-Javadoc)
   * @see gov.nih.nci.cadsr.cdecart.CdeCartUtilInterface#findCartNodes(javax.servlet.http.HttpSession, java.lang.String)
   */
  @Override
  public List<SearchNode> findCartNodes(HttpSession mySession, String principalName)
      throws Exception {

    String uid = principalName;

    // we shall be after login here, and uid is never null
    if (uid == null) {
      log.error("........No user found in session in findCartNodes");
      throw new AutheticationFailureException("Authenticated user not found in the session");
    }

    // we want to keep this cart in session not to retrieve it every time
    CDECart cdeCart = (CDECart) mySession.getAttribute(CaDSRConstants.CDE_CART);
    List<SearchNode> arr = null;

    try {
      if (cdeCart == null) {
        log.info("Object Cart is not found in session: " + principalName);
        cdeCart = findCdeCart(mySession, principalName);
      } else {
        log.info("Object Cart is found in session: " + principalName);
      }
      // We use either retrieved cart or found in the session cart to build the result for the
      // client page
      @SuppressWarnings("rawtypes")
      Collection col = cdeCart.getDataElements();

      arr = buildSearchNodeList(col);
      return arr;
    } catch (ObjectCartException oce) {
      log.error("Exception on cdeCart.getDataElements", oce);
      throw oce;
    }
  }
  /**
   * Displays CDE Cart.
   *
   * @param mapping The ActionMapping used to select this instance.
   * @param form The optional ActionForm bean for this request.
   * @param request The HTTP Request we are processing.
   * @param response The HTTP Response we are processing.
   * @return
   * @throws IOException
   * @throws ServletException
   */
  public ActionForward displayCDECart(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, ServletException {

    try {
      NCIUser user = (NCIUser) this.getSessionObject(request, CaDSRConstants.USER_KEY);
      if (user != null) {
        return mapping.findForward("secureSuccess");
      }
      // Get the cart in the session
      CDECart sessionCart = (CDECart) this.getSessionObject(request, CaDSRConstants.CDE_CART);
      Collection<CDECartItem> cartItems = sessionCart.getDataElements();
      Collection<CDECartItem> items = new ArrayList<CDECartItem>();

      for (Object o : cartItems) {
        CDECartItem item = (CDECartItem) o;
        item.setPersistedInd(false);
        items.add(item);
      }
      sessionCart.mergeDataElements(items);

      this.setSessionObject(request, CaDSRConstants.CDE_CART, sessionCart);
    } catch (Exception exp) {
      if (log.isErrorEnabled()) {
        log.error("Exception on displayCDECart.....", exp);
      }
      exp.printStackTrace();
    }
    return mapping.findForward(SUCCESS);
  }