MNP_RU_638 - Middleware Modernization 2024 (Lotto 5): implement ESITRICMVNO

This commit is contained in:
manuelstefanile
2024-06-10 14:52:38 +02:00
parent 3818aa2732
commit 3a11cbd3e8
17 changed files with 588 additions and 8 deletions

View File

@@ -44,9 +44,15 @@
</web>
</module>
<module>
<web>
<web-uri>esitoCessMnp.war</web-uri>
<context-root>/wsgispesito</context-root>
</web>
</module>
<web>
<web-uri>esitoCessMnp.war</web-uri>
<context-root>/wsgispesito</context-root>
</web>
</module>
<module>
<web>
<web-uri>esitoRicMvno.war</web-uri>
<context-root>/wso2cesitricmvno</context-root>
</web>
</module>
</application>

View File

@@ -0,0 +1,130 @@
package mnp.proxy.ws.o2c;
import javax.jws.WebService;
import javax.xml.namespace.QName;
import dbcmnp.soa.esitoricmvno.x20240605.EsitoRicMvnoRequest;
import dbcmnp.soa.esitoricmvno.x20240605.EsitoRicMvnoResponse;
import it.telecomitalia.soa.soap.soapheader.x20240605.holders.HeaderTypeHolder;
import mnp.database.UserTransactionUtility;
import mnp.log.Loggable;
import mnp.log.ProcessLogger;
import mnp.objects.LogInfo;
import mnp.objects.LogProcess;
import mnp.systemcontroller.gisp.handler.GispAttCessInEventHandler;
import mnp.utility.Resources;
import mnp.utility.XmlUtility;
import weblogic.jws.*;
import weblogic.transaction.UserTransaction;
/**
* EsitoRicMvnoPortTypeImpl class implements web service endpoint interface EsitoRicMvnoPortType */
@WebService(
serviceName="EsitoRicMvno",
targetNamespace="http://dbcmnp/SOA/EsitoRicMvno",
endpointInterface="mnp.proxy.ws.o2c.EsitoRicMvnoPortType")
@WLHttpTransport(contextPath="wso2cesitricmvno",serviceUri="EsitoRicMvno",portName="EsitoRicMvno")
public class EsitoRicMvnoPortTypeImpl implements EsitoRicMvnoPortType, Loggable {
/**Implemento anche loggable per poter implementare i metodi di loggable e tenere traccia
* dei log*/
private final String codiceLog = "ZF";
private String versione = "1.0";
private ProcessLogger log = null;
public EsitoRicMvnoPortTypeImpl() {
/** ProcessLogger utilizzato per stampare i log*/
try {
LogProcess logProcess = new LogProcess();
logProcess.setCodice(codiceLog);
logProcess.setProcess(this);
log = new ProcessLogger(logProcess);
} catch (Exception ex) {
System.out.println("Errore nella creazione del ProcessLogger per EsitoRicMvnoPortTypeImpl:" + ex.getMessage());
}
System.out.println("Created WS for EsitoRicMvnoPortTypeImpl");
}
public EsitoRicMvnoResponse esitoRicMvno(HeaderTypeHolder Header, EsitoRicMvnoRequest body)
{
EsitoRicMvnoResponse response = new EsitoRicMvnoResponse();
UserTransaction uTX = null;
try {
uTX = (UserTransaction) UserTransactionUtility.beginUserTransaction();
log.write("0001", "Start EsitoRicMvno");
logInput(Header, body);
String tracciato;
try{
/** converto l'oggetto request in stringa*/
tracciato = XmlUtility.getXmlStringFromCastorXmlObject(body,true);
}catch (Exception e){
/** rispondo con un ko e la descrizione è la descrizione dell'errore che manda in eccezione*/
if (uTX!=null)
UserTransactionUtility.endUserTransaction(uTX, false);
response.setCODICE_ACK("KO");
response.setDESCRIZIONE_ACK(e.getMessage());
log.write("0003", "richiesta in ingresso non valida per Nome_Richiesta: " + body.getNOME_RICHIESTA());
return response;
}
/** stesso Handler di esitoCessMnpPortType ossia di DBC_DISATMNPG in Ingresso, quindi IN
* per questo il Controller è IN ed anche l' Handler. Risali al percorso dalla classe
* GispMap*/
GispAttCessInEventHandler handler = new GispAttCessInEventHandler(log);
response = handler.processAcqSoapEvent(body, tracciato);
UserTransactionUtility.endUserTransaction(uTX, true);
} catch (Exception ex) {
if (uTX != null) {
try {
UserTransactionUtility.endUserTransaction(uTX, false);
} catch (Exception e) {
log.error("Exception generica " + e.getMessage());
}
}
log.error("Exception generica " + ex.getMessage());
//non viene usato. cosa faccio ??
//QName qname = new QName("http://dbcmnp/SOA/EsitoCessMnp/2023-03-30/", "Server");
//throw new SOAPFaultException(qname, "Exception generica:" + ex.getMessage(), "GISP", null);
}
return response;
}
private void logInput(HeaderTypeHolder header, EsitoRicMvnoRequest body) {
log.write("9999", "richiesta in ingresso header= " + header);
log.write("9999", "richiesta in ingresso body= " + body);
if (header != null && header.value != null) {
log.write("9999", "getBusinessID = " + header.value.getBusinessID());
log.write("9999", "getMessageID = " + header.value.getMessageID());
log.write("9999", "getSourceSystem = " + header.value.getSourceSystem());
log.write("9999", "getSourceSystem = " + header.value.getChannel());
log.write("9999", "getTransactionID = " + header.value.getTransactionID());
log.write("9999", "getInteractionDate = " + header.value.getInteractionDate());
log.write("9999", "getEventType = " + header.value.getEventType());
}
if (body != null) {
log.write("9999", "Nome_Richiesta = " + body.getNOME_RICHIESTA() + ", EsitoCas = " + body.getCAS() + ", DescrizioneEsito = " + body.getDESCRIZIONE_ESITO());
}
}
@Override
public LogInfo getLogInfo() throws Exception {
LogInfo logInfo = new LogInfo();
logInfo.setProcess(getClass().getName());
logInfo.setLogPath(Resources.getLogPath());
logInfo.setTypeInfo(Resources.getTypeInfo());
logInfo.setTypeDebug(Resources.getTypeDebug());
logInfo.setTypeError(Resources.getTypeError());
return logInfo;
}
}

