private void handleOperation()

in service/src/main/java/org/apache/fineract/cn/stellarbridge/service/internal/horizonadapter/HorizonServerEffectsListener.java [77:135]


  private void handleOperation(final EffectResponse effect) {

    if (effect instanceof AccountCreditedEffectResponse)
    {
      final AccountCreditedEffectResponse accountCreditedEffect = (AccountCreditedEffectResponse) effect;
      final BridgeConfigurationEntity toAccount
          = accountBridgeRepository.findByStellarAccountIdentifier(effect.getAccount().getAccountId());
      if (toAccount == null)
        return; //Nothing to do.  Not one of ours.

      final BigDecimal amount
          = StellarAccountHelpers.stellarBalanceToBigDecimal(accountCreditedEffect.getAmount());
      final Asset asset = accountCreditedEffect.getAsset();
      final String assetCode = StellarAccountHelpers.getAssetCode(asset);
      final String issuer = StellarAccountHelpers.getIssuer(asset);

      logger.info("Credit to {} of {}, in currency {}@{}",
          toAccount.getTenantIdentifier(), amount, assetCode, issuer);

      //TODO: This will prevent lumens from being registered in the mifos account (likewise below in debit)...
      if (!(asset instanceof AssetTypeCreditAlphaNum))
        return;

      final StellarPaymentCommand receivePaymentCommand =
          new StellarPaymentCommand(toAccount.getTenantIdentifier(), assetCode, amount,
              LocalDateTime.now(Clock.systemUTC()));
      commandGateway.process(receivePaymentCommand);
    }
    else if (effect instanceof AccountDebitedEffectResponse)
    {
      final AccountDebitedEffectResponse accountDebitedEffect = (AccountDebitedEffectResponse)effect;

      final BridgeConfigurationEntity toAccount = accountBridgeRepository
          .findByStellarAccountIdentifier(accountDebitedEffect.getAccount().getAccountId());
      if (toAccount == null)
        return; //Nothing to do.  Not one of ours.

      final BigDecimal amount
          = StellarAccountHelpers.stellarBalanceToBigDecimal(accountDebitedEffect.getAmount());
      final Asset asset = accountDebitedEffect.getAsset();
      final String assetCode = StellarAccountHelpers.getAssetCode(asset);
      final String issuer = StellarAccountHelpers.getIssuer(asset);

      logger.info("Debit to {} of {}, in currency {}@{}",
          toAccount.getTenantIdentifier(), amount, assetCode, issuer);

      if (!(asset instanceof AssetTypeCreditAlphaNum))
        return;

      final StellarPaymentCommand receivePaymentCommand =
          new StellarPaymentCommand(toAccount.getTenantIdentifier(), assetCode, amount.negate(),
              LocalDateTime.now(Clock.systemUTC()));
      commandGateway.process(receivePaymentCommand);
    }
    else
    {
      logger.info("Effect of type {}", effect.getType());
    }
  }