Skip to content

Commit dd529b1

Browse files
committed
[PAGOPA-2342] feat: included more explicative syntax's errors events
1 parent b54ba69 commit dd529b1

File tree

14 files changed

+174
-211
lines changed

14 files changed

+174
-211
lines changed

wispsoapconverter/src/main/scala/it/gov/pagopa/actors/NodoInviaCarrelloRPTActor.scala

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import it.gov.pagopa.common.exception.{DigitPaErrorCodes, DigitPaException}
1212
import it.gov.pagopa.common.message._
1313
import it.gov.pagopa.common.repo.{CosmosPrimitive, CosmosRepository}
1414
import it.gov.pagopa.common.util._
15-
import it.gov.pagopa.common.util.azure.cosmos.EventCategory
15+
import it.gov.pagopa.common.util.azure.cosmos.{Esito, EventCategory}
1616
import it.gov.pagopa.common.util.xml.XsdValid
1717
import it.gov.pagopa.commonxml.XmlEnum
1818
import it.gov.pagopa.exception.{CarrelloRptFaultBeanException, WorkflowExceptionErrorCodes}
@@ -48,6 +48,9 @@ case class NodoInviaCarrelloRPTActorPerRequest(cosmosRepository: CosmosRepositor
4848
}
4949
val recoverPipeline: PartialFunction[Throwable, Future[SoapResponse]] = {
5050
case cfb: CarrelloRptFaultBeanException =>
51+
MDC.put(Constant.MDCKey.PROCESS_OUTCOME, Esito.ERROR.toString)
52+
MDC.put(Constant.MDCKey.ERROR_LINE, cfb.digitPaException.getMessage)
53+
val exceptionCode = cfb.digitPaException.code
5154
if (cfb.workflowErrorCode.isDefined && cfb.idCarrello.isDefined && cfb.rptKeys.isDefined) {
5255
cfb.workflowErrorCode.get match {
5356
case WorkflowExceptionErrorCodes.CARRELLO_ERRORE_SEMANTICO | WorkflowExceptionErrorCodes.RPT_ERRORE_SEMANTICO =>
@@ -60,14 +63,24 @@ case class NodoInviaCarrelloRPTActorPerRequest(cosmosRepository: CosmosRepositor
6063
} yield res) recoverWith recoverGenericError
6164

6265
case _ =>
66+
if (exceptionCode.equals(DigitPaErrorCodes.PPT_SINTASSI_EXTRAXSD) || exceptionCode.equals(DigitPaErrorCodes.PPT_SINTASSI_XSD)) {
67+
val reCambioStato = re.get.copy(status = Some(WorkflowStatus.SYNTAX_CHECK_FAILED.toString), insertedTimestamp = Util.now())
68+
reEventFunc(reRequest.copy(re = reCambioStato), log, ddataMap)
69+
}
6370
val cfb = CarrelloRptFaultBeanException(exception.DigitPaException(DigitPaErrorCodes.PPT_SYSTEM_ERROR), idCanale = None)
6471
Future.successful(errorHandler(req.sessionId, req.testCaseId, cfb, re))
6572
}
6673
} else {
74+
if (exceptionCode.equals(DigitPaErrorCodes.PPT_SINTASSI_EXTRAXSD) || exceptionCode.equals(DigitPaErrorCodes.PPT_SINTASSI_XSD)) {
75+
val reCambioStato = re.get.copy(status = Some(WorkflowStatus.SYNTAX_CHECK_FAILED.toString), insertedTimestamp = Util.now())
76+
reEventFunc(reRequest.copy(re = reCambioStato), log, ddataMap)
77+
}
6778
Future.successful(errorHandler(req.sessionId, req.testCaseId, cfb, re))
6879
}
6980
case e: Throwable =>
7081
log.warn(e, e.getMessage)
82+
MDC.put(Constant.MDCKey.PROCESS_OUTCOME, Esito.ERROR.toString)
83+
MDC.put(Constant.MDCKey.ERROR_LINE, e.getMessage)
7184
val cfb = CarrelloRptFaultBeanException(exception.DigitPaException(DigitPaErrorCodes.PPT_SYSTEM_ERROR, e), idCanale = None)
7285
Future.successful(errorHandler(req.sessionId, req.testCaseId, cfb, re))
7386
}
@@ -94,8 +107,8 @@ case class NodoInviaCarrelloRPTActorPerRequest(cosmosRepository: CosmosRepositor
94107

95108
re = Some(
96109
Re(
110+
sessionId = Some(MDC.get(Constant.MDCKey.SESSION_ID)),
97111
eventCategory = EventCategory.INTERNAL,
98-
sessionId = None,
99112
requestPayload = None,
100113
insertedTimestamp = soapRequest.timestamp,
101114
businessProcess = Some(actorClassId),
@@ -112,7 +125,6 @@ case class NodoInviaCarrelloRPTActorPerRequest(cosmosRepository: CosmosRepositor
112125
_ = idCarrello = intestazioneCarrelloPPT.identificativoCarrello
113126
_ = re = re.map(r =>
114127
r.copy(
115-
sessionId = Some(MDC.get(Constant.MDCKey.SESSION_ID)),
116128
cartId = Some(idCarrello),
117129
psp = Some(nodoInviaCarrelloRPT.identificativoPSP),
118130
channel = Some(nodoInviaCarrelloRPT.identificativoCanale),
@@ -138,10 +150,10 @@ case class NodoInviaCarrelloRPTActorPerRequest(cosmosRepository: CosmosRepositor
138150

139151
pipeline
140152
.recoverWith(recoverPipeline)
141-
.map(sr => {
142-
traceInterfaceRequest(soapRequest, re.get, soapRequest.reExtra, reEventFunc, ddataMap)
153+
.map(soapResponse => {
154+
traceWebserviceInvocation(soapRequest, soapResponse, re.get, soapRequest.reExtra, reEventFunc, ddataMap)
143155
log.info(LogConstant.logEnd(actorClassId))
144-
replyTo ! sr
156+
replyTo ! soapResponse
145157
complete()
146158
})
147159
}

wispsoapconverter/src/main/scala/it/gov/pagopa/actors/NodoInviaRPTActor.scala

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import it.gov.pagopa.common.message._
1212
import it.gov.pagopa.common.repo.{CosmosPrimitive, CosmosRepository}
1313
import it.gov.pagopa.common.rpt.split.RptFlow
1414
import it.gov.pagopa.common.util._
15-
import it.gov.pagopa.common.util.azure.cosmos.EventCategory
15+
import it.gov.pagopa.common.util.azure.cosmos.{Esito, EventCategory}
1616
import it.gov.pagopa.config.Channel
1717
import it.gov.pagopa.exception.{RptFaultBeanException, WorkflowExceptionErrorCodes}
1818
import org.slf4j.MDC
@@ -34,6 +34,8 @@ case class NodoInviaRPTActorPerRequest(cosmosRepository: CosmosRepository, actor
3434
val uriAdapterEcommerce: String = context.system.settings.config.getString("adapterEcommerce.url")
3535
val recoverFuture: PartialFunction[Throwable, Future[SoapResponse]] = {
3636
case cfb: RptFaultBeanException =>
37+
MDC.put(Constant.MDCKey.PROCESS_OUTCOME, Esito.ERROR.toString)
38+
MDC.put(Constant.MDCKey.ERROR_LINE, cfb.digitPaException.getMessage)
3739
log.warn(s"Errore generico durante $actorClassId, message: [${cfb.getMessage}]")
3840
if (cfb.workflowErrorCode.isDefined && cfb.rptKey.isDefined) {
3941
cfb.workflowErrorCode.get match {
@@ -56,11 +58,19 @@ case class NodoInviaRPTActorPerRequest(cosmosRepository: CosmosRepository, actor
5658
Future.successful(SoapResponse(req.sessionId, resItems._1, StatusCodes.OK.intValue, re, req.testCaseId))
5759
}
5860
case dpaex: DigitPaException =>
61+
MDC.put(Constant.MDCKey.PROCESS_OUTCOME, Esito.ERROR.toString)
62+
MDC.put(Constant.MDCKey.ERROR_LINE, dpaex.getMessage)
5963
log.warn(s"Errore generico durante $actorClassId, message: [${dpaex.getMessage}]")
64+
if (dpaex.code.equals(DigitPaErrorCodes.PPT_SINTASSI_EXTRAXSD) || dpaex.code.equals(DigitPaErrorCodes.PPT_SINTASSI_XSD)) {
65+
val reCambioStato = re.get.copy(status = Some(WorkflowStatus.SYNTAX_CHECK_FAILED.toString), insertedTimestamp = Util.now())
66+
reEventFunc(reRequest.copy(re = reCambioStato), log, ddataMap)
67+
}
6068
val resItems = errorHandler(RptFaultBeanException(dpaex))
6169
Future.successful(SoapResponse(req.sessionId, resItems._1, StatusCodes.OK.intValue, re, req.testCaseId))
6270
case cause: Throwable =>
6371
log.warn(cause, s"Errore generico durante $actorClassId, message: [${cause.getMessage}]")
72+
MDC.put(Constant.MDCKey.PROCESS_OUTCOME, Esito.ERROR.toString)
73+
MDC.put(Constant.MDCKey.ERROR_LINE, cause.getMessage)
6474
val cfb = RptFaultBeanException(exception.DigitPaException(DigitPaErrorCodes.PPT_SYSTEM_ERROR, cause))
6575
val resItems = errorHandler(cfb)
6676
Future.successful(SoapResponse(req.sessionId, resItems._1, StatusCodes.OK.intValue, re, req.testCaseId))
@@ -172,10 +182,10 @@ case class NodoInviaRPTActorPerRequest(cosmosRepository: CosmosRepository, actor
172182

173183
pipeline
174184
.recoverWith(recoverFuture)
175-
.map(sr2 => {
176-
traceInterfaceRequest(soapRequest, re.get, soapRequest.reExtra, reEventFunc, ddataMap)
185+
.map(soapResponse => {
186+
traceWebserviceInvocation(soapRequest, soapResponse, re.get, soapRequest.reExtra, reEventFunc, ddataMap)
177187
log.info(LogConstant.logEnd(actorClassId))
178-
replyTo ! sr2
188+
replyTo ! soapResponse
179189
complete()
180190
})
181191
}

wispsoapconverter/src/main/scala/it/gov/pagopa/actors/flow/CarrelloFlow.scala

Lines changed: 79 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import scalaxbmodel.paginf.CtRichiestaPagamentoTelematico
1616
import scala.collection.mutable.{Map => MutMap}
1717
import scala.util.{Failure, Success, Try}
1818

19-
trait CarrelloFlow extends CommonRptCheck with ValidateRpt with ReUtil { this: PerRequestActor =>
19+
trait CarrelloFlow extends CommonRptCheck with ValidateRpt with ReUtil {
20+
this: PerRequestActor =>
2021

2122
def parseCarrello(payload: String, inputXsdValid: Boolean): Try[(IntestazioneCarrelloPPT, NodoInviaCarrelloRPT)] = {
2223
(for {
@@ -30,16 +31,16 @@ trait CarrelloFlow extends CommonRptCheck with ValidateRpt with ReUtil { this: P
3031
}
3132

3233
def validCarrello(
33-
ddataMap: ConfigData,
34-
maxNumRptInCart: Int,
35-
rptKeys: Seq[RPTKey],
36-
intestazioneCarrelloPPT: IntestazioneCarrelloPPT,
37-
nodoInviaCarrelloRPT: NodoInviaCarrelloRPT,
38-
multibeneficiario: Boolean,
39-
idCanaleAgid: String,
40-
idPspAgid: String,
41-
idIntPspAgid: String
42-
): Try[(BrokerCreditorInstitution, Station)] = {
34+
ddataMap: ConfigData,
35+
maxNumRptInCart: Int,
36+
rptKeys: Seq[RPTKey],
37+
intestazioneCarrelloPPT: IntestazioneCarrelloPPT,
38+
nodoInviaCarrelloRPT: NodoInviaCarrelloRPT,
39+
multibeneficiario: Boolean,
40+
idCanaleAgid: String,
41+
idPspAgid: String,
42+
idIntPspAgid: String
43+
): Try[(BrokerCreditorInstitution, Station)] = {
4344
val check = for {
4445
_ <- Success(())
4546
_ <- DDataChecks.checkPspIntermediarioPspCanale(
@@ -165,14 +166,14 @@ trait CarrelloFlow extends CommonRptCheck with ValidateRpt with ReUtil { this: P
165166
}
166167

167168
def validRpts(
168-
ddataMap: ConfigData,
169-
idCarrello: String,
170-
rptKeys: Seq[RPTKey],
171-
nodoInviaCarrelloRPT: NodoInviaCarrelloRPT,
172-
intestazioneCarrelloPPT: IntestazioneCarrelloPPT,
173-
isBolloEnabled: Boolean,
174-
maxVersamentiInSecondRpt: Int
175-
): Try[Boolean] = {
169+
ddataMap: ConfigData,
170+
idCarrello: String,
171+
rptKeys: Seq[RPTKey],
172+
nodoInviaCarrelloRPT: NodoInviaCarrelloRPT,
173+
intestazioneCarrelloPPT: IntestazioneCarrelloPPT,
174+
isBolloEnabled: Boolean,
175+
maxVersamentiInSecondRpt: Int
176+
): Try[Boolean] = {
176177

177178
val errorMap: MutMap[Int, RptFaultBeanException] = MutMap.empty
178179

@@ -194,65 +195,65 @@ trait CarrelloFlow extends CommonRptCheck with ValidateRpt with ReUtil { this: P
194195
val idDominioMulti = intestazioneCarrelloPPT.identificativoCarrello.substring(0, 11)
195196

196197
(if (index == 0) {
197-
for {
198-
_ <- DDataChecks.checkPaIntermediarioPaStazioneMultibeneficiario(
199-
log,
200-
ddataMap,
201-
rpt.dominio.identificativoDominio,
202-
intestazioneCarrelloPPT.identificativoIntermediarioPA,
203-
intestazioneCarrelloPPT.identificativoStazioneIntermediarioPA
204-
)
205-
//L’idCarrello deve essere composto nella seguente forma: <idDominio(11)><numeroAvviso(18)><-><Progressivo(5)>
206-
_ <-
207-
if (idDominioMulti != rpt.dominio.identificativoDominio) {
208-
Failure(exception.DigitPaException("L’idCarrello deve contenere idDominio e corrispondere al dominio della prima rpt", DigitPaErrorCodes.PPT_MULTI_BENEFICIARIO))
209-
} else {
210-
Success(())
211-
}
212-
213-
} yield ()
214-
215-
} else {
216-
for {
217-
_ <- DDataChecks.checkPA(log, ddataMap, rpt.dominio.identificativoDominio)
218-
219-
//La seconda RPT contiene solo 1 versamento
220-
_ <-
221-
if (rpt.datiVersamento.datiSingoloVersamento.size == maxVersamentiInSecondRpt) {
222-
Success(())
223-
} else {
224-
Failure(exception.DigitPaException(s"La seconda RPT non contiene solo $maxVersamentiInSecondRpt versamento", DigitPaErrorCodes.PPT_MULTI_BENEFICIARIO))
225-
}
226-
//Lo stesso Ente deve essere presente con una sola RPT
227-
_ <-
228-
if (rpt.dominio.identificativoDominio != primarpt.dominio.identificativoDominio) {
229-
Success(())
230-
} else {
231-
Failure(exception.DigitPaException("Lo stesso Ente deve essere presente con una sola RPT", DigitPaErrorCodes.PPT_MULTI_BENEFICIARIO))
232-
}
233-
//Lo IUV è identico per ogni RPT
234-
_ <-
235-
if (rpt.datiVersamento.identificativoUnivocoVersamento == primarpt.datiVersamento.identificativoUnivocoVersamento) {
236-
Success(())
237-
} else {
238-
Failure(exception.DigitPaException("Lo IUV non è identico per ogni RPT", DigitPaErrorCodes.PPT_MULTI_BENEFICIARIO))
239-
}
240-
//Il dato dataEsecuzionePagamento è il medesimo per tutte le RPT
241-
_ <-
242-
if (rpt.datiVersamento.dataEsecuzionePagamento == primarpt.datiVersamento.dataEsecuzionePagamento) {
243-
Success(())
244-
} else {
245-
Failure(exception.DigitPaException("Il dato dataEsecuzionePagamento non è il medesimo per tutte le RPT", DigitPaErrorCodes.PPT_MULTI_BENEFICIARIO))
246-
}
247-
//Il carrello deve avere massimo 5 versamenti totali ( tra le RPT )
248-
_ <-
249-
if (rpt.datiVersamento.datiSingoloVersamento.size + primarpt.datiVersamento.datiSingoloVersamento.size > 5) {
250-
Failure(exception.DigitPaException("Il carrello deve avere massimo 5 versamenti totali", DigitPaErrorCodes.PPT_MULTI_BENEFICIARIO))
251-
} else {
252-
Success(())
253-
}
254-
} yield ()
255-
}).flatMap(_ => {
198+
for {
199+
_ <- DDataChecks.checkPaIntermediarioPaStazioneMultibeneficiario(
200+
log,
201+
ddataMap,
202+
rpt.dominio.identificativoDominio,
203+
intestazioneCarrelloPPT.identificativoIntermediarioPA,
204+
intestazioneCarrelloPPT.identificativoStazioneIntermediarioPA
205+
)
206+
//L’idCarrello deve essere composto nella seguente forma: <idDominio(11)><numeroAvviso(18)><-><Progressivo(5)>
207+
_ <-
208+
if (idDominioMulti != rpt.dominio.identificativoDominio) {
209+
Failure(exception.DigitPaException("L’idCarrello deve contenere idDominio e corrispondere al dominio della prima rpt", DigitPaErrorCodes.PPT_MULTI_BENEFICIARIO))
210+
} else {
211+
Success(())
212+
}
213+
214+
} yield ()
215+
216+
} else {
217+
for {
218+
_ <- DDataChecks.checkPA(log, ddataMap, rpt.dominio.identificativoDominio)
219+
220+
//La seconda RPT contiene solo 1 versamento
221+
_ <-
222+
if (rpt.datiVersamento.datiSingoloVersamento.size == maxVersamentiInSecondRpt) {
223+
Success(())
224+
} else {
225+
Failure(exception.DigitPaException(s"La seconda RPT non contiene solo $maxVersamentiInSecondRpt versamento", DigitPaErrorCodes.PPT_MULTI_BENEFICIARIO))
226+
}
227+
//Lo stesso Ente deve essere presente con una sola RPT
228+
_ <-
229+
if (rpt.dominio.identificativoDominio != primarpt.dominio.identificativoDominio) {
230+
Success(())
231+
} else {
232+
Failure(exception.DigitPaException("Lo stesso Ente deve essere presente con una sola RPT", DigitPaErrorCodes.PPT_MULTI_BENEFICIARIO))
233+
}
234+
//Lo IUV è identico per ogni RPT
235+
_ <-
236+
if (rpt.datiVersamento.identificativoUnivocoVersamento == primarpt.datiVersamento.identificativoUnivocoVersamento) {
237+
Success(())
238+
} else {
239+
Failure(exception.DigitPaException("Lo IUV non è identico per ogni RPT", DigitPaErrorCodes.PPT_MULTI_BENEFICIARIO))
240+
}
241+
//Il dato dataEsecuzionePagamento è il medesimo per tutte le RPT
242+
_ <-
243+
if (rpt.datiVersamento.dataEsecuzionePagamento == primarpt.datiVersamento.dataEsecuzionePagamento) {
244+
Success(())
245+
} else {
246+
Failure(exception.DigitPaException("Il dato dataEsecuzionePagamento non è il medesimo per tutte le RPT", DigitPaErrorCodes.PPT_MULTI_BENEFICIARIO))
247+
}
248+
//Il carrello deve avere massimo 5 versamenti totali ( tra le RPT )
249+
_ <-
250+
if (rpt.datiVersamento.datiSingoloVersamento.size + primarpt.datiVersamento.datiSingoloVersamento.size > 5) {
251+
Failure(exception.DigitPaException("Il carrello deve avere massimo 5 versamenti totali", DigitPaErrorCodes.PPT_MULTI_BENEFICIARIO))
252+
} else {
253+
Success(())
254+
}
255+
} yield ()
256+
}).flatMap(_ => {
256257
for {
257258
//Il CCP delle RPT devono contenere l’idCarrello
258259
_ <-

wispsoapconverter/src/main/scala/it/gov/pagopa/common/enums/WorkflowStatus.scala

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,5 @@ package it.gov.pagopa.common.enums
22

33
// format: off
44
object WorkflowStatus extends Enumeration {
5-
val //RPT_RICEVUTA_NODO, CART_RICEVUTO_NODO, // SYNTAX_CHECK_PASSED
6-
//RPT_ACCETTATA_NODO, CART_ACCETTATO_NODO, // SEMANTIC_CHECK_PASSED
7-
//RPT_RIFIUTATA_NODO, CART_RIFIUTATO_NODO, // SEMANTIC_CHECK_FAILED
8-
RECEIVED,
9-
//RPT_PARCHEGGIATA_NODO, CART_PARCHEGGIATO_NODO, // RPT_STORED
10-
11-
SYNTAX_CHECK_PASSED,
12-
SEMANTIC_CHECK_PASSED,
13-
SEMANTIC_CHECK_FAILED,
14-
RPT_STORED
15-
16-
= Value
5+
val SYNTAX_CHECK_PASSED, SYNTAX_CHECK_FAILED, SEMANTIC_CHECK_PASSED, SEMANTIC_CHECK_FAILED, RPT_STORED, TRIGGER_PRIMITIVE_PROCESSED = Value
176
}

wispsoapconverter/src/main/scala/it/gov/pagopa/common/message/Re.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package it.gov.pagopa.common.message
22

33
import it.gov.pagopa.common.util.azure.Appfunction
4-
import it.gov.pagopa.common.util.azure.cosmos.{Esito, EventCategory}
4+
import it.gov.pagopa.common.util.azure.cosmos.EventCategory
55
import net.openhft.hashing.LongHashFunction
66

77
import java.time.Instant
@@ -16,12 +16,13 @@ case class Re(
1616
psp: Option[String] = None,
1717
station: Option[String] = None,
1818
channel: Option[String] = None,
19-
outcome: Option[Esito.Value] = None,
19+
outcome: Option[String] = None,
2020
sessionId: Option[String] = None,
2121
status: Option[String] = None,
2222
requestPayload: Option[Array[Byte]] = None,
2323
responsePayload: Option[Array[Byte]] = None,
2424
info: Option[String] = None,
25+
errorLine: Option[String] = None,
2526
businessProcess: Option[String] = None,
2627
noticeNumber: Option[String] = None,
2728
paymentToken: Option[String] = None

wispsoapconverter/src/main/scala/it/gov/pagopa/common/message/ReMessage.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package it.gov.pagopa.common.message
22

33
case class ReExtra(
44
uri: Option[String] = None,
5-
headers: Seq[(String, String)] = Nil,
5+
requestHeaders: Seq[(String, String)] = Nil,
6+
responseHeaders: Seq[(String, String)] = Nil,
67
httpMethod: Option[String] = None,
78
callRemoteAddress: Option[String] = None,
89
statusCode: Option[Int] = None,

wispsoapconverter/src/main/scala/it/gov/pagopa/common/util/Constant.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ object Constant {
3131

3232
object MDCKey {
3333
val SESSION_ID = "sessionId"
34+
val PROCESS_OUTCOME = "processOutcome"
35+
val ERROR_LINE = "errorLine"
3436
val ACTOR_CLASS_ID = "actorClassId"
3537
val ID_CARRELLO = "idCarrello"
3638
val IUV = "iuv"

0 commit comments

Comments
 (0)