Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PPANTT-107] feat: introduced management of new properties in station #59

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,163 changes: 1,969 additions & 2,194 deletions openapi/openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<properties>
<java.version>17</java.version>
<starter.version>1.20.1</starter.version>
<starter.version>1.22.3</starter.version>
<springdoc.version>1.6.14</springdoc.version>
<oracle.version>21.9.0.0</oracle.version>
<postgresql.version>42.5.5</postgresql.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
import it.gov.pagopa.apiconfig.selfcareintegration.model.creditorinstitution.CreditorInstitutionInfo;
import it.gov.pagopa.apiconfig.selfcareintegration.model.iban.IbanDetails;
import it.gov.pagopa.apiconfig.selfcareintegration.model.iban.IbanEnhanced;
import it.gov.pagopa.apiconfig.starter.entity.Canali;
import it.gov.pagopa.apiconfig.starter.entity.IbanMaster;
import it.gov.pagopa.apiconfig.starter.entity.Pa;
import it.gov.pagopa.apiconfig.starter.entity.PaStazionePa;
import it.gov.pagopa.apiconfig.selfcareintegration.model.station.StationDetails;
import it.gov.pagopa.apiconfig.starter.entity.*;
import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
import org.springframework.context.annotation.Bean;
Expand All @@ -34,6 +32,7 @@ ModelMapper modelMapper() {

mapper.createTypeMap(Pa.class, CreditorInstitutionInfo.class).setConverter(new ConvertPaToCreditorInstitutionInfo());
mapper.createTypeMap(IbanMaster.class, IbanEnhanced.class).setConverter(new ConvertIbanMasterToIbanDetailsTemp());
mapper.createTypeMap(Stazioni.class, StationDetails.class).setConverter(new ConvertStazioniToStationDetails());

return mapper;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package it.gov.pagopa.apiconfig.selfcareintegration.mapper;

import it.gov.pagopa.apiconfig.selfcareintegration.model.station.BrokerDetails;
import it.gov.pagopa.apiconfig.selfcareintegration.model.station.Protocol;
import it.gov.pagopa.apiconfig.selfcareintegration.model.station.StationDetails;
import it.gov.pagopa.apiconfig.starter.entity.Stazioni;
import org.modelmapper.Converter;
import org.modelmapper.spi.MappingContext;

import javax.validation.Valid;

import static it.gov.pagopa.apiconfig.selfcareintegration.util.Utility.*;

public class ConvertStazioniToStationDetails implements Converter<Stazioni, StationDetails> {

@Override
public StationDetails convert(MappingContext<Stazioni, StationDetails> context) {
@Valid Stazioni source = context.getSource();
return StationDetails.builder()
.idStazione(source.getIdStazione())
.enabled(source.getEnabled())
.versione(source.getVersione())
.password(source.getPassword())
.protocollo(Protocol.fromValue(source.getProtocollo()))
.ip(source.getIp())
.porta(source.getPorta())
.servizio(source.getServizio())
.servizioPof(source.getServizioPof())
.protocollo4Mod(
source.getProtocollo4Mod() != null
? Protocol.fromValue(source.getProtocollo4Mod())
: null)
.intermediarioPa(source.getIntermediarioPa() != null ?
BrokerDetails.builder()
.codiceIntermediario(source.getIntermediarioPa().getCodiceIntermediario())
.idIntermediarioPa(source.getIntermediarioPa().getIdIntermediarioPa())
.faultBeanEsteso(source.getIntermediarioPa().getFaultBeanEsteso())
.enabled(source.getIntermediarioPa().getEnabled())
.build()
: null)
.ip4Mod(source.getIp4Mod())
.porta4Mod(source.getPorta4Mod())
.servizio4Mod(source.getServizio4Mod())
.redirectProtocollo(
source.getRedirectProtocollo() != null
? Protocol.fromValue(source.getRedirectProtocollo())
: null)
.redirectIp(source.getRedirectIp())
.redirectPorta(source.getRedirectPorta())
.redirectPath(source.getRedirectPath())
.redirectQueryString(source.getRedirectQueryString())
.proxyEnabled(source.getProxyEnabled())
.proxyHost(source.getProxyHost())
.proxyPort(source.getProxyPort())
.proxyUsername(source.getProxyUsername())
.proxyPassword(source.getProxyPassword())
.targetHost(source.getTargetHost())
.targetPort(source.getTargetPort())
.targetPath(source.getTargetPath())
.targetHostPof(source.getTargetHostPof())
.targetPortPof(source.getTargetPortPof())
.targetPathPof(source.getTargetPathPof())
.flagOnline(source.getFlagOnline())
.numThread(source.getNumThread())
.timeoutA(source.getTimeoutA())
.timeoutB(source.getTimeoutB())
.timeoutC(source.getTimeoutC())
.invioRtIstantaneo(source.getInvioRtIstantaneo())
.versionePrimitive(source.getVersionePrimitive())
.isConnectionSync(isConnectionSync(source))
.createDate(toOffsetDateTime(source.getDataCreazione()))
.build();
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
package it.gov.pagopa.apiconfig.selfcareintegration.model.station;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.ser.OffsetDateTimeSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import it.gov.pagopa.apiconfig.selfcareintegration.util.Constants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.OffsetDateTime;

/** Station */
@Data
Expand Down Expand Up @@ -47,4 +55,16 @@ public class Station {
@Schema(description = "The version of the station")
@NotNull
private Long versione;

@Schema(description = "Describe the station connection's type, true synchronous, false asynchronous")
@JsonProperty("is_connection_sync")
private Boolean isConnectionSync;

@JsonProperty("create_date")
@Schema(description = "Station creation date")
@JsonFormat(pattern = Constants.DateTimeFormat.DATE_TIME_FORMAT)
@JsonSerialize(using = OffsetDateTimeSerializer.class)
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private OffsetDateTime createDate;

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
package it.gov.pagopa.apiconfig.selfcareintegration.model.station;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.ser.OffsetDateTimeSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import it.gov.pagopa.apiconfig.selfcareintegration.util.Constants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.OffsetDateTime;

/** StationDetails */
@EqualsAndHashCode(callSuper = true)
Expand Down Expand Up @@ -185,4 +193,5 @@ public class StationDetails extends Station {
allowableValues = {"1", "2"})
@JsonProperty("primitive_version")
private Integer versionePrimitive;

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package it.gov.pagopa.apiconfig.selfcareintegration.util;

import it.gov.pagopa.apiconfig.selfcareintegration.model.PageInfo;
import it.gov.pagopa.apiconfig.starter.entity.Stazioni;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Page;

import java.sql.Timestamp;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.Optional;

public class Utility {
Expand Down Expand Up @@ -31,4 +36,28 @@ public static String deNull(Object value) {
public static Boolean deNull(Boolean value) {
return Optional.ofNullable(value).orElse(false);
}

/**
* Compute the station's connection flag
*
* @param station station model
* @return true if the station is configured to be synchronous, false otherwise
*/
public static boolean isConnectionSync(Stazioni station) {
return (StringUtils.isNotBlank(station.getTargetPath()) && StringUtils.isNotBlank(station.getRedirectIp()))
|| StringUtils.isNotBlank(station.getTargetPathPof());
}

/**
* @param timestamp {@link Timestamp} to convert
* @return convert timestamp to {@link OffsetDateTime}
*/
public static OffsetDateTime toOffsetDateTime(Timestamp timestamp) {
return timestamp != null
? OffsetDateTime.of(timestamp.toLocalDateTime(), ZoneOffset.UTC)
: null;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"target_host_pof": "localhost",
"target_port_pof": 443,
"target_path_pof": "/",
"primitive_version": 1
"primitive_version": 1,
"is_connection_sync": true
}
],
"page_info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"target_host_pof": "localhost",
"target_port_pof": 443,
"target_path_pof": "/",
"primitive_version": 1
"primitive_version": 1,
"is_connection_sync": true
}
],
"page_info": {
Expand Down
Loading