if (itemList == null) {
throw new ProtocolException("itemList cannot be null");
}
// Create the <items> tag and add each item in the list to the cart
ShoppingCart cart = _objectFact.createShoppingCart();
Items items = _objectFact.createShoppingCartItems();
List<Item> item_list = items.getItem();
for (Item item : itemList) {
item_list.add(item);
}
cart.setItems(items);
// Add the expiration date if one is provided
if (cartExpire != null) {
GregorianCalendar gCal = new GregorianCalendar();
gCal.setTime(cartExpire);
XMLGregorianCalendar xmlCalendar
= _dataFactory.newXMLGregorianCalendar(gCal);
CartExpiration cartExpiry = _objectFact.createCartExpiration();
cartExpiry.setGoodUntilDate(xmlCalendar);
cart.setCartExpiration(cartExpiry);
}
// Add merchantPrivateData if it is provided
if (merchantPrivateData != null) {
AnyType anyType = _objectFact.createAnyType();
anyType.setAny(merchantPrivateData);
cart.setMerchantPrivateData(anyType);
}
return cart;
}