public void deactivateChannel()

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


  public void deactivateChannel(
      Channel channel, SettingsDeactivateChannelInputDto input, String accessToken) {

    if (!userRoleVerifierService.verify(channel, accessToken)) {
      auditFacade.sendDeactivationAuditOnFailure(channel, input, "User role verification failed");
      throw new AccessDeniedException("Invalid user role for deactivate operation");
    }

    var settings = getSettingsFromToken(accessToken);
    var notificationChannel =
        channelRepository.findBySettingsIdAndChannel(settings.getId(), channel);
    try {
      if (notificationChannel.isPresent()) {
        log.info("Deactivation of existing channel {}", channel);
        var address =
            input.getAddress() == null
                ? notificationChannel.get().getAddress()
                : input.getAddress();
        channelRepository.deactivateChannel(
            notificationChannel.get().getId(),
            address,
            input.getDeactivationReason(),
            LocalDateTime.now());
      } else {
        log.info("Creation of deactivated {} channel", channel);
        channelRepository.create(
            settings.getId(), channel, input.getAddress(), false, input.getDeactivationReason());
      }
      auditFacade.sendDeactivationAuditOnSuccess(channel, input);
    } catch (RuntimeException exception) {
      auditFacade.sendDeactivationAuditOnFailure(channel, input, exception.getMessage());
      throw exception;
    }
  }