use of org.folio.orders.utils.ResourcePathResolver.PO_LINES_BUSINESS in project mod-orders by folio-org.
the class OrdersApi method postOrdersCompositeOrders.
@Override
@Validate
public void postOrdersCompositeOrders(String lang, CompositePurchaseOrder compPO, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
RequestContext requestContext = new RequestContext(vertxContext, okapiHeaders);
// First validate content of the PO and proceed only if all is okay
configurationEntriesService.loadConfiguration(ORDER_CONFIG_MODULE_NAME, requestContext).thenCompose(tenantConfig -> purchaseOrderHelper.validateOrder(compPO, tenantConfig, requestContext)).thenCompose(errors -> {
if (CollectionUtils.isEmpty(errors)) {
logger.info("Creating PO and POLines...");
return purchaseOrderHelper.createPurchaseOrder(compPO, new RequestContext(vertxContext, okapiHeaders)).thenAccept(withIds -> {
logger.info("Successfully Placed Order: {}", JsonObject.mapFrom(withIds).encodePrettily());
String okapiUrl = okapiHeaders.get(OKAPI_URL);
String url = resourceByIdPath(PO_LINES_BUSINESS, compPO.getId());
asyncResultHandler.handle(succeededFuture(buildResponseWithLocation(okapiUrl, url, compPO)));
});
} else {
throw new HttpException(422, new Errors().withErrors(errors).withTotalRecords(errors.size()));
}
}).exceptionally(t -> handleErrorResponse(asyncResultHandler, t));
}
Aggregations