Package client.ws.milanas.helpers.dom

Examples of client.ws.milanas.helpers.dom.DOMCartHandler


        ArrayList<CartItem> items = new ArrayList<CartItem>();
        CartItem item = null;
        Cart auxCart = null;
        HashMap<String, String> parameters = new HashMap<String, String>();
        SOAPMessage message, response = null;
        DOMCartHandler dch = null;
        Document doc = null;
       
        if(quantity <= 0)
        {
            return true;
        }
       
        item = new CartItem();
        item.setOfferId(offerId);
        item.setQuantity(quantity);
        items.add(item);
       
        if(cart != null)
        {
            parameters.put("CartId", cart.getCartId());
            parameters.put("HMAC", cart.getCartHmac());
            message = SOAPEnvelopeCreator.createAmazonCartSOAPEnvelope("CartAdd", parameters, items, properties);
            try
            {
                response = connection.call(message, properties.getProperty("endpoint"));
                dch = new DOMCartHandler();
                doc = response.getSOAPBody().extractContentAsDocument();
                auxCart = dch.getCart(doc);
                cart.setItems(auxCart.getItems());
                cart.setTotal(auxCart.getTotal());
                cart.setUrl(auxCart.getUrl());
                if(dch.isItemAdded(doc))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch(SOAPException se){return false;}
        }
        else
        {
            parameters.put("AssociateTag", properties.getProperty("AssociateTag"));
            message = SOAPEnvelopeCreator.createAmazonCartSOAPEnvelope("CartCreate", parameters, items, properties);
            try
            {
               
                response = connection.call(message, properties.getProperty("endpoint"));              
                dch = new DOMCartHandler();
                doc = response.getSOAPBody().extractContentAsDocument();
                if(dch.isItemAdded(doc))
                {
                    cart = new Cart(dch.getCartId(doc), dch.getCartHmac(doc));
                    auxCart = dch.getCart(doc);
                    cart.setItems(auxCart.getItems());
                    cart.setTotal(auxCart.getTotal());
                    cart.setUrl(auxCart.getUrl());
                    return true;
                }
View Full Code Here


     */
    public void modifyItems(ArrayList<CartItem> items) throws SOAPEnvelopeCreationException
    {
        HashMap<String, String> parameters = new HashMap<String, String>();
        SOAPMessage message, response = null;
        DOMCartHandler dch = null;
        Document doc = null;
        Cart auxCart = null;
        if(cart != null)
        {
            parameters.put("CartId", cart.getCartId());
            parameters.put("HMAC", cart.getCartHmac());
            message = SOAPEnvelopeCreator.createAmazonCartSOAPEnvelope("CartModify", parameters,  items, properties);
            try
            {
                response = connection.call(message, properties.getProperty("endpoint"));
                dch = new DOMCartHandler();
                doc = response.getSOAPBody().extractContentAsDocument();
                auxCart = dch.getCart(doc);
                cart.setItems(auxCart.getItems());
                cart.setTotal(auxCart.getTotal());
                cart.setUrl(auxCart.getUrl());
            }
            catch(SOAPException se){}
View Full Code Here

     */
    public void resetCart() throws SOAPEnvelopeCreationException
    {
        HashMap<String, String> parameters = new HashMap<String, String>();
        SOAPMessage message, response = null;
        DOMCartHandler dch = null;
        Document doc = null;
        Cart auxCart = null;
        if(cart != null)
        {
            parameters.put("CartId", cart.getCartId());
            parameters.put("HMAC", cart.getCartHmac());
            parameters.put("AssociateTag", properties.getProperty("AssociateTag"));
            message = SOAPEnvelopeCreator.createAmazonCartSOAPEnvelope("CartClear", parameters,  new ArrayList<CartItem>(), properties);
            try
            {
                response = connection.call(message, properties.getProperty("endpoint"));
                dch = new DOMCartHandler();
                doc = response.getSOAPBody().extractContentAsDocument();
                auxCart = dch.getCart(doc);
                cart.setItems(auxCart.getItems());
                cart.setTotal(auxCart.getTotal());
                cart.setUrl(auxCart.getUrl());
            }
            catch(SOAPException se){}
View Full Code Here

TOP

Related Classes of client.ws.milanas.helpers.dom.DOMCartHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.