First Commit - Source Code from Reply

This commit is contained in:
vincenzofariello
2024-05-13 12:54:14 +02:00
parent 73e32a5020
commit a15aee1f08
11184 changed files with 1065913 additions and 0 deletions

View File

@@ -0,0 +1,259 @@
package proxy.jms;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.jms.*;
import javax.naming.InitialContext;
import tim.infobus.data.TID;
import javax.naming.Context;
import obj.TipoFlusso;
import conf.SimConfFile;
public class MessageHandler {
private static MessageHandler onlyInstance = new MessageHandler();
private static final String JMS_FACTORY = "jms/ConnectionFactory";
private static final String GISP_SYSTEM = "GISP";
private static final String GISP_ATT_SERVICE = "esitoRichiesta";
private static final String GISP_CESS_SERVICE = "esitoRichiesta";
private static final String GISP_NOTIFICA_IN_SERVICE = "notificaEventoGISP";
private static final String GISP_QUEUE_NAME = "jms/GispAcqServiceQueue";
private static final String TISCALI_QUEUE_NAME = "jms/MVNOAcqServiceQueue";
private static final String TRCS_QUEUE_NAME = "jms/TRCSAcqServiceQueue";
private static final String TISCALI_SYSTEM = "MVNO";
private static final String TISCALI_VAL_SERVICE = "notifyValidationDonor";
private static final String TISCALI_ACQ_SERVICE = "requestPortingInRecipient";
private static final String MVNO_UPDATEDCO = "updateDcoDonor";
private static final String CREDIT_TRANSFER_DONOR_MVNO = "notifyCreditTransferDonor";
private static final String MSP_IN_QUEUE_NAME = "jms/MSPAcqServiceQueue";
private static final String MSP_SYSTEM = "MSP";
private static final String CREDIT_TRANSFER_MSP = "notifyCreditTransferDonorTIM";
private static final String MSP_COOP_IN_QUEUE_NAME = "jms/MSPCOOPAcqServiceQueue";
private static final String MSP_COOP_SYSTEM = "MSPCOOP";
private static final String CREDIT_TRANSFER_MSP_COOP = "notifyCreditTransferDonorESP";
public static final String QUEUE_NAME = "QUEUE_NAME";
public static final String ID_SYSTEM = "ID_SYSTEM";
public static final String ID_SERVICE = "ID_SERVICE";
private MessageHandler() {}
public static MessageHandler getInstance() {
return onlyInstance;
}
/**
* invia un messagge a DBC
*
* @param xmlResponse String
*/
public void sendMessage(String xml, String queueName, String system, String service)
throws JMSException, Exception {
QueueConnection qcon = null;
QueueSession qsession = null;
QueueSender qsender = null;
QueueConnectionFactory qconFactory = null;
Queue q = null;
BytesMessage message = null;
Context initialcontext = null;
TID tid = null;
try {
tid = new TID();
initialcontext = getInitialContext();
// ottengo la jms factory
qconFactory = (QueueConnectionFactory) initialcontext.lookup(JMS_FACTORY);
// Creo connessione fisica a JMS
qcon = qconFactory.createQueueConnection();
//creo la sessione
qsession = qcon.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
// Ottengo il riferimento alla coda
q = (Queue) initialcontext.lookup(queueName);
//creo il sender
qsender = qsession.createSender(q);
message = qsession.createBytesMessage();
System.out.println("Creato il messaggio");
message.writeBytes(xml.getBytes());
message.setJMSCorrelationID(tid.toString());
message.setStringProperty("TID", tid.toString());
message.setStringProperty("SERVICE", service);
message.setStringProperty("SYSTEM", system);
qsender.send(message);
System.out.println("Inviato il messaggio");
closeAll(qcon, qsession, qsender, initialcontext);
}
catch (JMSException ex) {
System.out.println("Problemi nell'invio del messaggio");
throw ex;
}
catch (Exception ex) {
System.out.println("Problemi nell'invio del messaggio");
throw ex;
}
}
/**
* getInitialContext
*
* @return InitialContext
*/
private Context getInitialContext() throws Exception {
String user = "";
String password = "";
try {
Properties env = SimConfFile.getInstance().ReadSection("JNDI");
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
env.getProperty("java.naming.factory.initial"));
properties.put(Context.PROVIDER_URL, env.getProperty("java.naming.provider.url"));
user = env.getProperty("java.naming.security.principal");
password = env.getProperty("java.naming.security.credentials");
if ( (user != null) && (!user.equals(""))) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS,
password == null ? "" : password);
}
return new InitialContext(properties);
}
catch (Exception e) {
// System.out.println("I parametri di configurazione del Context sono : \n");
// System.out.println("context.factory : [" +
// Resources.getWLServerContextFactory() + "]");
// System.out.println("url : [" + Resources.getWLServerDbcUrl() + "]");
// System.out.println("user [" + user + "]");
//System.out.println("password [" +password+"]");
throw e;
}
}
/**
* chiude initialcontext, sender,sessione,connection
*
* @param qcon QueueConnection
* @param qsession QueueSession
* @param qsender QueueSender
*/
private static void closeAll(QueueConnection qcon, QueueSession qsession,
QueueSender qsender, Context initialcontext) {
try {
initialcontext.close();
qsender.close();
qsession.close();
qcon.close();
}
catch (Exception ex) {
System.out.println("Problemi nella chiusura dei servizi JMS");
System.out.println(ex.getMessage());
}
}
/**
* Ritorna la mappa dei parametri di comunicazione a partire dal tipo
* flusso. Le chiavi sono: QUEUE_NAME, ID_SYSTEM, ID_SERVICE
* @param flowType
* @return
* @throws Exception
*/
public static Map getParams(String flowType) throws Exception {
Map params;
if (flowType.equals(TipoFlusso.ATTIVAZIONE)) {
params = new HashMap();
params.put(QUEUE_NAME, TISCALI_QUEUE_NAME);
params.put(ID_SYSTEM, TISCALI_SYSTEM);
params.put(ID_SERVICE, TISCALI_ACQ_SERVICE);
return params;
}
else if (flowType.equals(TipoFlusso.VALIDAZIONE)) {
params = new HashMap();
params.put(QUEUE_NAME, TISCALI_QUEUE_NAME);
params.put(ID_SYSTEM, TISCALI_SYSTEM);
params.put(ID_SERVICE, TISCALI_VAL_SERVICE);
return params;
}
else if (flowType.equals(TipoFlusso.RISP_ATTIVAZIONE)) {
params = new HashMap();
params.put(QUEUE_NAME, GISP_QUEUE_NAME);
params.put(ID_SYSTEM, GISP_SYSTEM);
params.put(ID_SERVICE, GISP_ATT_SERVICE);
return params;
}
else if (flowType.equals(TipoFlusso.RISP_CESSAZIONE)) {
params = new HashMap();
params.put(QUEUE_NAME, GISP_QUEUE_NAME);
params.put(ID_SYSTEM, GISP_SYSTEM);
params.put(ID_SERVICE, GISP_CESS_SERVICE);
return params;
}
else if (flowType.equals(TipoFlusso.NOT_ATTIVAZIONE)
|| flowType.equals(TipoFlusso.NOT_CESSAZIONE)) {
params = new HashMap();
params.put(QUEUE_NAME, GISP_QUEUE_NAME);
params.put(ID_SYSTEM, GISP_SYSTEM);
params.put(ID_SERVICE, GISP_NOTIFICA_IN_SERVICE);
return params;
}
else if (flowType.equals(TipoFlusso.NOT_CESSAZIONE)) {
params = new HashMap();
params.put(QUEUE_NAME, GISP_QUEUE_NAME);
params.put(ID_SYSTEM, GISP_SYSTEM);
params.put(ID_SERVICE, GISP_NOTIFICA_IN_SERVICE);
return params;
}
else if (flowType.equals(TipoFlusso.NOTIFICA_MVNO_TC)) {
params = new HashMap();
params.put(QUEUE_NAME, TISCALI_QUEUE_NAME);
params.put(ID_SYSTEM, TISCALI_SYSTEM);
params.put(ID_SERVICE, CREDIT_TRANSFER_DONOR_MVNO);
return params;
}
else if (flowType.equals(TipoFlusso.NOTIFICA_MSP_TC)) {
params = new HashMap();
params.put(QUEUE_NAME, MSP_IN_QUEUE_NAME);
params.put(ID_SYSTEM, MSP_SYSTEM);
params.put(ID_SERVICE, CREDIT_TRANSFER_MSP);
return params;
}
else if (flowType.equals(TipoFlusso.NOTIFICA_MSPCOOP_TC)) {
params = new HashMap();
params.put(QUEUE_NAME, MSP_COOP_IN_QUEUE_NAME);
params.put(ID_SYSTEM, MSP_COOP_SYSTEM);
params.put(ID_SERVICE, CREDIT_TRANSFER_MSP_COOP);
return params;
}
else if (flowType.equals(TipoFlusso.UPDATEDCO_MVNO)) {
params = new HashMap();
params.put(QUEUE_NAME, TISCALI_QUEUE_NAME);
params.put(ID_SYSTEM, TISCALI_SYSTEM);
params.put(ID_SERVICE, MVNO_UPDATEDCO);
return params;
}
else
throw new IllegalArgumentException("Tipo flusso errato!");
}
}

