01: /*******************************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *******************************************************************************/package org.ofbiz.order.shoppingcart;
19:
20: import java.util.Locale;
21:
22: import javax.servlet.http.HttpServletRequest;
23: import javax.servlet.http.HttpSession;
24:
25: import org.ofbiz.base.util.UtilHttp;
26: import org.ofbiz.entity.GenericDelegator;
27: import org.ofbiz.entity.GenericValue;
28: import org.ofbiz.product.store.ProductStoreWorker;
29: import org.ofbiz.webapp.website.WebSiteWorker;
30:
31: /**
32: * WebShoppingCart.java
33: *
34: * Extension of {@link org.ofbiz.order.shoppingcart.ShoppingCart ShoppingCart}
35: * class which provides web presentation layer specific functionality
36: * related specifically to user session information.
37: */
38: public class WebShoppingCart extends ShoppingCart {
39: public WebShoppingCart(HttpServletRequest request, Locale locale,
40: String currencyUom) {
41: // for purchase orders, bill to customer partyId must be set - otherwise, no way to know who we're purchasing for. supplierPartyId is furnished
42: // by order manager for PO entry.
43: // TODO: refactor constructor and the getCartObject method which calls them to multiple constructors for different types of orders
44: super (
45: (GenericDelegator) request.getAttribute("delegator"),
46: ProductStoreWorker.getProductStoreId(request),
47: WebSiteWorker.getWebSiteId(request),
48: (locale != null ? locale : ProductStoreWorker
49: .getStoreLocale(request)),
50: (currencyUom != null ? currencyUom : ProductStoreWorker
51: .getStoreCurrencyUomId(request)),
52: request.getParameter("billToCustomerPartyId"),
53: (request.getParameter("supplierPartyId") != null ? request
54: .getParameter("supplierPartyId")
55: : request.getParameter("billFromVendorPartyId")));
56:
57: HttpSession session = request.getSession(true);
58: this .userLogin = (GenericValue) session
59: .getAttribute("userLogin");
60: this .autoUserLogin = (GenericValue) session
61: .getAttribute("autoUserLogin");
62: this .orderPartyId = (String) session
63: .getAttribute("orderPartyId");
64: }
65:
66: public WebShoppingCart(HttpServletRequest request) {
67: this (request, UtilHttp.getLocale(request), UtilHttp
68: .getCurrencyUom(request));
69: }
70:
71: /** Creates a new cloned ShoppingCart Object. */
72: public WebShoppingCart(ShoppingCart cart) {
73: super(cart);
74: }
75: }
|