diff --git a/src/main/kotlin/no/nb/mlt/wls/order/service/OrderService.kt b/src/main/kotlin/no/nb/mlt/wls/order/service/OrderService.kt index 422d4d81..055c02b9 100644 --- a/src/main/kotlin/no/nb/mlt/wls/order/service/OrderService.kt +++ b/src/main/kotlin/no/nb/mlt/wls/order/service/OrderService.kt @@ -69,31 +69,31 @@ class OrderService(val db: OrderRepository, val synqService: SynqOrderService) { return ResponseEntity.status(HttpStatus.CREATED).body(order.toApiOrderPayload()) } - private fun throwIfInvalidPayload(payload: ApiOrderPayload) { - if (payload.orderId.isBlank()) { - throw ServerWebInputException("The order's orderId is required, and can not be blank") - } - if (payload.hostOrderId.isBlank()) { - throw ServerWebInputException("The order's hostOrderId is required, and can not be blank") - } - if (payload.productLine.isEmpty()) { - throw ServerWebInputException("The order must contain product lines") - } - } - + /** + * Gets an order from the WLS database + */ suspend fun getOrder( hostName: HostName, hostOrderId: String ): ResponseEntity { val order = db.findByHostNameAndHostOrderId(hostName, hostOrderId) - .onErrorMap(IncorrectResultSizeDataAccessException::class.java) { - TODO("Handle duplicate order ID's somehow") - } .awaitSingleOrNull() if (order != null) { return ResponseEntity.ok(order) } throw ResponseStatusException(HttpStatus.NOT_FOUND, "Order with id $hostOrderId from $hostName was not found") } + + private fun throwIfInvalidPayload(payload: ApiOrderPayload) { + if (payload.orderId.isBlank()) { + throw ServerWebInputException("The order's orderId is required, and can not be blank") + } + if (payload.hostOrderId.isBlank()) { + throw ServerWebInputException("The order's hostOrderId is required, and can not be blank") + } + if (payload.productLine.isEmpty()) { + throw ServerWebInputException("The order must contain product lines") + } + } }