PROX-396: damsel-cds -> cds-proto (#18)

* PROX-396: damsel-cds -> cds-proto
This commit is contained in:
Anatoly Cherkasov 2020-03-19 13:34:13 +03:00 committed by GitHub
parent 22b06a56dd
commit f19526235f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 15 deletions

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.rbkmoney</groupId>
<artifactId>adapter-bank-payout-spring-boot-starter</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>
<packaging>jar</packaging>
<name>Adapter-bank-payout-spring-boot-starter</name>
@ -15,10 +15,10 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>8</java.version>
<spring-boot.version>2.1.1.RELEASE</spring-boot.version>
<damsel-utils.version>2.1.9</damsel-utils.version>
<damsel.version>1.303-d99319c</damsel.version>
<damsel.version>1.391-8fe5f98</damsel.version>
<serializer.version>0.6.7</serializer.version>
<error-mapping.version>1.0.4</error-mapping.version>
<adapter-common-lib.version>0.0.19</adapter-common-lib.version>
</properties>
<dependencies>
@ -71,7 +71,7 @@
<dependency>
<groupId>com.rbkmoney</groupId>
<artifactId>adapter-common-lib</artifactId>
<version>0.0.15</version>
<version>${adapter-common-lib.version}</version>
</dependency>
<dependency>
<groupId>com.rbkmoney</groupId>

View File

@ -0,0 +1,10 @@
package com.rbkmoney.adapter.bank.payout.spring.boot.starter.handler;
import com.rbkmoney.damsel.withdrawals.provider_adapter.GetQuoteParams;
import com.rbkmoney.damsel.withdrawals.provider_adapter.Quote;
import java.util.Map;
public interface GetQuoteHandler {
Quote handle(GetQuoteParams getQuoteParams, Map<String, String> map);
}

View File

@ -5,14 +5,13 @@ import com.rbkmoney.adapter.bank.payout.spring.boot.starter.converter.ExitStateT
import com.rbkmoney.adapter.bank.payout.spring.boot.starter.converter.WithdrawalToEntryStateConverter;
import com.rbkmoney.adapter.bank.payout.spring.boot.starter.flow.StepResolver;
import com.rbkmoney.adapter.bank.payout.spring.boot.starter.handler.CommonHandler;
import com.rbkmoney.adapter.bank.payout.spring.boot.starter.handler.GetQuoteHandler;
import com.rbkmoney.adapter.bank.payout.spring.boot.starter.model.EntryStateModel;
import com.rbkmoney.adapter.bank.payout.spring.boot.starter.model.ExitStateModel;
import com.rbkmoney.adapter.bank.payout.spring.boot.starter.validator.WithdrawalValidator;
import com.rbkmoney.adapter.common.exception.UnsupportedMethodException;
import com.rbkmoney.damsel.msgpack.Value;
import com.rbkmoney.damsel.withdrawals.provider_adapter.AdapterSrv;
import com.rbkmoney.damsel.withdrawals.provider_adapter.ProcessResult;
import com.rbkmoney.damsel.withdrawals.provider_adapter.Withdrawal;
import com.rbkmoney.damsel.withdrawals.provider_adapter.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.thrift.TException;
@ -29,6 +28,7 @@ public class PayoutAdapterService<T extends EntryStateModel, X extends ExitState
private final List<CommonHandler<T, X>> handlers;
private final StepResolver<T, X> resolver;
private final WithdrawalValidator validator;
private final GetQuoteHandler getQuoteHandler;
@Override
public ProcessResult processWithdrawal(Withdrawal withdrawal, Value state, Map<String, String> options) throws TException {
@ -43,4 +43,9 @@ public class PayoutAdapterService<T extends EntryStateModel, X extends ExitState
exitStateModel.getNextState().setStep(resolver.resolveExit(exitStateModel));
return exitStateToProcessResultConverter.convert(exitStateModel);
}
@Override
public Quote getQuote(GetQuoteParams getQuoteParams, Map<String, String> map) throws GetQuoteFailure, TException {
return getQuoteHandler.handle(getQuoteParams, map);
}
}

View File

@ -1,9 +1,7 @@
package com.rbkmoney.adapter.bank.payout.spring.boot.starter.service;
import com.rbkmoney.damsel.msgpack.Value;
import com.rbkmoney.damsel.withdrawals.provider_adapter.AdapterSrv;
import com.rbkmoney.damsel.withdrawals.provider_adapter.ProcessResult;
import com.rbkmoney.damsel.withdrawals.provider_adapter.Withdrawal;
import com.rbkmoney.damsel.withdrawals.provider_adapter.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.thrift.TException;
@ -28,12 +26,31 @@ public class PayoutAdapterServiceLogDecorator implements AdapterSrv.Iface {
return processResult;
} catch (Exception ex) {
String message = "Exception in processPayment with withdrawalId " + withdrawalId;
logMessage(ex, message);
throw ex;
}
}
@Override
public Quote getQuote(GetQuoteParams getQuoteParams, Map<String, String> map) throws GetQuoteFailure, TException {
String withdrawalId = getQuoteParams.getIdempotencyId();
log.info("processWithdrawal: start with withdrawalId {}", withdrawalId);
try {
Quote quote = payoutAdapterService.getQuote(getQuoteParams, map);
log.info("processWithdrawal: finish {} with withdrawalId {}", quote, withdrawalId);
return quote;
} catch (Exception ex) {
String message = "Exception in getQuote with withdrawalId " + withdrawalId;
logMessage(ex, message);
throw ex;
}
}
private void logMessage(Exception ex, String message) {
if (isUndefinedResultOrUnavailable(ex)) {
log.warn(message, ex);
} else {
log.error(message, ex);
}
throw ex;
}
}
}