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,417 @@
package it.valueteam.gnp.proxy;
/**
* <p>Title: GNP</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
import java.rmi.*;
import it.valueteam.gnp.exception.infobus.*;
import it.valueteam.gnp.log.ProcessLogger;
import it.valueteam.gnp.obj.*;
import it.valueteam.gnp.proxy.exception.*;
import it.valueteam.gnp.utility.*;
import tim.infobus.data.*;
public class InfobusHandler {
private static int redelivery = -1;
// blocco di inizializzazione statica
static {
initStatic();
}
private static void initStatic() {
//lettura del file di property per reperire i parametri di configurazione
try {
try {
redelivery = Resources.getInfobusRedelivery();
}
catch (NumberFormatException nfe) {
redelivery = -1;
System.out.println(
"Il valore della propriet<65> infobus.redelivery non <20> valido");
System.out.println("Uso valore di default [redelivery=1]");
}
}
catch (Exception e) {
redelivery = -1;
System.out.println(
"Problemi nella lettura del file di property per infobus redelivery");
System.out.println("Uso valore di default [redelivery=1]");
}
finally {
if (redelivery < 0)
redelivery = 1;
}
}
public InfobusHandler() {
}
public int notificaSMS(String tracciato, ProcessLogger log) throws InfobusHandlerException, IBSendException,Exception {
String buffer = null;
int reply = 0;
//preparazione dei dati per costruire una IBData
buffer = tracciato;
//Creazione IBData
try {
IBData ibData = null;
try {
ibData = new IBData(InfobusMap.IDSYSTEM_SMS, InfobusMap.IDSRVC_SMS, new TID(), InfobusMap.APP_CODE_SMS, buffer.getBytes());
}
catch (IBException ex) {
ex.printStackTrace();
throw new IBSendException("Errore durante la creazione del messaggio infobus");
}
reply = request(ibData);
log.write("9999","TID: "+ibData.getTID()+", MESSAGGIO INVIATO VIA INFOBUS : [" + new String(ibData.getData()) + "]");
return reply;
}
catch (Exception ex1) {
ex1.printStackTrace();
System.out.println("Tracciato non inviato [" + tracciato + "]");
throw ex1;
}
}
public int notificaCRMR(String tracciato, String idEsigenza, ProcessLogger log) throws
InfobusHandlerException, IBSendException, Exception {
String buffer = null;
int reply = 0;
//preparazione dei dati per costruire una IBData
buffer = tracciato;
//Creazione IBData
try {
IBData ibData = null;
try {
ibData = new IBData(InfobusMap.IDSYSTEM_CRMR, InfobusMap.IDSRVC_CRMR,
new TID(), InfobusMap.APP_CODE_CRMR,
buffer.getBytes());
}
catch (IBException ex) {
ex.printStackTrace();
throw new IBSendException(
"Errore durante la creazione del messaggio infobus");
}
reply = request(ibData);
log.write("9999","TID: "+ibData.getTID()+", MESSAGGIO INVIATO VIA INFOBUS A: CRMR [" + new String(ibData.getData()) + "]");
return reply;
}
catch (Exception ex1) {
ex1.printStackTrace();
System.out.println("Tracciato non inviato [" + tracciato + "]");
throw ex1;
}
}
public int notificaCRMB(String tracciato, String idEsigenza, ProcessLogger log) throws
InfobusHandlerException, IBSendException, Exception {
String buffer = null;
int reply = 0;
//preparazione dei dati per costruire una IBData
buffer = tracciato;
//Creazione IBData
try {
IBData ibData = null;
try {
ibData = new IBData(InfobusMap.IDSYSTEM_CRMB, InfobusMap.IDSRVC_CRMB,
new TID(), InfobusMap.APP_CODE_CRMB,
buffer.getBytes());
}
catch (IBException ex) {
ex.printStackTrace();
throw new IBSendException(
"Errore durante la creazione del messaggio infobus");
}
reply = request(ibData);
log.write("9999","TID: "+ibData.getTID()+", MESSAGGIO INVIATO VIA INFOBUS A: CRMB [" + new String(ibData.getData()) + "]");
return reply;
}
catch (Exception ex1) {
ex1.printStackTrace();
System.out.println("Tracciato non inviato [" + tracciato + "]");
throw ex1;
}
}
private final int request(IBData ibData) throws IBSendException,
InfobusHandlerException {
int count = 0;
int reply = 0;
tim.infobus.connector.ejb.InfoBUSConnector infoBUSConnector = null;
LoaderEjbInfobus infobusEjb = null;
try {
infobusEjb = LoaderEjbInfobus.getInstance();
//Invio della notifica
while (count < redelivery && reply != 1) {
try {
//Creazione Ejb Infobus
infoBUSConnector = infobusEjb.getInfoBUSConnector();
//Invio della notifica asincrona
infoBUSConnector.request(ibData);
reply = 1;
}
catch (tim.infobus.data.IBException ibe) {
reply = 0;
System.out.println(this.getClassName() + " throws a [" +
ibe.getClass().getName() + "] 'n reports\n" +
ibe.getMessage());
count++;
if (count >= redelivery)
throw new IBSendException("Invio fallito dopo [" + redelivery +
"] tentativi");
}
}
}
catch (RemoteException re) {
System.out.println(this.getClassName() + " throws a [" +
re.getClass().getName() + "] 'n reports\n" +
re.getMessage());
throw new InfobusHandlerException(this.getClassName() + " throws a [" +
re.getClass().getName() +
"] 'n reports\n" + re.getMessage());
}
catch (LoaderEjbInfobusException ele) {
System.out.println(this.getClassName() + " throws a [" +
ele.getClass().getName() + "] 'n reports\n" +
ele.getMessage());
throw new InfobusHandlerException(this.getClassName() + " throws a [" +
ele.getClass().getName() +
"] 'n reports\n" + ele.getMessage());
}
return reply;
}
/**
* Ritorna il nome della classe
* @return
*/
private String getClassName() {
return this.getClass().getName() + " ";
}
/**
* Invia una notifica HZ al sistema DBC
* @param tracciato
* @param log
* @return
* @throws Exception
*/
public int notificaHzDBC(String tracciato, ProcessLogger log) throws Exception {
String buffer = null;
IBData reply = null;
//preparazione dei dati per costruire una IBData
buffer = tracciato;
//Creazione IBData
try {
IBData ibData = null;
try {
ibData = new IBData(InfobusMap.IDSYSTEM_DBC,
InfobusMap.IDSRVC_HZ_DBC, new TID(),
InfobusMap.APP_CODE_DBC, buffer.getBytes());
} catch (IBException ex) {
ex.printStackTrace();
throw new IBSendException(
"Errore durante la creazione del messaggio infobus");
}
reply = requestReply(ibData);
log.write("9999", "TID: " + ibData.getTID()
+ ", MESSAGGIO INVIATO VIA INFOBUS A: CRMB ["
+ new String(ibData.getData()) + "]");
return reply.getApplicationRetCode();
} catch (Exception ex1) {
ex1.printStackTrace();
System.out.println("Tracciato non inviato [" + tracciato + "]");
throw ex1;
}
}
/**
* Invio notifica sincrona a infobus
* @param ibData IBData
* @throws IBSendException
* @throws InfobusHandlerException
* @return IBData
*/
private final IBData requestReply(IBData ibData) throws IBSendException, InfobusHandlerException {
int count = 0;
IBData ibReply = null;
tim.infobus.connector.ejb.InfoBUSConnector infoBUSConnector = null;
LoaderEjbInfobus infobusEjb = null;
try {
infobusEjb = LoaderEjbInfobus.getInstance();
//Invio della notifica
while (count < redelivery && ibReply == null) {
try {
//Creazione Ejb Infobus
infoBUSConnector = infobusEjb.getInfoBUSConnector();
//Invio della notifica sincrona
ibReply = infoBUSConnector.requestReply(ibData);
}
catch (tim.infobus.data.IBException ibe) {
ibReply = null;
System.out.println(this.getClassName() + " throws a [" + ibe.getClass().getName() + "] 'n reports\n" + ibe.getMessage());
count++;
if (count >= redelivery)
throw new IBSendException("Invio fallito dopo [" + redelivery + "] tentativi");
}
}
}
catch (RemoteException re) {
System.out.println(this.getClassName() + " throws a [" + re.getClass().getName() + "] 'n reports\n" + re.getMessage());
throw new InfobusHandlerException(this.getClassName() + " throws a [" + re.getClass().getName() + "] 'n reports\n" + re.getMessage());
}
catch (LoaderEjbInfobusException ele) {
System.out.println(this.getClassName() + " throws a [" + ele.getClass().getName() + "] 'n reports\n" + ele.getMessage());
throw new InfobusHandlerException(this.getClassName() + " throws a [" + ele.getClass().getName() + "] 'n reports\n" + ele.getMessage());
}
return ibReply;
}
public int verificaCsCrmR(String tracciato, ProcessLogger log) throws
InfobusHandlerException, IBSendException, Exception {
String buffer = null;
int reply = 0;
//preparazione dei dati per costruire una IBData
buffer = tracciato;
//Creazione IBData
try {
IBData ibData = null;
try {
ibData = new IBData(InfobusMap.IDSYSTEM_VERIFICACS_CRMR, InfobusMap.IDSRVS_VERIFICACS_CRMR,
new TID(), InfobusMap.APP_VERIFICACS_CRMR,
buffer.getBytes());
}
catch (IBException ex) {
ex.printStackTrace();
throw new IBSendException(
"Errore durante la creazione del messaggio infobus");
}
reply = request(ibData);
log.write("9999","TID: "+ibData.getTID()+", MESSAGGIO INVIATO VIA INFOBUS A: CRMR [" + new String(ibData.getData()) + "]");
return reply;
}
catch (Exception ex1) {
ex1.printStackTrace();
System.out.println("Tracciato non inviato [" + tracciato + "]");
throw ex1;
}
}
public int verificaCsCrmB(String tracciato, ProcessLogger log) throws
InfobusHandlerException, IBSendException, Exception {
String buffer = null;
int reply = 0;
//preparazione dei dati per costruire una IBData
buffer = tracciato;
//Creazione IBData
try {
IBData ibData = null;
try {
ibData = new IBData(InfobusMap.IDSYSTEM_VERIFICACS_CRMB, InfobusMap.IDSRVS_VERIFICACS_CRMB,
new TID(), InfobusMap.APP_VERIFICACS_CRMB,
buffer.getBytes());
}
catch (IBException ex) {
ex.printStackTrace();
throw new IBSendException(
"Errore durante la creazione del messaggio infobus");
}
reply = request(ibData);
log.write("9999","TID: "+ibData.getTID()+", MESSAGGIO INVIATO VIA INFOBUS A: CRMB [" + new String(ibData.getData()) + "]");
return reply;
}
catch (Exception ex1) {
ex1.printStackTrace();
System.out.println("Tracciato non inviato [" + tracciato + "]");
throw ex1;
}
}
/**
* Invia una richiesta di verifica RID al sistema CRMB (processo DONOR fase III)
* @param tracciato
* @param log
* @return
* @throws Exception
*/
public String richiestaVerificaRid(String tracciato, ProcessLogger log) throws Exception {
String buffer = null;
IBData reply = null;
//preparazione dei dati per costruire una IBData
buffer = tracciato;
//Creazione IBData
try {
IBData ibData = null;
try {
ibData = new IBData(InfobusMap.IDSYSTEM_VERIFICARID_CRMB,
InfobusMap.IDSRVS_VERIFICARID_CRMB, new TID(),
InfobusMap.APP_VERIFICARID_CRMB, buffer.getBytes());
} catch (IBException ex) {
ex.printStackTrace();
throw new IBSendException(
"Errore durante la creazione del messaggio infobus");
}
reply = requestReply(ibData);
log.write("9999", "TID: " + ibData.getTID()
+ ", MESSAGGIO INVIATO VIA INFOBUS A: CRMB ["
+ new String(ibData.getData()) + "]");
return new String(reply.getData());
} catch (Exception ex1) {
ex1.printStackTrace();
System.out.println("Tracciato non inviato [" + tracciato + "]");
throw ex1;
}
}
public int notificaCRMB_VOIP35(String tracciato, ProcessLogger log) throws Exception {
String buffer = null;
int reply = 0;
//preparazione dei dati per costruire una IBData
buffer = tracciato;
//Creazione IBData
try {
IBData ibData = null;
try {
ibData = new IBData(InfobusMap.IDSYSTEM_CRMB_VOIP35, InfobusMap.IDSRVC_CRMB_VOIP35, new TID(), InfobusMap.APP_CODE_CRMB_VOIP35, buffer.getBytes());
} catch (IBException ex) {
ex.printStackTrace();
throw new IBSendException("Errore durante la creazione del messaggio infobus");
}
reply = request(ibData);
log.write("9999","TID: "+ibData.getTID()+", MESSAGGIO INVIATO VIA INFOBUS A: CRMB [" + new String(ibData.getData()) + "]");
return reply;
} catch (Exception ex1) {
ex1.printStackTrace();
System.out.println("Tracciato non inviato [" + tracciato + "]");
throw ex1;
}
}
// 152248
public void notificaCRMB_VOIP103(String tracciato, ProcessLogger log) {
// non serve
}
}

