use of org.folio.circulation.support.http.server.NoContentResponse in project mod-circulation by folio-org.
the class RequestCollectionResource method replace.
@Override
void replace(RoutingContext routingContext) {
final var context = new WebContext(routingContext);
final var clients = Clients.create(context, client);
final var representation = routingContext.getBodyAsJson();
write(representation, "id", getRequestId(routingContext));
final var itemRepository = new ItemRepository(clients);
final var userRepository = new UserRepository(clients);
final var loanRepository = new LoanRepository(clients, itemRepository, userRepository);
final var requestRepository = RequestRepository.using(clients, itemRepository, userRepository, loanRepository);
final var requestQueueRepository = new RequestQueueRepository(requestRepository);
final var updateRequestQueue = UpdateRequestQueue.using(clients, requestRepository, requestQueueRepository);
final var loanPolicyRepository = new LoanPolicyRepository(clients);
final var eventPublisher = new EventPublisher(routingContext);
final var requestNoticeSender = createRequestNoticeSender(clients, representation);
final var configurationRepository = new ConfigurationRepository(clients);
final var updateItem = new UpdateItem(itemRepository);
final var updateUponRequest = new UpdateUponRequest(updateItem, new UpdateLoan(clients, loanRepository, loanPolicyRepository), updateRequestQueue);
final var errorHandler = new FailFastErrorHandler();
final var createRequestService = new CreateRequestService(new CreateRequestRepositories(requestRepository, new RequestPolicyRepository(clients), configurationRepository), updateUponRequest, new RequestLoanValidator(new ItemByInstanceIdFinder(clients.holdingsStorage(), itemRepository), loanRepository), requestNoticeSender, regularRequestBlockValidators(clients), eventPublisher, errorHandler);
final var updateRequestService = new UpdateRequestService(requestRepository, updateRequestQueue, new ClosedRequestValidator(requestRepository), requestNoticeSender, updateItem, eventPublisher);
final var requestFromRepresentationService = new RequestFromRepresentationService(new InstanceRepository(clients), itemRepository, new RequestQueueRepository(requestRepository), userRepository, loanRepository, new ServicePointRepository(clients), configurationRepository, createProxyRelationshipValidator(representation, clients), new ServicePointPickupLocationValidator(), errorHandler, new ItemByInstanceIdFinder(clients.holdingsStorage(), itemRepository));
final var requestScheduledNoticeService = RequestScheduledNoticeService.using(clients);
fromFutureResult(requestFromRepresentationService.getRequestFrom(Request.Operation.REPLACE, representation)).flatMapFuture(when(requestRepository::exists, updateRequestService::replaceRequest, createRequestService::createRequest)).flatMapFuture(records -> eventPublisher.publishDueDateChangedEvent(records, loanRepository)).map(requestScheduledNoticeService::rescheduleRequestNotices).map(toFixedValue(NoContentResponse::noContent)).onComplete(context::write, context::write);
}
use of org.folio.circulation.support.http.server.NoContentResponse in project mod-circulation by folio-org.
the class ClaimItemReturnedResource method claimItemReturned.
private void claimItemReturned(RoutingContext routingContext) {
final WebContext context = new WebContext(routingContext);
final EventPublisher eventPublisher = new EventPublisher(routingContext);
createRequest(routingContext).after(request -> processClaimItemReturned(routingContext, request)).thenCompose(r -> r.after(eventPublisher::publishItemClaimedReturnedEvent)).thenApply(r -> r.map(toFixedValue(NoContentResponse::noContent))).thenAccept(context::writeResultToHttpResponse);
}
use of org.folio.circulation.support.http.server.NoContentResponse in project mod-circulation by folio-org.
the class DeclareLostResource method declareLost.
private void declareLost(RoutingContext routingContext) {
final WebContext context = new WebContext(routingContext);
final Clients clients = Clients.create(context, client);
final EventPublisher eventPublisher = new EventPublisher(routingContext);
validateDeclaredLostRequest(routingContext).after(request -> declareItemLost(request, clients, context)).thenComposeAsync(r -> r.after(loan -> publishEvent(loan, eventPublisher))).thenApply(r -> r.map(toFixedValue(NoContentResponse::noContent))).thenAccept(context::writeResultToHttpResponse);
}
use of org.folio.circulation.support.http.server.NoContentResponse in project mod-circulation by folio-org.
the class LoanCollectionResource method empty.
@Override
void empty(RoutingContext routingContext) {
WebContext context = new WebContext(routingContext);
Clients clients = Clients.create(context, client);
clients.loansStorage().delete().thenApply(r -> r.map(toFixedValue(NoContentResponse::noContent))).thenAccept(context::writeResultToHttpResponse);
}
use of org.folio.circulation.support.http.server.NoContentResponse in project mod-circulation by folio-org.
the class LoanCollectionResource method delete.
@Override
void delete(RoutingContext routingContext) {
WebContext context = new WebContext(routingContext);
Clients clients = Clients.create(context, client);
String id = routingContext.request().getParam("id");
clients.loansStorage().delete(id).thenApply(r -> r.map(toFixedValue(NoContentResponse::noContent))).thenAccept(context::writeResultToHttpResponse);
}
Aggregations