use of org.folio.inventory.validation.InstancesValidators in project mod-inventory by folio-org.
the class Instances method update.
private void update(RoutingContext rContext) {
WebContext wContext = new WebContext(rContext);
JsonObject instanceRequest = rContext.getBodyAsJson();
Instance updatedInstance = Instance.fromJson(instanceRequest);
InstanceCollection instanceCollection = storage.getInstanceCollection(wContext);
completedFuture(updatedInstance).thenCompose(InstancePrecedingSucceedingTitleValidators::refuseWhenUnconnectedHasNoTitle).thenCompose(instance -> instanceCollection.findById(rContext.request().getParam("id"))).thenCompose(InstancesValidators::refuseWhenInstanceNotFound).thenCompose(existingInstance -> fetchPrecedingSucceedingTitles(new Success<>(existingInstance), rContext, wContext)).thenCompose(existingInstance -> refuseWhenBlockedFieldsChanged(existingInstance, updatedInstance)).thenCompose(existingInstance -> refuseWhenHridChanged(existingInstance, updatedInstance)).thenAccept(existingInstance -> updateInstance(updatedInstance, rContext, wContext)).exceptionally(doExceptionally(rContext));
}
Aggregations