View File

@@ -5,6 +5,7 @@ import java.util.List;
import java.util.Locale;
import dbcmnp.soa.esitocessmnp.x20230406.EsitoCessMnpRequest;
import dbcmnp.soa.esitoricmvno.x20240605.EsitoRicMvnoRequest;
import mnp.bo.BoFactory;
import mnp.bo.RequestIF;
import mnp.bo.donor.*;
@@ -219,6 +220,97 @@ public class GispAttCessInFormatController extends FormatController {
}
}
/** Creo un metodo per gli esiti delle richieste di ATTIVAZIONE MVNO **/
public int checkTracciatoSoapAtt(EsitoRicMvnoRequest esitoRicMvnoRequest, String tracciato, ProcessLogger log) {
try {
if(!checkMandatory(esitoRicMvnoRequest)) {
mnpGispScartoAttCessIn = new MnpGispScartoAttCessIn(truncString(tracciato, MAX_LENGTH_RECORD), GispMap.GISP_SCARTO_CAMPO_OBBLIGATORIO);
return ESITO_KO;
}
/** Creo un metodo che possa gestire anche le richieste di Attivazione **/
mnpGispAttCessIn = createMnpGispAttInFromSoapReq(esitoRicMvnoRequest);
//mnpGispAttCessIn = GispAttCessInXAO.getMnpGispAttCessInByXml(tracciato);
log.debug("estratta MnpGispAttCessIn con NOME_RICHIESTA: " + mnpGispAttCessIn.getNomeRichiesta());
/** QUESTI CONTROLLI VENGONO FATTI INDIPENDENTEMENTE DALL' ESITO DI attivazione o cessazione
* (creo un metodo generale? se si, modificare anche checkTracciatoSoap in modo che richiami il nuovo
* metodo di controlli generale) **/
if (mnpGispAttCessIn.getNomeRichiesta().equals(GispMap.GISP_ATT_TIPO_RICHIESTA)) {
try {
List processList = new ArrayList();
processList.add(ProcessMapper.proc_RECIPIENT);
processList.add(ProcessMapper.proc_RECIPIENT_VIRT);
RequestIF request_if = BoFactory.getBusinessRequest(mnpGispAttCessIn.getCodiceRiproposizione(),processList);
//se non ho eccezioni la richiesta esiste
request_if = null;
processList = null;
return ESITO_OK;
} catch (NonExistantRequestException e) {
//non esiste la richiesta, scarto
log.error(e.getMessage());
mnpGispScartoAttCessIn = new MnpGispScartoAttCessIn(truncString(tracciato, MAX_LENGTH_RECORD),
GispMap.GISP_SCARTO_RICHIESTA_INESISTENTE);
return ESITO_KO;
}
}
//se si tratta di una risposta di cessazione, verifico se esiste la richiesta donor o recipient virtuale
else if (mnpGispAttCessIn.getNomeRichiesta().equals(GispMap.GISP_CESS_TIPO_RICHIESTA)
||mnpGispAttCessIn.getNomeRichiesta().equals(GispMap.GISP_CESS_TIPO_RICHIESTA_PP)
||mnpGispAttCessIn.getNomeRichiesta().equals(GispMap.GISP_CESS_TIPO_RICHIESTA_COABB)
||mnpGispAttCessIn.getNomeRichiesta().equals(GispMap.GISP_CESS_TIPO_RICHIESTA_BUABB)) {
try {
List processList = new ArrayList();
processList.add(ProcessMapper.proc_DONOR);
processList.add(ProcessMapper.proc_RECIPIENT_VIRT);
RequestIF request_if = BoFactory.getBusinessRequest(mnpGispAttCessIn.getCodiceRiproposizione(),processList);
//se non ho eccezioni la richiesta esiste
request_if = null;
processList = null;
return ESITO_OK;
} catch (NonExistantRequestException e) {
//non esiste la richiesta, scarto
log.error(e.getMessage());
mnpGispScartoAttCessIn = new MnpGispScartoAttCessIn(truncString(tracciato, MAX_LENGTH_RECORD),
GispMap.GISP_SCARTO_RICHIESTA_INESISTENTE);
return ESITO_KO;
}
} else if (mnpGispAttCessIn.getNomeRichiesta().equals(GispMap.GISP_CESS_TIPO_RICHIESTA_RESTITUZIONE)||
mnpGispAttCessIn.getNomeRichiesta().equals(GispMap.GISP_CESS_TIPO_RICHIESTA_TP)){
try {
if (mnpGispAttCessIn.getNomeRichiesta().equals(GispMap.GISP_CESS_TIPO_RICHIESTA_RESTITUZIONE)){
RichiestaCessazioneDAO dao = new RichiestaCessazioneDAO();
RichiestaCessazione ric = dao.getRichiestaByID(mnpGispAttCessIn.getCodiceRiproposizione());
if(ric==null) throw new NonExistantRequestException();
} else if(mnpGispAttCessIn.getNomeRichiesta().equals(GispMap.GISP_CESS_TIPO_RICHIESTA_TP)){
RichiestaPortingDAO dao= new RichiestaPortingDAO();
RichiestaPorting ric = dao.getRichiestaByID(mnpGispAttCessIn.getCodiceRiproposizione());
if(ric==null) throw new NonExistantRequestException();
}
return ESITO_OK;
} catch (NonExistantRequestException e) {
log.error(e.getMessage());
//non esiste la richiesta, scarto
mnpGispScartoAttCessIn = new MnpGispScartoAttCessIn(truncString(tracciato, MAX_LENGTH_RECORD),
GispMap.GISP_SCARTO_RICHIESTA_INESISTENTE);
return ESITO_KO;
}
}
else {
//non dovrei mai raggiungere questo punto perchè se gli esiti sono errati ottengo un errore
//in fase di parsing
throw new Exception("Esito non previsto:" +mnpGispAttCessIn.getNomeRichiesta());
}
} catch (Exception ex) {
// Un'eccezione presa qui indicare un errore di parse della risposta
log.error(ex.getMessage());
mnpGispScartoAttCessIn = new MnpGispScartoAttCessIn(truncString(tracciato, MAX_LENGTH_RECORD), GispMap.GISP_SCARTO_RISP_PARSE);
return ESITO_KO;
}
}
private MnpGispAttCessIn createMnpGispAttCessInFromSoapReq(EsitoCessMnpRequest esitoCessMnpRequest) throws Exception {
MnpGispAttCessIn attCessIn = new MnpGispAttCessIn();
@@ -234,10 +326,33 @@ public class GispAttCessInFormatController extends FormatController {
return attCessIn;
}
/** metodo che crea un oggetto MnpGispAttCessIn da poter mappare in tabella.
* prendendo come parametro formale un esito di richiesta ATTIVAZIONE EsitoRicMvnoRequest **/
private MnpGispAttCessIn createMnpGispAttInFromSoapReq(EsitoRicMvnoRequest esitoRicMvnoMnpRequest) throws Exception {
MnpGispAttCessIn attCessIn = new MnpGispAttCessIn();
attCessIn.setNomeRichiesta(esitoRicMvnoMnpRequest.getNOME_RICHIESTA());
attCessIn.setCodiceRiproposizione(esitoRicMvnoMnpRequest.getCODICE_RIPROPOSIZIONE());
if(!Func.isNull(esitoRicMvnoMnpRequest.getDATA_ESPLETAMENTO()))
attCessIn.setDataEspletamento(DateUtils.toDateLocale(esitoRicMvnoMnpRequest.getDATA_ESPLETAMENTO(),GispMap.DATA_ESPL_FORMAT, Locale.ENGLISH));
attCessIn.setDaScodare(0L);
attCessIn.setEsitoCas(esitoRicMvnoMnpRequest.getCAS());
attCessIn.setDescrizioneEsito(esitoRicMvnoMnpRequest.getDESCRIZIONE_ESITO());
if(!Func.isNull(esitoRicMvnoMnpRequest.getDETTAGLIO_ESITO()))
attCessIn.setDettaglioEsito(esitoRicMvnoMnpRequest.getDETTAGLIO_ESITO());
return attCessIn;
}
private boolean checkMandatory(EsitoCessMnpRequest request) {
return !Func.isNull(request.getNOME_RICHIESTA()) && !Func.isNull(request.getESITO_CAS()) && !Func.isNull(request.getDESCRIZIONE_ESITO()) /*&& !Func.isNull(request.getSysdate())*/;
}
/** creo un CheckMandatory anche per gli esiti di ATTIVAZIONE MVNO**/
private boolean checkMandatory(EsitoRicMvnoRequest request) {
return !Func.isNull(request.getNOME_RICHIESTA()) && !Func.isNull(request.getCAS()) && !Func.isNull(request.getDESCRIZIONE_ESITO()) ;
}
/**
* Ritorna il dto che mappa la tabella di ingresso

View File

@@ -8,6 +8,8 @@ import java.util.Map;
import dbcmnp.soa.esitocessmnp.x20230406.EsitoCessMnpRequest;
import dbcmnp.soa.esitocessmnp.x20230406.EsitoCessMnpResponse;
import dbcmnp.soa.esitoricmvno.x20240605.EsitoRicMvnoRequest;
import dbcmnp.soa.esitoricmvno.x20240605.EsitoRicMvnoResponse;
import mnp.bo.BoFactory;
import mnp.bo.donor.RichiestaDonorBO;
import mnp.bo.recipient.RichiestaRecipientBO;
@@ -437,7 +439,6 @@ public class GispAttCessInEventHandler extends AbstractEventHandler {
}
}
}
public EsitoCessMnpResponse processAcqSoapEvent(EsitoCessMnpRequest body, String tracciato) throws Exception {
GispAttCessInFormatController formatter = new GispAttCessInFormatController();
EsitoCessMnpResponse response = new EsitoCessMnpResponse();
@@ -481,6 +482,62 @@ public class GispAttCessInEventHandler extends AbstractEventHandler {
return response;
}
/** utilizzato per le richieste di ATTIVAZIONE. Crea un controller per le richieste di att/cess.
* il checkTracciatoSoap va nella classe GispAttCessInFormatController per la gestione del processo di validazione
* del tracciatO di attivazione donor/attivazione recipient in ingresso.
* mi faccio tornare un tipo generico MnpGispAttCessIn, setto da scodare a 1
* e salvo in tabella Mnp_Gisp_Att_Cess_In.
* Creo una notifica che metto in coda
* **/
public EsitoRicMvnoResponse processAcqSoapEvent(EsitoRicMvnoRequest body, String tracciato) throws Exception {
GispAttCessInFormatController formatter = new GispAttCessInFormatController();
EsitoRicMvnoResponse response = new EsitoRicMvnoResponse();
// esegue i controlli di consistenza e formali sul tracciato
int esito = formatter.checkTracciatoSoapAtt(body, tracciato, log);
if (esito == GispAttCessInFormatController.ESITO_OK) {
MnpGispAttCessIn rispAttCess = formatter.getMnpGispAttCessIn();
// da scodare a 1
rispAttCess.setDaScodare(new Long(MSG_DA_SCODARE));
//rispAttCess.setDaScodare(new Long(MSG_SCODATO));
dao.save(rispAttCess);
// N - RICHIESTA INSERITA NELLA TABELLA
log.write("0095", "MNP_GISP_ATT_CESS_IN - UNIQUE_ID:" + rispAttCess.getUniqueId());
String processType = getProcessType(rispAttCess);
// creo il messaggio di notifica
NotificationMessage message = creaUniqueIdNotificationMessage(rispAttCess.getUniqueId(), NotificationMessageIF.NotificationType_Gisp_Att_Cess_In, NotificationMessageIF.SystemProvider_GISP, processType);
inserisciNotificaInCoda(message, getSelector(processType));
// N - INSERIMENTO MESSAGGIO NELLA CODA
log.write("0046", "MessageQueueGispIn - UNIQUE_ID:" + rispAttCess.getUniqueId());
response.setCODICE_ACK("OK");
response.setDESCRIZIONE_ACK("");
//logIBA// security logction(ibFlowInWrapper.getTid(), ibFlowInWrapper.getIdSystem(), rispAttCess.getCodiceRiproposizione(), ActionLogMapping.RicezioneNotificaInfobus, true);
} else if (esito == GispAttCessInFormatController.ESITO_KO) {
log.write("9999", "RISPOSTA DI ATTIVAZIONE/CESSAZIONE DA GISP SCARTATA PER CONTROLLI FORMALI, TRACCIATO :" + tracciato);
MnpGispScartoAttCessIn scartoAttCessIn = formatter.getMnpGispScartoAttCessIn();
scartoDao.save(scartoAttCessIn);
// N - RICHIESTA INSERITA NELLA TABELLA
log.write("0095", "MNP_GISP_SCARTO_ATT_CESS_IN - UNIQUE_ID:" + scartoAttCessIn.getUniqueId());
// security log
//logIBAction(ibFlowInWrapper.getTid(), ibFlowInWrapper.getIdSystem(), null, ActionLogMapping.RicezioneNotificaInfobus, false);
//todo codici ko
response.setCODICE_ACK("KO");
response.setDESCRIZIONE_ACK("");
} else {
throw new Exception("Errore durante il processamento del tracciato di risposta di attivazione, esito inconsistente : " + esito);
}
return response;
}
/*
public void testDonor() throws Exception {
MnpGispAttCessIn rispAttCess = new MnpGispAttCessIn();