View File

@@ -0,0 +1,181 @@
package it.valueteam.gnp.proxy;
import it.valueteam.gnp.proxy.exception.LoaderEjbInfobusException;
import it.valueteam.gnp.utility.Resources;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import tim.infobus.connector.ejb.InfoBUSConnector;
import tim.infobus.connector.ejb.InfoBUSConnectorHome;
/**
* Gestisce la comunicazione con IB in uscita
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2007</p>
* <p>Company: valueteam</p>
* @author Carlo Poccia
* @version 1.0
*/
public class LoaderEjbInfobus {
private static LoaderEjbInfobus onlyInstance = null;
// Cache EJBHome object references
private InfoBUSConnectorHome ibHomeCache;
/**
* Inizializza l'oggetto di Properties propLoaderEjb
* @throws LoaderEjbInfobusException
*/
private LoaderEjbInfobus() throws LoaderEjbInfobusException {
}
/**
* Implementazione del Singleton
* @throws LoaderEjbInfobusException
* @return LoaderEjbInfobus
*/
public static LoaderEjbInfobus getInstance() throws LoaderEjbInfobusException {
if (onlyInstance == null) {
synchronized (LoaderEjbInfobus.class) {
if (onlyInstance == null)
onlyInstance = new LoaderEjbInfobus();
}
}
return onlyInstance;
}
/**
* finalize
*
* @throws Throwable
* @todo Implement this java.lang.Object method
*/
protected void finalize() throws Throwable {
super.finalize();
ibHomeCache = null;
}
private void closeContext(Context ctx) {
try {
if (ctx != null) {
ctx.close();
}
}
catch (NamingException ex) {
System.out.println("InitialContext già chiuso");
}
}
/**
* Metodo per il lookup sull'IntialContext
* @param bindingName
* @param narrowTo
* @return
* @throws EjbLoaderException
*/
private final EJBHome lookupHome(String bindingName, Class narrowTo) throws
LoaderEjbInfobusException {
Context ctx = null;
EJBHome ejbHome = null;
if (bindingName == null) {
throw new LoaderEjbInfobusException(this.getClassName() +
" Il bindingName non può essere null ");
}
if (narrowTo == null) {
throw new LoaderEjbInfobusException(this.getClassName() +
"il parametro per il narrowTo non può essere null");
}
try {
ctx = new InitialContext();
Object home = ctx.lookup(bindingName);
ejbHome = (EJBHome) PortableRemoteObject.narrow(home, narrowTo);
}
catch (NamingException ne) {
throw new LoaderEjbInfobusException(this.getClassName() + " throws a [" +
ne.getClass().getName() +
"] 'n reports\n" + ne.getMessage());
}
finally {
closeContext(ctx);
}
return ejbHome;
}
// /**
// * Effettua il lookup per ottenere la InfoBUSinHome
// * @throws EjbLoaderException
// */
// private final InfoBUSConnectorHome getInfoBUSConnectorHome() throws LoaderEjbInfobusException {
// return (InfoBUSConnectorHome) lookupHome((String)propLoaderEjb.get(INFOBUSKEY), InfoBUSinHome.class);
// }
/**
* Torna l'interfaccia remota per l'invocazione dei servizi Infobus
* @throws EjbLoaderException
*/
public InfoBUSConnector getInfoBUSConnector() throws
LoaderEjbInfobusException {
InfoBUSConnector infobus = null;
String infobusKey = Resources.getServizioInfobus();
try {
//Cache EJBHome object references
if (ibHomeCache == null) {
synchronized (this) {
if (ibHomeCache == null)
ibHomeCache = (InfoBUSConnectorHome) lookupHome(infobusKey,
InfoBUSConnectorHome.class); ;
}
}
infobus = (InfoBUSConnector) ibHomeCache.create();
}
catch (CreateException ce) {
ibHomeCache = null;
throw new LoaderEjbInfobusException(this.getClassName() + " throws a [" +
ce.getClass().getName() +
"] 'n reports\n" + ce.getMessage());
}
catch (RemoteException re) {
throw new LoaderEjbInfobusException(this.getClassName() + " throws a [" +
re.getClass().getName() +
"] 'n reports\n" + re.getMessage());
}
return infobus;
}
/**
* Ritorna il nome della classe
* @return
*/
private String getClassName() {
return this.getClass().getName() + " ";
}
//main per il test
public static void main(String[] args) {
try {
LoaderEjbInfobus LoaderEjbInfobus = new LoaderEjbInfobus();
InfoBUSConnector infobusEjb = LoaderEjbInfobus.getInfoBUSConnector();
System.out.println("InfoBUSin :[" + infobusEjb + "]");
}
catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,20 @@
package it.valueteam.gnp.proxy.exception;
/**
* <p>Title: Progetto Gateway OLO MNP</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author Marco Palmini
* @version 1.0
*/
public class InfobusHandlerException extends Exception {
public InfobusHandlerException(Exception e){
super(e.getMessage());
}
public InfobusHandlerException(String msg) {
super(msg);
}
}

View File

@@ -0,0 +1,23 @@
package it.valueteam.gnp.proxy.exception;
/**
* <p>Title: Progetto Gateway OLO MNP</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author Marco Palmini
* @version 1.0
*/
public class LoaderEjbInfobusException extends Exception
{
public LoaderEjbInfobusException(Exception e)
{
super(e.getMessage());
}
public LoaderEjbInfobusException(String msg)
{
super(msg);
}
}