First Commit from Source Code Reply

This commit is contained in:
vincenzofariello
2024-05-09 17:40:24 +02:00
parent 11e3b57c5b
commit 107a016cb9
35225 changed files with 1111346 additions and 1 deletions

View File

@@ -0,0 +1,177 @@
package it.valueteam.gnp.ws.now;
import dbcfx.soa.checkretailplatform.x20160704.CheckRetailPlatformRequest;
import dbcfx.soa.checkretailplatform.x20160704.CheckRetailPlatformResponse;
import it.telecomitalia.soa.customerlocationquery.x20150511.Parameter;
import it.telecomitalia.soa.customerlocationquery.x20150511.RetrieveByLineNumberResponseMessage;
import it.telecomitalia.soa.soap.soapheader.holders.HeaderTypeHolder;
import it.valueteam.gnp.log.Loggable;
import it.valueteam.gnp.log.ProcessLogger;
import it.valueteam.gnp.obj.LogInfo;
import it.valueteam.gnp.obj.LogProcess;
import it.valueteam.gnp.systemcontroller.SystemControllerIF;
import it.valueteam.gnp.systemcontroller.crm.AbstractCRMController;
import it.valueteam.gnp.systemcontroller.formatcontroller.now.NowController;
import it.valueteam.gnp.utility.Resources;
import weblogic.jws.WLHttpTransport;
import javax.jws.HandlerChain;
import javax.jws.WebService;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* CheckRetailPlatformPortTypeImpl class implements web service endpoint interface CheckRetailPlatformPortType
* @version 3.1 20180417 migliorie ai log
*/
@WebService(
serviceName = "CheckRetailPlatform-1.0",
targetNamespace = "http://dbcfx/SOA/CheckRetailPlatform",
endpointInterface = "it.valueteam.gnp.ws.now.CheckRetailPlatformPortType")
@WLHttpTransport(contextPath = "wsnow", serviceUri = "CheckRetailPlatform", portName = "CheckRetailPlatform")
@HandlerChain(file = "handler.config.xml", name = "wsCheckRetailPlatformHandlerChain")
public class CheckRetailPlatformPortTypeImpl implements CheckRetailPlatformPortType, Loggable {
private static final String dateFormat = "yyyy-MM-dd hh:mm:ss";
private static final String RET_CODE_OK_TO_RET = "00";
private static final String RET_CODE_ERR_DB_O_NESS_RISP_TO_RET = "01";
private static final String RET_CODE_SIST_RETAIL_NON_TROV_TO_RET = "03";
private static final String ERR_MSG_ERR_DB_TO_RET = "ERRORE DB";
private static final String ERR_MSG_SIST_RETAIL_NON_TROV_TO_RET = "SISTEMA RETAIL NON TROVATO";
/*
private static final String RET_CODE_ERR_DB_TO_RET = "01";
//private static final String RET_CODE_CAMPO_OBB_MANC_TO_RET = "02";
private static final String RET_CODE_SIST_RETAIL_NON_TROV_TO_RET = "03";
private static final String ERR_MSG_ERR_DB_TO_RET = "ERRORE DB";
private static final String ERR_MSG_SIST_RETAIL_NON_TROV_TO_RET = "SISTEMA RETAIL NON TROVATO";
*/
protected static final String versione = "1.0.0";
protected static final String codiceProcesso = "CR";
protected ProcessLogger log;
public CheckRetailPlatformPortTypeImpl() {
System.out.println("Create Server WS [CheckRetailPlatform] Class [CheckRetailPlatformPortTypeImpl]");
try {
LogProcess logProcess = new LogProcess();
logProcess.setCodice(codiceProcesso);
logProcess.setProcess(this);
log = new ProcessLogger(logProcess);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Errore nella creazione del ProcessLogger, classe:" + CheckRetailPlatformPortTypeImpl.class + " - " + ex.toString());
}
}
/**
* @version 4.1 20180417 migliorie ai log
*/
public CheckRetailPlatformResponse checkDN(HeaderTypeHolder Header, CheckRetailPlatformRequest body) {
String methSig = " [checkDN] ";
log.write("0001", methSig + "versione " + versione);
String requestDn = null;
Date date = new Date();
String dateStr;
RetrieveByLineNumberResponseMessage respFromWs = null;
CheckRetailPlatformResponse respToRet = new CheckRetailPlatformResponse();
try {
requestDn = body.getDN();
methSig = " [checkDN] on DN ["+requestDn+"] ";
log.write("9999", methSig + "start");
dateStr = new SimpleDateFormat(dateFormat).format(date);
respToRet.setDATA_RISPOSTA(dateStr);
log.write("9999", methSig + "giro richiesta a DBSS sul ws [CustomerLocationQuery.retrieveByLineNumber]");
respFromWs = NowController.getInstance().checkDN(body);
if (respFromWs == null) {
log.write("9999", methSig + "- response from DBSS [CustomerLocationQuery.retrieveByLineNumber] is null");
respToRet.setRETURN_CODE(RET_CODE_ERR_DB_O_NESS_RISP_TO_RET);
respToRet.setERROR_MSG(ERR_MSG_ERR_DB_TO_RET);
log.write("0002", methSig + "FAIL, returning response ["+respToRet.getRETURN_CODE()+"]["+respToRet.getERROR_MSG()+"] system ["+respToRet.getSISTEMA_RETAIL()+"] fine");
return respToRet;
}
//return code puo' essere a una cifra o due (es. 01 o 1)
int retCodeFromWsInt = new Integer(respFromWs.getProcessData().getReturnCode());
log.write("9999", methSig + "- response from DBSS [CustomerLocationQuery.retrieveByLineNumber] is ["+retCodeFromWsInt+"]");
switch (retCodeFromWsInt) {
//0
case (NowController.RET_CODE_OK_FROM_WS):
//itera sui (tre) parameter, se ne trova uno con valore == 'Y' ne restituisce il name, altrimenti restituisce codice di errore
Parameter[] params = respFromWs.getProcessData().getParameters().getParameter();
for (Parameter p : params) {
log.write("9999", methSig + "- response from DBSS contains ["+p.getName()+"]=["+p.getValue()+"]");
if (!("Y").equalsIgnoreCase(p.getValue())) continue; //se diverso da Y passa al successivo
//se uguale a Y assegna name e codice di ritorno ed esce
respToRet.setRETURN_CODE(RET_CODE_OK_TO_RET);
//log.write("9999", "trovato elemento con valore = Y e name " + p.getName());
if (SystemControllerIF.SystemProvider_CRMB_DESC.equals(p.getName())) {
log.write("9999", methSig + "- Chiamata https verso CRMB");
String sistRetail = AbstractCRMController.callCRMBVerificheA428(requestDn, log);
log.write("9999", methSig + "- CRMB returns Sistema retail ["+sistRetail+"]");
respToRet.setSISTEMA_RETAIL(sistRetail);
// DISMISSIONE CRMR: nel caso la richiesta risulti proveniente da CRMR entra nell'else (caso DBSS)
// } else if (SystemControllerIF.SystemProvider_CRMR_DESC.equals(p.getName())) {
// log.write("9999", methSig + "- Chiamata https verso CRMR");
// String sistRetail = AbstractCRMController.callCRMRVerificheA428(requestDn, log);
// log.write("9999", methSig + "- CRMR returns Sistema retail ["+sistRetail+"]");
// respToRet.setSISTEMA_RETAIL(sistRetail);
} else {
log.write("9999", methSig + "- DBSS set Sistema retail ["+p.getName()+"]");
respToRet.setSISTEMA_RETAIL(p.getName());
}
log.write("0002", methSig + "returning response ["+respToRet.getRETURN_CODE()+"]["+respToRet.getERROR_MSG()+"] system ["+respToRet.getSISTEMA_RETAIL()+"] fine");
return respToRet;
}
//se non e' stato trovato un value = Y
log.write("9999", methSig + "- response from DBSS contains no affirmatives");
respToRet.setRETURN_CODE(RET_CODE_SIST_RETAIL_NON_TROV_TO_RET);
respToRet.setERROR_MSG(ERR_MSG_SIST_RETAIL_NON_TROV_TO_RET);
log.write("0002", methSig + "returning response ["+respToRet.getRETURN_CODE()+"]["+respToRet.getERROR_MSG()+"] system ["+respToRet.getSISTEMA_RETAIL()+"] fine");
return respToRet;
case (NowController.RET_CODE_UTENZA_NON_PRESENTE_FROM_WS):
case (NowController.RET_CODE_SERV_CRMB_NON_DISPONIBILE):
case (NowController.RET_CODE_SERV_CRMR_NON_DISPONIBILE):
respToRet.setRETURN_CODE(RET_CODE_SIST_RETAIL_NON_TROV_TO_RET);
respToRet.setERROR_MSG(ERR_MSG_SIST_RETAIL_NON_TROV_TO_RET);
log.write("0002", methSig + "returning response ["+respToRet.getRETURN_CODE()+"]["+respToRet.getERROR_MSG()+"] system ["+respToRet.getSISTEMA_RETAIL()+"] fine");
return respToRet;
case (NowController.RET_CODE_ERRORE_GENERICO_WS):
respToRet.setRETURN_CODE(RET_CODE_ERR_DB_O_NESS_RISP_TO_RET);
respToRet.setERROR_MSG(ERR_MSG_ERR_DB_TO_RET);
log.write("0002", methSig + "returning response ["+respToRet.getRETURN_CODE()+"]["+respToRet.getERROR_MSG()+"] system ["+respToRet.getSISTEMA_RETAIL()+"] fine");
return respToRet;
//se return code non e' tra quelli previsti viene restituito un errore db catchando l'eccezione
default:
//log.write("9999", " [checkDN] on DN ["+requestDn+"] lancio eccezione");
throw new Exception("return code ["+retCodeFromWsInt+"] non previsto");
}
} catch (Exception e) {
//e.printStackTrace();
log.write("9999", methSig + "FAIL ["+e.getClass().getName()+"] "+e.getMessage());
respToRet.setRETURN_CODE(RET_CODE_ERR_DB_O_NESS_RISP_TO_RET);
respToRet.setERROR_MSG(ERR_MSG_ERR_DB_TO_RET);
log.write("0003", methSig + "returning response ["+respToRet.getRETURN_CODE()+"]["+respToRet.getERROR_MSG()+"] system ["+respToRet.getSISTEMA_RETAIL()+"] on error");
return respToRet;
}
}
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

@@ -0,0 +1,161 @@
package it.valueteam.gnp.ws.now;
import javax.jws.WebService;
import javax.transaction.UserTransaction;
import dbcfx.soa.msgdonating.x20160915.MsgDonating;
import dbcfx.soa.msgdonating.x20160915.MsgDonatingAck;
import dbcfx.soa.richiestaverificacodicesessione.x20160915.Ack;
import it.valueteam.gnp.dao.db.hb.GnpNowD82RichiesteIn;
import it.valueteam.gnp.dao.db.hb.GnpNowD82RichiesteInDAO;
import it.valueteam.gnp.jms.MessageHandler;
import it.valueteam.gnp.log.Loggable;
import it.valueteam.gnp.log.ProcessLogger;
import it.valueteam.gnp.obj.LogInfo;
import it.valueteam.gnp.obj.LogProcess;
import it.valueteam.gnp.obj.jms.NotificationMessage;
import it.valueteam.gnp.obj.jms.NotificationMessageIF;
import it.valueteam.gnp.obj.jms.UniqueIdNotificationMessage;
import it.valueteam.gnp.utility.DateUtils;
import it.valueteam.gnp.utility.Resources;
import it.valueteam.gnp.utility.UserTransactionUtility;
import weblogic.jws.*;
import java.util.Date;
/**
* MsgDonatingPortTypeImpl class implements web service endpoint interface MsgDonatingPortType */
@WebService(
serviceName="MsgDonating-1.1",
targetNamespace="http://dbcfx/SOA/MsgDonating",
endpointInterface="it.valueteam.gnp.ws.now.MsgDonatingPortType")
@WLHttpTransport(contextPath="wsnowMsgDonating",serviceUri="MsgDonating",portName="MsgDonating")
public class MsgDonatingPortTypeImpl implements MsgDonatingPortType, Loggable {
protected static final String codiceProcesso = "RE";
protected ProcessLogger log;
public MsgDonatingPortTypeImpl() {
System.out.println("Create Server WS [MsgDonating] Class [MsgDonatingPortTypeImpl]");
try {
LogProcess logProcess = new LogProcess();
logProcess.setCodice(codiceProcesso);
logProcess.setProcess(this);
log = new ProcessLogger(logProcess);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Errore nella creazione del ProcessLogger, classe:" + MsgDonatingPortTypeImpl.class + " - " + ex.toString());
}
}
public dbcfx.soa.msgdonating.x20160915.MsgDonatingAck sendNotificaMsgDonating(it.telecomitalia.soa.soap.soapheader.holders.HeaderTypeHolder Header,dbcfx.soa.msgdonating.x20160915.MsgDonatingRequest body)
{
MsgDonatingAck myAck = new MsgDonatingAck();
if (body.getMsgDonating() != null) {
try {
log.write("9999", "Inizio Verifica Codice Sessione");
GnpNowD82RichiesteIn richiestaIn = createNowRichiesteIn(body.getMsgDonating());
// Crea il messaggio di notifica e inserisce in coda
NotificationMessage msg = creaNotificationMessageDonor(richiestaIn.getUniqueId(), NotificationMessageIF.NotificationType_WS_NOW_D82_MSGDON_IN);
inserisciNotificaInCoda(msg);
if (richiestaIn != null) {
myAck.setCodice("OK");
myAck.setDescrizione("Richiesta DEL82 acquisita correttamente");
return myAck;
}
} catch (Exception e) {
e.printStackTrace();
log.write("0003", e.getMessage());
myAck.setCodice("KO");
myAck.setDescrizione("Errore in acquisizione richiesta; " + e.getMessage());
return myAck;
}
}
myAck.setCodice("KO");
myAck.setDescrizione("Errore in acquisizione richiesta");
return myAck;
}
private GnpNowD82RichiesteIn createNowRichiesteIn(MsgDonating request) throws Exception {
UserTransaction utx;
GnpNowD82RichiesteInDAO richiesteInDAO = new GnpNowD82RichiesteInDAO();
GnpNowD82RichiesteIn richiesteIn = new GnpNowD82RichiesteIn();
GnpNowD82RichiesteIn richN8 = (GnpNowD82RichiesteIn) richiesteInDAO.findByProperty("codiceOrdineWhs", request.getCODICE_ORDINE_WHS()).get(0);
try {
utx = UserTransactionUtility.beginUserTransaction();
} catch (Exception e) {
log.error(e, "createNowRichiesteIn: beginUserTransaction");
throw e;
}
try {
richiesteIn.setDataRicezione(new Date());
richiesteIn.setCodiceOperatoreRecipient(request.getCODICE_OPERATORE_RECIPIENT());
richiesteIn.setCodiceOperatoreWhs(request.getCODICE_OPERATORE_WHS());
richiesteIn.setTipoNotifica("N10");
richiesteIn.setCodiceRisorsa(request.getCOR());
richiesteIn.setCodiceOrdineWhs(request.getCODICE_ORDINE_WHS());
richiesteIn.setDaScodare(1L);
richiesteIn.setDataNotifica(DateUtils.toDate(request.getDATA_NOTIFICA(), "yyyy-MM-dd HH:mm:ss"));
richiesteIn.setIdNotifica(request.getID_NOTIFICA());
richiesteIn.setTipoEvento(request.getEVENTO());
log.write("9999","Salvo richiesta con tipoEvento: " + request.getEVENTO());
if (request.getDATA() != null && request.getORA() != null) {
if (request.getEVENTO().equals("2")) {
richiesteIn.setDataDac(DateUtils.toDate(request.getDATA() + " " + request.getORA(), "yyyy-MM-dd HH:mm:ss"));
} else {
richiesteIn.setDataEspletamento(DateUtils.toDate(request.getDATA() + " " + request.getORA(), "yyyy-MM-dd HH:mm:ss"));
}
} else if (request.getDATA() != null) {
if (request.getEVENTO().equals("2")){
richiesteIn.setDataDac(DateUtils.toDate(request.getDATA(), "yyyy-MM-dd"));
} else {
richiesteIn.setDataEspletamento(DateUtils.toDate(request.getDATA(), "yyyy-MM-dd"));
}
}
richiesteIn.setIdRichiestaD82(richN8.getIdRichiestaD82());
richiesteInDAO.save(richiesteIn);
UserTransactionUtility.endUserTransaction(utx, true);
} catch (Exception ex) {
try {
// Rollback the transaction
UserTransactionUtility.endUserTransaction(utx, false);
log.error(ex, "createNowRichiesteIn: UserTransactionUtility");
ex.printStackTrace();
} catch (Exception e) {
log.error(e, "createNowRichiesteIn: UserTransactionUtility");
e.printStackTrace();
throw e;
}
throw ex;
}
return richiesteIn;
}
protected NotificationMessage creaNotificationMessageDonor(Long uniqueId, int notificationType) {
UniqueIdNotificationMessage messaggio = new UniqueIdNotificationMessage();
messaggio.setUnique_id(uniqueId);
messaggio.setNotificationType(notificationType);
messaggio.setSystemProvider(NotificationMessageIF.SystemProvider_NOW);
return messaggio;
}
protected void inserisciNotificaInCoda(NotificationMessage messaggio) throws Exception {
MessageHandler messageH = null;
messageH = MessageHandler.getInstance();
messageH.insertQueue(messaggio);
}
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

@@ -0,0 +1,158 @@
package it.valueteam.gnp.ws.now;
import javax.jws.WebService;
import javax.transaction.UserTransaction;
import dbcfx.soa.richiestaverificacodicesessione.x20160915.Ack;
import dbcfx.soa.richiestaverificacodicesessione.x20160915.VerificaCodiceSessione;
import it.valueteam.gnp.dao.db.hb.GnpNowD82RichiesteIn;
import it.valueteam.gnp.dao.db.hb.GnpNowD82RichiesteInDAO;
import it.valueteam.gnp.jms.MessageHandler;
import it.valueteam.gnp.log.Loggable;
import it.valueteam.gnp.log.ProcessLogger;
import it.valueteam.gnp.obj.LogInfo;
import it.valueteam.gnp.obj.LogProcess;
import it.valueteam.gnp.obj.jms.NotificationMessage;
import it.valueteam.gnp.obj.jms.NotificationMessageIF;
import it.valueteam.gnp.obj.jms.UniqueIdNotificationMessage;
import it.valueteam.gnp.systemcontroller.dbcfxgo.DbcfxgoController;
import it.valueteam.gnp.utility.DateUtils;
import it.valueteam.gnp.utility.Resources;
import it.valueteam.gnp.utility.UserTransactionUtility;
import weblogic.jws.*;
import java.util.Date;
/**
* RichiestaVerificaCodiceSessionePortTypeImpl class implements web service endpoint interface RichiestaVerificaCodiceSessionePortType */
@WebService(
serviceName="RichiestaVerificaCodiceSessione-1.1",
targetNamespace="http://dbcfx/SOA/RichiestaVerificaCodiceSessione",
endpointInterface="it.valueteam.gnp.ws.now.RichiestaVerificaCodiceSessionePortType")
@WLHttpTransport(contextPath="wsnowCodiceSessione",serviceUri="RichiestaVerificaCodiceSessione",portName="RichiestaVerificaCodiceSessione")
public class RichiestaVerificaCodiceSessionePortTypeImpl implements RichiestaVerificaCodiceSessionePortType, Loggable {
protected static final String codiceProcesso = "RE";
protected ProcessLogger log;
public RichiestaVerificaCodiceSessionePortTypeImpl() {
System.out.println("Create Server WS [RichiestaVerificaCodiceSessione] Class [RichiestaVerificaCodiceSessionePortTypeImpl]");
try {
LogProcess logProcess = new LogProcess();
logProcess.setCodice(codiceProcesso);
logProcess.setProcess(this);
log = new ProcessLogger(logProcess);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Errore nella creazione del ProcessLogger, classe:" + RichiestaVerificaCodiceSessionePortTypeImpl.class + " - " + ex.toString());
}
}
public dbcfx.soa.richiestaverificacodicesessione.x20160915.Ack checkSessionCode(it.telecomitalia.soa.soap.soapheader.holders.HeaderTypeHolder Header,dbcfx.soa.richiestaverificacodicesessione.x20160915.Request body)
{
Ack myAck = new Ack();
if (body.getVerificaCodiceSessione() != null) {
try {
log.write("9999", "Inizio Verifica Codice Sessione");
GnpNowD82RichiesteIn richiestaIn = createNowRichiesteIn(body.getVerificaCodiceSessione());
// Crea il messaggio di notifica e inserisce in coda
NotificationMessage msg = creaNotificationMessageDonor(richiestaIn.getUniqueId(), NotificationMessageIF.NotificationType_WS_NOW_D82_VERSES_IN);
inserisciNotificaInCoda(msg);
if (richiestaIn != null) {
myAck.setCodice("OK");
myAck.setDescrizione("Richiesta DEL82 acquisita correttamente");
return myAck;
}
} catch (Exception e) {
e.printStackTrace();
log.write("0003", e.getMessage());
myAck.setCodice("KO");
myAck.setDescrizione("Errore in acquisizione richiesta; " + e.getMessage());
return myAck;
}
}
myAck.setCodice("KO");
myAck.setDescrizione("Errore in acquisizione richiesta");
return myAck;
}
protected NotificationMessage creaNotificationMessageDonor(Long uniqueId, int notificationType) {
UniqueIdNotificationMessage messaggio = new UniqueIdNotificationMessage();
messaggio.setUnique_id(uniqueId);
messaggio.setNotificationType(notificationType);
messaggio.setSystemProvider(NotificationMessageIF.SystemProvider_NOW);
return messaggio;
}
protected void inserisciNotificaInCoda(NotificationMessage messaggio) throws Exception {
MessageHandler messageH = null;
messageH = MessageHandler.getInstance();
messageH.insertQueue(messaggio);
}
public GnpNowD82RichiesteIn createNowRichiesteIn(VerificaCodiceSessione request) throws Exception {
UserTransaction utx;
GnpNowD82RichiesteInDAO richiesteInDAO = new GnpNowD82RichiesteInDAO();
GnpNowD82RichiesteIn richiesteIn = new GnpNowD82RichiesteIn();
try {
utx = UserTransactionUtility.beginUserTransaction();
} catch (Exception e) {
log.error(e, "createNowRichiesteIn: beginUserTransaction");
throw e;
}
try {
richiesteIn.setDataRicezione(new Date());
richiesteIn.setCodiceOperatoreRecipient(request.getCODICE_OPERATORE_RECIPIENT());
richiesteIn.setCodiceOperatoreWhs(request.getCODICE_OPERATORE_WHS());
richiesteIn.setTipoNotifica("N8");
richiesteIn.setCodiceSessione(request.getCODICE_SESSIONE());
richiesteIn.setCodiceRisorsa(request.getCOR());
richiesteIn.setCodiceOrdineWhs(request.getCODICE_ORDINE_WHS());
richiesteIn.setDaScodare(1L);
richiesteIn.setDataNotifica(DateUtils.toDate(request.getDATA_NOTIFICA(),"yyyy-MM-dd HH:mm:ss"));
richiesteIn.setIdNotifica(request.getID_NOTIFICA());
richiesteIn.setNote(request.getNOTE());
richiesteIn.setNpDn1(request.getDN1());
richiesteIn.setNpDn2(request.getDN2());
richiesteIn.setNpDn3(request.getDN3());
richiesteIn.setNpDn4(request.getDN4());
richiesteIn.setNpDn5(request.getDN5());
richiesteIn.setNpDn6(request.getDN6());
richiesteIn.setNpDn7(request.getDN7());
richiesteIn.setNpDn8(request.getDN8());
richiesteIn.setNpDn9(request.getDN9());
richiesteIn.setNpDn10(request.getDN10());
richiesteInDAO.save(richiesteIn);
UserTransactionUtility.endUserTransaction(utx, true);
} catch (Exception ex) {
try {
// Rollback the transaction
UserTransactionUtility.endUserTransaction(utx, false);
log.error(ex, "createNowRichiesteIn: UserTransactionUtility");
ex.printStackTrace();
} catch (Exception e) {
log.error(e, "createNowRichiesteIn: UserTransactionUtility");
e.printStackTrace();
throw e;
}
throw ex;
}
return richiesteIn;
}
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

@@ -0,0 +1,71 @@
package it.valueteam.gnp.ws.now;
import javax.jws.HandlerChain;
import javax.jws.WebService;
import javax.xml.rpc.soap.SOAPFaultException;
import dbcfx.soa.richiestaverificaesitofase2.x20160915.Ack;
import dbcfx.soa.richiestaverificaesitofase2.x20160915.Request;
import it.telecomitalia.soa.soap.soapheader.holders.HeaderTypeHolder;
import it.valueteam.gnp.log.Loggable;
import it.valueteam.gnp.log.ProcessLogger;
import it.valueteam.gnp.obj.LogInfo;
import it.valueteam.gnp.obj.LogProcess;
import it.valueteam.gnp.systemcontroller.crmws.WSCrmwsController;
import it.valueteam.gnp.systemcontroller.formatcontroller.now.NowController;
import it.valueteam.gnp.systemcontroller.formatcontroller.now.WSNowRichiestaVerificaEsitoFase2SOAPHandler;
import it.valueteam.gnp.utility.Resources;
import weblogic.jws.*;
/**
* RichiestaVerificaEsitoFase2PortTypeImpl class implements web service endpoint interface RichiestaVerificaEsitoFase2PortType
*/
@WebService(
serviceName = "RichiestaVerificaEsitoFase2-1.1",
targetNamespace = "http://dbcfx/SOA/RichiestaVerificaEsitoFase2",
endpointInterface = "it.valueteam.gnp.ws.now.RichiestaVerificaEsitoFase2PortType")
@WLHttpTransport(contextPath = "wsnowesitofase2", serviceUri = "RichiestaVerificaEsitoFase2", portName = "RichiestaVerificaEsitoFase2")
@HandlerChain(file = "handler.esitofase2.config.xml", name = "wsRichiestaVerificaEsitoFase2HandlerChain")
public class RichiestaVerificaEsitoFase2PortTypeImpl implements RichiestaVerificaEsitoFase2PortType, Loggable {
protected static final String codiceProcesso = "RE";
protected ProcessLogger log;
public RichiestaVerificaEsitoFase2PortTypeImpl() {
System.out.println("Create Server WS [RichiestaVerificaEsitoFase2] Class [RichiestaVerificaEsitoFase2PortTypeImpl]");
try {
LogProcess logProcess = new LogProcess();
logProcess.setCodice(codiceProcesso);
logProcess.setProcess(this);
log = new ProcessLogger(logProcess);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Errore nella creazione del ProcessLogger, classe:" + RichiestaVerificaEsitoFase2PortTypeImpl.class + " - " + ex.toString());
}
}
public Ack checkDN(HeaderTypeHolder Header, Request body) {
try {
String bid = Header != null && Header.value != null ? Header.value.getBusinessID() : "";
log.write("9999", "ricevuto checkDN con bid = [" + bid+"]");
// Delega al controller la gestione dell'evento
Ack ack = NowController.getInstance().acquisisciRichiestaVerifica(body);
log.write("0002", " fine");
return ack;
} catch(Exception ex) {
log.write("0003", " eccezione " + ex);
throw new SOAPFaultException(null, ex.getMessage(), "DBCFX", null);
}
}
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

@@ -0,0 +1,60 @@
package it.valueteam.gnp.ws.now;
import javax.jws.HandlerChain;
import javax.jws.WebService;
import dbcfx.soa.verificarientrointi.x20211005.VerificaRientroInTIRequest;
import dbcfx.soa.verificarientrointi.x20211005.VerificaRientroInTIResponse;
import it.telecomitalia.soa.soap.soapheader.holders.HeaderTypeHolder;
import it.valueteam.gnp.log.Loggable;
import it.valueteam.gnp.log.ProcessLogger;
import it.valueteam.gnp.obj.LogInfo;
import it.valueteam.gnp.obj.LogProcess;
import it.valueteam.gnp.systemcontroller.formatcontroller.now.NowController;
import it.valueteam.gnp.utility.Resources;
import weblogic.jws.WLHttpTransport;
/**
* VerificaRientroInTIPortTypeImpl class implements web service endpoint interface VerificaRientroInTIPortType
*/
@WebService(serviceName = "VerificaRientroInTI", targetNamespace = "http://dbcfx/SOA/VerificaRientroInTI", endpointInterface = "it.valueteam.gnp.ws.now.VerificaRientroInTIPortType")
@WLHttpTransport(contextPath = "wsverificarientro", serviceUri = "VerificaRientroInTI", portName = "VerificaRientroInTI")
@HandlerChain(file = "handler.verificarientro.config.xml", name = "wsVerificaRientroInTIHandlerChain")
public class VerificaRientroInTIPortTypeImpl implements VerificaRientroInTIPortType, Loggable {
protected static final String codiceProcesso = "VR";
protected ProcessLogger log;
public VerificaRientroInTIPortTypeImpl() {
System.out.println("Create Server WS [VerificaRientroInTI] Class [VerificaRientroInTIPortTypeImpl]");
try {
LogProcess logProcess = new LogProcess();
logProcess.setCodice(codiceProcesso);
logProcess.setProcess(this);
log = new ProcessLogger(logProcess);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Errore nella creazione del ProcessLogger, classe:" + VerificaRientroInTIPortTypeImpl.class + " - " + ex.toString());
}
}
public VerificaRientroInTIResponse checkRientro(HeaderTypeHolder Header, VerificaRientroInTIRequest body) {
String bid = Header != null && Header.value != null ? Header.value.getBusinessID() : "";
log.write("0001", "Ricevuto checkRientro con bid = [" + bid + "]");
// Delega al controller la gestione dell'evento
log.write("9999", "Chiamata al metodo checkRientroInTI in NowController...");
VerificaRientroInTIResponse verificaRientroInTIResponse = NowController.getInstance().checkRientroInTI(Header, body);
log.write("0002", "Fine checkRientro");
return verificaRientroInTIResponse;
}
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

@@ -0,0 +1,85 @@
package it.valueteam.gnp.ws.now.checknp;
import it.valueteam.gnp.log.Loggable;
import it.valueteam.gnp.systemcontroller.formatcontroller.crm.WSSOAPHandler;
import javax.xml.namespace.QName;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import java.io.ByteArrayOutputStream;
import it.valueteam.gnp.log.ProcessLogger;
import it.valueteam.gnp.obj.LogProcess;
public class CheckNPSOAPHandler extends WSSOAPHandler implements Loggable {
protected ProcessLogger log;
public CheckNPSOAPHandler() throws Exception {
LogProcess logProcess = new LogProcess();
logProcess.setCodice(codiceProcesso);
logProcess.setProcess(this);
log = new ProcessLogger(logProcess);
}
private QName[] headers;
public QName[] getHeaders() {
return headers;
}
public boolean handleRequest(MessageContext context) {
try {
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) context;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SOAPMessage message = soapMsgCtx.getMessage();
SOAPHeader header = message.getSOAPHeader();
String bid = getBid(header);
log.write("9999",bid + " - [CheckNPSOAPHandler] - Inizio Log Invio Notifica");
soapMsgCtx.getMessage().writeTo(baos);
log.write("9999",bid + " - "+ baos.toString());
log.write("9999",bid + " - [CheckNPSOAPHandler] - Fine Log Invio Notifica");
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
public boolean handleResponse(MessageContext context) {
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) context;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
SOAPHeader header = ((SOAPMessageContext) context).getMessage().getSOAPHeader();
String bid = getBid(header);
log.write("9999",bid+" - "+"[CheckNPSOAPHandler] - Inizio Log Response Notifica");
soapMsgCtx.getMessage().writeTo(baos);
log.write("9999",baos.toString());
log.write("9999",bid+" - "+"[CheckNPSOAPHandler] - Fine Log Response Notifica");
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
public boolean handleFault(MessageContext context) {
try {
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) context;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SOAPMessage message = soapMsgCtx.getMessage();
SOAPHeader header = message.getSOAPHeader();
String bid = getBid(header);
log.write("9999",bid + " - "+"[CheckNPSOAPHandler] - Inizio Log Errore Invio Notifica");
soapMsgCtx.getMessage().writeTo(baos);
log.write("9999",bid + " - "+baos.toString());
log.write("9999",bid + " - "+"[CheckNPSOAPHandler] - Fine Log Errore Invio Notifica");
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
}

View File

@@ -0,0 +1,282 @@
package it.valueteam.gnp.ws.now.checknp;
import com.tim.now.wsdl.verificasistemanp.*;
import com.tim.now.wsdl.verificasistemanp.holders.RispostaTypeHolder;
import com.tim.now.wsdl.verificasistemanp.holders.TestataTypeHolder;
import it.valueteam.gnp.log.Loggable;
import it.valueteam.gnp.log.ProcessLogger;
import it.valueteam.gnp.obj.LogInfo;
import it.valueteam.gnp.obj.LogProcess;
import it.valueteam.gnp.utility.DateUtils;
import it.valueteam.gnp.utility.Resources;
import it.valueteam.gnp.ws.utlities.WSUtils;
import it.valueteam.now.webservices.client.chechnp.VerificaSistemaNP_PortType;
import it.valueteam.now.webservices.client.chechnp.VerificaSistemaNP_Service_Impl;
import org.apache.http.Header;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.w3c.dom.Node;
import tim.infobus.data.TID;
import javax.ejb.CreateException;
import javax.net.ssl.SSLContext;
import javax.xml.rpc.Stub;
import javax.xml.soap.*;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.TimeUnit;
public class CheckNpClient implements Loggable {
private String url;
private int timeOut;
private static final int defaultTimeOut = 30000;
protected ProcessLogger log;
protected String codiceProcesso = "CN"; // come da MNP_ANAGRAFICA_PROCESSO
private static final String SYSTEM_DBCFX = "DBCFX";
protected String versione = "1.0.0.0";
public CheckNpClient() throws Exception {
try {
LogProcess logProcess = new LogProcess();
logProcess.setCodice(codiceProcesso);
logProcess.setProcess(this);
log = new ProcessLogger(logProcess);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Errore nella creazione del ProcessLogger, classe:" + CheckNpClient.class + " - " + ex.toString());
throw new CreateException();
}
log.write("0001", " versione " + versione);
url = Resources.getURL_WS_NOW_CHECKNP();
if ("".equals(url)) {
log.write("0003", "");
throw new Exception("Errore in creazione client - impossibile recuperare url del ws da properties");
}
String timeOutStr = Resources.getTIMEOUT_WS_NOW_CHECKNP();
log.write("9999", " dbss client - url: " + url + " - timeOut: " + timeOutStr);
try {
timeOut = Integer.parseInt(timeOutStr);
} catch (NumberFormatException nfe) {
log.write("9999", " impossibile recuperare property timeout - impostato valore di default: " + defaultTimeOut);
timeOut = defaultTimeOut;
}
}
/**
* Imposta le modalita' di logging
*
* @return
* @throws Exception
*/
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;
}
public RispostaType VerificaSistemaGestioneNP(String[] dn, String ambito, String transactionID) throws Exception {
String methSig = "CheckNP_DBCFX DN [" + dnArrToString(dn) + "] TID [" + transactionID + "] ";
log.write("9999", methSig + "START");
TestataType testataType = new TestataType();
String tid = transactionID != null && !transactionID.equals("") ? transactionID.trim() : new TID().toString();
testataType.setTransaction_Id(tid);
testataType.setTransaction_Date(Calendar.getInstance());
testataType.setSistema_Origine(Sistema_Origine.dbcfx);
RichiestaType richiestaType = new RichiestaType();
if ("DEL35".equalsIgnoreCase(ambito)) {
richiestaType.setAmbito(Ambito.del35);
} else {
richiestaType.setAmbito(Ambito.del274);
}
richiestaType.setDN(dn);
if (Resources.SOAP_TO_HTTP_CHECKNP_ENABLED()) {
CloseableHttpClient client = null;
CloseableHttpResponse response = null;
StringBuilder resp = new StringBuilder();
try {
SSLContext sslContext = WSUtils.createSSLContext("SSL");
if(sslContext != null) {
SSLConnectionSocketFactory scf = WSUtils.createSSLConnectionSocketFactory(sslContext,
Resources.NOW_SUPPORTED_PROTOCOLS(), Resources.NOW_SUPPORTED_CIPHER_SUITES());
client = HttpClients.custom().useSystemProperties().setSSLSocketFactory(scf).setConnectionTimeToLive(timeOut,
TimeUnit.MILLISECONDS).build();
} else {
client = HttpClients.custom().useSystemProperties().setConnectionTimeToLive(timeOut, TimeUnit.MILLISECONDS).build();
}
HttpPost httpPost = new HttpPost(url);
Header[] headers = new BasicHeader[2];
headers[0] = new BasicHeader("Content-Type", "text/xml; charset=UTF-8");
headers[1] = new BasicHeader("SOAPAction", "VerificaSistemaGestioneNP");
httpPost.setHeaders(headers);
StringEntity lEntity = new StringEntity(createHttpRequest(testataType, richiestaType));
httpPost.setEntity(lEntity);
response = client.execute(httpPost);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line;
while ((line = rd.readLine()) != null) {
resp.append(line).append('\n');
}
if (response.getStatusLine().getStatusCode() != 200) {
log.write("9999",tid + " - "+"[CheckNPSOAPHandler] - Inizio Log Errore Invio Notifica");
log.write("9999",tid + " - "+resp.toString());
log.write("9999",tid + " - "+"[CheckNPSOAPHandler] - Fine Log Errore Invio Notifica");
throw new Exception(tid + " - Soap fault exception");
}
log.write("9999",tid+" - "+"[CheckNPSOAPHandler] - Inizio Log Response Notifica");
log.write("9999",resp.toString());
log.write("9999",tid+" - "+"[CheckNPSOAPHandler] - Fine Log Response Notifica");
RispostaType rt = getRispostaFromHttp(resp.toString());
log.write("9999", methSig + "END");
return rt;
} catch (Exception e) {
log.write("0003", methSig + "FAIL " + e);
throw e;
} finally {
try {
if (client != null) {
client.close();
}
if (response != null) {
response.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
try {
VerificaSistemaNP_Service_Impl service = new VerificaSistemaNP_Service_Impl();
VerificaSistemaNP_PortType endPoint = service.getVerificaSistemaNPSOAP();
((Stub) endPoint)._setProperty("javax.xml.rpc.service.endpoint.address", url);
((Stub) endPoint)._setProperty("weblogic.wsee.transport.connection.timeout", timeOut);
RispostaTypeHolder risposta = new RispostaTypeHolder();
TestataTypeHolder respTestataTypeHolder = new TestataTypeHolder();
endPoint.verificaSistemaGestioneNP(testataType, richiestaType, respTestataTypeHolder, risposta);
RispostaType resp = null;
if (null == risposta) {
log.write("9999", methSig + "null response");
} else {
resp = risposta.value;
log.write("9999", methSig + "valid response RC [" + (null != resp && null != resp.getRC() ? resp.getRC().getValue() : "null") + "]");
}
log.write("9999", methSig + "END");
return resp;
} catch (Exception e) {
log.write("0003", methSig + "FAIL " + e);
throw e;
}
}
}
private String dnArrToString(String[] dns) {
String toRet = "";
for (String dn : dns) {
toRet += dn + " - ";
}
return toRet;
}
private String createHttpRequest(TestataType header, RichiestaType request) throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
String serverURI = "http://www.tim.com/NOW/wsdl/VerificaSistemaNP/";
SOAPEnvelope envelope = soapPart.getEnvelope();
// SOAPHeader soapHeader = envelope.getHeader();
SOAPBody soapBody = envelope.getBody();
SOAPBodyElement hElement = soapBody.addBodyElement(envelope.createName("Testata", "ver", serverURI));
hElement.addChildElement("Transaction_Id", "").addTextNode(header.getTransaction_Id());
String transactionDate = DateUtils.toString(header.getTransaction_Date().getTime(),
"yyyy-MM-dd'T'HH:mm:ss.SSSZ");
int index = transactionDate.indexOf("+");
transactionDate = transactionDate.substring(0, index +3) + ":" + transactionDate.substring(index + 3);
hElement.addChildElement("Transaction_date", "").addTextNode(transactionDate);
hElement.addChildElement("Sistema_origine", "").addTextNode(header.getSistema_Origine().getValue());
SOAPBodyElement element = soapBody.addBodyElement(envelope.createName("Richiesta", "ver", serverURI));
element.addChildElement("Ambito", "").addTextNode(request.getAmbito().getValue());
for (String dn : request.getDN()) {
element.addChildElement("DN", "").addTextNode(dn);
}
soapMessage.saveChanges();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
soapMessage.writeTo(baos);
String tracciato = baos.toString();
log.write("9999",header.getTransaction_Id() + " - [CheckNPSOAPHandler] - Inizio Log Invio Notifica");
log.write("9999",header.getTransaction_Id() + " - "+ tracciato);
log.write("9999",header.getTransaction_Id() + " - [CheckNPSOAPHandler] - Fine Log Invio Notifica");
return tracciato;
}
private RispostaType getRispostaFromHttp(String risposta) throws Exception {
SOAPBody soapBody = WSUtils.getSOAPBody(risposta);
RispostaType rt = new RispostaType();
String tag = "DataRisposta";
if(soapBody.getElementsByTagName(tag).getLength() > 0) {
Calendar cal = Calendar.getInstance();
String dates = soapBody.getElementsByTagName(tag).item(0).getFirstChild().getNodeValue();
int index = dates.indexOf("+");
dates = dates.substring(0, index);
Date d = DateUtils.toDate(dates, "yyyy-MM-dd'T'HH:mm:ss.SSS");
cal.setTime(d);
rt.setDataRisposta(cal);
}
tag = "RC";
if(soapBody.getElementsByTagName(tag).getLength() > 0) {
RC rc = RC.fromValue(soapBody.getElementsByTagName(tag).item(0).getFirstChild().getNodeValue());
rt.setRC(rc);
}
tag = "ErrMSG";
if(soapBody.getElementsByTagName(tag).getLength() > 0) {
rt.setErrMSG(soapBody.getElementsByTagName(tag).item(0).getFirstChild().getNodeValue());
}
tag = "Sistema_DN";
int sistemaDnLength = soapBody.getElementsByTagName(tag).getLength();
if(sistemaDnLength > 0) {
Sistema_DNType[] sistemaDnTypes = new Sistema_DNType[sistemaDnLength];
for (int j = 0; j < sistemaDnLength; j++) {
Sistema_DNType sistemaDnType = new Sistema_DNType();
Node n = WSUtils.getChildByName(soapBody.getElementsByTagName(tag).item(j), "SistemaDiCompetenza");
if(n != null) {
sistemaDnType.setSistemaDiCompetenza(SistemaDiCompetenza.fromValue(n.getFirstChild().getNodeValue()));
}
n = WSUtils.getChildByName(soapBody.getElementsByTagName(tag).item(j), "DN");
if(n != null) {
sistemaDnType.setDN(n.getFirstChild().getNodeValue());
}
sistemaDnTypes [j] = sistemaDnType;
}
rt.setSistema_DN(sistemaDnTypes);
}
return rt;
}
}

View File

@@ -0,0 +1,9 @@
<jwshc:handler-config xmlns:jwshc="http://www.bea.com/xml/ns/jws" xmlns="http://java.sun.com/xml/ns/j2ee" >
<jwshc:handler-chain>
<jwshc:handler-chain-name>wsCheckRetailPlatformHandlerChain</jwshc:handler-chain-name>
<jwshc:handler>
<handler-name>handler</handler-name>
<handler-class>it.valueteam.gnp.systemcontroller.formatcontroller.now.WSNowCheckRetailPlatformSOAPHandler</handler-class>
</jwshc:handler>
</jwshc:handler-chain>
</jwshc:handler-config>

View File

@@ -0,0 +1,9 @@
<jwshc:handler-config xmlns:jwshc="http://www.bea.com/xml/ns/jws" xmlns="http://java.sun.com/xml/ns/j2ee" >
<jwshc:handler-chain>
<jwshc:handler-chain-name>wsRichiestaVerificaEsitoFase2HandlerChain</jwshc:handler-chain-name>
<jwshc:handler>
<handler-name>handler</handler-name>
<handler-class>it.valueteam.gnp.systemcontroller.formatcontroller.now.WSNowRichiestaVerificaEsitoFase2SOAPHandler</handler-class>
</jwshc:handler>
</jwshc:handler-chain>
</jwshc:handler-config>

View File

@@ -0,0 +1,9 @@
<jwshc:handler-config xmlns:jwshc="http://www.bea.com/xml/ns/jws" xmlns="http://java.sun.com/xml/ns/j2ee" >
<jwshc:handler-chain>
<jwshc:handler-chain-name>wsVerificaRientroInTIHandlerChain</jwshc:handler-chain-name>
<jwshc:handler>
<handler-name>handler</handler-name>
<handler-class>it.valueteam.gnp.systemcontroller.formatcontroller.now.WSNowVerificaRientroInTISOAPHandler</handler-class>
</jwshc:handler>
</jwshc:handler-chain>
</jwshc:handler-config>

View File

@@ -0,0 +1,244 @@
package it.valueteam.gnp.ws.now.rispostaverificaesitofase2;
import com.tim.now.xsd.rispostaverificaesitofase2.NumerazioniAccessoType;
import com.tim.now.xsd.rispostaverificaesitofase2.RispostaVerificaEsitoFase2_Ack;
import com.tim.now.xsd.rispostaverificaesitofase2.RispostaVerificaEsitoFase2_Request;
import com.tim.now.xsd.rispostaverificaesitofase2.VerificaFase2Type;
import it.telecomitalia.soa.soap.soapheader.HeaderType;
import it.telecomitalia.soa.soap.soapheader.InteractionDateType;
import it.telecomitalia.soa.soap.soapheader.holders.HeaderTypeHolder;
import it.valueteam.gnp.log.Loggable;
import it.valueteam.gnp.log.ProcessLogger;
import it.valueteam.gnp.obj.LogInfo;
import it.valueteam.gnp.obj.LogProcess;
import it.valueteam.gnp.utility.DateUtils;
import it.valueteam.gnp.utility.Resources;
import it.valueteam.gnp.ws.utlities.WSUtils;
import it.valueteam.now.webservices.client.rispostaverificaesitofase2.RispostaVerificaEsitoFase2PortType_PortType;
import it.valueteam.now.webservices.client.rispostaverificaesitofase2.RispostaVerificaEsitoFase2PortType_Service_Impl;
import org.apache.http.Header;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import tim.infobus.data.TID;
import javax.ejb.CreateException;
import javax.net.ssl.SSLContext;
import javax.xml.rpc.Stub;
import javax.xml.soap.*;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
public class RispVerEsitoFase2Client implements Loggable {
private String url;
private int timeOut;
private static final int defaultTimeOut = 30000;
private static final String dateFormat = "yyyy-MM-dd";
private static final String timeFormat = "HH:mm:ss";
private static final String dataPicFormat = "yyyy-MM-ddZ";
protected ProcessLogger log;
protected String codiceProcesso = "RV"; // come da MNP_ANAGRAFICA_PROCESSO
private static final String SYSTEM_DBCFX = "DBCFX";
protected String versione = "1.0.0.0";
public RispVerEsitoFase2Client() throws Exception {
try {
LogProcess logProcess = new LogProcess();
logProcess.setCodice(codiceProcesso);
logProcess.setProcess(this);
log = new ProcessLogger(logProcess);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Errore nella creazione del ProcessLogger, classe:" + RispVerEsitoFase2Client.class + " - " + ex.toString());
throw new CreateException();
}
log.write("0001", " versione " + versione);
url = Resources.getURL_WS_NOW_RISP_VER_ESITO_FASE2();
if ("".equals(url)) {
log.write("0003", "");
throw new Exception("Errore in creazione client - impossibile recuperare url del ws da properties");
}
String timeOutStr = Resources.getTIMEOUT_WS_NOW_RISP_VER_ESITO_FASE2();
log.write("9999", " now client - url: " + url + " - timeOut: " + timeOutStr);
try {
timeOut = Integer.parseInt(timeOutStr);
} catch (NumberFormatException nfe) {
log.write("9999", " impossibile recuperare property timeout - impostato valore di default: " + defaultTimeOut);
timeOut = defaultTimeOut;
}
}
public RispostaVerificaEsitoFase2_Ack checkDN(RispostaVerificaEsitoFase2_Request request) throws Exception {
log.write("9999", "checkDN start");
HeaderTypeHolder holder = new HeaderTypeHolder();
HeaderType header = new HeaderType();
header.setSourceSystem(SYSTEM_DBCFX);
header.setTransactionID(new TID().toString());
Date date = new Date();
InteractionDateType idt = new InteractionDateType();
idt.setDate(new SimpleDateFormat(dateFormat).format(date));
idt.setTime(new SimpleDateFormat(timeFormat).format(date));
header.setInteractionDate(idt);
holder.value = header;
if (Resources.SOAP_TO_HTTP_VERIFICA_FASE2_ENABLED()) {
CloseableHttpClient client = null;
CloseableHttpResponse response = null;
StringBuilder resp = new StringBuilder();
try {
SSLContext sslContext = WSUtils.createSSLContext("SSL");
if(sslContext != null) {
SSLConnectionSocketFactory scf = WSUtils.createSSLConnectionSocketFactory(sslContext,
Resources.NOW_SUPPORTED_PROTOCOLS(), Resources.NOW_SUPPORTED_CIPHER_SUITES());
client = HttpClients.custom().useSystemProperties().setSSLSocketFactory(scf).setConnectionTimeToLive(timeOut,
TimeUnit.MILLISECONDS).build();
} else {
client = HttpClients.custom().useSystemProperties().setConnectionTimeToLive(timeOut, TimeUnit.MILLISECONDS).build();
}
HttpPost httpPost = new HttpPost(url);
Header[] headers = new BasicHeader[2];
headers[0] = new BasicHeader("Content-Type", "text/xml; charset=UTF-8");
headers[1] = new BasicHeader("SOAPAction", "checkDN");
httpPost.setHeaders(headers);
StringEntity lEntity = new StringEntity(createHttpRequest(header, request));
httpPost.setEntity(lEntity);
response = client.execute(httpPost);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line;
while ((line = rd.readLine()) != null) {
resp.append(line).append('\n');
}
if (response.getStatusLine().getStatusCode() != 200) {
log.write("9999", header.getTransactionID() + " - [RispVerEsitoFase2SOAPHandler] - Inizio Log Error");
log.write("9999", header.getTransactionID() + " - " + resp.toString());
log.write("9999", header.getTransactionID() + " - [RispVerEsitoFase2SOAPHandler] - Fine Log Error");
throw new Exception(header.getTransactionID() + " - Soap fault exception");
}
log.write("9999", header.getTransactionID() + " - [RispVerEsitoFase2SOAPHandler] - Inizio Log Response");
log.write("9999", header.getTransactionID() + " - " + resp.toString());
log.write("9999", header.getTransactionID() + " - [RispVerEsitoFase2SOAPHandler] - Fine Log Response");
RispostaVerificaEsitoFase2_Ack ack = getRispostaFromHttp(resp.toString());
log.write("9999", "checkDN end");
return ack;
} catch (Exception e) {
log.write("0003", "eccezione durante l'invocazione del ws [RispVerEsitoFase2Client.checkDN]: " + e);
throw e;
} finally {
try {
if (client != null) {
client.close();
}
if (response != null) {
response.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
try {
RispostaVerificaEsitoFase2PortType_Service_Impl service = new RispostaVerificaEsitoFase2PortType_Service_Impl();
RispostaVerificaEsitoFase2PortType_PortType endPoint = service.getRispostaVerificaEsitoFase2PortTypeSOAP();
((Stub) endPoint)._setProperty("javax.xml.rpc.service.endpoint.address", url);
((Stub) endPoint)._setProperty("weblogic.wsee.transport.connection.timeout", timeOut);
RispostaVerificaEsitoFase2_Ack ack = endPoint.checkDN(holder, request);
log.write("9999", "checkDN end");
return ack;
} catch (Exception e) {
log.write("0003", "eccezione durante l'invocazione del ws [RispVerEsitoFase2Client.checkDN]: " + e);
throw e;
}
}
}
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;
}
private String createHttpRequest(HeaderType header, RispostaVerificaEsitoFase2_Request request) throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
String serverURI = "http://telecomitalia.it/SOA/SOAP/SOAPHeader";
String serverURI2 = "http://www.tim.com/NOW/xsd/RispostaVerificaEsitoFase2/";
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPHeader soapHeader = envelope.getHeader();
SOAPHeaderElement hElement = soapHeader.addHeaderElement(envelope.createName("Header", "soap", serverURI));
hElement.addChildElement("sourceSystem", "soap").addTextNode(header.getSourceSystem());
SOAPElement interactionDate = hElement.addChildElement("interactionDate", "soap");
interactionDate.addChildElement("Date", "soap").addTextNode(header.getInteractionDate().getDate());
interactionDate.addChildElement("Time", "soap").addTextNode(header.getInteractionDate().getTime());
hElement.addChildElement("transactionID", "soap").addTextNode(header.getTransactionID());
SOAPBody soapBody = envelope.getBody();
SOAPBodyElement element = soapBody.addBodyElement(envelope.createName("RispostaVerificaEsitoFase2_Request", "ris", serverURI2));
element.addChildElement("IdentificativoRichiestaOLO", "ris").addTextNode(request.getIdentificativoRichiestaOLO());
element.addChildElement("CodiceOrdineTI", "ris").addTextNode(request.getCodiceOrdineTI());
element.addChildElement("IdLinea", "ris").addTextNode(request.getIdLinea());
if(request.getVerificaFase2() != null) {
for (VerificaFase2Type verificaFase2Types : request.getVerificaFase2()) {
SOAPElement verificaFase2 = element.addChildElement("VerificaFase2", "ris");
verificaFase2.addChildElement("CodiceOLO", "ris").addTextNode(verificaFase2Types.getCodiceOLO());
String dataPic = DateUtils.toString(verificaFase2Types.getDataPic().getTime(), dataPicFormat);
int index = dataPic.indexOf("+");
dataPic = dataPic.substring(0, index + 3) + ":" + dataPic.substring(index + 3);
verificaFase2.addChildElement("DataPic", "ris").addTextNode(dataPic);
verificaFase2.addChildElement("Esito", "ris").addTextNode(verificaFase2Types.getEsito().getValue());
}
}
if (request.getNumerazioniAccesso() != null) {
for (NumerazioniAccessoType numerazioniAccessoType : request.getNumerazioniAccesso()) {
SOAPElement numerazioniAccesso = element.addChildElement("NumerazioniAccesso", "ris");
numerazioniAccesso.addChildElement("DN", "ris").addTextNode(numerazioniAccessoType.getDN());
numerazioniAccesso.addChildElement("Direzionalita", "ris")
.addTextNode(numerazioniAccessoType.getDirezionalita().getValue());
}
}
soapMessage.saveChanges();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
soapMessage.writeTo(baos);
return baos.toString();
}
private RispostaVerificaEsitoFase2_Ack getRispostaFromHttp(String risposta) throws Exception {
SOAPBody soapBody = WSUtils.getSOAPBody(risposta);
RispostaVerificaEsitoFase2_Ack ack = new RispostaVerificaEsitoFase2_Ack();
org.w3c.dom.Node nMaster = soapBody.getChildNodes().item(0);
if(nMaster != null) {
org.w3c.dom.Node n = WSUtils.getChildByName(nMaster, "Codice");
if (n != null) {
ack.setCodice(n.getFirstChild().getNodeValue());
}
n = WSUtils.getChildByName(nMaster, "Descrizione");
if (n != null) {
ack.setDescrizione(n.getFirstChild().getNodeValue());
}
}
return ack;
}
}

View File

@@ -0,0 +1,81 @@
package it.valueteam.gnp.ws.now.rispostaverificaesitofase2;
import it.valueteam.gnp.log.Loggable;
import it.valueteam.gnp.log.ProcessLogger;
import it.valueteam.gnp.obj.LogProcess;
import it.valueteam.gnp.systemcontroller.formatcontroller.crm.WSSOAPHandler;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import java.io.ByteArrayOutputStream;
public class RispVerEsitoFase2SOAPHandler extends WSSOAPHandler implements Loggable {
protected ProcessLogger log;
public RispVerEsitoFase2SOAPHandler() throws Exception {
LogProcess logProcess = new LogProcess();
logProcess.setCodice(codiceProcesso);
logProcess.setProcess(this);
log = new ProcessLogger(logProcess);
}
public boolean handleRequest(MessageContext context) {
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) context;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
SOAPMessage message = soapMsgCtx.getMessage();
SOAPHeader header = message.getSOAPHeader();
String bid = getBid(header);
log.write("9999",bid + " - [RispVerEsitoFase2SOAPHandler] - Inizio Log Request");
soapMsgCtx.getMessage().writeTo(baos);
log.write("9999",baos.toString());
log.write("9999",bid + " - [RispVerEsitoFase2SOAPHandler] - Fine Log Request");
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
public boolean handleResponse(MessageContext context) {
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) context;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
SOAPHeader header = ((SOAPMessageContext) context).getMessage().getSOAPHeader();
String bid = getBid(header);
log.write("9999",bid + " - [RispVerEsitoFase2SOAPHandler] - Inizio Log Response");
soapMsgCtx.getMessage().writeTo(baos);
log.write("9999",bid + " - "+baos.toString());
log.write("9999",bid + " - [RispVerEsitoFase2SOAPHandler] - Fine Log Response");
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
public boolean handleFault(MessageContext context) {
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) context;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
SOAPMessage message = soapMsgCtx.getMessage();
SOAPHeader header = message.getSOAPHeader();
String bid = getBid(header);
log.write("9999",bid + " - [RispVerEsitoFase2SOAPHandler] - Inizio Log Error");
soapMsgCtx.getMessage().writeTo(baos);
log.write("9999",bid + " - "+baos.toString());
log.write("9999",bid + " - [RispVerEsitoFase2SOAPHandler] - Fine Log Error");
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
}