Что делает фрагмент java-кода ниже


    @Override
    public OutputMessageProcessingAttempt findById(UUID id) {
        return outputMessageProcessingAttemptRepo.findById(id)
                .orElseThrow(() -> new EntityNotFoundException("OM00006", id));
    }

    @Override
    public UUID createAttempt(OutputMessage outputMessage, String replyUrl, String correlationId) {
        return outputMessageProcessingAttemptRepo.save(
                new OutputMessageProcessingAttempt(
                        outputMessage,
                        replyUrl,
                        correlationId
                )
        ).getId();
    }

    @Override
    public UUID createAttempt(ReSendOutputFile reSendOutputFile) {
        return outputMessageRepository.findById(reSendOutputFile.getOutputMessageId())
                .map(outputMessage -> createAttempt(
                        outputMessage,
                        reSendOutputFile.getReplyUrl(),
                        reSendOutputFile.getCorrelationId()
                ))
                .orElseThrow(() -> new OutputMessageNotFoundByIdException(reSendOutputFile.getOutputMessageId()));
    }

    @Override
    public List<OutputMessageProcessingAttempt> createAttempts(List<UUID> messageIds) {
        return outputMessageProcessingAttemptRepo.saveAll(findAllByMessageId(messageIds));
    }

    /**
     * Найти все попытки по id.
     *
     * @param messageIds Ids сообщений
     * @return Список попыток обработки сообщений
     */
    public List<OutputMessageProcessingAttempt> findAllByMessageId(List<UUID> messageIds) {
        List<OutputMessageProcessingAttempt> list = outputMessageRepository.findAllById(messageIds)
                .stream().map(outputMessage -> new OutputMessageProcessingAttempt(outputMessage, null, null))
                .collect(Collectors.toList());

        if (list.size() < messageIds.size()) {
            List<UUID> intersectList = messageIds;
            intersectList.removeAll(list);
            throw new OutputMessageNotFoundByIdException(intersectList.get(0));
        }
        return list;
    }

    @Override
    public void startAttempt(OutputMessageProcessingAttempt attempt) {
        if (attempt.getFinishedAt() == null && attempt.getStatus() == AttemptStatus.NEW) {
            attempt.setStatus(AttemptStatus.IN_PROGRESS);
            outputMessageProcessingAttemptRepo.save(attempt);
        }
    }

    @Override
    public void finishAttempt(OutputMessageProcessingAttempt attempt, AttemptStatus status, String responseBodyId) {
        var outputMessage = attempt.getOutputMessage();
        var outputSettings = outputSettingsService.findBySettingsName(outputMessage.getSettingsName());
        boolean successful = AttemptStatus.SUCCESSFUL.equals(status);
        if (!successful) {
            String outputMessageId = outputMessage.getId().toString();
            log.error("Ошибка при отправке исходящего сообщения. outputMessageId = {}.", outputMessageId);

            errorJournalService.save(
                    "IN00005",
                    Stream.of(responseBodyId, outputMessageId)
                            .map(String::valueOf)
                            .collect(Collectors.toList()),
                    null,
                    outputMessage.getId()
            );
        }

        attempt.setFinishedAt(OffsetDateTime.now());
        attempt.setStatus(status);
        attempt.setResponseBodyId(responseBodyId);
        outputMessageProcessingAttemptRepo.save(attempt);

        notifyAboutResult(successful, outputMessage, status);

        if (attempt.getReplyUrl() != null) {
            sendReply(
                    attempt.getReplyUrl(),
                    attempt.getCorrelationId() == null ? attempt.getId().toString() : attempt.getCorrelationId(),
                    new OutputFileProcessingResponse(
                            outputMessage.getId().toString(),
                            successful,
                            responseBodyId,
                            outputSettings.getIntegrationType() != null ? outputSettings.getIntegrationType().name() : null,
                            outputSettings.getExternalRecipientSystem()
                    )
            );
        }
    }