View File

@@ -0,0 +1,47 @@
package proxy.ws.dbssresponse;
import javax.jws.HandlerChain;
import javax.jws.WebService;
import it.telecomitalia.soa.mobilenumberportabilitymgmtresponse.x20150511.PortInResultRequest;
import it.telecomitalia.soa.mobilenumberportabilitymgmtresponse.x20150511.PortOutCreditResultRequest;
import it.telecomitalia.soa.soap.soapheader.HeaderType;
import mnp.proxy.ws.dbssresponse.MobileNumberPortabilityMgmtResponsePortType;
import weblogic.jws.WLHttpTransport;
/**
* MobileNumberPortabilityMgmtResponsePortTypeImpl class implements web service endpoint interface MobileNumberPortabilityMgmtResponsePortType
*/
@WebService(
serviceName = "serviceResponse",
targetNamespace = "http://telecomitalia.it/SOA/MobileNumberPortabilityMgmtResponse-v1/service-b",
endpointInterface = "mnp.proxy.ws.dbssresponse.MobileNumberPortabilityMgmtResponsePortType")
@WLHttpTransport(contextPath = "simwscdbssresp", serviceUri = "MobileNumberPortabilityMgmtResponse", portName = "MobileNumberPortabilityMgmtResponseHttpEndpoint")
@HandlerChain(file = "handler.config.xml", name = "portInResultChain")
public class MobileNumberPortabilityMgmtResponsePortTypeImpl implements MobileNumberPortabilityMgmtResponsePortType {
public MobileNumberPortabilityMgmtResponsePortTypeImpl() {
System.out.println("Created SIM WS for DBSS: [MobileNumberPortabilityMgmtResponsePortTypeImpl]");
}
public void portInResult(PortInResultRequest body, it.telecomitalia.soa.soap.soapheader.HeaderType header) {
// N - INIZIO PROCESSO
System.out.println("*********************************");
System.out.println("Ricezione richiesta PortInResult.");
System.out.println("header ["+header+"]");
System.out.println("portInResult ["+body+"]");
System.out.println("*********************************");
}
public void portOutCreditResult(PortOutCreditResultRequest portOutCreditResultRequest, HeaderType headerType) {
// N - INIZIO PROCESSO
System.out.println("*********************************");
System.out.println("Ricezione richiesta portOutCreditResult.");
System.out.println("header ["+headerType+"]");
System.out.println("portInResult ["+portOutCreditResultRequest+"]");
System.out.println("*********************************");
}
}

