public void activateChannel()

in src/main/java/com/epam/digital/data/platform/settings/api/service/SettingsActivationService.java [61:93]


  public void activateChannel(ActivateChannelInputDto input, Channel channel, String accessToken) {
    if (!userRoleVerifierService.verify(channel, accessToken)) {
      auditFacade.sendActivationAuditOnFailure(channel, input, "User role verification failed");
      throw new AccessDeniedException("Invalid user role for activate operation");
    }

    boolean successfullyVerified =
        channelVerificationService.verify(
            channel, accessToken, input.getVerificationCode(), input.getAddress());
    if (!successfullyVerified) {
      auditFacade.sendActivationAuditOnFailure(
          channel, input, "Communication channel verification failed");
      throw new ChannelVerificationException("Communication channel verification failed");
    }
    var settings = getSettingsFromToken(accessToken);
    var notificationChannel =
        channelRepository.findBySettingsIdAndChannel(settings.getId(), channel);

    try {
      if (notificationChannel.isPresent()) {
        log.info("Activation of existing {} channel", channel.getValue());
        channelRepository.activateChannel(
            notificationChannel.get().getId(), input.getAddress(), LocalDateTime.now());
      } else {
        log.info("Creation of activated {} channel", channel.getValue());
        channelRepository.create(settings.getId(), channel, input.getAddress(), true, null);
      }
      auditFacade.sendActivationAuditOnSuccess(channel, input);
    } catch (RuntimeException exception) {
      auditFacade.sendActivationAuditOnFailure(channel, input, exception.getMessage());
      throw exception;
    }
  }