diff options
Diffstat (limited to 'branches/sca-android/tutorials/store/www-services/cart-amazon/amazon/cart')
3 files changed, 615 insertions, 0 deletions
diff --git a/branches/sca-android/tutorials/store/www-services/cart-amazon/amazon/cart/AmazonCart.java b/branches/sca-android/tutorials/store/www-services/cart-amazon/amazon/cart/AmazonCart.java new file mode 100644 index 0000000000..6f968bdba3 --- /dev/null +++ b/branches/sca-android/tutorials/store/www-services/cart-amazon/amazon/cart/AmazonCart.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package amazon.cart; + +import org.apache.tuscany.sca.databinding.annotation.DataBinding; +import org.osoa.sca.annotations.Remotable; + +import com.cart.amazon.CartAdd; +import com.cart.amazon.CartAddResponse; +import com.cart.amazon.CartClear; +import com.cart.amazon.CartClearResponse; +import com.cart.amazon.CartCreate; +import com.cart.amazon.CartCreateResponse; +import com.cart.amazon.CartGet; +import com.cart.amazon.CartGetResponse; + +@Remotable +@DataBinding(value="commonj.sdo.DataObject", wrapped=true) +public interface AmazonCart { + + public CartCreateResponse CartCreate(CartCreate cartCreate); + + public CartAddResponse CartAdd(CartAdd cartAdd); + + public CartClearResponse CartClear(CartClear cartClear); + + public CartGetResponse CartGet(CartGet cartGet); +} diff --git a/branches/sca-android/tutorials/store/www-services/cart-amazon/amazon/cart/AmazonCart.wsdl b/branches/sca-android/tutorials/store/www-services/cart-amazon/amazon/cart/AmazonCart.wsdl new file mode 100644 index 0000000000..051c8ad906 --- /dev/null +++ b/branches/sca-android/tutorials/store/www-services/cart-amazon/amazon/cart/AmazonCart.wsdl @@ -0,0 +1,451 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://amazon.cart.com/" targetNamespace="http://amazon.cart.com/">
+ <types>
+ <xs:schema targetNamespace="http://amazon.cart.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://amazon.cart.com/" elementFormDefault="qualified">
+ <xs:element name="CartGet">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="MarketplaceDomain" type="xs:string" minOccurs="0"/>
+ <xs:element name="AWSAccessKeyId" type="xs:string" minOccurs="0"/>
+ <xs:element name="SubscriptionId" type="xs:string" minOccurs="0"/>
+ <xs:element name="AssociateTag" type="xs:string" minOccurs="0"/>
+ <xs:element name="Validate" type="xs:string" minOccurs="0"/>
+ <xs:element name="XMLEscaping" type="xs:string" minOccurs="0"/>
+ <xs:element name="Shared" type="tns:CartGetRequest" minOccurs="0"/>
+ <xs:element name="Request" type="tns:CartGetRequest" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="CartGetRequest">
+ <xs:sequence>
+ <xs:element name="CartId" type="xs:string" minOccurs="0"/>
+ <xs:element name="HMAC" type="xs:string" minOccurs="0"/>
+ <xs:element name="MergeCart" type="xs:string" minOccurs="0"/>
+ <xs:element name="ResponseGroup" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="CartAdd">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="MarketplaceDomain" type="xs:string" minOccurs="0"/>
+ <xs:element name="AWSAccessKeyId" type="xs:string" minOccurs="0"/>
+ <xs:element name="SubscriptionId" type="xs:string" minOccurs="0"/>
+ <xs:element name="AssociateTag" type="xs:string" minOccurs="0"/>
+ <xs:element name="Validate" type="xs:string" minOccurs="0"/>
+ <xs:element name="XMLEscaping" type="xs:string" minOccurs="0"/>
+ <xs:element name="Shared" type="tns:CartAddRequest" minOccurs="0"/>
+ <xs:element name="Request" type="tns:CartAddRequest" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="CartAddRequest">
+ <xs:sequence>
+ <xs:element name="CartId" type="xs:string" minOccurs="0"/>
+ <xs:element name="HMAC" type="xs:string" minOccurs="0"/>
+ <xs:element name="MergeCart" type="xs:string" minOccurs="0"/>
+ <xs:element name="Items" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Item" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="OfferListingId" type="xs:string" minOccurs="0"/>
+ <xs:element name="Quantity" type="xs:positiveInteger" minOccurs="0"/>
+ <xs:element name="AssociateTag" type="xs:string" minOccurs="0"/>
+ <xs:element name="ListItemId" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="ResponseGroup" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="CartCreate">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="MarketplaceDomain" type="xs:string" minOccurs="0"/>
+ <xs:element name="AWSAccessKeyId" type="xs:string" minOccurs="0"/>
+ <xs:element name="SubscriptionId" type="xs:string" minOccurs="0"/>
+ <xs:element name="AssociateTag" type="xs:string" minOccurs="0"/>
+ <xs:element name="Validate" type="xs:string" minOccurs="0"/>
+ <xs:element name="XMLEscaping" type="xs:string" minOccurs="0"/>
+ <xs:element name="Shared" type="tns:CartCreateRequest" minOccurs="0"/>
+ <xs:element name="Request" type="tns:CartCreateRequest" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="CartCreateRequest">
+ <xs:sequence>
+ <xs:element name="MergeCart" type="xs:string" minOccurs="0"/>
+ <xs:element name="Items" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Item" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="OfferListingId" type="xs:string" minOccurs="0"/>
+ <xs:element name="Quantity" type="xs:positiveInteger" minOccurs="0"/>
+ <xs:element name="AssociateTag" type="xs:string" minOccurs="0"/>
+ <xs:element name="ListItemId" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="ResponseGroup" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="CartClear">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="MarketplaceDomain" type="xs:string" minOccurs="0"/>
+ <xs:element name="AWSAccessKeyId" type="xs:string" minOccurs="0"/>
+ <xs:element name="SubscriptionId" type="xs:string" minOccurs="0"/>
+ <xs:element name="AssociateTag" type="xs:string" minOccurs="0"/>
+ <xs:element name="Validate" type="xs:string" minOccurs="0"/>
+ <xs:element name="XMLEscaping" type="xs:string" minOccurs="0"/>
+ <xs:element name="Shared" type="tns:CartClearRequest" minOccurs="0"/>
+ <xs:element name="Request" type="tns:CartClearRequest" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="CartClearRequest">
+ <xs:sequence>
+ <xs:element name="CartId" type="xs:string" minOccurs="0"/>
+ <xs:element name="HMAC" type="xs:string" minOccurs="0"/>
+ <xs:element name="MergeCart" type="xs:string" minOccurs="0"/>
+ <xs:element name="ResponseGroup" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="CartGetResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="tns:OperationRequest" minOccurs="0"/>
+ <xs:element ref="tns:Cart" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="CartAddResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="tns:OperationRequest" minOccurs="0"/>
+ <xs:element ref="tns:Cart" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="CartCreateResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="tns:OperationRequest" minOccurs="0"/>
+ <xs:element ref="tns:Cart" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="CartClearResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="tns:OperationRequest" minOccurs="0"/>
+ <xs:element ref="tns:Cart" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Cart">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="tns:Request" minOccurs="0"/>
+ <xs:element name="CartId" type="xs:string"/>
+ <xs:element name="HMAC" type="xs:string"/>
+ <xs:element name="URLEncodedHMAC" type="xs:string"/>
+ <xs:element name="PurchaseURL" type="xs:string" minOccurs="0"/>
+ <xs:element name="SubTotal" type="tns:Price" minOccurs="0"/>
+ <xs:element ref="tns:CartItems" minOccurs="0"/>
+ <xs:element ref="tns:SavedForLaterItems" minOccurs="0"/>
+ <xs:element ref="tns:SimilarProducts" minOccurs="0"/>
+ <xs:element ref="tns:TopSellers" minOccurs="0"/>
+ <xs:element ref="tns:NewReleases" minOccurs="0"/>
+ <xs:element ref="tns:SimilarViewedProducts" minOccurs="0"/>
+ <xs:element ref="tns:OtherCategoriesSimilarProducts" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="SavedForLaterItems">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="SubTotal" type="tns:Price" minOccurs="0"/>
+ <xs:element name="SavedForLaterItem" type="tns:CartItem" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="SimilarProducts">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="SimilarProduct" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="Title" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="TopSellers">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="TopSeller" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="Title" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="NewReleases">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="NewRelease" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="Title" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="SimilarViewedProducts">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="SimilarViewedProduct" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="Title" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="OtherCategoriesSimilarProducts">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="OtherCategoriesSimilarProduct" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="Title" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="CartItems">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="SubTotal" type="tns:Price" minOccurs="0"/>
+ <xs:element name="CartItem" type="tns:CartItem" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="OperationRequest">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="tns:HTTPHeaders" minOccurs="0"/>
+ <xs:element name="RequestId" type="xs:string" minOccurs="0"/>
+ <xs:element ref="tns:Arguments" minOccurs="0"/>
+ <xs:element ref="tns:Errors" minOccurs="0"/>
+ <xs:element name="RequestProcessingTime" type="xs:float" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Request">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="CartGetRequest" type="tns:CartGetRequest" minOccurs="0"/>
+ <xs:element name="CartAddRequest" type="tns:CartAddRequest" minOccurs="0"/>
+ <xs:element name="CartCreateRequest" type="tns:CartCreateRequest" minOccurs="0"/>
+ <xs:element name="CartClearRequest" type="tns:CartClearRequest" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Arguments">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Argument" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="Name" type="xs:string" use="required"/>
+ <xs:attribute name="Value" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Errors">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Error" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Code" type="xs:string"/>
+ <xs:element name="Message" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="HTTPHeaders">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Header" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="Name" type="xs:string" use="required"/>
+ <xs:attribute name="Value" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="CartItem">
+ <xs:sequence>
+ <xs:element name="CartItemId" type="xs:string"/>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="ExchangeId" type="xs:string" minOccurs="0"/>
+ <xs:element name="MerchantId" type="xs:string" minOccurs="0"/>
+ <xs:element name="SellerId" type="xs:string" minOccurs="0"/>
+ <xs:element name="SellerNickname" type="xs:string" minOccurs="0"/>
+ <xs:element name="Quantity" type="xs:string"/>
+ <xs:element name="Title" type="xs:string" minOccurs="0"/>
+ <xs:element name="ProductGroup" type="xs:string" minOccurs="0"/>
+ <xs:element name="ListOwner" type="xs:string" minOccurs="0"/>
+ <xs:element name="ListType" type="xs:string" minOccurs="0"/>
+ <xs:element name="Price" type="tns:Price" minOccurs="0"/>
+ <xs:element name="ItemTotal" type="tns:Price" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="Price">
+ <xs:sequence>
+ <xs:element name="Amount" type="xs:integer" minOccurs="0"/>
+ <xs:element name="CurrencyCode" type="xs:string" minOccurs="0"/>
+ <xs:element name="FormattedPrice" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ </types>
+ <message name="CartGetRequestMsg">
+ <part name="body" element="tns:CartGet"/>
+ </message>
+ <message name="CartGetResponseMsg">
+ <part name="body" element="tns:CartGetResponse"/>
+ </message>
+ <message name="CartAddRequestMsg">
+ <part name="body" element="tns:CartAdd"/>
+ </message>
+ <message name="CartAddResponseMsg">
+ <part name="body" element="tns:CartAddResponse"/>
+ </message>
+ <message name="CartCreateRequestMsg">
+ <part name="body" element="tns:CartCreate"/>
+ </message>
+ <message name="CartCreateResponseMsg">
+ <part name="body" element="tns:CartCreateResponse"/>
+ </message>
+ <message name="CartClearRequestMsg">
+ <part name="body" element="tns:CartClear"/>
+ </message>
+ <message name="CartClearResponseMsg">
+ <part name="body" element="tns:CartClearResponse"/>
+ </message>
+ <portType name="AmazonCartServicePortType">
+ <operation name="CartGet">
+ <input message="tns:CartGetRequestMsg"/>
+ <output message="tns:CartGetResponseMsg"/>
+ </operation>
+ <operation name="CartAdd">
+ <input message="tns:CartAddRequestMsg"/>
+ <output message="tns:CartAddResponseMsg"/>
+ </operation>
+ <operation name="CartCreate">
+ <input message="tns:CartCreateRequestMsg"/>
+ <output message="tns:CartCreateResponseMsg"/>
+ </operation>
+ <operation name="CartClear">
+ <input message="tns:CartClearRequestMsg"/>
+ <output message="tns:CartClearResponseMsg"/>
+ </operation>
+ </portType>
+ <binding name="AmazonCartServiceBinding" type="tns:AmazonCartServicePortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="CartGet">
+ <soap:operation soapAction="http://soap.amazon.cart.com"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="CartCreate">
+ <soap:operation soapAction="http://soap.amazon.cart.com"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="CartAdd">
+ <soap:operation soapAction="http://soap.amazon.cart.com"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="CartClear">
+ <soap:operation soapAction="http://soap.amazon.cart.com"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="AmazonCartService">
+ <port name="AmazonCartServicePort" binding="tns:AmazonCartServiceBinding">
+ <soap:address location="http://localhost:8080/AmazonCartServiceComponent"/>
+ </port>
+ </service>
+</definitions>
diff --git a/branches/sca-android/tutorials/store/www-services/cart-amazon/amazon/cart/AmazonCartImpl.java b/branches/sca-android/tutorials/store/www-services/cart-amazon/amazon/cart/AmazonCartImpl.java new file mode 100644 index 0000000000..66d72c57c4 --- /dev/null +++ b/branches/sca-android/tutorials/store/www-services/cart-amazon/amazon/cart/AmazonCartImpl.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package amazon.cart; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.osoa.sca.annotations.Service; + +import com.cart.amazon.AmazonFactory; +import com.cart.amazon.Cart; +import com.cart.amazon.CartAdd; +import com.cart.amazon.CartAddRequest; +import com.cart.amazon.CartAddResponse; +import com.cart.amazon.CartClear; +import com.cart.amazon.CartClearResponse; +import com.cart.amazon.CartCreate; +import com.cart.amazon.CartCreateResponse; +import com.cart.amazon.CartGet; +import com.cart.amazon.CartGetResponse; +import com.cart.amazon.CartItem; +import com.cart.amazon.CartItems; +import com.cart.amazon.Item1; +import com.cart.amazon.Items1; + +@Service(AmazonCart.class) +public class AmazonCartImpl { + + protected Map<String, Cart> cartsHash = new HashMap<String, Cart>(); + + public CartCreateResponse CartCreate(CartCreate cartCreate) { + + System.out.println("CartServiceID: " + this.toString()); + System.out.println("Entering cartCreate..."); + String userId = cartCreate.getAWSAccessKeyId(); + + Cart cart = getCart(userId); + if (cart != null) { + System.out.println("User " + cartCreate.getAWSAccessKeyId() + + " has already created a cart with ID: " + + cart.getCartId()); + return null; + } + cart = new Cart(); + cart.setCartItems(new CartItems()); + addCart(userId, cart); + + CartCreateResponse response = AmazonFactory.INSTANCE.createCartCreateResponse(); + System.out.println("Exiting cartCreate..."); + return response; + + } + + public CartAddResponse CartAdd(CartAdd cartAdd) { + + String userId = cartAdd.getAWSAccessKeyId(); + + Cart cart = getCart(userId); + if (cart == null) { + System.out.println("User has not associated Cart yet..."); + return null; + } + + List cartAddRequestList = cartAdd.getRequest(); + CartAddRequest car = (CartAddRequest)cartAddRequestList.get(0); + Items1 carItems = car.getItems(); + List itemList = carItems.getItem(); + Item1 item = (Item1)itemList.get(0); //Take only the first one, no iteration for now + System.out.println("item.getASIN: " + item.getASIN()); + System.out.println("item.getQuantity(): " + item.getQuantity()); + CartItems cartItems = cart.getCartItems(); + List<CartItem> cartItemList = cartItems.getCartItem(); + cart.setCartItems(cartItems); + return null; + } + + public CartClearResponse CartClear(CartClear cartClear) { + String userId = cartClear.getAWSAccessKeyId(); + + Cart cart = getCart(userId); + if (cart == null) { + System.out.println("User has not associated Cart yet..."); + return null; + } + + cart.setCartItems(new CartItems()); + return null; + } + + public CartGetResponse CartGet(CartGet cartGet) { + return null; + } + + private Cart getCart(String userId) { + Cart cart = null; + cart = this.cartsHash.get(userId); + return cart; + } + + private void addCart(String userId, Cart cart) { + this.cartsHash.put(userId, cart); + } +} |