01: /*
02: * $Id: WebShoppingCart.java,v 1.5 2003/11/08 20:54:17 ajzeneski Exp $
03: *
04: * Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org
05: *
06: * Permission is hereby granted, free of charge, to any person obtaining a
07: * copy of this software and associated documentation files (the "Software"),
08: * to deal in the Software without restriction, including without limitation
09: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10: * and/or sell copies of the Software, and to permit persons to whom the
11: * Software is furnished to do so, subject to the following conditions:
12: *
13: * The above copyright notice and this permission notice shall be included
14: * in all copies or substantial portions of the Software.
15: *
16: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17: * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21: * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22: * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23: */
24: package org.ofbiz.order.shoppingcart;
25:
26: import javax.servlet.http.HttpServletRequest;
27: import javax.servlet.http.HttpSession;
28:
29: import org.ofbiz.entity.GenericDelegator;
30: import org.ofbiz.entity.GenericValue;
31: import org.ofbiz.product.catalog.CatalogWorker;
32: import org.ofbiz.product.store.ProductStoreWorker;
33: import org.ofbiz.base.util.UtilHttp;
34:
35: /**
36: * <p><b>Title:</b> WebShoppingCart.java
37: * <p><b>Description:</b> This is a very basic
38: * extension of the
39: * {@link org.ofbiz.order.shoppingcart.ShoppingCart ShoppingCart}
40: * class which provides web presentation layer specific functionality
41: * related specifically to user session information.
42: *
43: * @author <a href="mailto:jaz@ofbiz.org">Andy Zeneski</a>
44: * @author <a href="mailto:cnelson@einnovation.com">Chris Nelson</a>
45: * @author <a href="mailto:jonesde@ofbiz.org">David E. Jones</a>
46: * @author <a href="mailto:tristana@twibble.org">Tristan Austin</a>
47: * @version $Revision: 1.5 $
48: * @since 2.0
49: */
50: public class WebShoppingCart extends ShoppingCart {
51: private HttpSession session = null;
52:
53: /** Creates a new cloned ShoppingCart Object. */
54: public WebShoppingCart(ShoppingCart cart, HttpSession session) {
55: super (cart);
56: this .session = session;
57: }
58:
59: /** Creates new empty ShoppingCart object. */
60: public WebShoppingCart(HttpServletRequest request) {
61: super ((GenericDelegator) request.getAttribute("delegator"),
62: ProductStoreWorker.getProductStoreId(request),
63: CatalogWorker.getWebSiteId(request), UtilHttp
64: .getCurrencyUom(request));
65: super .setLocale(UtilHttp.getLocale(request));
66: this .session = request.getSession();
67: }
68:
69: /** Gets the userLogin from the session; may be null */
70: public GenericValue getUserLogin() {
71: return (GenericValue) this .session.getAttribute("userLogin");
72: }
73:
74: public GenericValue getAutoUserLogin() {
75: return (GenericValue) this .session
76: .getAttribute("autoUserLogin");
77: }
78:
79: public String getWebSiteId() {
80: return (String) session.getAttribute("webSiteId");
81: }
82:
83: public String getPartyId() {
84: String partyId = (String) session.getAttribute("orderPartyId");
85: if (partyId == null && getUserLogin() != null)
86: partyId = getUserLogin().getString("partyId");
87: if (partyId == null && getAutoUserLogin() != null)
88: partyId = getAutoUserLogin().getString("partyId");
89: return partyId;
90: }
91: }
|