View File

@@ -0,0 +1,40 @@
package proxy.ws.dbssresponse;
import javax.jws.WebService;
import dbss_goa.mobileprepaidmnptransfercreditordermgmt.UpdatePortinCreditTransferRequest;
import dbss_goa.mobileprepaidmnptransfercreditordermgmt.UpdatePortinCreditTransferResponse;
import dbss_goa.mobileprepaidmnptransfercreditordermgmt.UpdatePortoutCreditTransferRequest;
import dbss_goa.mobileprepaidmnptransfercreditordermgmt.UpdatePortoutCreditTransferResponse;
import mnp.proxy.ws.dbssresponse.MobilePrepaidMNPTransferCreditOrderMgmtPortType;
import weblogic.jws.WLHttpTransport;
/**
* MobilePrepaidMNPTransferCreditOrderMgmtPortTypeImpl class implements web service endpoint interface MobilePrepaidMNPTransferCreditOrderMgmtPortType
*/
@WebService(
serviceName = "CreditOrderMgmt",
targetNamespace = "http://xmlns.example.com/1449226534659",
endpointInterface = "mnp.proxy.ws.dbssresponse.MobilePrepaidMNPTransferCreditOrderMgmtPortType")
@WLHttpTransport(contextPath = "/", serviceUri = "CreditOrderMgmt", portName = "mobilePrepaidMNPTransferCreditOrderMgmtPortTypeEndpoint1")
public class MobilePrepaidMNPTransferCreditOrderMgmtPortTypeImpl implements MobilePrepaidMNPTransferCreditOrderMgmtPortType {
public MobilePrepaidMNPTransferCreditOrderMgmtPortTypeImpl() {
System.out.println("Created SIM WS for DBSS-GOA: [MobilePrepaidMNPTransferCreditOrderMgmt]");
}
public UpdatePortinCreditTransferResponse portinTrasferCredit(it.telecomitalia.soa.soap.soapheader.holders.HeaderTypeHolder Header, UpdatePortinCreditTransferRequest body) {
System.out.println("********** [SIM.CreditOrderMgmt] START **********");
System.out.println("[SIM] CreditOrderMgmt.portinTrasferCredit. Ricezione richiesta portinTrasferCredit.");
System.out.println("[SIM] CreditOrderMgmt.portinTrasferCredit. header [" + Header + "]");
System.out.println("********** [SIM.CreditOrderMgmt] END **********");
return null;
}
public UpdatePortoutCreditTransferResponse portoutTrasferCredit(it.telecomitalia.soa.soap.soapheader.holders.HeaderTypeHolder Header, UpdatePortoutCreditTransferRequest body)
{
// Non utilizzato da DBC
return null;
}
}

