Package org.bookstore.order.service
Class OrderService
java.lang.Object
org.bookstore.order.service.OrderService
The class OrderService defines a service to manage the orders of a bookstore.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancelOrder
(long id) Tries to cancel an order.findOrder
(long id) Finds an order by identifier.placeOrder
(long customerId, List<OrderItem> items) Places an order with the bookstore.searchOrders
(long customerId, int year) Searches for orders by customer and year.
-
Constructor Details
-
OrderService
public OrderService()
-
-
Method Details
-
placeOrder
public Order placeOrder(long customerId, List<OrderItem> items) throws CustomerNotFoundException, PaymentFailedException Places an order with the bookstore.- Parameters:
customerId
- the identifier of the customeritems
- the items to be ordered- Returns:
- the data of the placed order
- Throws:
CustomerNotFoundException
- if no customer with the specified identifier existsPaymentFailedException
- if the credit card payment failed
-
findOrder
Finds an order by identifier.- Parameters:
id
- the identifier of the order- Returns:
- the data of the found order
- Throws:
OrderNotFoundException
- if no order with the specified identifier exists
-
searchOrders
Searches for orders by customer and year.- Parameters:
customerId
- the identifier of the customeryear
- the year of the orders- Returns:
- the matching orders
- Throws:
CustomerNotFoundException
- if no customer with the specified identifier exists
-
cancelOrder
Tries to cancel an order.- Parameters:
id
- the identifier of the order- Throws:
OrderNotFoundException
- if no order with the specified identifier existsOrderAlreadyShippedException
- if the order has already been shipped
-