From da25c3fb71fd413d6b0b253975575ce8dc970b6d Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Mon, 11 Nov 2024 14:43:28 +0100 Subject: [PATCH 01/15] P4ADEV-1346-create-activity-verify-authorization --- build.gradle.kts | 8 +++ .../activities/activity/PositionDebt.java | 5 -- .../VerifyAuthorizationInstallments.java | 24 +++++++ .../activities/constants/Constants.java | 8 +++ .../pagopa/payhub/activities/dto/CityDTO.java | 19 +++++ ...tallmentElaboratedPrimaryOrganization.java | 31 +++++++++ .../dto/InstallmentMultiBeneficiaryDTO.java | 32 +++++++++ ...InstallmentMultiBeneficiaryElaborated.java | 33 +++++++++ .../InstallmentPrimaryOrganizationDTO.java | 28 ++++++++ .../dto/InstallmentsOperatorDTO.java | 69 +++++++++++++++++++ .../payhub/activities/dto/NationDTO.java | 23 +++++++ .../activities/dto/OrganizationDTO.java | 60 ++++++++++++++++ .../dto/OrganizationInstallmentTypeDTO.java | 58 ++++++++++++++++ .../dto/OrganizationTypeInstallmentDTO.java | 32 +++++++++ .../payhub/activities/dto/ProvinceDTO.java | 19 +++++ .../activities/dto/RegistryStatusDTO.java | 43 ++++++++++++ .../exception/ActivitiesException.java | 20 ++++++ .../exception/ValidatorException.java | 8 +++ 18 files changed, 515 insertions(+), 5 deletions(-) delete mode 100644 src/main/java/it/gov/pagopa/payhub/activities/activity/PositionDebt.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/constants/Constants.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/CityDTO.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentElaboratedPrimaryOrganization.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryDTO.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryElaborated.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentPrimaryOrganizationDTO.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentsOperatorDTO.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/NationDTO.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationDTO.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationInstallmentTypeDTO.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationTypeInstallmentDTO.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/ProvinceDTO.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/RegistryStatusDTO.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/exception/ActivitiesException.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/exception/ValidatorException.java diff --git a/build.gradle.kts b/build.gradle.kts index 5396df55..239375b7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,6 +37,9 @@ val janinoVersion = "3.1.12" val wiremockVersion = "3.5.4" val snakeYamlVersion = "2.0" val hibernateValidatorVersion = "8.0.1.Final" +val commonsCompressVersion = "1.27.1" +val commonsLang3Version = "3.17.0" +val commonsTextVersion = "1.12.0" dependencies { @@ -45,6 +48,11 @@ dependencies { implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310") implementation("org.hibernate.validator:hibernate-validator:$hibernateValidatorVersion") + //apache commons + implementation("org.apache.commons:commons-compress:$commonsCompressVersion") + implementation("org.apache.commons:commons-lang3:$commonsLang3Version") + implementation("org.apache.commons:commons-text:$commonsTextVersion") + // Security fixes implementation("org.yaml:snakeyaml:$snakeYamlVersion") diff --git a/src/main/java/it/gov/pagopa/payhub/activities/activity/PositionDebt.java b/src/main/java/it/gov/pagopa/payhub/activities/activity/PositionDebt.java deleted file mode 100644 index 71ad9b88..00000000 --- a/src/main/java/it/gov/pagopa/payhub/activities/activity/PositionDebt.java +++ /dev/null @@ -1,5 +0,0 @@ -package it.gov.pagopa.payhub.activities.activity; - -public class PositionDebt { - //TODO to be implemented with task https://pagopa.atlassian.net/browse/P4ADEV-1346 -} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java b/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java new file mode 100644 index 00000000..a26650eb --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java @@ -0,0 +1,24 @@ +package it.gov.pagopa.payhub.activities.activity; + +import it.gov.pagopa.payhub.activities.constants.Constants; +import it.gov.pagopa.payhub.activities.dto.InstallmentsOperatorDTO; +import it.gov.pagopa.payhub.activities.dto.OrganizationInstallmentTypeDTO; +import it.gov.pagopa.payhub.activities.exception.ValidatorException; + +import java.util.List; + +public class VerifyAuthorizationInstallments { + + public OrganizationInstallmentTypeDTO verifyAuth(InstallmentsOperatorDTO installmentsOperatorDTO, + List organizationInstallmentTypeList){ + + if (installmentsOperatorDTO.getTipoDovuto().getCodTipo().equals(Constants.TIPO_DOVUTO_MARCA_BOLLO_DIGITALE)){ + throw new ValidatorException("Operation not authorized for installment type MARCA_BOLLO_DIGITALE"); + } + + return organizationInstallmentTypeList.stream() + .filter(etd -> etd.getCodTipo().equals(installmentsOperatorDTO.getTipoDovuto().getCodTipo())) + .findFirst() + .orElseThrow(() -> new ValidatorException("OrganizationInstallmentType is not active for this operator")); + } +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/constants/Constants.java b/src/main/java/it/gov/pagopa/payhub/activities/constants/Constants.java new file mode 100644 index 00000000..23b1dcc0 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/constants/Constants.java @@ -0,0 +1,8 @@ +package it.gov.pagopa.payhub.activities.constants; + +public class Constants { + private Constants() { + } + + public static final String TIPO_DOVUTO_MARCA_BOLLO_DIGITALE = "MARCA_BOLLO_DIGITALE"; +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/CityDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/CityDTO.java new file mode 100644 index 00000000..f979dd1f --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/CityDTO.java @@ -0,0 +1,19 @@ +package it.gov.pagopa.payhub.activities.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CityDTO implements Serializable { + + private Long comuneId; + private String comune; + private Long provinciaId; +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentElaboratedPrimaryOrganization.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentElaboratedPrimaryOrganization.java new file mode 100644 index 00000000..e16856dd --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentElaboratedPrimaryOrganization.java @@ -0,0 +1,31 @@ +package it.gov.pagopa.payhub.activities.dto; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InstallmentElaboratedPrimaryOrganization implements Serializable { + + private String denominazioneBeneficiario; + private String codiceIdentificativoUnivoco; + private String ibanAddebito; + private String indirizzoBeneficiario; + private String civicoBeneficiario; + private String capBeneficiario; + private String nazioneBeneficiario; + private String provinciaBeneficiario; + private String localitaBeneficiario; + private String importo; + + @JsonIgnore + private Long idDovutoElaborato; + +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryDTO.java new file mode 100644 index 00000000..8b786bd3 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryDTO.java @@ -0,0 +1,32 @@ +package it.gov.pagopa.payhub.activities.dto; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InstallmentMultiBeneficiaryDTO implements Serializable { + + private String denominazioneBeneficiario; + private String codiceIdentificativoUnivoco; + private String ibanAddebito; + private String indirizzoBeneficiario; + private String civicoBeneficiario; + private String capBeneficiario; + private String nazioneBeneficiario; + private String provinciaBeneficiario; + private String localitaBeneficiario; + private String importoSecondario; + private String causaleMB; + private String datiSpecificiRiscossione; + + @JsonIgnore + private Long idDovuto; +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryElaborated.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryElaborated.java new file mode 100644 index 00000000..de4fcd46 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryElaborated.java @@ -0,0 +1,33 @@ +package it.gov.pagopa.payhub.activities.dto; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InstallmentMultiBeneficiaryElaborated implements Serializable { + + @JsonIgnore + private Long idDovutoMultibeneficiarioElaborato; + + private String denominazioneBeneficiario; + private String codiceIdentificativoUnivoco; + private String ibanAddebito; + private String indirizzoBeneficiario; + private String civicoBeneficiario; + private String capBeneficiario; + private String nazioneBeneficiario; + private String provinciaBeneficiario; + private String localitaBeneficiario; + private String importoSecondario; + + @JsonIgnore + private Long idDovutoElaborato; +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentPrimaryOrganizationDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentPrimaryOrganizationDTO.java new file mode 100644 index 00000000..fb8d7322 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentPrimaryOrganizationDTO.java @@ -0,0 +1,28 @@ +package it.gov.pagopa.payhub.activities.dto; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InstallmentPrimaryOrganizationDTO { + + private String denominazioneBeneficiario; + private String codiceIdentificativoUnivoco; + private String ibanAddebito; + private String indirizzoBeneficiario; + private String civicoBeneficiario; + private String capBeneficiario; + private String nazioneBeneficiario; + private String provinciaBeneficiario; + private String localitaBeneficiario; + private String importo; + + @JsonIgnore + private Long idDovuto; +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentsOperatorDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentsOperatorDTO.java new file mode 100644 index 00000000..e126df37 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentsOperatorDTO.java @@ -0,0 +1,69 @@ +package it.gov.pagopa.payhub.activities.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InstallmentsOperatorDTO implements Serializable { + private Long id; + private String codFiscale; + private String iud; + private String iuv; + private String causale; + private String causaleVisualizzata; + private String importo; + private LocalDate dataScadenza; + private String stato; + private String codStato; + private LocalDateTime dataStato; + private boolean hasAvviso; + private boolean hasRicevuta; + + + //details + private OrganizationTypeInstallmentDTO tipoDovuto; + private String anagrafica; + private String tipoSoggetto; + private boolean flgAnagraficaAnonima; + private boolean hasCodFiscale; + private String email; + private String indirizzo; + private String numCiv; + private String cap; + private NationDTO nazione; + private ProvinceDTO prov; + private CityDTO comune; + private boolean flgGenerateIuv; + private String iuf; + + //datails dovutoElaborato + private LocalDateTime dataInizioTransazione; + private String identificativoTransazione; + private String intestatario; + private String pspScelto; + + private String dovutoType; // "debito" or "pagato" + + private String invalidDesc; // Message thrown by ValidatorException when insertion, update. + + private boolean flgMultibeneficiario; + private boolean flgIuvVolatile; + + //Ente primario detail + private InstallmentPrimaryOrganizationDTO entePrimarioDetail; + private InstallmentElaboratedPrimaryOrganization entePrimarioElaboratoDetail; + + //dovuto multibeneficiario + private InstallmentMultiBeneficiaryDTO dovutoMultibeneficiario; + private InstallmentMultiBeneficiaryElaborated dovutoMultibeneficiarioElaborato; + +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/NationDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/NationDTO.java new file mode 100644 index 00000000..d5adda09 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/NationDTO.java @@ -0,0 +1,23 @@ +package it.gov.pagopa.payhub.activities.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class NationDTO implements Serializable { + private Long nazioneId; + private String nomeNazione; + private String codiceIsoAlpha2; + + public boolean hasProvince(){ + return StringUtils.equalsIgnoreCase(codiceIsoAlpha2, "it"); + } +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationDTO.java new file mode 100644 index 00000000..50d28568 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationDTO.java @@ -0,0 +1,60 @@ +package it.gov.pagopa.payhub.activities.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.time.LocalDate; + +@Data +@Builder(toBuilder=true) +@NoArgsConstructor +@AllArgsConstructor +public class OrganizationDTO implements Serializable { + + + private Long mygovEnteId; + private String codIpaEnte; + private String codiceFiscaleEnte; + private String deNomeEnte; + private String emailAmministratore; + private Timestamp dtCreazione; + private Timestamp dtUltimaModifica; + private String codRpDatiVersTipoVersamento; + private BigDecimal numRpDatiVersDatiSingVersCommissioneCaricoPa; + private String codRpDatiVersDatiSingVersIbanAccredito; + private String codRpDatiVersDatiSingVersBicAccredito; + private String codRpDatiVersDatiSingVersIbanAppoggio; + private String codRpDatiVersDatiSingVersBicAppoggio; + private String myboxClientKey; + private String myboxClientSecret; + private String enteSilInviaRispostaPagamentoUrl; + private String codGlobalLocationNumber; + private String dePassword; + private Boolean codRpDatiVersDatiSingVersBicAccreditoSeller; + private String deRpEnteBenefDenominazioneBeneficiario; + private String deRpEnteBenefIndirizzoBeneficiario; + private String deRpEnteBenefCivicoBeneficiario; + private String codRpEnteBenefCapBeneficiario; + private String deRpEnteBenefLocalitaBeneficiario; + private String deRpEnteBenefProvinciaBeneficiario; + private String codRpEnteBenefNazioneBeneficiario; + private String deRpEnteBenefTelefonoBeneficiario; + private String deRpEnteBenefSitoWebBeneficiario; + private String deRpEnteBenefEmailBeneficiario; + private String applicationCode; + private String codCodiceInterbancarioCbill; + private String deInformazioniEnte; + private String deLogoEnte; + private String deAutorizzazione; + private RegistryStatusDTO cdStatoEnte; + private String deUrlEsterniAttiva; + private String linguaAggiuntiva; + private String codTipoEnte; + private LocalDate dtAvvio; + private Long mygovIntermediarioId; +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationInstallmentTypeDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationInstallmentTypeDTO.java new file mode 100644 index 00000000..399f7b9b --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationInstallmentTypeDTO.java @@ -0,0 +1,58 @@ +package it.gov.pagopa.payhub.activities.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor +public class OrganizationInstallmentTypeDTO implements Serializable { + + + private Long mygovEnteTipoDovutoId; + private OrganizationDTO mygovEnteId; + private String codTipo; + private String deTipo; + private String ibanAccreditoPi; + private String bicAccreditoPi; + private String ibanAppoggioPi; + private String bicAppoggioPi; + private String ibanAccreditoPsp; + private String bicAccreditoPsp; + private String ibanAppoggioPsp; + private String bicAppoggioPsp; + private String codContoCorrentePostale; + private String codXsdCausale; + private boolean bicAccreditoPiSeller; + private boolean bicAccreditoPspSeller; + private boolean spontaneo; + private BigDecimal importo; + private String deUrlPagamentoDovuto; + private String deBilancioDefault; + private boolean flgCfAnonimo; + private boolean flgScadenzaObbligatoria; + private boolean flgStampaDataScadenza; + private String deIntestatarioCcPostale; + private String deSettoreEnte; + private boolean flgNotificaIo; + private boolean flgNotificaEsitoPush; + private Integer maxTentativiInoltroEsito; + private Long mygovEnteSilId; + private boolean flgAttivo; + private String codiceContestoPagamento; + private boolean flgDisabilitaStampaAvviso; + private String macroArea; + private String tipoServizio; + private String motivoRiscossione; + private String codTassonomico; + private String urlNotificaPnd; + private String userPnd; + private String pswPnd; + private String urlNotificaAttualizzazionePnd; +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationTypeInstallmentDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationTypeInstallmentDTO.java new file mode 100644 index 00000000..4d91e4d4 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationTypeInstallmentDTO.java @@ -0,0 +1,32 @@ +package it.gov.pagopa.payhub.activities.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.time.LocalDateTime; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OrganizationTypeInstallmentDTO implements Serializable { + private Long mygovEnteTipoDovutoId; + private Long mygovEnteId; + private String codIpaEnte; + private String deNomeEnte; + private String thumbLogoEnte; + private String hashThumbLogoEnte; + private String codTipo; + private String deTipo; + private String deUrlPagamentoDovuto; + private boolean flgCfAnonimo; + private boolean flgScadenzaObbligatoria; + private boolean flgAttivo; + private String importo; + + private LocalDateTime dtUltimaAbilitazione; + private LocalDateTime dtUltimaDisabilitazione; +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/ProvinceDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/ProvinceDTO.java new file mode 100644 index 00000000..9b648365 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/ProvinceDTO.java @@ -0,0 +1,19 @@ +package it.gov.pagopa.payhub.activities.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ProvinceDTO implements Serializable { + + private Long provinciaId; + private String provincia; + private String sigla; +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/RegistryStatusDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/RegistryStatusDTO.java new file mode 100644 index 00000000..4446ce2f --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/RegistryStatusDTO.java @@ -0,0 +1,43 @@ +package it.gov.pagopa.payhub.activities.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.sql.Timestamp; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class RegistryStatusDTO implements Serializable { + + public static final String STATO_ENTE_ESERCIZIO = "ESERCIZIO"; + public static final String STATO_ENTE_PRE_ESERCIZIO = "PRE-ESERCIZIO"; + + public static final String STATO_TIPO_CARRELLO = "carrel"; + public static final String STATO_CARRELLO_PAGATO = "PAGATO"; + public static final String STATO_CARRELLO_NON_PAGATO = "NON_PAGATO"; + + public static final String STATO_TIPO_DOVUTO = "dovuto"; + public static final String STATO_DOVUTO_DA_PAGARE = "INSERIMENTO_DOVUTO"; + public static final String STATO_DOVUTO_PAGAMENTO_INIZIATO = "PAGAMENTO_INIZIATO"; + public static final String STATO_DOVUTO_PREDISPOSTO = "PREDISPOSTO"; + public static final String STATO_DOVUTO_COMPLETATO = "COMPLETATO"; + public static final String STATO_DOVUTO_ANNULLATO = "ANNULLATO"; + public static final String STATO_DOVUTO_ERRORE = "ERROR_DOVUTO"; + public static final String STATO_DOVUTO_ABORT = "ABORT"; + public static final String STATO_DOVUTO_SCADUTO = "SCADUTO"; + public static final String STATO_DOVUTO_SCADUTO_ELABORATO = "SCADUTO_ELABORATO"; + public static final String STATO_TIPO_FLUSSO = "flusso"; + public static final String STATO_ENTE = "ente"; + + private Long mygovAnagraficaStatoId; + private String codStato; + private String deStato; + private String deTipoStato; + private Timestamp dtCreazione; + private Timestamp dtUltimaModifica; +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/exception/ActivitiesException.java b/src/main/java/it/gov/pagopa/payhub/activities/exception/ActivitiesException.java new file mode 100644 index 00000000..69fa39e1 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/exception/ActivitiesException.java @@ -0,0 +1,20 @@ +package it.gov.pagopa.payhub.activities.exception; + +public class ActivitiesException extends RuntimeException { + + public ActivitiesException(String message) { + super(message); + } + + public ActivitiesException(String message, Throwable cause) { + super(message, cause); + } + + public ActivitiesException(Throwable cause) { + super(cause); + } + + public ActivitiesException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/exception/ValidatorException.java b/src/main/java/it/gov/pagopa/payhub/activities/exception/ValidatorException.java new file mode 100644 index 00000000..bf17318e --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/exception/ValidatorException.java @@ -0,0 +1,8 @@ +package it.gov.pagopa.payhub.activities.exception; + +public class ValidatorException extends ActivitiesException{ + + public ValidatorException(String message) { + super(message); + } +} From 37fe88e32c798ba2ba61d767b10ba328c78f92fb Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Mon, 11 Nov 2024 15:36:12 +0100 Subject: [PATCH 02/15] P4ADEV-1346-create-activity-verify-authorization --- force-release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/force-release b/force-release index 5325a8df..d7887218 100644 --- a/force-release +++ b/force-release @@ -1 +1 @@ -001 +003 From e38bf6f73e154f1bc8fbf3fe678a08af258c4fbe Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Tue, 12 Nov 2024 09:42:31 +0100 Subject: [PATCH 03/15] P4ADEV-1346-create-activity-verify-authorization --- build.gradle.kts | 22 ++++++++++++++++++- .../VerifyAuthorizationInstallments.java | 16 +++++++++----- .../dao/OrganizationInstallmentTypeDao.java | 10 +++++++++ 3 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dao/OrganizationInstallmentTypeDao.java diff --git a/build.gradle.kts b/build.gradle.kts index 239375b7..e1927b86 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -95,6 +95,26 @@ configure { } } +//publishing { +// publications { +// create("azureArtifacts") { +// from(components["java"]) +// groupId = project.group.toString() +// artifactId = project.name +// version = project.version.toString() +// } +// } +// repositories { +// maven { +// name = "AzureArtifacts" +// url = uri("https://pkgs.dev.azure.com/pagopaspa/_packaging/pagopaspa/maven/v1") +// credentials { +// username = "" +// password = "" +// } +// } +// } +//} publishing { publications { create("github") { @@ -115,4 +135,4 @@ publishing { } } } -} +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java b/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java index a26650eb..3ece42f8 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java @@ -1,6 +1,6 @@ package it.gov.pagopa.payhub.activities.activity; -import it.gov.pagopa.payhub.activities.constants.Constants; +import it.gov.pagopa.payhub.activities.dao.OrganizationInstallmentTypeDao; import it.gov.pagopa.payhub.activities.dto.InstallmentsOperatorDTO; import it.gov.pagopa.payhub.activities.dto.OrganizationInstallmentTypeDTO; import it.gov.pagopa.payhub.activities.exception.ValidatorException; @@ -9,12 +9,16 @@ public class VerifyAuthorizationInstallments { - public OrganizationInstallmentTypeDTO verifyAuth(InstallmentsOperatorDTO installmentsOperatorDTO, - List organizationInstallmentTypeList){ + private final OrganizationInstallmentTypeDao organizationInstallmentTypeDao; - if (installmentsOperatorDTO.getTipoDovuto().getCodTipo().equals(Constants.TIPO_DOVUTO_MARCA_BOLLO_DIGITALE)){ - throw new ValidatorException("Operation not authorized for installment type MARCA_BOLLO_DIGITALE"); - } + public VerifyAuthorizationInstallments(OrganizationInstallmentTypeDao organizationInstallmentTypeDao) { + this.organizationInstallmentTypeDao = organizationInstallmentTypeDao; + } + + public OrganizationInstallmentTypeDTO verifyAuth(InstallmentsOperatorDTO installmentsOperatorDTO, String username, Long mygovEnteId){ + + List organizationInstallmentTypeList = + organizationInstallmentTypeDao.getByMygovEnteIdAndOperatoreUsername(mygovEnteId, username); return organizationInstallmentTypeList.stream() .filter(etd -> etd.getCodTipo().equals(installmentsOperatorDTO.getTipoDovuto().getCodTipo())) diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dao/OrganizationInstallmentTypeDao.java b/src/main/java/it/gov/pagopa/payhub/activities/dao/OrganizationInstallmentTypeDao.java new file mode 100644 index 00000000..37021557 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/dao/OrganizationInstallmentTypeDao.java @@ -0,0 +1,10 @@ +package it.gov.pagopa.payhub.activities.dao; + +import it.gov.pagopa.payhub.activities.dto.OrganizationInstallmentTypeDTO; + +import java.util.List; + +public interface OrganizationInstallmentTypeDao { + + List getByMygovEnteIdAndOperatoreUsername(Long mygovEnteId, String operatoreUsername); +} From d98806ab884fb33b2d541c0556f109645623282d Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Tue, 12 Nov 2024 12:01:13 +0100 Subject: [PATCH 04/15] P4ADEV-1346-create-activity-verify-authorization --- build.gradle.kts | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e1927b86..a0ee9606 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -95,26 +95,6 @@ configure { } } -//publishing { -// publications { -// create("azureArtifacts") { -// from(components["java"]) -// groupId = project.group.toString() -// artifactId = project.name -// version = project.version.toString() -// } -// } -// repositories { -// maven { -// name = "AzureArtifacts" -// url = uri("https://pkgs.dev.azure.com/pagopaspa/_packaging/pagopaspa/maven/v1") -// credentials { -// username = "" -// password = "" -// } -// } -// } -//} publishing { publications { create("github") { From 6b0a08469986830b256c8e12c7bf1c1f16ce4208 Mon Sep 17 00:00:00 2001 From: Benedetta-fabbri Date: Tue, 12 Nov 2024 13:09:04 +0100 Subject: [PATCH 05/15] removed useless class post merge --- .../pagopa/payhub/activities/dto/CityDTO.java | 2 +- ...tallmentElaboratedPrimaryOrganization.java | 31 ----------------- .../dto/InstallmentMultiBeneficiaryDTO.java | 32 ------------------ ...InstallmentMultiBeneficiaryElaborated.java | 33 ------------------- .../InstallmentPrimaryOrganizationDTO.java | 2 +- .../dto/InstallmentsOperatorDTO.java | 2 +- .../payhub/activities/dto/NationDTO.java | 2 +- .../activities/dto/OrganizationDTO.java | 2 +- .../dto/OrganizationInstallmentTypeDTO.java | 2 +- .../dto/OrganizationTypeInstallmentDTO.java | 2 +- .../activities/dto/RegistryStatusDTO.java | 2 +- 11 files changed, 8 insertions(+), 104 deletions(-) delete mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentElaboratedPrimaryOrganization.java delete mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryDTO.java delete mode 100644 src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryElaborated.java diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/CityDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/CityDTO.java index a19ba5df..dc18ceba 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/CityDTO.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/CityDTO.java @@ -16,4 +16,4 @@ public class CityDTO implements Serializable { private Long municipalityId; private String municipality; private Long provinceId; -} +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentElaboratedPrimaryOrganization.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentElaboratedPrimaryOrganization.java deleted file mode 100644 index e16856dd..00000000 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentElaboratedPrimaryOrganization.java +++ /dev/null @@ -1,31 +0,0 @@ -package it.gov.pagopa.payhub.activities.dto; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InstallmentElaboratedPrimaryOrganization implements Serializable { - - private String denominazioneBeneficiario; - private String codiceIdentificativoUnivoco; - private String ibanAddebito; - private String indirizzoBeneficiario; - private String civicoBeneficiario; - private String capBeneficiario; - private String nazioneBeneficiario; - private String provinciaBeneficiario; - private String localitaBeneficiario; - private String importo; - - @JsonIgnore - private Long idDovutoElaborato; - -} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryDTO.java deleted file mode 100644 index 8b786bd3..00000000 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryDTO.java +++ /dev/null @@ -1,32 +0,0 @@ -package it.gov.pagopa.payhub.activities.dto; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InstallmentMultiBeneficiaryDTO implements Serializable { - - private String denominazioneBeneficiario; - private String codiceIdentificativoUnivoco; - private String ibanAddebito; - private String indirizzoBeneficiario; - private String civicoBeneficiario; - private String capBeneficiario; - private String nazioneBeneficiario; - private String provinciaBeneficiario; - private String localitaBeneficiario; - private String importoSecondario; - private String causaleMB; - private String datiSpecificiRiscossione; - - @JsonIgnore - private Long idDovuto; -} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryElaborated.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryElaborated.java deleted file mode 100644 index de4fcd46..00000000 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentMultiBeneficiaryElaborated.java +++ /dev/null @@ -1,33 +0,0 @@ -package it.gov.pagopa.payhub.activities.dto; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InstallmentMultiBeneficiaryElaborated implements Serializable { - - @JsonIgnore - private Long idDovutoMultibeneficiarioElaborato; - - private String denominazioneBeneficiario; - private String codiceIdentificativoUnivoco; - private String ibanAddebito; - private String indirizzoBeneficiario; - private String civicoBeneficiario; - private String capBeneficiario; - private String nazioneBeneficiario; - private String provinciaBeneficiario; - private String localitaBeneficiario; - private String importoSecondario; - - @JsonIgnore - private Long idDovutoElaborato; -} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentPrimaryOrganizationDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentPrimaryOrganizationDTO.java index 5f157fa4..c1d34712 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentPrimaryOrganizationDTO.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentPrimaryOrganizationDTO.java @@ -26,4 +26,4 @@ public class InstallmentPrimaryOrganizationDTO { @JsonIgnore private Long installmentId; -} +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentsOperatorDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentsOperatorDTO.java index 60f4e0fa..717c15a0 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentsOperatorDTO.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentsOperatorDTO.java @@ -65,4 +65,4 @@ public class InstallmentsOperatorDTO implements Serializable { private MultiBeneficiaryInstallmentDTO multiBeneficiaryInstallmentDetail; private ElaboratedMultiBeneficiaryInstallmentDTO elaboratedMultiBeneficiaryInstallmentDetail; -} +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/NationDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/NationDTO.java index 694575d6..196582b4 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/NationDTO.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/NationDTO.java @@ -21,4 +21,4 @@ public class NationDTO implements Serializable { // public boolean hasProvince(){ // return StringUtils.equalsIgnoreCase(codiceIsoAlpha2, "it"); // } -} +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationDTO.java index 90b7af66..97a3972f 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationDTO.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationDTO.java @@ -56,4 +56,4 @@ public class OrganizationDTO implements Serializable { private String orgTypeCode; private LocalDate startDate; private Long brokerId; -} +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationInstallmentTypeDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationInstallmentTypeDTO.java index f8b20ceb..1224f950 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationInstallmentTypeDTO.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationInstallmentTypeDTO.java @@ -54,4 +54,4 @@ public class OrganizationInstallmentTypeDTO implements Serializable { private String userPnd; private String pswPnd; private String urlNotifyActualizationPnd; -} +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationTypeInstallmentDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationTypeInstallmentDTO.java index cbedc1ac..bebb7d9b 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationTypeInstallmentDTO.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/OrganizationTypeInstallmentDTO.java @@ -29,4 +29,4 @@ public class OrganizationTypeInstallmentDTO implements Serializable { private String amount; private LocalDateTime lastEnablingDate; private LocalDateTime lastDisablingDate; -} +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/RegistryStatusDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/RegistryStatusDTO.java index f1d3a2ef..41d23aba 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/RegistryStatusDTO.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/RegistryStatusDTO.java @@ -40,4 +40,4 @@ public class RegistryStatusDTO implements Serializable { private String statusType; private Timestamp creationDate; private Timestamp lastChangeDate; -} +} \ No newline at end of file From 31ec66fe65a6aeed6d4e5b3c6316681bd4007aad Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Tue, 12 Nov 2024 14:55:24 +0100 Subject: [PATCH 06/15] P4ADEV-1346-create-activity-verify-authorization --- .../activity/VerifyAuthorizationInstallments.java | 2 +- .../activities/dto/InstallmentPrimaryOrganizationDTO.java | 6 ++++-- .../payhub/activities/dto/InstallmentsOperatorDTO.java | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java b/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java index 3ece42f8..e239240d 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java @@ -21,7 +21,7 @@ public OrganizationInstallmentTypeDTO verifyAuth(InstallmentsOperatorDTO install organizationInstallmentTypeDao.getByMygovEnteIdAndOperatoreUsername(mygovEnteId, username); return organizationInstallmentTypeList.stream() - .filter(etd -> etd.getCodTipo().equals(installmentsOperatorDTO.getTipoDovuto().getCodTipo())) + .filter(etd -> etd.getTypeCode().equals(installmentsOperatorDTO.getOrganizationTypeInstallment().getTypeCode())) .findFirst() .orElseThrow(() -> new ValidatorException("OrganizationInstallmentType is not active for this operator")); } diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentPrimaryOrganizationDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentPrimaryOrganizationDTO.java index c1d34712..1e9d1e28 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentPrimaryOrganizationDTO.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentPrimaryOrganizationDTO.java @@ -6,11 +6,13 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data -@Builder +@Builder(toBuilder = true) @NoArgsConstructor @AllArgsConstructor -public class InstallmentPrimaryOrganizationDTO { +public class InstallmentPrimaryOrganizationDTO implements Serializable { private String beneficiaryName; private String uniqueIdentificationCode; diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentsOperatorDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentsOperatorDTO.java index 717c15a0..1de0195a 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentsOperatorDTO.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/InstallmentsOperatorDTO.java @@ -10,7 +10,7 @@ import java.time.LocalDateTime; @Data -@Builder +@Builder(toBuilder = true) @NoArgsConstructor @AllArgsConstructor public class InstallmentsOperatorDTO implements Serializable { @@ -45,7 +45,7 @@ public class InstallmentsOperatorDTO implements Serializable { private boolean flagGenerateIuv; private String iuf; - //datails elaborated installment + //details elaborated installment private LocalDateTime transactionStartDate; private String transactionId; private String holder; @@ -61,7 +61,7 @@ public class InstallmentsOperatorDTO implements Serializable { private InstallmentPrimaryOrganizationDTO installmentPrimaryOrgDetail; private ElaboratedInstallmentPrimaryOrganizationDTO elaboratedInstallmentPrimaryOrgDetail; - //multibeneficiary detail + //multi beneficiary detail private MultiBeneficiaryInstallmentDTO multiBeneficiaryInstallmentDetail; private ElaboratedMultiBeneficiaryInstallmentDTO elaboratedMultiBeneficiaryInstallmentDetail; From 6a7e0f56919caa4787d168fd4b4b1f374cad5bd9 Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Wed, 13 Nov 2024 12:42:03 +0100 Subject: [PATCH 07/15] P4ADEV-1346-create-activity-verify-authorization --- .../activity/VerifyAuthorizationInstallments.java | 2 ++ .../java/it/gov/pagopa/payhub/activities/dto/NationDTO.java | 6 +++--- .../activity/VerifyAuthorizationInstallmentsTest.java | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/test/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallmentsTest.java diff --git a/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java b/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java index e239240d..84f64fb0 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java @@ -4,9 +4,11 @@ import it.gov.pagopa.payhub.activities.dto.InstallmentsOperatorDTO; import it.gov.pagopa.payhub.activities.dto.OrganizationInstallmentTypeDTO; import it.gov.pagopa.payhub.activities.exception.ValidatorException; +import org.springframework.stereotype.Service; import java.util.List; +@Service public class VerifyAuthorizationInstallments { private final OrganizationInstallmentTypeDao organizationInstallmentTypeDao; diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/NationDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/NationDTO.java index 196582b4..5ac1fae7 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/dto/NationDTO.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/NationDTO.java @@ -18,7 +18,7 @@ public class NationDTO implements Serializable { private String nationName; private String codeIsoAlpha2; - // public boolean hasProvince(){ - // return StringUtils.equalsIgnoreCase(codiceIsoAlpha2, "it"); - // } + public boolean hasProvince(){ + return StringUtils.equalsIgnoreCase(codeIsoAlpha2, "it"); + } } \ No newline at end of file diff --git a/src/test/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallmentsTest.java b/src/test/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallmentsTest.java new file mode 100644 index 00000000..25384d9e --- /dev/null +++ b/src/test/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallmentsTest.java @@ -0,0 +1,4 @@ +package it.gov.pagopa.payhub.activities.activity; + +public class VerifyAuthorizationInstallmentsTest { +} From c874c3d6f699f7e076a72b0da02390f8e272e309 Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Wed, 13 Nov 2024 14:27:53 +0100 Subject: [PATCH 08/15] P4ADEV-1346-create-activity-verify-authorization --- .../payhub/activities/ActivitiesApplication.java | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 src/main/java/it/gov/pagopa/payhub/activities/ActivitiesApplication.java diff --git a/src/main/java/it/gov/pagopa/payhub/activities/ActivitiesApplication.java b/src/main/java/it/gov/pagopa/payhub/activities/ActivitiesApplication.java deleted file mode 100644 index 0052d781..00000000 --- a/src/main/java/it/gov/pagopa/payhub/activities/ActivitiesApplication.java +++ /dev/null @@ -1,14 +0,0 @@ -package it.gov.pagopa.payhub.activities; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class ActivitiesApplication { - - - public static void main(String[] args) { - SpringApplication.run(ActivitiesApplication.class, args); - } - -} From a90d279089262a864f64aeab63a871e52695344a Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Wed, 13 Nov 2024 14:34:10 +0100 Subject: [PATCH 09/15] P4ADEV-1346-create-activity-verify-authorization --- build.gradle.kts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index a0ee9606..a395982a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,5 @@ +import org.springframework.boot.gradle.tasks.bundling.BootJar + plugins { java id("org.springframework.boot") version "3.3.5" @@ -115,4 +117,13 @@ publishing { } } } -} \ No newline at end of file +} + +tasks.withType { + enabled = false +} + +tasks.withType { + enabled = false +} + From 6e325d0ada77ca701dda4d3290ce9da16717b7ff Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Wed, 13 Nov 2024 15:21:15 +0100 Subject: [PATCH 10/15] P4ADEV-1346-create-activity-verify-authorization --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index a395982a..9157206e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -120,7 +120,7 @@ publishing { } tasks.withType { - enabled = false + enabled = true } tasks.withType { From 4f5abf8d96659ff3bad4ed085cbb64308093295c Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Wed, 13 Nov 2024 15:31:47 +0100 Subject: [PATCH 11/15] P4ADEV-1346-create-activity-verify-authorization --- build.gradle.kts | 2 +- .../payhub/activities/ActivitiesApplication.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/ActivitiesApplication.java diff --git a/build.gradle.kts b/build.gradle.kts index 9157206e..14a864f8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -124,6 +124,6 @@ tasks.withType { } tasks.withType { - enabled = false + enabled = true } diff --git a/src/main/java/it/gov/pagopa/payhub/activities/ActivitiesApplication.java b/src/main/java/it/gov/pagopa/payhub/activities/ActivitiesApplication.java new file mode 100644 index 00000000..0052d781 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/ActivitiesApplication.java @@ -0,0 +1,14 @@ +package it.gov.pagopa.payhub.activities; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ActivitiesApplication { + + + public static void main(String[] args) { + SpringApplication.run(ActivitiesApplication.class, args); + } + +} From 2f788c4609e1cbc66bd3f2006a543d32a7ce0039 Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Wed, 13 Nov 2024 17:13:27 +0100 Subject: [PATCH 12/15] P4ADEV-1346-create-activity-verify-authorization --- .../payhub/activities/config/JsonConfig.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/config/JsonConfig.java diff --git a/src/main/java/it/gov/pagopa/payhub/activities/config/JsonConfig.java b/src/main/java/it/gov/pagopa/payhub/activities/config/JsonConfig.java new file mode 100644 index 00000000..aea4c5a7 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/config/JsonConfig.java @@ -0,0 +1,35 @@ +package it.gov.pagopa.payhub.activities.config; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.TimeZone; + +@Configuration +public class JsonConfig { + + @Bean + public ObjectMapper objectMapper() { + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModule(new JavaTimeModule()); + mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); + mapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.PUBLIC_ONLY); + mapper.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.PUBLIC_ONLY); + mapper.setVisibility(PropertyAccessor.SETTER, JsonAutoDetect.Visibility.PUBLIC_ONLY); + mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); + mapper.setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.setTimeZone(TimeZone.getDefault()); + return mapper; + } +} \ No newline at end of file From 4a7a1065363b14883232247b43fb58d02fad75ca Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Wed, 13 Nov 2024 17:47:06 +0100 Subject: [PATCH 13/15] P4ADEV-1346-create-activity-verify-authorization --- .../payhub/activities/config/JsonConfig.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/it/gov/pagopa/payhub/activities/config/JsonConfig.java b/src/main/java/it/gov/pagopa/payhub/activities/config/JsonConfig.java index aea4c5a7..31f8f9b4 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/config/JsonConfig.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/config/JsonConfig.java @@ -6,14 +6,27 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.DateSerializer; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; import java.util.TimeZone; @Configuration public class JsonConfig { + public static final String DATE_FORMAT = "yyyy/MM/dd"; + public static final String DATE_TIME_FORMAT = "yyyy/MM/dd-HH:mm:ss"; @Bean public ObjectMapper objectMapper() { @@ -30,6 +43,16 @@ public ObjectMapper objectMapper() { mapper.setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setTimeZone(TimeZone.getDefault()); + + SimpleModule module = new SimpleModule(); + module.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DATE_FORMAT))); + module.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT))); + module.addSerializer(Date.class, new DateSerializer(null, new SimpleDateFormat(DATE_TIME_FORMAT))); + + module.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DATE_FORMAT))); + module.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT))); + + mapper.registerModule(module); return mapper; } } \ No newline at end of file From 83d24c4a1a1f21de1b019962c8162088602c9f97 Mon Sep 17 00:00:00 2001 From: Benedetta-fabbri Date: Wed, 13 Nov 2024 18:33:05 +0100 Subject: [PATCH 14/15] fix json config --- build.gradle.kts | 3 +++ .../it/gov/pagopa/payhub/activities/config/JsonConfig.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 14a864f8..255f3d7f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,6 +42,7 @@ val hibernateValidatorVersion = "8.0.1.Final" val commonsCompressVersion = "1.27.1" val commonsLang3Version = "3.17.0" val commonsTextVersion = "1.12.0" +val jacksonModuleVersion = "2.18.1" dependencies { @@ -58,6 +59,8 @@ dependencies { // Security fixes implementation("org.yaml:snakeyaml:$snakeYamlVersion") + implementation("com.fasterxml.jackson.module:jackson-module-parameter-names:$jacksonModuleVersion") + // Testing testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.junit.jupiter:junit-jupiter-api") diff --git a/src/main/java/it/gov/pagopa/payhub/activities/config/JsonConfig.java b/src/main/java/it/gov/pagopa/payhub/activities/config/JsonConfig.java index 31f8f9b4..68924ade 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/config/JsonConfig.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/config/JsonConfig.java @@ -1,6 +1,7 @@ package it.gov.pagopa.payhub.activities.config; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -13,6 +14,7 @@ import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -32,6 +34,7 @@ public class JsonConfig { public ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); + mapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.DEFAULT)); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); From ac76a0f2aef77163a19801c18a2367b692f8532c Mon Sep 17 00:00:00 2001 From: LarissaASLeite Date: Thu, 14 Nov 2024 09:42:33 +0100 Subject: [PATCH 15/15] P4ADEV-1346-create-activity-verify-authorization --- .../VerifyAuthorizationInstallments.java | 2 +- .../exception/ActivitiesException.java | 12 ---- .../exception/ValidatorException.java | 8 --- .../exception/custom/ValidatorException.java | 11 +++ .../VerifyAuthorizationInstallmentsTest.java | 68 ++++++++++++++++++- 5 files changed, 79 insertions(+), 22 deletions(-) delete mode 100644 src/main/java/it/gov/pagopa/payhub/activities/exception/ValidatorException.java create mode 100644 src/main/java/it/gov/pagopa/payhub/activities/exception/custom/ValidatorException.java diff --git a/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java b/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java index 84f64fb0..8dd23711 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallments.java @@ -3,7 +3,7 @@ import it.gov.pagopa.payhub.activities.dao.OrganizationInstallmentTypeDao; import it.gov.pagopa.payhub.activities.dto.InstallmentsOperatorDTO; import it.gov.pagopa.payhub.activities.dto.OrganizationInstallmentTypeDTO; -import it.gov.pagopa.payhub.activities.exception.ValidatorException; +import it.gov.pagopa.payhub.activities.exception.custom.ValidatorException; import org.springframework.stereotype.Service; import java.util.List; diff --git a/src/main/java/it/gov/pagopa/payhub/activities/exception/ActivitiesException.java b/src/main/java/it/gov/pagopa/payhub/activities/exception/ActivitiesException.java index 69fa39e1..da1da819 100644 --- a/src/main/java/it/gov/pagopa/payhub/activities/exception/ActivitiesException.java +++ b/src/main/java/it/gov/pagopa/payhub/activities/exception/ActivitiesException.java @@ -5,16 +5,4 @@ public class ActivitiesException extends RuntimeException { public ActivitiesException(String message) { super(message); } - - public ActivitiesException(String message, Throwable cause) { - super(message, cause); - } - - public ActivitiesException(Throwable cause) { - super(cause); - } - - public ActivitiesException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } } diff --git a/src/main/java/it/gov/pagopa/payhub/activities/exception/ValidatorException.java b/src/main/java/it/gov/pagopa/payhub/activities/exception/ValidatorException.java deleted file mode 100644 index bf17318e..00000000 --- a/src/main/java/it/gov/pagopa/payhub/activities/exception/ValidatorException.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.gov.pagopa.payhub.activities.exception; - -public class ValidatorException extends ActivitiesException{ - - public ValidatorException(String message) { - super(message); - } -} diff --git a/src/main/java/it/gov/pagopa/payhub/activities/exception/custom/ValidatorException.java b/src/main/java/it/gov/pagopa/payhub/activities/exception/custom/ValidatorException.java new file mode 100644 index 00000000..fe903920 --- /dev/null +++ b/src/main/java/it/gov/pagopa/payhub/activities/exception/custom/ValidatorException.java @@ -0,0 +1,11 @@ +package it.gov.pagopa.payhub.activities.exception.custom; + +import it.gov.pagopa.payhub.activities.exception.ActivitiesException; + + +public class ValidatorException extends ActivitiesException { + + public ValidatorException(String message) { + super(message); + } +} diff --git a/src/test/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallmentsTest.java b/src/test/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallmentsTest.java index 25384d9e..71e8f46e 100644 --- a/src/test/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallmentsTest.java +++ b/src/test/java/it/gov/pagopa/payhub/activities/activity/VerifyAuthorizationInstallmentsTest.java @@ -1,4 +1,70 @@ package it.gov.pagopa.payhub.activities.activity; -public class VerifyAuthorizationInstallmentsTest { +import it.gov.pagopa.payhub.activities.dao.OrganizationInstallmentTypeDao; +import it.gov.pagopa.payhub.activities.dto.InstallmentsOperatorDTO; +import it.gov.pagopa.payhub.activities.dto.OrganizationInstallmentTypeDTO; +import it.gov.pagopa.payhub.activities.dto.OrganizationTypeInstallmentDTO; +import it.gov.pagopa.payhub.activities.exception.custom.ValidatorException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class VerifyAuthorizationInstallmentsTest { + + @Mock + private OrganizationInstallmentTypeDao organizationInstallmentTypeDao; + + private VerifyAuthorizationInstallments verifyAuthorizationInstallments; + + @BeforeEach + void init() { + verifyAuthorizationInstallments = new VerifyAuthorizationInstallments(organizationInstallmentTypeDao); + } + + @Test + void givenVerifyAuthThenSuccess() { + String username = "username"; + Long mygovEnteId = 1L; + InstallmentsOperatorDTO installmentsOperatorDTO = new InstallmentsOperatorDTO(); + OrganizationTypeInstallmentDTO organizationTypeInstallmentDTO = new OrganizationTypeInstallmentDTO(); + + installmentsOperatorDTO.setOrganizationTypeInstallment(organizationTypeInstallmentDTO); + organizationTypeInstallmentDTO.setTypeCode("TYPE_CODE"); + + OrganizationInstallmentTypeDTO organizationInstallmentTypeDTO = new OrganizationInstallmentTypeDTO(); + organizationInstallmentTypeDTO.setTypeCode("TYPE_CODE"); + + when(organizationInstallmentTypeDao.getByMygovEnteIdAndOperatoreUsername(mygovEnteId, username)) + .thenReturn(List.of(organizationInstallmentTypeDTO)); + + OrganizationInstallmentTypeDTO result = verifyAuthorizationInstallments.verifyAuth(installmentsOperatorDTO, username, mygovEnteId); + + assertEquals(organizationInstallmentTypeDTO, result); + } + + @Test + void givenVerifyAuthWhenNotEqualTypeCodeThenThrowValidatorException() { + String username = "username"; + Long mygovEnteId = 1L; + InstallmentsOperatorDTO installmentsOperatorDTO = new InstallmentsOperatorDTO(); + + OrganizationInstallmentTypeDTO organizationInstallmentTypeDTO = new OrganizationInstallmentTypeDTO(); + organizationInstallmentTypeDTO.setTypeCode("TYPE_CODE"); + + when(organizationInstallmentTypeDao.getByMygovEnteIdAndOperatoreUsername(mygovEnteId, username)) + .thenReturn(List.of()); + + assertThrows(ValidatorException.class, () -> + verifyAuthorizationInstallments.verifyAuth(installmentsOperatorDTO, username, mygovEnteId)); + } } +