View File

@@ -0,0 +1,75 @@
package proxy.ws.dbssresponse;
import javax.xml.namespace.QName;
import javax.xml.rpc.handler.GenericHandler;
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import java.io.ByteArrayOutputStream;
/**
* utilizzato come Handler dal WS MobileNumberPortabilityMgmtResponsePortTypeImpl per loggare
* in formato testo i messaggi SOAP in ingresso.
*/
public class PortInResultSOAPHandler extends GenericHandler {
private QName[] headers;
/* (non-Javadoc)
* @see javax.xml.rpc.handler.GenericHandler#init(javax.xml.rpc.handler.HandlerInfo)
*/
@Override
public void init(HandlerInfo config) {
super.init(config);
headers = config.getHeaders();
}
@Override
public QName[] getHeaders() {
return headers;
}
/* (non-Javadoc)
* @see javax.xml.rpc.handler.GenericHandler#handleRequest(javax.xml.rpc.handler.MessageContext)
*/
@Override
public boolean handleRequest(MessageContext msgctx) {
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) msgctx;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
System.out.println("-------------------------------ricevuta chiamata Simulatore DBSS Response-------------------------------");
System.out.println("PortInResultSOAPHandler - " + new java.util.Date());
System.out.println("--------------------------------------------------------------------------------------------------------");
soapMsgCtx.getMessage().writeTo(baos);
System.out.println(baos.toString());
System.out.println("---------------------------------fine chiamata Simulatore DBSS Response---------------------------------");
} catch (Exception ex) {
ex.printStackTrace();
}
return super.handleRequest(msgctx);
}
/* (non-Javadoc)
* @see javax.xml.rpc.handler.GenericHandler#handleFault(javax.xml.rpc.handler.MessageContext)
*/
@Override
public boolean handleFault(MessageContext msgctx) {
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) msgctx;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
System.out.println("-----------------------ricevuta chiamata Simulatore DBSS Response - fallita------------------------------");
System.out.println("PortInResultSOAPHandler (fault) - " + new java.util.Date());
System.out.println("---------------------------------------------------------------------------------------------------------");
soapMsgCtx.getMessage().writeTo(baos);
System.out.println(baos.toString());
System.out.println("---------------------------------fine chiamata Simulatore DBSS Response----------------------------------");
} catch (Exception ex) {
ex.printStackTrace();
}
return super.handleFault(msgctx);
}
}

