Skip to content

Commit

Permalink
PIN-4903 BKE - Error during selfcare information retrieve at the crea…
Browse files Browse the repository at this point in the history
…tion of agreement contract (#263)

Co-authored-by: nttdata-rtorsoli <riccardo.torsoli@emeal.nttdata.com>
  • Loading branch information
nttdata-rtorsoli and nttdata-rtorsoli authored May 30, 2024
1 parent 88402a0 commit d36df0c
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import akka.http.scaladsl.model.MediaTypes
import it.pagopa.interop.agreementprocess.common.Adapters._
import it.pagopa.interop.agreementmanagement.client.model.{DocumentSeed, UpdateAgreementSeed}
import it.pagopa.interop.agreementprocess.common.system.ApplicationConfiguration
import it.pagopa.interop.agreementprocess.error.AgreementProcessErrors.{MissingUserInfo, StampNotFound}
import it.pagopa.interop.agreementprocess.error.AgreementProcessErrors.{
MissingUserInfo,
StampNotFound,
SelfcareIdNotFound
}
import it.pagopa.interop.agreementprocess.service.util.PDFPayload
import it.pagopa.interop.commons.cqrs.service.ReadModelService
import it.pagopa.interop.commons.files.service.FileManager
Expand Down Expand Up @@ -119,14 +123,20 @@ final class AgreementContractCreator(

}

def getSubmissionInfo(
seed: UpdateAgreementSeed
)(implicit contexts: Seq[(String, String)], ec: ExecutionContext): Future[(String, OffsetDateTime)] =
def getSubmissionInfo(seed: UpdateAgreementSeed, consumer: PersistentTenant)(implicit
contexts: Seq[(String, String)],
ec: ExecutionContext
): Future[(String, OffsetDateTime)] =
for {
selfcareUuidd <- getSelfcareIdFutureUUID(contexts)
submission <- seed.stamps.submission.toFuture(StampNotFound("submission"))
userResponse <- selfcareV2ClientService.getUserById(selfcareUuidd, submission.who).map(_.toApi)
userResponseApi <- userResponse.toFuture.recoverWith { case _ => Future.failed(MissingUserInfo(submission.who)) }
submission <- seed.stamps.submission.toFuture(StampNotFound("submission"))
consumerSelfcareId <- consumer.selfcareId.toFuture(SelfcareIdNotFound(consumer.id))
consumerSelfcareUuid <- consumerSelfcareId.toFutureUUID
userResponse <- selfcareV2ClientService
.getUserById(consumerSelfcareUuid, submission.who)
.map(_.toApi)
userResponseApi <- userResponse.toFuture.recoverWith { case _ =>
Future.failed(MissingUserInfo(consumer.id))
}
submitter = getUserText(userResponseApi)
} yield (submitter, submission.when)

Expand All @@ -152,7 +162,7 @@ final class AgreementContractCreator(
)(implicit contexts: Seq[(String, String)], ec: ExecutionContext): Future[PDFPayload] = {
for {
(certified, declared, verified) <- getAttributeInvolved(consumer, seed)
(submitter, submissionTimestamp) <- getSubmissionInfo(seed)
(submitter, submissionTimestamp) <- getSubmissionInfo(seed, consumer)
(activator, activationTimestamp) <- getActivationInfo(seed)
} yield PDFPayload(
today = offsetDateTimeSupplier.get(),
Expand Down

0 comments on commit d36df0c

Please sign in to comment.