diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/systemcontroller/formatcontroller/dbss/DBSSFormatController.java b/gnpdev/dbcfx/src/it/valueteam/gnp/systemcontroller/formatcontroller/dbss/DBSSFormatController.java index 0eca3211..1394a5da 100644 --- a/gnpdev/dbcfx/src/it/valueteam/gnp/systemcontroller/formatcontroller/dbss/DBSSFormatController.java +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/systemcontroller/formatcontroller/dbss/DBSSFormatController.java @@ -1072,12 +1072,11 @@ public class DBSSFormatController extends FormatController { dbssDonorOut.setSistComp(richiesta.getCrmCompetenza()); dbssDonorOut.setDataOrdine(richiesta.getDataRicezione()); dbssDonorOut.setCognomeCliente(richiesta.getCognomeCliente()); + dbssDonorOut.setIdOperatoreDonor("TLC"); + dbssDonorOut.setIdOperatoreDonating("TLC"); String aggiuntivi = ""; - if (!Func.isNull(richiesta.getDn())) { - aggiuntivi += richiesta.getDn() + ";"; - } if (!Func.isNull(richiesta.getDn2())) aggiuntivi += richiesta.getDn2() + ";"; if (!Func.isNull(richiesta.getDn3())) aggiuntivi += richiesta.getDn3() + ";"; if (!Func.isNull(richiesta.getDn4())) aggiuntivi += richiesta.getDn4() + ";"; @@ -1423,6 +1422,8 @@ public class DBSSFormatController extends FormatController { Calendar calendar = Calendar.getInstance(); calendar.setTime(dbssDonorOut.getDataOrdine()); + int charValueIndex = 0; //usato come indice per l'array CharacteristicValueType + if (operation.equals(DBSSMap.EVENTO_ESITO_VERIFICA_COD_SESSIONE)) { request.setOperationType(OP_TYPE_CHECKFASE3); } else { @@ -1430,9 +1431,20 @@ public class DBSSFormatController extends FormatController { } request.setInteractionDate(calendar); - CharacteristicValueType[] characteristics = new CharacteristicValueType[13]; + CharacteristicValueType[] characteristics = new CharacteristicValueType[11]; + + if (!Func.isNull(dbssDonorOut.getAggiuntivi())) { + characteristics = new CharacteristicValueType[12]; + } + if (operation.equals(DBSSMap.EVENTO_ESITO_VERIFICA_COD_SESSIONE)) { - characteristics = new CharacteristicValueType[15]; + + if (!Func.isNull(dbssDonorOut.getAggiuntivi())) { + characteristics = new CharacteristicValueType[14]; + } + else { + characteristics = new CharacteristicValueType[13]; + } } CharacteristicValueType reqType = new CharacteristicValueType(); @@ -1440,91 +1452,95 @@ public class DBSSFormatController extends FormatController { reqName.setName("RequestType"); reqType.setCharacteristicSpecification(reqName); reqType.setValue(dbssDonorOut.getAmbito()); - characteristics[0] = reqType; + characteristics[charValueIndex++] = reqType; CharacteristicValueType reqId = new CharacteristicValueType(); CharacteristicSpecificationType reqIdName = new CharacteristicSpecificationType(); reqIdName.setName("RequestId"); reqId.setCharacteristicSpecification(reqIdName); reqId.setValue(dbssDonorOut.getCodiceSessione()); - characteristics[1] = reqId; + characteristics[charValueIndex++] = reqId; CharacteristicValueType externalId = new CharacteristicValueType(); CharacteristicSpecificationType externalIdName = new CharacteristicSpecificationType(); externalIdName.setName("ExternalID"); externalId.setCharacteristicSpecification(externalIdName); externalId.setValue(dbssDonorOut.getCodiceOrdineOlo()); - characteristics[2] = externalId; + characteristics[charValueIndex++] = externalId; CharacteristicValueType dnType = new CharacteristicValueType(); CharacteristicSpecificationType dnName = new CharacteristicSpecificationType(); dnName.setName("ServiceNumber"); dnType.setCharacteristicSpecification(dnName); dnType.setValue(dbssDonorOut.getDirectoryNumber()); - characteristics[3] = dnType; + characteristics[charValueIndex++] = dnType; + /* CharacteristicValueType noteType = new CharacteristicValueType(); CharacteristicSpecificationType noteName = new CharacteristicSpecificationType(); noteName.setName("Comments"); noteType.setCharacteristicSpecification(noteName); noteType.setValue(dbssDonorOut.getNote()); - characteristics[4] = noteType; + characteristics[charValueIndex++] = noteType; + */ CharacteristicValueType donorType = new CharacteristicValueType(); CharacteristicSpecificationType donorName = new CharacteristicSpecificationType(); donorName.setName("DonorCode"); donorType.setCharacteristicSpecification(donorName); donorType.setValue(dbssDonorOut.getIdOperatoreDonor()); - characteristics[5] = donorType; + characteristics[charValueIndex++] = donorType; - CharacteristicValueType additionalType = new CharacteristicValueType(); - CharacteristicSpecificationType additionalName = new CharacteristicSpecificationType(); - additionalName.setName("AdditionalServiceNumber"); - additionalType.setCharacteristicSpecification(additionalName); - additionalType.setValue(dbssDonorOut.getAggiuntivi()); - characteristics[6] = additionalType; + if (!Func.isNull(dbssDonorOut.getAggiuntivi())) { + CharacteristicValueType additionalType = new CharacteristicValueType(); + CharacteristicSpecificationType additionalName = new CharacteristicSpecificationType(); + additionalName.setName("AdditionalServiceNumber"); + additionalType.setCharacteristicSpecification(additionalName); + additionalType.setValue(dbssDonorOut.getAggiuntivi()); + characteristics[charValueIndex++] = additionalType; + } CharacteristicValueType isnpType = new CharacteristicValueType(); CharacteristicSpecificationType isnpName = new CharacteristicSpecificationType(); isnpName.setName("isNP"); isnpType.setCharacteristicSpecification(isnpName); isnpType.setValue(dbssDonorOut.getFlagNp()); - characteristics[7] = isnpType; + characteristics[charValueIndex++] = isnpType; CharacteristicValueType oloCodeType = new CharacteristicValueType(); CharacteristicSpecificationType oloCodeName = new CharacteristicSpecificationType(); oloCodeName.setName("OLOCode"); oloCodeType.setCharacteristicSpecification(oloCodeName); - oloCodeType.setValue(dbssDonorOut.getCow()); - characteristics[8] = oloCodeType; + oloCodeType.setValue(dbssDonorOut.getIdOperatoreDonating()); + characteristics[charValueIndex++] = oloCodeType; CharacteristicValueType cosCodeType = new CharacteristicValueType(); CharacteristicSpecificationType cosCodeName = new CharacteristicSpecificationType(); cosCodeName.setName("COSCode"); cosCodeType.setCharacteristicSpecification(cosCodeName); cosCodeType.setValue(dbssDonorOut.getCodiceSegreto()); - characteristics[9] = cosCodeType; + characteristics[charValueIndex++] = cosCodeType; CharacteristicValueType corCodeType = new CharacteristicValueType(); CharacteristicSpecificationType corCodeName = new CharacteristicSpecificationType(); corCodeName.setName("CORCode"); corCodeType.setCharacteristicSpecification(corCodeName); corCodeType.setValue(dbssDonorOut.getCor()); - characteristics[10] = corCodeType; + characteristics[charValueIndex++] = corCodeType; CharacteristicValueType oloRecType = new CharacteristicValueType(); CharacteristicSpecificationType oloRecName = new CharacteristicSpecificationType(); oloRecName.setName("RepientOLOCode"); oloRecType.setCharacteristicSpecification(oloRecName); oloRecType.setValue(dbssDonorOut.getCodiceOloRecipient()); - characteristics[11] = oloRecType; + characteristics[charValueIndex++] = oloRecType; CharacteristicValueType cognomeClienteType = new CharacteristicValueType(); CharacteristicSpecificationType cognomeClienteName = new CharacteristicSpecificationType(); - cognomeClienteName.setName("FamilyName"); + cognomeClienteName.setName("COWCode"); cognomeClienteType.setCharacteristicSpecification(cognomeClienteName); - cognomeClienteType.setValue(dbssDonorOut.getCognomeCliente()); - characteristics[12] = cognomeClienteType; + cognomeClienteType.setValue(dbssDonorOut.getCow()); + characteristics[charValueIndex++] = cognomeClienteType; if (operation.equals(DBSSMap.EVENTO_ESITO_VERIFICA_COD_SESSIONE)) { GnpNowD82RichiesteOutDAO nowDonorOutDAO = new GnpNowD82RichiesteOutDAO(); @@ -1536,14 +1552,14 @@ public class DBSSFormatController extends FormatController { phase3ResultName.setName("Phase3Result"); phase3Result.setCharacteristicSpecification(phase3ResultName); phase3Result.setValue(nowDonorOut.getEsito()); - characteristics[13] = phase3Result; + characteristics[charValueIndex++] = phase3Result; CharacteristicValueType phase3ResultD = new CharacteristicValueType(); CharacteristicSpecificationType phase3ResultDName = new CharacteristicSpecificationType(); phase3ResultDName.setName("Phase3ResultDescription"); phase3ResultD.setCharacteristicSpecification(phase3ResultDName); phase3ResultD.setValue(nowDonorOut.getMotivazione()); - characteristics[14] = phase3ResultD; + characteristics[charValueIndex++] = phase3ResultD; } } diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/systemcontroller/formatcontroller/sms/SmsFormatController.java b/gnpdev/dbcfx/src/it/valueteam/gnp/systemcontroller/formatcontroller/sms/SmsFormatController.java index bb2a373e..3957938e 100644 --- a/gnpdev/dbcfx/src/it/valueteam/gnp/systemcontroller/formatcontroller/sms/SmsFormatController.java +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/systemcontroller/formatcontroller/sms/SmsFormatController.java @@ -111,7 +111,10 @@ public class SmsFormatController return dao103.findById(idRichiesta).getPiattaformaProvenienza(); } else { GnpRichiesteNpg103DAO dao = new GnpRichiesteNpg103DAO(); - return dao.findById(idRichiesta).getPiattaformaProvenienza(); + if (dao.findById(idRichiesta) != null) { + return dao.findById(idRichiesta).getPiattaformaProvenienza(); + } + else return null; } } diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/DynamicField.java b/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/DynamicField.java new file mode 100644 index 00000000..c684a5be --- /dev/null +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/DynamicField.java @@ -0,0 +1,94 @@ +/* + * OpenAMDS REST API - OpenAPI 3.0 + * REST API per OpenAMDS + * + * OpenAPI spec version: 1.0.11 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package it.valueteam.gnp.ws.amds.model; + +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +/** + * DynamicField + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2024-05-10T08:42:45.887229576Z[GMT]") + +public class DynamicField { + @SerializedName("fieldName") + private String fieldName = null; + + @SerializedName("value") + private String value = null; + + public DynamicField fieldName(String fieldName) { + this.fieldName = fieldName; + return this; + } + + /** + * Get fieldName + * @return fieldName + **/ + public String getFieldName() { + return fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public DynamicField value(String value) { + this.value = value; + return this; + } + + /** + * Get value + * @return value + **/ + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DynamicField {\n"); + + sb.append(" fieldName: ").append(toIndentedString(fieldName)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/NotifyMessage.java b/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/NotifyMessage.java index d7c39c35..d1c5684f 100644 --- a/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/NotifyMessage.java +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/NotifyMessage.java @@ -12,6 +12,7 @@ package it.valueteam.gnp.ws.amds.model; +import java.util.ArrayList; import java.util.Arrays; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -40,15 +41,46 @@ public class NotifyMessage { @SerializedName("timestamp") private String timestamp = null; + @SerializedName("serviceNumber") + private String serviceNumber = null; + + @SerializedName("archive") + private String archive = null; + + @SerializedName("drNotify") + private String drNotify = null; + + @SerializedName("messageType") + private String messageType = null; + + @SerializedName("smsMessageList") + private SmsMessage[] smsMessageList; + + public String getServiceNumber() { + return serviceNumber; + } + + public void setServiceNumber(String serviceNumber) { + this.serviceNumber = serviceNumber; + } + + public SmsMessage[] getSmsMessageList() { + return smsMessageList; + } + + public void setSmsMessageList(SmsMessage[] smsMessageList) { + this.smsMessageList = smsMessageList; + } + public NotifyMessage sourceNumber(String sourceNumber) { this.sourceNumber = sourceNumber; return this; } - /** + /** * Get sourceNumber * @return sourceNumber - **/ + **/ public String getSourceNumber() { return sourceNumber; } @@ -62,10 +94,10 @@ public class NotifyMessage { return this; } - /** + /** * Get destinationNumber * @return destinationNumber - **/ + **/ public String getDestinationNumber() { return destinationNumber; } @@ -79,10 +111,10 @@ public class NotifyMessage { return this; } - /** + /** * Get content * @return content - **/ + **/ public String getContent() { return content; } @@ -96,10 +128,10 @@ public class NotifyMessage { return this; } - /** + /** * Get timestamp * @return timestamp - **/ + **/ public String getTimestamp() { return timestamp; } @@ -108,6 +140,29 @@ public class NotifyMessage { this.timestamp = timestamp; } + public String getArchive() { + return archive; + } + + public void setArchive(String archive) { + this.archive = archive; + } + + public String getDrNotify() { + return drNotify; + } + + public void setDrNotify(String drNotify) { + this.drNotify = drNotify; + } + + public String getMessageType() { + return messageType; + } + + public void setMessageType(String messageType) { + this.messageType = messageType; + } @Override public boolean equals(Object o) { @@ -124,7 +179,7 @@ public class NotifyMessage { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class NotifyMessage {\n"); - + sb.append(" sourceNumber: ").append(toIndentedString(sourceNumber)).append("\n"); sb.append(" destinationNumber: ").append(toIndentedString(destinationNumber)).append("\n"); sb.append(" content: ").append(toIndentedString(content)).append("\n"); diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/SmsMessage.java b/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/SmsMessage.java new file mode 100644 index 00000000..328cf656 --- /dev/null +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/SmsMessage.java @@ -0,0 +1,405 @@ +/* + * OpenAMDS REST API - OpenAPI 3.0 + * REST API per OpenAMDS + * + * OpenAPI spec version: 1.0.11 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package it.valueteam.gnp.ws.amds.model; + +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import it.valueteam.gnp.ws.amds.model.SmsTemplate; +import java.io.IOException; +/** + * SmsMessage + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2024-05-10T08:42:45.887229576Z[GMT]") + +public class SmsMessage { + @SerializedName("destinationNumber") + private String destinationNumber = null; + + @SerializedName("sender") + private String sender = null; + + @SerializedName("content") + private String content = null; + + @SerializedName("validity") + private String validity = null; + + public SmsMessage(String destinationNumber, String content) { + this.destinationNumber = destinationNumber; + this.content = content; + } + + /** + * Gets or Sets archive + */ + @JsonAdapter(ArchiveEnum.Adapter.class) + public enum ArchiveEnum { + @SerializedName("Y") + Y("Y"), + @SerializedName("N") + N("N"); + + private String value; + + ArchiveEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + public static ArchiveEnum fromValue(String input) { + for (ArchiveEnum b : ArchiveEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ArchiveEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public ArchiveEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return ArchiveEnum.fromValue((String)(value)); + } + } + } @SerializedName("archive") + private ArchiveEnum archive = ArchiveEnum.N; + + /** + * Gets or Sets drNotify + */ + @JsonAdapter(DrNotifyEnum.Adapter.class) + public enum DrNotifyEnum { + @SerializedName("Y") + Y("Y"), + @SerializedName("N") + N("N"); + + private String value; + + DrNotifyEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + public static DrNotifyEnum fromValue(String input) { + for (DrNotifyEnum b : DrNotifyEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final DrNotifyEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public DrNotifyEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return DrNotifyEnum.fromValue((String)(value)); + } + } + } @SerializedName("drNotify") + private DrNotifyEnum drNotify = DrNotifyEnum.N; + + @SerializedName("type") + private String type = null; + + /** + * Gets or Sets messageEncoding + */ + @JsonAdapter(MessageEncodingEnum.Adapter.class) + public enum MessageEncodingEnum { + @SerializedName("Text") + TEXT("Text"), + @SerializedName("Binary") + BINARY("Binary"); + + private String value; + + MessageEncodingEnum(String value) { + this.value = value; + } + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + public static MessageEncodingEnum fromValue(String input) { + for (MessageEncodingEnum b : MessageEncodingEnum.values()) { + if (b.value.equals(input)) { + return b; + } + } + return null; + } + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final MessageEncodingEnum enumeration) throws IOException { + jsonWriter.value(String.valueOf(enumeration.getValue())); + } + + @Override + public MessageEncodingEnum read(final JsonReader jsonReader) throws IOException { + Object value = jsonReader.nextString(); + return MessageEncodingEnum.fromValue((String)(value)); + } + } + } @SerializedName("messageEncoding") + private MessageEncodingEnum messageEncoding = null; + + @SerializedName("uid") + private String uid = null; + + @SerializedName("smsTemplate") + private SmsTemplate smsTemplate = null; + + public SmsMessage destinationNumber(String destinationNumber) { + this.destinationNumber = destinationNumber; + return this; + } + + /** + * Get destinationNumber + * @return destinationNumber + **/ + public String getDestinationNumber() { + return destinationNumber; + } + + public void setDestinationNumber(String destinationNumber) { + this.destinationNumber = destinationNumber; + } + + public SmsMessage sender(String sender) { + this.sender = sender; + return this; + } + + /** + * Get sender + * @return sender + **/ + public String getSender() { + return sender; + } + + public void setSender(String sender) { + this.sender = sender; + } + + public SmsMessage content(String content) { + this.content = content; + return this; + } + + /** + * Get content + * @return content + **/ + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public SmsMessage validity(String validity) { + this.validity = validity; + return this; + } + + /** + * Get validity + * @return validity + **/ + public String getValidity() { + return validity; + } + + public void setValidity(String validity) { + this.validity = validity; + } + + public SmsMessage archive(ArchiveEnum archive) { + this.archive = archive; + return this; + } + + /** + * Get archive + * @return archive + **/ + public ArchiveEnum getArchive() { + return archive; + } + + public void setArchive(ArchiveEnum archive) { + this.archive = archive; + } + + public SmsMessage drNotify(DrNotifyEnum drNotify) { + this.drNotify = drNotify; + return this; + } + + /** + * Get drNotify + * @return drNotify + **/ + public DrNotifyEnum getDrNotify() { + return drNotify; + } + + public void setDrNotify(DrNotifyEnum drNotify) { + this.drNotify = drNotify; + } + + public SmsMessage type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public SmsMessage messageEncoding(MessageEncodingEnum messageEncoding) { + this.messageEncoding = messageEncoding; + return this; + } + + /** + * Get messageEncoding + * @return messageEncoding + **/ + public MessageEncodingEnum getMessageEncoding() { + return messageEncoding; + } + + public void setMessageEncoding(MessageEncodingEnum messageEncoding) { + this.messageEncoding = messageEncoding; + } + + public SmsMessage uid(String uid) { + this.uid = uid; + return this; + } + + /** + * Get uid + * @return uid + **/ + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public SmsMessage smsTemplate(SmsTemplate smsTemplate) { + this.smsTemplate = smsTemplate; + return this; + } + + /** + * Get smsTemplate + * @return smsTemplate + **/ + public SmsTemplate getSmsTemplate() { + return smsTemplate; + } + + public void setSmsTemplate(SmsTemplate smsTemplate) { + this.smsTemplate = smsTemplate; + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SmsMessage {\n"); + + sb.append(" destinationNumber: ").append(toIndentedString(destinationNumber)).append("\n"); + sb.append(" sender: ").append(toIndentedString(sender)).append("\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" validity: ").append(toIndentedString(validity)).append("\n"); + sb.append(" archive: ").append(toIndentedString(archive)).append("\n"); + sb.append(" drNotify: ").append(toIndentedString(drNotify)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" messageEncoding: ").append(toIndentedString(messageEncoding)).append("\n"); + sb.append(" uid: ").append(toIndentedString(uid)).append("\n"); + sb.append(" smsTemplate: ").append(toIndentedString(smsTemplate)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toJsonString(String destinationNumber, String content) { + StringBuilder sb = new StringBuilder(); + sb.append("{\n"); + + sb.append(" destinationNumber: ").append(toIndentedString(destinationNumber)).append(",\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/SmsSendRequest.java b/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/SmsSendRequest.java new file mode 100644 index 00000000..c39ae8f6 --- /dev/null +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/SmsSendRequest.java @@ -0,0 +1,99 @@ +/* + * OpenAMDS REST API - OpenAPI 3.0 + * REST API per OpenAMDS + * + * OpenAPI spec version: 1.0.11 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package it.valueteam.gnp.ws.amds.model; + +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import it.valueteam.gnp.ws.amds.model.SmsMessage; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +/** + * SmsSendRequest + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2024-05-10T08:42:45.887229576Z[GMT]") + +public class SmsSendRequest { + @SerializedName("serviceNumber") + private String serviceNumber = null; + + @SerializedName("smsMessageList") + private SmsMessage[] smsMessageList = new SmsMessage[1]; + + public SmsSendRequest serviceNumber(String serviceNumber) { + this.serviceNumber = serviceNumber; + return this; + } + + /** + * Get serviceNumber + * @return serviceNumber + **/ + public String getServiceNumber() { + return serviceNumber; + } + + public void setServiceNumber(String serviceNumber) { + this.serviceNumber = serviceNumber; + } + + public SmsSendRequest smsMessageList(SmsMessage[] smsMessageList) { + this.smsMessageList = smsMessageList; + return this; + } + + public SmsSendRequest addSmsMessageListItem(SmsMessage smsMessageListItem) { + this.smsMessageList[0] = smsMessageListItem; + return this; + } + + /** + * Get smsMessageList + * @return smsMessageList + **/ + public SmsMessage[] getSmsMessageList() { + return smsMessageList; + } + + public void setSmsMessageList(SmsMessage[] smsMessageList) { + this.smsMessageList = smsMessageList; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SmsSendRequest {\n"); + + sb.append(" serviceNumber: ").append(toIndentedString(serviceNumber)).append("\n"); + sb.append(" smsMessageList: ").append(toIndentedString(smsMessageList)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/SmsTemplate.java b/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/SmsTemplate.java new file mode 100644 index 00000000..31a1d623 --- /dev/null +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/ws/amds/model/SmsTemplate.java @@ -0,0 +1,100 @@ +/* + * OpenAMDS REST API - OpenAPI 3.0 + * REST API per OpenAMDS + * + * OpenAPI spec version: 1.0.11 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +package it.valueteam.gnp.ws.amds.model; + +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import it.valueteam.gnp.ws.amds.model.DynamicField; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +/** + * SmsTemplate + */ + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2024-05-10T08:42:45.887229576Z[GMT]") + +public class SmsTemplate { + @SerializedName("id") + private String id = null; + + @SerializedName("dynamicFieldList") + private List dynamicFieldList = new ArrayList(); + + public SmsTemplate id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public SmsTemplate dynamicFieldList(List dynamicFieldList) { + this.dynamicFieldList = dynamicFieldList; + return this; + } + + public SmsTemplate addDynamicFieldListItem(DynamicField dynamicFieldListItem) { + this.dynamicFieldList.add(dynamicFieldListItem); + return this; + } + + /** + * Get dynamicFieldList + * @return dynamicFieldList + **/ + public List getDynamicFieldList() { + return dynamicFieldList; + } + + public void setDynamicFieldList(List dynamicFieldList) { + this.dynamicFieldList = dynamicFieldList; + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SmsTemplate {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" dynamicFieldList: ").append(toIndentedString(dynamicFieldList)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/ws/utlities/WSRestHandler.java b/gnpdev/dbcfx/src/it/valueteam/gnp/ws/utlities/WSRestHandler.java index ebbf3f09..417e4113 100644 --- a/gnpdev/dbcfx/src/it/valueteam/gnp/ws/utlities/WSRestHandler.java +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/ws/utlities/WSRestHandler.java @@ -12,11 +12,11 @@ import it.valueteam.gnp.utility.Func; import it.valueteam.gnp.utility.Resources; import it.valueteam.gnp.ws.amds.model.DeliveryReport; import it.valueteam.gnp.ws.amds.model.NotifyMessage; +import it.valueteam.gnp.ws.amds.model.SmsMessage; +import it.valueteam.gnp.ws.amds.model.SmsSendRequest; import it.valueteam.gnp.ws.sdp.ErrorDTO; import it.valueteam.gnp.ws.sdp.model.*; import org.apache.http.Header; -import org.apache.http.HttpHost; -import org.apache.http.HttpRequest; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; @@ -28,12 +28,12 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicHeader; import tim.infobus.data.TID; -import javax.annotation.Resource; import javax.net.ssl.SSLContext; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -194,11 +194,9 @@ public class WSRestHandler { public String createNotifyMessage(String sourceNumber, String destinationNumber, String content, Date timestamp) { NotifyMessage message = new NotifyMessage(); - message.setSourceNumber(sourceNumber); - message.setDestinationNumber(destinationNumber); - message.setContent(content); - message.setTimestamp(DateUtils.toString(timestamp,"yyyy-MM-dd HH:mm:ss.SSS")); - + message.setServiceNumber(sourceNumber); + SmsMessage[] smsMessageList = new SmsMessage[1]; + message.setSmsMessageList(smsMessageList); return createPostRequest(new Gson(), message); } @@ -211,16 +209,19 @@ public class WSRestHandler { CloseableHttpResponse response = null; StringBuilder jsonString = new StringBuilder(); try { + StringEntity postingString = new StringEntity(json); + SSLContext sslContext = WSUtils.createSSLContext("SSL"); //verificare WSUtils SSLConnectionSocketFactory scf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE); - //client = HttpClients.custom().useSystemProperties().build(); + //client = HttpClients.custom().useSystemProperties().build(); client = HttpClients.custom().useSystemProperties().setSSLSocketFactory(scf).build(); - StringEntity postingString = new StringEntity(json); + HttpPost post = new HttpPost(url); post.setEntity(postingString); post.setHeader("Content-type","application/json"); - post.setHeader("X-SourceSystem","DBCFX"); - post.setHeader("X-Business-ID", String.valueOf(new TID())); + post.setHeader("sourceSystem","DBCFX"); + post.setHeader("businessId", String.valueOf(new TID())); + post.setHeader("transactionId", String.valueOf(new TID())); response = client.execute(post); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); @@ -276,7 +277,8 @@ public class WSRestHandler { //Header[] headers = setHeader("postSmsOut", log); - NotifyMessage sms = new NotifyMessage(); + SmsSendRequest request = new SmsSendRequest(); + SmsMessage sms = new SmsMessage("",""); if (smsOut.getDn() == null) { //Recipient standard sms.setContent(Resources.getSMS_MESSAGE()); @@ -316,15 +318,36 @@ public class WSRestHandler { sms.setContent(MessageFormat.format(messageSMS, parametri)); } sms.setDestinationNumber(smsOut.getRecapitoAlternativo()); - sms.setSourceNumber(Resources.getSMS_SOURCE()); + request.setServiceNumber(Resources.getSMS_SOURCE()); - String notifyMessageString = createNotifyMessage(sms.getSourceNumber(), sms.getDestinationNumber(), sms.getContent(), new Date()); + log.write("9999", "request.getServiceNumber() = " + request.getServiceNumber()); + log.write("9999", "sms.getDestinationNumber() = " + sms.getDestinationNumber()); + log.write("9999", "sms.getServiceNumber() = " + sms.getContent()); + + String smsString = createSmsMessageStr(sms.getDestinationNumber(), sms.getContent()); + log.write("9999", "log smsString :" + smsString); + + String smsMessageString = createNotifyMessage(request.getServiceNumber(), sms.getDestinationNumber(), sms.getContent(), smsOut.getDataInvio()); + String newString = smsMessageString.replace("[null]", "[" + smsString + "]"); try { - String restPost = restPost(Resources.getAMDS_REST_URL(), null, notifyMessageString, log); + log.write("9999", "invio JSON verso SDP/AMDS :" + newString); + String restPost = restPost(Resources.getAMDS_REST_URL(), null, newString, log); //logga la response - log.debug(restPost); + log.write("9999", "postSmsOut [AMDS]: CHIAMATA SERVIZIO REST inviata, response: " + restPost); }catch (Exception e) { - log.error(e.getMessage()); + log.write("9999", "postSmsOut [AMDS]: CHIAMATA SERVIZIO REST in ERRORE: " + e.getMessage()); + e.printStackTrace(); } } + + private String createSmsMessageStr(String destinationNumber, String content) { + NotifyMessage message = new NotifyMessage(); + message.setDestinationNumber("+39" + destinationNumber); + message.setContent(content); + message.setArchive("N"); + message.setDrNotify("N"); + message.setMessageType("Text"); + Gson gson = new Gson(); + return createPostRequest(gson, message); + } }