View File

@@ -0,0 +1,45 @@
package proxy.ws.dbssresponse;
import javax.jws.HandlerChain;
import javax.jws.WebService;
import it.telecomitalia.soa.portingoutmgmt.NotifyPortoutRequest;
import it.telecomitalia.soa.portingoutmgmt.PortoutOrderRequest;
import it.telecomitalia.soa.portingoutmgmt.ValidatePortoutRequest;
import mnp.proxy.ws.dbssresponse.PortingOutPortType;
import weblogic.jws.WLHttpTransport;
/**
* PortingOutPortTypeImpl class implements web service endpoint interface PortingOutPortType
*/
@WebService(serviceName = "PortoutService", targetNamespace = "http://xmlns.example.com/1449226534659",
endpointInterface = "mnp.proxy.ws.dbssresponse.PortingOutPortType")
@HandlerChain(file = "handler.config.xml", name = "portInResultChain")
@WLHttpTransport(contextPath = "simwscdbssportingout", serviceUri = "PortoutService", portName = "PortingOutPortTypeEndpoint1")
public class PortingOutPortTypeImpl implements PortingOutPortType {
public PortingOutPortTypeImpl() {
}
public void notifyPortout(NotifyPortoutRequest body, it.telecomitalia.soa.soap.soapheader.HeaderType Header) {
System.out.println("********** [SIM.PortingOutMgmt] START **********");
System.out.println("[SIM] PortingOutMgmt.notifyPortout. Ricezione richiesta notifyPortout.");
System.out.println("[SIM] PortingOutMgmt.notifyPortout. header [" + Header + "]");
System.out.println("********** [SIM.PortingOutMgmt] END **********");
}
public void portoutOrder(PortoutOrderRequest body, it.telecomitalia.soa.soap.soapheader.HeaderType Header) {
System.out.println("********** [SIM.PortingOutMgmt] START **********");
System.out.println("[SIM] PortingOutMgmt.portoutOrder. Ricezione richiesta portoutOrder.");
System.out.println("[SIM] PortingOutMgmt.portoutOrder. header [" + Header + "]");
System.out.println("********** [SIM.PortingOutMgmt] END **********");
}
public void validatePortout(ValidatePortoutRequest body, it.telecomitalia.soa.soap.soapheader.HeaderType Header) {
System.out.println("********** [SIM.PortingOutMgmt] START **********");
System.out.println("[SIM] PortingOutMgmt.validatePortout. Ricezione richiesta validatePortout.");
System.out.println("[SIM] PortingOutMgmt.validatePortout. header [" + Header + "]");
System.out.println("********** [SIM.PortingOutMgmt] END **********");
}
}

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>portInResultChain</jwshc:handler-chain-name>
<jwshc:handler>
<handler-name>PortInResultSOAPHandler</handler-name>
<handler-class>proxy.ws.dbssresponse.PortInResultSOAPHandler</handler-class>
</jwshc:handler>
</jwshc:handler-chain>
</jwshc:handler-config>