GestoreRegistroThread.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */


  20. package org.openspcoop2.web.ctrlstat.gestori;

  21. import java.sql.Connection;
  22. import java.sql.Timestamp;
  23. import java.util.ArrayList;
  24. import java.util.List;

  25. import javax.jms.JMSException;
  26. import javax.jms.ObjectMessage;
  27. import javax.jms.Queue;
  28. import javax.jms.QueueConnection;
  29. import javax.jms.QueueConnectionFactory;
  30. import javax.jms.QueueReceiver;
  31. import javax.jms.QueueSession;
  32. import javax.xml.ws.BindingProvider;

  33. import org.openspcoop2.core.id.IDAccordo;
  34. import org.openspcoop2.core.id.IDAccordoCooperazione;
  35. import org.openspcoop2.core.registry.AccordoCooperazione;
  36. import org.openspcoop2.core.registry.AccordoServizioParteComune;
  37. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  38. import org.openspcoop2.core.registry.IdAccordoCooperazione;
  39. import org.openspcoop2.core.registry.IdAccordoServizioParteComune;
  40. import org.openspcoop2.core.registry.IdAccordoServizioParteSpecifica;
  41. import org.openspcoop2.core.registry.IdPortaDominio;
  42. import org.openspcoop2.core.registry.IdSoggetto;
  43. import org.openspcoop2.core.registry.PortaDominio;
  44. import org.openspcoop2.core.registry.Soggetto;
  45. import org.openspcoop2.core.registry.driver.DriverRegistroServiziNotFound;
  46. import org.openspcoop2.core.registry.driver.IDAccordoCooperazioneFactory;
  47. import org.openspcoop2.core.registry.driver.IDAccordoFactory;
  48. import org.openspcoop2.core.registry.ws.client.accordocooperazione.all.AccordoCooperazioneSoap11Service;
  49. import org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.all.AccordoServizioParteComuneSoap11Service;
  50. import org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.all.AccordoServizioParteSpecificaSoap11Service;
  51. import org.openspcoop2.core.registry.ws.client.portadominio.all.PortaDominioSoap11Service;
  52. import org.openspcoop2.core.registry.ws.client.soggetto.all.SoggettoSoap11Service;
  53. import org.openspcoop2.pdd.config.OpenSPCoop2ConfigurationException;
  54. import org.openspcoop2.utils.Utilities;
  55. import org.openspcoop2.utils.transport.jms.ExceptionListenerJMS;
  56. import org.openspcoop2.web.ctrlstat.config.ConsoleProperties;
  57. import org.openspcoop2.web.ctrlstat.config.DatasourceProperties;
  58. import org.openspcoop2.web.ctrlstat.core.ControlStationCoreException;
  59. import org.openspcoop2.web.ctrlstat.core.ControlStationLogger;
  60. import org.openspcoop2.web.ctrlstat.core.DBManager;
  61. import org.openspcoop2.web.ctrlstat.core.QueueManager;
  62. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  63. import org.openspcoop2.web.ctrlstat.costanti.OperationsParameter;
  64. import org.openspcoop2.web.ctrlstat.costanti.TipoOggettoDaSmistare;
  65. import org.openspcoop2.web.ctrlstat.servlet.ac.AccordiCooperazioneCore;
  66. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCore;
  67. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCore;
  68. import org.openspcoop2.web.ctrlstat.servlet.pdd.PddCore;
  69. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  70. import org.openspcoop2.web.lib.queue.ClassQueue;
  71. import org.openspcoop2.web.lib.queue.ClassQueueException;
  72. import org.openspcoop2.web.lib.queue.costanti.OperationStatus;
  73. import org.openspcoop2.web.lib.queue.costanti.Operazione;
  74. import org.openspcoop2.web.lib.queue.costanti.TipoOperazione;
  75. import org.openspcoop2.web.lib.queue.dao.FilterParameter;
  76. import org.openspcoop2.web.lib.queue.dao.Operation;
  77. import org.openspcoop2.web.lib.queue.dao.Parameter;
  78. import org.slf4j.Logger;

  79. /**
  80.  * GestoreRegistroThread
  81.  *
  82.  * @author Andrea Poli (apoli@link.it)
  83.  * @author Stefano Corallo (corallo@link.it)
  84.  * @author Sandra Giangrandi (sandra@link.it)
  85.  * @author $Author$
  86.  * @version $Rev$, $Date$
  87.  *
  88.  */
  89. public class GestoreRegistroThread extends GestoreGeneral {

  90.     private ConsoleProperties consoleProperties;
  91.     private DatasourceProperties datasourceProperties;
  92.    
  93.     private String name = null;
  94.    
  95.     /** run */
  96.     public boolean stop = false;
  97.     private boolean isRunning = false;
  98.     public boolean isRunning() {
  99.         return this.isRunning;
  100.     }
  101.    
  102.     /** Gestore Registro Servizi */
  103.     private SoggettiCore soggettiCore;
  104.     private PddCore pddCore;
  105.     private AccordiServizioParteComuneCore apcCore;
  106.     private AccordiServizioParteSpecificaCore apsCore;
  107.     private AccordiCooperazioneCore acCore;

  108.     // JMS
  109.     private QueueReceiver receiver = null;
  110.     private Queue queue = null;
  111.     private QueueConnectionFactory qcf = null;
  112.     private QueueConnection qc = null;
  113.     private QueueSession qs = null;

  114.     // //DB
  115.     private DBManager dbm;
  116.     private Connection con;

  117.     /** Web Service */
  118.     private org.openspcoop2.core.registry.ws.client.accordocooperazione.all.AccordoCooperazioneSoap11Service accordoCooperazioneService;
  119.     private org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.all.AccordoServizioParteComuneSoap11Service accordoServizioParteComuneService;
  120.     private org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.all.AccordoServizioParteSpecificaSoap11Service accordoServizioParteSpecificaService;
  121.     private org.openspcoop2.core.registry.ws.client.soggetto.all.SoggettoSoap11Service soggettoService;
  122.     private org.openspcoop2.core.registry.ws.client.portadominio.all.PortaDominioSoap11Service pddService;
  123.    
  124.     private org.openspcoop2.core.registry.ws.client.accordocooperazione.all.AccordoCooperazione accordoCooperazionePort;
  125.     private org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.all.AccordoServizioParteComune accordoServizioParteComunePort;
  126.     private org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.all.AccordoServizioParteSpecifica accordoServizioParteSpecificaPort;
  127.     private org.openspcoop2.core.registry.ws.client.soggetto.all.Soggetto soggettoPort;
  128.     private org.openspcoop2.core.registry.ws.client.portadominio.all.PortaDominio pddPort;

  129.     private boolean singlePdD = false;

  130.     // Logger
  131.     private Logger log;

  132.     private ExceptionListenerJMS exceptionListenerJMS = new ExceptionListenerJMS();

  133.     /** Costruttore
  134.      * @throws OpenSPCoop2ConfigurationException */
  135.     public GestoreRegistroThread() throws OpenSPCoop2ConfigurationException {
  136.        
  137.         this.log = ControlStationLogger.getGestoreRegistroLogger();
  138.         this.name = "GestoreRegistro";
  139.        
  140.         this.consoleProperties = ConsoleProperties.getInstance();
  141.         this.datasourceProperties = DatasourceProperties.getInstance();
  142.     }

  143.     /**
  144.      * Metodo che fa partire il Thread.
  145.      *
  146.      * @since 0.4
  147.      */
  148.     @Override
  149.     public void run() {

  150.         this.isRunning = true;
  151.        
  152.         // effettuo inizializzazione
  153.         try {
  154.             this.initGestore();

  155.             if (this.singlePdD) {
  156.                 this.log.warn("GestoreRegistroServizi non avviato: govwayConsole avviata in singlePdD mode.");
  157.                 return;
  158.             }

  159.             this.dbm = DBManager.getInstance();

  160.             this.log.info(this.getClass().getName() + " Inizializzato ...");
  161.         } catch (GestoreNonAttivoException e) {
  162.             this.log.warn("Inizializzazione Gestore non effettuata : " + e.getMessage());
  163.             this.stop = true;
  164.         } catch (Exception e) {
  165.             this.log.error("Inizializzazione Gestore [" + this.getClass().getName() + "] Fallita : " + e.getMessage(), e);
  166.             this.stop = true;
  167.         }

  168.         // Avvio Gestione Registro
  169.         boolean riconnessioneConErrore = false;
  170.         while (this.stop == false) {
  171.             Operation operation = null;
  172.             ClassQueue operationManager = null;
  173.             try {

  174.                 // riconnessione precedente non riuscita.....
  175.                 if (riconnessioneConErrore) {
  176.                     throw new JMSException("RiconnessioneJMS non riuscita...");
  177.                 }

  178.                 // Controllo ExceptionListenerJMS
  179.                 if (this.exceptionListenerJMS.isConnessioneCorrotta()) {
  180.                     this.log.error("ExceptionJMSListener ha rilevato una connessione jms corrotta", this.exceptionListenerJMS.getException());
  181.                     throw new JMSException("ExceptionJMSListener ha rilevato una connessione jms corrotta: " + this.exceptionListenerJMS.getException().getMessage());
  182.                 }

  183.                 this.log.info("GestoreRegistro: Ricezione operazione...");
  184.                 ObjectMessage richiesta = null;
  185.                 while (this.stop == false) {
  186.                     richiesta = (ObjectMessage) this.receiver.receive(CostantiControlStation.INTERVALLO_RECEIVE);
  187.                     if (richiesta != null) {
  188.                         break;
  189.                     }
  190.                 }
  191.                 if (this.stop == true) {
  192.                     break;
  193.                 }

  194.                 // Attendo tempi di delay (TransazioneSimilXA)
  195.                 Utilities.sleep(CostantiControlStation.INTERVALLO_TRANSAZIONE_XA);

  196.                 // Ricezione Operazione
  197.                 Object objOp;
  198.                 try {
  199.                     objOp = (Object) richiesta.getObject();
  200.                 } catch (Exception e) {
  201.                     this.log.error("GestoreRegistro: Ricevuta richiesta con tipo errato:" + e.toString());
  202.                     this.qs.commit();
  203.                     continue;
  204.                 }
  205.                 String idOperazione = richiesta.getStringProperty("ID");

  206.                 int idOp = (int) Integer.parseInt(objOp.toString());
  207.                 if (idOp == 0) {
  208.                     this.log.error("GestoreRegistro: Ricevuta richiesta con parametri scorretti.");
  209.                     this.qs.commit();
  210.                     continue;
  211.                 }

  212.                 this.log.info(CostantiControlStation.OPERATIONS_DELIMITER+"GestoreRegistro: Ricevuta richiesta di operazione con ID: " + idOperazione + " id_operation [" + idOp + "]");

  213.                 // Connessione al db
  214.                 this.con = this.dbm.getConnection();

  215.                 // Prendo i dati dell'operazione
  216.                 String tipoOperazioneParam = "", tipoOperazioneCRUDParam = "", singleSu = "";
  217.                 int deleted = 0;
  218.                 operationManager = new ClassQueue(this.con, this.datasourceProperties.getTipoDatabase());
  219.                 try {
  220.                     operation = operationManager.getOperation(idOp);
  221.                 } catch (Exception e) {
  222.                     this.log.error("Impossibile recuperare l'operation con id=" + idOp, e);
  223.                     this.qs.rollback();
  224.                     this.dbm.releaseConnection(this.con);
  225.                     continue;
  226.                 }
  227.                 tipoOperazioneParam = operation.getTipo();
  228.                 tipoOperazioneCRUDParam = operation.getOperation();
  229.                 singleSu = operation.getSuperUser();
  230.                 deleted = operation.isDeleted() ? 1 : 0;

  231.                 // Operazione in gestione
  232.                 GestioneOperazione operazioneInGestione = new GestioneOperazione(this.dbm, this.con, this.qs, operation, operationManager,
  233.                         this.log, tipoOperazioneCRUDParam, "GestoreRegistro");

  234.                 // Oggetto in Gestione
  235.                 String oggettoDaSmistare = operation.getParameterValue(OperationsParameter.OGGETTO.getNome());
  236.                 if (oggettoDaSmistare == null || "".equals(oggettoDaSmistare)) {
  237.                     operazioneInGestione.invalid("Ricevuta operazione con parametri scorretti (oggetto:" + oggettoDaSmistare + ") non valida");
  238.                     continue;
  239.                 }
  240.                 TipoOggettoDaSmistare tipoOggettoDaSmistare = null;
  241.                 try{
  242.                     tipoOggettoDaSmistare = TipoOggettoDaSmistare.valueOf(oggettoDaSmistare);
  243.                     if(tipoOggettoDaSmistare==null){
  244.                         throw new Exception("Conversione in Enumeration non riuscita");
  245.                     }
  246.                 }catch(Exception e){
  247.                     this.log.error("Ricevuta operazione con parametri scorretti (oggetto:" + oggettoDaSmistare + ") non valida: "+e.getMessage(), e);
  248.                     operazioneInGestione.invalid("Ricevuta operazione con parametri scorretti (oggetto:" + oggettoDaSmistare + ") non valida: "+e.getMessage());
  249.                     continue;
  250.                 }

  251.                 // Check valori operazioni
  252.                 if ((tipoOperazioneParam == null) || tipoOperazioneParam.equals("") || (tipoOperazioneCRUDParam == null) || tipoOperazioneCRUDParam.equals("") || (singleSu == null) || singleSu.equals("")) {
  253.                     operazioneInGestione.invalid("Ricevuta operazione con parametri scorretti :" + operation.toString());
  254.                     continue;
  255.                 }
  256.                
  257.                 // Operazione CRUD      
  258.                 Operazione tipoOperazioneCRUD = null;
  259.                 try{
  260.                     tipoOperazioneCRUD = Operazione.valueOf(tipoOperazioneCRUDParam);
  261.                     if(tipoOperazioneCRUD==null){
  262.                         throw new Exception("Conversione in Enumeration non riuscita");
  263.                     }
  264.                 }catch(Exception e){
  265.                     this.log.error("Ricevuta operazione con parametri scorretti (tipoOperazioneCRUD:" + tipoOperazioneCRUDParam + ") non valida: "+e.getMessage(), e);
  266.                     operazioneInGestione.invalid("Ricevuta operazione con parametri scorretti (tipoOperazioneCRUD:" + tipoOperazioneCRUDParam + ") non valida: "+e.getMessage());
  267.                     continue;
  268.                 }
  269.                
  270.                 // Operazione Queue
  271.                 TipoOperazione tipoOperazione = null;
  272.                 try{
  273.                     tipoOperazione = TipoOperazione.valueOf(tipoOperazioneParam);
  274.                     if(tipoOperazione==null){
  275.                         throw new Exception("Conversione in Enumeration non riuscita");
  276.                     }
  277.                 }catch(Exception e){
  278.                     this.log.error("Ricevuta operazione con parametri scorretti (tipoOperazione:" + tipoOperazioneParam + ") non valida: "+e.getMessage(), e);
  279.                     operazioneInGestione.invalid("Ricevuta operazione con parametri scorretti (tipoOperazione:" + tipoOperazioneParam + ") non valida: "+e.getMessage());
  280.                     continue;
  281.                 }
  282.                
  283.                 this.log.debug("Ricevuta Operation:" + operation.toString());

  284.                 // ID Table
  285.                 int idTable = -1;
  286.                 String idTableString = null;
  287.                 try {
  288.                     idTableString = operation.getParameterValue(OperationsParameter.ID_TABLE.getNome());
  289.                     idTable = Integer.parseInt(idTableString);
  290.                     if (idTable <= 0)
  291.                         throw new Exception("IDTable <= 0");
  292.                 } catch (Exception e) {
  293.                     operazioneInGestione.invalid("Ricevuta operazione con parametri scorretti (idTable[" + idTableString + "]) non valida: " + e.getMessage());
  294.                     continue;
  295.                 }

  296.                
  297.                 if (!TipoOggettoDaSmistare.soggetto.equals(tipoOggettoDaSmistare) &&
  298.                         //!TipoOggettoDaSmistare.fruitore.equals(tipoOggettoDaSmistare) &&
  299.                         !TipoOggettoDaSmistare.servizio.equals(tipoOggettoDaSmistare) &&
  300.                         !TipoOggettoDaSmistare.accordo.equals(tipoOggettoDaSmistare) &&
  301.                         !TipoOggettoDaSmistare.accordoCooperazione.equals(tipoOggettoDaSmistare) &&
  302.                         !TipoOggettoDaSmistare.pdd.equals(tipoOggettoDaSmistare)) {
  303.                     operazioneInGestione.invalid("Ricevuta operazione con parametri scorretti (oggetto:" + tipoOggettoDaSmistare.name() + ")");
  304.                     continue;
  305.                 }
  306.                
  307.                 if (!TipoOperazione.webService.equals(tipoOperazione)) {
  308.                     operazioneInGestione.invalid("Ricevuta operazione con parametri scorretti (tipo operazione:" + tipoOperazione.name() + " non supportata dal gestore)");
  309.                     continue;
  310.                 }


  311.                 /* ----- filtro per mantenimento ordine operazioni ----- */
  312.                 List<FilterParameter> filtroOrdine = new ArrayList<FilterParameter>();

  313.                 FilterParameter idTableFiltro = new FilterParameter();
  314.                 idTableFiltro.addFilterParameter(new Parameter(OperationsParameter.ID_TABLE.getNome(), idTable + ""));
  315.                 filtroOrdine.add(idTableFiltro);

  316.                 if (TipoOggettoDaSmistare.pdd.equals(tipoOggettoDaSmistare)) {

  317.                     // Chiave primaria per il soggetto e' nome
  318.                     String nomePddFiltro = operation.getParameterValue(OperationsParameter.PORTA_DOMINIO.getNome());
  319.                     FilterParameter asPdd = new FilterParameter();
  320.                     asPdd.addFilterParameter(new Parameter(OperationsParameter.PORTA_DOMINIO.getNome(), nomePddFiltro));
  321.                     filtroOrdine.add(asPdd);

  322.                 } else if (TipoOggettoDaSmistare.soggetto.equals(tipoOggettoDaSmistare)) {

  323.                     // Chiave primaria per il soggetto e' tipo e nome
  324.                     String tipoSoggFiltro = operation.getParameterValue(OperationsParameter.TIPO_SOGGETTO.getNome());
  325.                     String nomeSoggFiltro = operation.getParameterValue(OperationsParameter.NOME_SOGGETTO.getNome());
  326.                     FilterParameter soggettoFiltro = new FilterParameter();
  327.                     soggettoFiltro.addFilterParameter(new Parameter(OperationsParameter.TIPO_SOGGETTO.getNome(), tipoSoggFiltro));
  328.                     soggettoFiltro.addFilterParameter(new Parameter(OperationsParameter.NOME_SOGGETTO.getNome(), nomeSoggFiltro));
  329.                     filtroOrdine.add(soggettoFiltro);

  330.                     // OLD valori per tipo e nome se abbiamo una operazione di
  331.                     // change
  332.                     if (Operazione.change.equals(tipoOperazioneCRUD)) {
  333.                         String oldTipoSogg = operation.getParameterValue(OperationsParameter.OLD_TIPO_SOGGETTO.getNome());
  334.                         String oldNomeSogg = operation.getParameterValue(OperationsParameter.OLD_NOME_SOGGETTO.getNome());
  335.                         FilterParameter soggettoOldFiltro = new FilterParameter();
  336.                         soggettoOldFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_TIPO_SOGGETTO.getNome(), oldTipoSogg));
  337.                         soggettoOldFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_NOME_SOGGETTO.getNome(), oldNomeSogg));
  338.                         filtroOrdine.add(soggettoOldFiltro);
  339.                     }
  340.                 } else if (TipoOggettoDaSmistare.servizio.equals(tipoOggettoDaSmistare)
  341.                     //  || TipoOggettoDaSmistare.fruitore.equals(tipoOggettoDaSmistare)
  342.                         ) {

  343.                     // Chiave primaria che identifica un servizio e'
  344.                     // soggettoErogatore e servizio
  345.                     String tipoSoggFiltro = operation.getParameterValue(OperationsParameter.TIPO_SOGGETTO.getNome());
  346.                     String nomeSoggFiltro = operation.getParameterValue(OperationsParameter.NOME_SOGGETTO.getNome());
  347.                     String tipoServFiltro = operation.getParameterValue(OperationsParameter.TIPO_SERVIZIO.getNome());
  348.                     String nomeServFiltro = operation.getParameterValue(OperationsParameter.NOME_SERVIZIO.getNome());
  349.                     String nomeAccordo = operation.getParameterValue(OperationsParameter.NOME_ACCORDO.getNome());
  350.                     String versioneAccordo = operation.getParameterValue(OperationsParameter.VERSIONE_ACCORDO.getNome());
  351.                    
  352.                     //System.out.println("SERVIZIO  TS["+tipoSoggFiltro+"] NS["+nomeSoggFiltro+"] TSV["+tipoServFiltro+"] NSV["+nomeServFiltro+"]");
  353.                    
  354.                     FilterParameter servizioFiltro = new FilterParameter();
  355.                     servizioFiltro.addFilterParameter(new Parameter(OperationsParameter.TIPO_SOGGETTO.getNome(), tipoSoggFiltro));
  356.                     servizioFiltro.addFilterParameter(new Parameter(OperationsParameter.NOME_SOGGETTO.getNome(), nomeSoggFiltro));
  357.                     servizioFiltro.addFilterParameter(new Parameter(OperationsParameter.TIPO_SERVIZIO.getNome(), tipoServFiltro));
  358.                     servizioFiltro.addFilterParameter(new Parameter(OperationsParameter.NOME_SERVIZIO.getNome(), nomeServFiltro));
  359.                     servizioFiltro.addFilterParameter(new Parameter(OperationsParameter.NOME_ACCORDO.getNome(), nomeAccordo));
  360.                     servizioFiltro.addFilterParameter(new Parameter(OperationsParameter.VERSIONE_ACCORDO.getNome(), versioneAccordo));
  361.                     filtroOrdine.add(servizioFiltro);

  362.                     // OLD valori per tipo e nome se abbiamo una operazione di
  363.                     // change del servizio o add/del di fruitore
  364.                     if ((Operazione.change.equals(tipoOperazioneCRUD))
  365.                         //  || (TipoOggettoDaSmistare.fruitore.equals(tipoOggettoDaSmistare))
  366.                             ) {
  367.                         String oldtipoServizio = operation.getParameterValue(OperationsParameter.OLD_TIPO_SERVIZIO.getNome());
  368.                         String oldNomeServizio = operation.getParameterValue(OperationsParameter.OLD_NOME_SERVIZIO.getNome());

  369.                         String oldTipoSogg = operation.getParameterValue(OperationsParameter.OLD_TIPO_SOGGETTO.getNome());
  370.                         String oldNomeSogg = operation.getParameterValue(OperationsParameter.OLD_NOME_SOGGETTO.getNome());
  371.                        
  372.                         String oldNomeAccordo = operation.getParameterValue(OperationsParameter.OLD_NOME_ACCORDO.getNome());
  373.                         String oldVersioneAccordo = operation.getParameterValue(OperationsParameter.OLD_VERSIONE_ACCORDO.getNome());

  374.                         FilterParameter servizioOldFiltro = new FilterParameter();
  375.                         if( (oldTipoSogg!=null && oldNomeSogg!=null) || (oldtipoServizio!=null && oldNomeServizio!=null) || oldNomeAccordo!=null || oldVersioneAccordo!=null ){
  376.                             if(oldTipoSogg!=null && oldNomeSogg!=null){
  377.                                 servizioOldFiltro.addFilterParameter(new Parameter(OperationsParameter.TIPO_SOGGETTO.getNome(), oldTipoSogg));
  378.                                 servizioOldFiltro.addFilterParameter(new Parameter(OperationsParameter.NOME_SOGGETTO.getNome(), oldNomeSogg));
  379.                             }else{
  380.                                 servizioOldFiltro.addFilterParameter(new Parameter(OperationsParameter.TIPO_SOGGETTO.getNome(), tipoSoggFiltro));
  381.                                 servizioOldFiltro.addFilterParameter(new Parameter(OperationsParameter.NOME_SOGGETTO.getNome(), nomeSoggFiltro));
  382.                             }
  383.                             if(oldtipoServizio!=null && oldNomeServizio!=null){
  384.                                 servizioOldFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_TIPO_SERVIZIO.getNome(), oldtipoServizio));
  385.                                 servizioOldFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_NOME_SERVIZIO.getNome(), oldNomeServizio));
  386.                             }else{
  387.                                 servizioOldFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_TIPO_SERVIZIO.getNome(), tipoServFiltro));
  388.                                 servizioOldFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_NOME_SERVIZIO.getNome(), nomeServFiltro));
  389.                             }
  390.                             if(oldNomeAccordo!=null){
  391.                                 servizioOldFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_NOME_ACCORDO.getNome(), oldNomeAccordo));
  392.                             }
  393.                             else{
  394.                                 servizioOldFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_NOME_ACCORDO.getNome(), nomeAccordo));
  395.                             }
  396.                             if(oldVersioneAccordo!=null){
  397.                                 servizioOldFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_VERSIONE_ACCORDO.getNome(), oldVersioneAccordo));
  398.                             }
  399.                             else{
  400.                                 servizioOldFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_VERSIONE_ACCORDO.getNome(), versioneAccordo));
  401.                             }
  402.                             filtroOrdine.add(servizioOldFiltro);
  403.                         }
  404.                     }
  405.                 } else if (TipoOggettoDaSmistare.accordo.equals(tipoOggettoDaSmistare)) {

  406.                     // Chiave primaria che identifica l'accordo e' il nome
  407.                     String nomeAccFiltro = operation.getParameterValue(OperationsParameter.NOME_ACCORDO.getNome());
  408.                     String versioneAccFiltro = operation.getParameterValue(OperationsParameter.VERSIONE_ACCORDO.getNome());
  409.                     String tipoReferenteAccFiltro = operation.getParameterValue(OperationsParameter.TIPO_REFERENTE.getNome());
  410.                     String nomeReferenteAccFiltro = operation.getParameterValue(OperationsParameter.NOME_REFERENTE.getNome());
  411.                     //System.out.println("ACCORDO  ["+nomeAccFiltro+"] ["+versioneAccFiltro+"] ["+tipoReferenteAccFiltro+"] ["+nomeReferenteAccFiltro+"]");
  412.                    
  413.                     FilterParameter asFiltro = new FilterParameter();
  414.                     asFiltro.addFilterParameter(new Parameter(OperationsParameter.NOME_ACCORDO.getNome(), nomeAccFiltro));
  415.                     asFiltro.addFilterParameter(new Parameter(OperationsParameter.VERSIONE_ACCORDO.getNome(), versioneAccFiltro));
  416.                     asFiltro.addFilterParameter(new Parameter(OperationsParameter.TIPO_REFERENTE.getNome(), tipoReferenteAccFiltro));
  417.                     asFiltro.addFilterParameter(new Parameter(OperationsParameter.NOME_REFERENTE.getNome(), nomeReferenteAccFiltro));
  418.                     filtroOrdine.add(asFiltro);
  419.                    
  420.                     // OLD valori se siamo in una operazione di
  421.                     // change dell'accordo
  422.                     if ((Operazione.change.equals(tipoOperazioneCRUD))){
  423.                         // Chiave primaria che identifica l'accordo e' il nome,soggettoreferente,versione
  424.                         String nomeOLDAccFiltro = operation.getParameterValue(OperationsParameter.OLD_NOME_ACCORDO.getNome());
  425.                         String versioneOLDAccFiltro = operation.getParameterValue(OperationsParameter.OLD_VERSIONE_ACCORDO.getNome());
  426.                         String tipoReferenteOLDAccFiltro = operation.getParameterValue(OperationsParameter.OLD_TIPO_REFERENTE.getNome());
  427.                         String nomeReferenteOLDAccFiltro = operation.getParameterValue(OperationsParameter.OLD_NOME_REFERENTE.getNome());
  428.                         //System.out.println("OLD ACCORDO  ["+nomeOLDAccFiltro+"] ["+versioneOLDAccFiltro+"] ["+tipoReferenteOLDAccFiltro+"] ["+nomeReferenteOLDAccFiltro+"]");
  429.                        
  430.                         FilterParameter asOLDFiltro = new FilterParameter();
  431.                         asOLDFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_NOME_ACCORDO.getNome(), nomeOLDAccFiltro));
  432.                         asOLDFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_VERSIONE_ACCORDO.getNome(), versioneOLDAccFiltro));
  433.                         asOLDFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_TIPO_REFERENTE.getNome(), tipoReferenteOLDAccFiltro));
  434.                         asOLDFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_NOME_REFERENTE.getNome(), nomeReferenteOLDAccFiltro));
  435.                         filtroOrdine.add(asOLDFiltro);
  436.                     }
  437.                 }else if (TipoOggettoDaSmistare.accordoCooperazione.equals(tipoOggettoDaSmistare)) {
  438.                     // Chiave primaria che identifica l'accordo e' il nome,versione
  439.                     String nomeAccFiltro = operation.getParameterValue(OperationsParameter.NOME_ACCORDO.getNome());
  440.                     String versioneAccFiltro = operation.getParameterValue(OperationsParameter.VERSIONE_ACCORDO.getNome());
  441.                     //System.out.println("ACCORDO COOPERAZIONE  ["+nomeAccFiltro+"] ["+versioneAccFiltro+"]");
  442.                        
  443.                     FilterParameter acFiltro = new FilterParameter();
  444.                     acFiltro.addFilterParameter(new Parameter(OperationsParameter.NOME_ACCORDO.getNome(), nomeAccFiltro));
  445.                     acFiltro.addFilterParameter(new Parameter(OperationsParameter.VERSIONE_ACCORDO.getNome(), versioneAccFiltro));
  446.                     filtroOrdine.add(acFiltro);
  447.                        
  448.                     // OLD valori se siamo in una operazione di
  449.                     // change dell'accordo
  450.                     if ((Operazione.change.equals(tipoOperazioneCRUD))){
  451.                         // Chiave primaria che identifica l'accordo e' il nome,versione
  452.                         String nomeOLDAccFiltro = operation.getParameterValue(OperationsParameter.OLD_NOME_ACCORDO.getNome());
  453.                         String versioneOLDAccFiltro = operation.getParameterValue(OperationsParameter.OLD_VERSIONE_ACCORDO.getNome());
  454.                         //System.out.println("OLD ACCORDO COOPERAZIONE  ["+nomeOLDAccFiltro+"] ["+versioneOLDAccFiltro+"]");
  455.                        
  456.                         FilterParameter asOLDFiltro = new FilterParameter();
  457.                         asOLDFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_NOME_ACCORDO.getNome(), nomeOLDAccFiltro));
  458.                         asOLDFiltro.addFilterParameter(new Parameter(OperationsParameter.OLD_VERSIONE_ACCORDO.getNome(), versioneOLDAccFiltro));
  459.                         filtroOrdine.add(asOLDFiltro);
  460.                     }
  461.                 }else {
  462.                     operazioneInGestione.invalid("Ricevuta operazione con oggetto non conosciuto dal Gestore (oggetto:" + tipoOggettoDaSmistare.name() + ")");
  463.                     continue;
  464.                 }

  465.                 operationManager.setOperazioniPrecedentiByFilterSearch(operation, filtroOrdine.toArray(new FilterParameter[0]), false, tipoOggettoDaSmistare.name());
  466.                 if (operation.sizeOperazioniPrecedentiAncoraDaGestireList() > 0) {
  467.                     StringBuilder operazioniPrecedenti = new StringBuilder();
  468.                     for (int i = 0; i < operation.sizeOperazioniPrecedentiAncoraDaGestireList(); i++) {
  469.                         operazioniPrecedenti.append("\n" + operation.getOperazionePrecedenteAncoraDaGestire(i).toString());
  470.                     }
  471.                     operazioneInGestione.error("Ricevuta operazione su una entita' di cui esistono operazioni attivate precedentementi ancora in coda:\n" + operazioniPrecedenti.toString());
  472.                     continue;
  473.                 }

  474.                 /* ----- Fine filtro per mantenimento ordine operazioni ----- */

  475.                 // Se l'operazione e' stata marcata come deleted, la rimuovo
  476.                 // dalla coda (basta fare il commit)
  477.                 String statoOperazioneCancellata = "";
  478.                 if (deleted == 1) {

  479.                     operazioneInGestione.delete();
  480.                     statoOperazioneCancellata = " (L'operazione non e' stata propagata, possiede una stato 'deleted')";

  481.                 } else {

  482.                     // Effettuo filtro di altre modifiche con stesso
  483.                     // idOperazione
  484.                     if (Operazione.change.equals(tipoOperazioneCRUD)) {
  485.                        
  486.                         List<Operation> listFilteredOperations = filterOperations(idOperazione, operationManager, operation, this.qs, this.queue, this.log);

  487.                         if (listFilteredOperations.size() > 0) {
  488.                             StringBuilder bf = new StringBuilder();
  489.                             for (Operation operationFiltered : listFilteredOperations) {
  490.                                 if(bf.length()>0){
  491.                                     bf.append(",");
  492.                                 }
  493.                                 bf.append(operationFiltered.getId());
  494.                             }
  495.                             this.log.debug(getName() + ": Filtrate [" + listFilteredOperations.size() + "] operation con stessa property jms ['ID'="+idOperazione+"] (ids: "+bf.toString()+")");
  496.                         }
  497.                     }

  498.                     /*  SOGGETTI */
  499.                     if (TipoOggettoDaSmistare.soggetto.equals(tipoOggettoDaSmistare)) {

  500.                         String oldTipoSogg = operation.getParameterValue(OperationsParameter.OLD_TIPO_SOGGETTO.getNome());
  501.                         String oldNomeSogg = operation.getParameterValue(OperationsParameter.OLD_NOME_SOGGETTO.getNome());
  502.                         String tipoSogg = operation.getParameterValue(OperationsParameter.TIPO_SOGGETTO.getNome());
  503.                         String nomeSogg = operation.getParameterValue(OperationsParameter.NOME_SOGGETTO.getNome());

  504.                         // CREAZIONE/MODIFICA
  505.                         if (Operazione.change.equals(tipoOperazioneCRUD) || Operazione.add.equals(tipoOperazioneCRUD)) {

  506.                             // Ottengo nuova immagine del soggetto
  507.                             Soggetto soggetto = null;
  508.                             try {
  509.                                 soggetto = this.soggettiCore.getSoggettoRegistro(idTable);
  510.                                 this.log.debug("Caricato soggetto :" + soggetto.getNome());
  511.                             } catch (DriverRegistroServiziNotFound de) {
  512.                                 operazioneInGestione.waitBeforeInvalid("Soggetto non esistente nel database della govwayConsole: " + de.toString());
  513.                                 continue;
  514.                             } catch (Exception e) {
  515.                                 operazioneInGestione.error("Riscontrato errore durante la get dell'immagine del soggetto: " + e.toString(), e);
  516.                                 continue;
  517.                             }

  518.                             // Propago in remoto sul registro
  519.                             try {
  520.                                 if (Operazione.add.equals(tipoOperazioneCRUD)) {
  521.                                     this.soggettoPort.create(soggetto);
  522.                                 } else if (Operazione.change.equals(tipoOperazioneCRUD)) {
  523.                                     IdSoggetto oldIdSoggetto = new IdSoggetto();
  524.                                     if(oldTipoSogg!=null)
  525.                                         oldIdSoggetto.setTipo(oldTipoSogg);
  526.                                     else
  527.                                         oldIdSoggetto.setTipo(tipoSogg);
  528.                                     if(oldNomeSogg!=null)
  529.                                         oldIdSoggetto.setNome(oldNomeSogg);
  530.                                     else
  531.                                         oldIdSoggetto.setNome(nomeSogg);
  532.                                     this.soggettoPort.update(oldIdSoggetto, soggetto);
  533.                                 }
  534.                             } catch (Exception e) {
  535.                                 operazioneInGestione.error("Riscontrato errore di creazione/update soggetto: " + e.toString(), e);
  536.                                 continue;
  537.                             }

  538.                         }
  539.                         // ELIMINAZIONE
  540.                         else if (Operazione.del.equals(tipoOperazioneCRUD)) {
  541.                             try {
  542.                                 // Effettuo operazione sul registro
  543.                                 IdSoggetto idSoggetto = new IdSoggetto();
  544.                                 idSoggetto.setTipo(tipoSogg);
  545.                                 idSoggetto.setNome(nomeSogg);
  546.                                 this.soggettoPort.deleteById(idSoggetto);
  547.                             } catch (Exception e) {
  548.                                 operazioneInGestione.error("Riscontrato errore di eliminazione soggetto: " + e.toString(), e);
  549.                                 continue;
  550.                             }

  551.                         }
  552.                     }

  553.                     /*  ACCORDO DI SERVIZIO PARTE SPECIFICA */
  554.                     if (TipoOggettoDaSmistare.servizio.equals(tipoOggettoDaSmistare)
  555.                         //  || TipoOggettoDaSmistare.fruitore.equals(tipoOggettoDaSmistare)
  556.                             ) {

  557.                         AccordoServizioParteSpecifica accordoServizioParteSpecifica = null;
  558.                        
  559.                         String tipoServizio = operation.getParameterValue(OperationsParameter.TIPO_SERVIZIO.getNome());
  560.                         String nomeServizio = operation.getParameterValue(OperationsParameter.NOME_SERVIZIO.getNome());
  561.                         String tipoSogg = operation.getParameterValue(OperationsParameter.TIPO_SOGGETTO.getNome());
  562.                         String nomeSogg = operation.getParameterValue(OperationsParameter.NOME_SOGGETTO.getNome());
  563.                         String versioneServizio = operation.getParameterValue(OperationsParameter.VERSIONE_ACCORDO.getNome());
  564.                        
  565.                         String oldTipoServizio = operation.getParameterValue(OperationsParameter.OLD_TIPO_SERVIZIO.getNome());
  566.                         String oldNomeServizio = operation.getParameterValue(OperationsParameter.OLD_NOME_SERVIZIO.getNome());
  567.                         String oldTipoSogg = operation.getParameterValue(OperationsParameter.OLD_TIPO_SOGGETTO.getNome());
  568.                         String oldNomeSogg = operation.getParameterValue(OperationsParameter.OLD_NOME_SOGGETTO.getNome());
  569.                         String oldVersioneServizio = operation.getParameterValue(OperationsParameter.OLD_VERSIONE_ACCORDO.getNome());

  570.                         // CREAZIONE/MODIFICA
  571.                         if (
  572.                                 (
  573.                                         Operazione.change.equals(tipoOperazioneCRUD)
  574.                                 )
  575.                             ||
  576.                                 (
  577.                                         Operazione.add.equals(tipoOperazioneCRUD)
  578.                                 )
  579. //                          ||
  580. //                              (
  581. //                                      TipoOggettoDaSmistare.fruitore.equals(tipoOggettoDaSmistare) && Operazione.del.equals(tipoOperazioneCRUD)
  582. //                              )
  583.                             ) {

  584.                             // Ottengo nuova immagine del servizio
  585.                             try {
  586.                                 accordoServizioParteSpecifica = this.apsCore.getAccordoServizioParteSpecifica(idTable,true);
  587.                             } catch (DriverRegistroServiziNotFound de) {
  588.                                 operazioneInGestione.waitBeforeInvalid("Servizio non esistente nel database della govwayConsole: " + de.toString());
  589.                                 continue;
  590.                             } catch (Exception e) {
  591.                                 operazioneInGestione.error("Riscontrato errore durante la get dell'immagine del servizio: " + e.getMessage(), e);
  592.                                 continue;
  593.                             }

  594.                             // Propago in remoto sul registro
  595.                             try {
  596.                                 // Effettuo operazione sul registro
  597.                                 if (TipoOggettoDaSmistare.servizio.equals(tipoOggettoDaSmistare) && Operazione.add.equals(tipoOperazioneCRUD)) {

  598.                                     this.accordoServizioParteSpecificaPort.create(accordoServizioParteSpecifica);

  599.                                     // se operazione change oppure add (e
  600.                                     // ovviamente change) del fruitore
  601.                                     // allora eseguo la modificaServizio
  602.                                 } else if (TipoOggettoDaSmistare.servizio.equals(tipoOggettoDaSmistare) && Operazione.change.equals(tipoOperazioneCRUD)) {

  603.                                     IdAccordoServizioParteSpecifica idAccordoServizioParteSpecifica = new IdAccordoServizioParteSpecifica();
  604.                                     if(oldTipoServizio!=null){
  605.                                         idAccordoServizioParteSpecifica.setNome(oldTipoServizio);
  606.                                     }else{
  607.                                         idAccordoServizioParteSpecifica.setNome(tipoServizio);
  608.                                     }
  609.                                     if(oldNomeServizio!=null){
  610.                                         idAccordoServizioParteSpecifica.setNome(oldNomeServizio);
  611.                                     }else{
  612.                                         idAccordoServizioParteSpecifica.setNome(nomeServizio);
  613.                                     }
  614.                                     if(oldVersioneServizio!=null){
  615.                                         idAccordoServizioParteSpecifica.setVersione(Integer.parseInt(oldVersioneServizio));
  616.                                     }
  617.                                     else{
  618.                                         idAccordoServizioParteSpecifica.setVersione(Integer.parseInt(versioneServizio));
  619.                                     }
  620.                                     idAccordoServizioParteSpecifica.setSoggettoErogatore(new IdSoggetto());
  621.                                     idAccordoServizioParteSpecifica.getSoggettoErogatore().setTipo(tipoSogg);
  622.                                     idAccordoServizioParteSpecifica.getSoggettoErogatore().setNome(nomeSogg);
  623.                                    
  624.                                     if(oldTipoSogg!=null && oldNomeSogg!=null){
  625.                                         // Check se operazione di change che  l'operazione di modifica del soggetto non sia ancora in rollback.
  626.                                         // Se sussite, aspetto l'operazione.
  627.                                         FilterParameter filtro = operazioneInGestione.getFilterChangeIDSoggetto(tipoSogg,nomeSogg,oldTipoSogg,oldNomeSogg);                                    
  628.                                         if(operazioneInGestione.existsOperationNotCompleted("change", operation.getHostname(), filtro)){
  629.                                             idAccordoServizioParteSpecifica.getSoggettoErogatore().setTipo(oldTipoSogg);
  630.                                             idAccordoServizioParteSpecifica.getSoggettoErogatore().setNome(oldNomeSogg);
  631.                                             this.log.debug("ChangeServizio: operazione change ID Soggetto non ancora completata: utilizzo OLD nome");
  632.                                         }else{
  633.                                             this.log.debug("ChangeServizio: operazione change ID Soggetto completata: utilizzo nome");
  634.                                         }
  635.                                     }
  636.                                    
  637.                                     // NOTA: Il soggetto del servizio, nella govwayConsole non e' modificabile.
  638.                                     this.accordoServizioParteSpecificaPort.update(idAccordoServizioParteSpecifica, accordoServizioParteSpecifica);

  639.                                 }
  640.                                 /*
  641.                                 else if (TipoOggettoDaSmistare.fruitore.equals(tipoOggettoDaSmistare)) {

  642.                                     IdAccordoServizioParteSpecifica idAccordoServizioParteSpecifica = new IdAccordoServizioParteSpecifica();
  643.                                     idAccordoServizioParteSpecifica.setNome(nomeAccordo);
  644.                                     idAccordoServizioParteSpecifica.setVersione(versioneAccordo);
  645.                                     idAccordoServizioParteSpecifica.setSoggettoErogatore(new IdSoggetto());
  646.                                     idAccordoServizioParteSpecifica.getSoggettoErogatore().setTipo(tipoSogg);
  647.                                     idAccordoServizioParteSpecifica.getSoggettoErogatore().setNome(nomeSogg);
  648.                                    
  649.                                     this.accordoServizioParteSpecificaPort.update(idAccordoServizioParteSpecifica, accordoServizioParteSpecifica);
  650.                                 }
  651.                                 */
  652.                                
  653.                             } catch (Exception e) {
  654.                                 operazioneInGestione.error("Riscontrato errore di creazione/update servizio: " + e.toString(), e);
  655.                                 continue;
  656.                             }
  657.                         }

  658.                         // ELIMINAZIONE servizio
  659.                         else if (TipoOggettoDaSmistare.servizio.equals(tipoOggettoDaSmistare) && Operazione.del.equals(tipoOperazioneCRUD)) {

  660.                             try {
  661.                                 IdAccordoServizioParteSpecifica idAccordoServizioParteSpecifica = new IdAccordoServizioParteSpecifica();
  662.                                 idAccordoServizioParteSpecifica.setTipo(tipoServizio);
  663.                                 idAccordoServizioParteSpecifica.setNome(nomeServizio);
  664.                                 idAccordoServizioParteSpecifica.setVersione(Integer.parseInt(versioneServizio));
  665.                                 idAccordoServizioParteSpecifica.setSoggettoErogatore(new IdSoggetto());
  666.                                 idAccordoServizioParteSpecifica.getSoggettoErogatore().setTipo(tipoSogg);
  667.                                 idAccordoServizioParteSpecifica.getSoggettoErogatore().setNome(nomeSogg);
  668.                                
  669.                                 this.accordoServizioParteSpecificaPort.deleteById(idAccordoServizioParteSpecifica);
  670.                                
  671.                             } catch (Exception e) {
  672.                                 operazioneInGestione.error("Riscontrato errore di eliminazione servizio: " + e.toString(), e);
  673.                                 continue;
  674.                             }
  675.                         }
  676.                     }

  677.                     // * ***** ACCORDI DI SERVIZIO PARTE COMUNE ***** */
  678.                     if (TipoOggettoDaSmistare.accordo.equals(tipoOggettoDaSmistare)) {

  679.                         String nomeAcc = operation.getParameterValue(OperationsParameter.NOME_ACCORDO.getNome());
  680.                         String versioneAcc = operation.getParameterValue(OperationsParameter.VERSIONE_ACCORDO.getNome());
  681.                         Integer versioneAccordoInt = Integer.parseInt(versioneAcc);
  682.                         String tipoReferenteAcc = operation.getParameterValue(OperationsParameter.TIPO_REFERENTE.getNome());
  683.                         String nomeReferenteAcc = operation.getParameterValue(OperationsParameter.NOME_REFERENTE.getNome());
  684.                         IDAccordo idAccordoServizioParteComune =
  685.                                 IDAccordoFactory.getInstance().getIDAccordoFromValues(nomeAcc,tipoReferenteAcc,nomeReferenteAcc,versioneAccordoInt);

  686.                         AccordoServizioParteComune accordoServizioParteComune = null;
  687.                        
  688.                         // CREAZIONE/MODIFICA
  689.                         if (Operazione.change.equals(tipoOperazioneCRUD) || Operazione.add.equals(tipoOperazioneCRUD)) {

  690.                             // Ottengo nuova immagine dell'accordo
  691.                             try {
  692.                                 accordoServizioParteComune = this.apcCore.getAccordoServizioFull(idAccordoServizioParteComune,true);
  693.                             } catch (DriverRegistroServiziNotFound de) {
  694.                                 operazioneInGestione.waitBeforeInvalid("Accordo di Servizio non esistente nel database della govwayConsole: " + de.toString());
  695.                                 continue;
  696.                             } catch (Exception e) {
  697.                                 operazioneInGestione.error("Riscontrato errore durante la get dell'immagine dell'accordo: " + e.getMessage(), e);
  698.                                 continue;
  699.                             }

  700.                             try {

  701.                                 if (Operazione.add.equals(tipoOperazioneCRUD)) {
  702.                                    
  703.                                     this.accordoServizioParteComunePort.create(accordoServizioParteComune);
  704.                                    
  705.                                 } else if (Operazione.change.equals(tipoOperazioneCRUD)) {
  706.                                    
  707.                                     String nomeOLDAcc = operation.getParameterValue(OperationsParameter.OLD_NOME_ACCORDO.getNome());
  708.                                     if(nomeOLDAcc!=null){
  709.                                         String versioneOLDAcc = operation.getParameterValue(OperationsParameter.OLD_VERSIONE_ACCORDO.getNome());
  710.                                         Integer versioneOldAccordoInt = Integer.parseInt(versioneOLDAcc);
  711.                                         String tipoReferenteOLDAcc = operation.getParameterValue(OperationsParameter.OLD_TIPO_REFERENTE.getNome());
  712.                                         String nomeReferenteOLDAcc = operation.getParameterValue(OperationsParameter.OLD_NOME_REFERENTE.getNome());
  713.                                         IDAccordo oldIdAccordoServizioParteComune = IDAccordoFactory.getInstance().
  714.                                                 getIDAccordoFromValues(nomeOLDAcc,tipoReferenteOLDAcc,nomeReferenteOLDAcc,versioneOldAccordoInt);
  715.                                        
  716.                                         if(tipoReferenteOLDAcc!=null && nomeReferenteOLDAcc!=null){
  717.                                             // Check se operazione di change che  l'operazione di modifica del soggetto non sia ancora in rollback.
  718.                                             // Se sussite, aspetto l'operazione.
  719.                                             FilterParameter filtro = operazioneInGestione.getFilterChangeIDSoggetto(tipoReferenteAcc,nomeReferenteAcc,tipoReferenteOLDAcc,nomeReferenteOLDAcc);                                    
  720.                                             if(operazioneInGestione.existsOperationNotCompleted("change", operation.getHostname(), filtro)){
  721.                                                 this.log.debug("ChangeServizio: operazione change ID Soggetto non ancora completata: utilizzo OLD nome");
  722.                                             }else{
  723.                                                 this.log.debug("ChangeServizio: operazione change ID Soggetto completata: utilizzo nome");
  724.                                                 oldIdAccordoServizioParteComune.getSoggettoReferente().setTipo(tipoReferenteAcc);
  725.                                                 oldIdAccordoServizioParteComune.getSoggettoReferente().setNome(nomeReferenteAcc);
  726.                                             }
  727.                                         }
  728.                                        
  729.                                         accordoServizioParteComune.setOldIDAccordoForUpdate(oldIdAccordoServizioParteComune);
  730.                                        
  731.                                         this.accordoServizioParteComunePort.update(new IdAccordoServizioParteComune(oldIdAccordoServizioParteComune), accordoServizioParteComune);
  732.                                     }
  733.                                     else{
  734.                                        
  735.                                         this.accordoServizioParteComunePort.update(new IdAccordoServizioParteComune(idAccordoServizioParteComune), accordoServizioParteComune);
  736.                                        
  737.                                     }
  738.                                 }

  739.                             } catch (Exception e) {
  740.                                 operazioneInGestione.error("Riscontrato errore di creazione/update accordo servizio: " + e.toString(), e);
  741.                                 continue;
  742.                             }
  743.                         }

  744.                         // ELIMINAZIONE
  745.                         else if (Operazione.del.equals(tipoOperazioneCRUD)) {
  746.                             try {

  747.                                 this.accordoServizioParteComunePort.deleteById(new IdAccordoServizioParteComune(idAccordoServizioParteComune));

  748.                             } catch (Exception e) {
  749.                                 operazioneInGestione.error("Riscontrato errore di cancellazione accordo servizio: " + e.toString(), e);
  750.                                 continue;
  751.                             }

  752.                         }
  753.                     }
  754.                    
  755.                    
  756.                     // * ***** ACCORDI DI COOPERAZIONE ***** */
  757.                     if (TipoOggettoDaSmistare.accordoCooperazione.equals(tipoOggettoDaSmistare)) {

  758.                         String nomeAcc = operation.getParameterValue(OperationsParameter.NOME_ACCORDO.getNome());
  759.                         String versioneAcc = operation.getParameterValue(OperationsParameter.VERSIONE_ACCORDO.getNome());
  760.                         Integer versioneAccordoInt = Integer.parseInt(versioneAcc);
  761.                         String tipoReferenteAcc = operation.getParameterValue(OperationsParameter.TIPO_REFERENTE.getNome());
  762.                         String nomeReferenteAcc = operation.getParameterValue(OperationsParameter.NOME_REFERENTE.getNome());
  763.                         IDAccordoCooperazione idAccordoCooperazione =
  764.                                 IDAccordoCooperazioneFactory.getInstance().getIDAccordoFromValues(nomeAcc,tipoReferenteAcc,nomeReferenteAcc,versioneAccordoInt);

  765.                         AccordoCooperazione accordoCooperazione = null;
  766.                        
  767.                         // CREAZIONE/MODIFICA
  768.                         if (Operazione.change.equals(tipoOperazioneCRUD) || Operazione.add.equals(tipoOperazioneCRUD)) {

  769.                             // Ottengo nuova immagine dell'accordo
  770.                             try {
  771.                                 accordoCooperazione = this.acCore.getAccordoCooperazione(idAccordoCooperazione,true);
  772.                             } catch (DriverRegistroServiziNotFound de) {
  773.                                 operazioneInGestione.waitBeforeInvalid("Accordo di Cooperazione non esistente nel database della govwayConsole: " + de.toString());
  774.                                 continue;
  775.                             } catch (Exception e) {
  776.                                 operazioneInGestione.error("Riscontrato errore durante la get dell'immagine dell'accordo di cooperazione: " + e.getMessage(), e);
  777.                                 continue;
  778.                             }

  779.                             try {

  780.                                 if (Operazione.add.equals(tipoOperazioneCRUD)) {
  781.                                    
  782.                                     this.accordoCooperazionePort.create(accordoCooperazione);
  783.                                
  784.                                 } else if (Operazione.change.equals(tipoOperazioneCRUD)) {
  785.                                    
  786.                                     String nomeOLDAcc = operation.getParameterValue(OperationsParameter.OLD_NOME_ACCORDO.getNome());
  787.                                     if(nomeOLDAcc!=null){
  788.                                         String versioneOLDAcc = operation.getParameterValue(OperationsParameter.OLD_VERSIONE_ACCORDO.getNome());
  789.                                         Integer versioneOldAccordoInt = Integer.parseInt(versioneOLDAcc);
  790.                                         String tipoReferenteOLDAcc = operation.getParameterValue(OperationsParameter.OLD_TIPO_REFERENTE.getNome());
  791.                                         String nomeReferenteOLDAcc = operation.getParameterValue(OperationsParameter.OLD_NOME_REFERENTE.getNome());
  792.                                         IDAccordoCooperazione oldIdAccordoCooperazione = IDAccordoCooperazioneFactory.getInstance().
  793.                                                 getIDAccordoFromValues(nomeOLDAcc,tipoReferenteOLDAcc,nomeReferenteOLDAcc,versioneOldAccordoInt);
  794.                                        
  795.                                         if(tipoReferenteOLDAcc!=null && nomeReferenteOLDAcc!=null){
  796.                                             // Check se operazione di change che  l'operazione di modifica del soggetto non sia ancora in rollback.
  797.                                             // Se sussite, aspetto l'operazione.
  798.                                             FilterParameter filtro = operazioneInGestione.getFilterChangeIDSoggetto(tipoReferenteAcc,nomeReferenteAcc,tipoReferenteOLDAcc,nomeReferenteOLDAcc);                                    
  799.                                             if(operazioneInGestione.existsOperationNotCompleted("change", operation.getHostname(), filtro)){
  800.                                                 this.log.debug("ChangeServizio: operazione change ID Soggetto non ancora completata: utilizzo OLD nome");
  801.                                             }else{
  802.                                                 this.log.debug("ChangeServizio: operazione change ID Soggetto completata: utilizzo nome");
  803.                                                 oldIdAccordoCooperazione.getSoggettoReferente().setTipo(tipoReferenteAcc);
  804.                                                 oldIdAccordoCooperazione.getSoggettoReferente().setNome(nomeReferenteAcc);
  805.                                             }
  806.                                         }
  807.                                        
  808.                                         accordoCooperazione.setOldIDAccordoForUpdate(oldIdAccordoCooperazione);
  809.                                        
  810.                                         this.accordoCooperazionePort.update(new IdAccordoCooperazione(oldIdAccordoCooperazione), accordoCooperazione);
  811.                                     }
  812.                                     else{
  813.                                         this.accordoCooperazionePort.update(new IdAccordoCooperazione(idAccordoCooperazione), accordoCooperazione);
  814.                                     }
  815.                                    
  816.                                 }

  817.                             } catch (Exception e) {
  818.                                 operazioneInGestione.error("Riscontrato errore di creazione/update accordo di cooperazione: " + e.toString(), e);
  819.                                 continue;
  820.                             }
  821.                         }

  822.                         // ELIMINAZIONE
  823.                         else if (Operazione.del.equals(tipoOperazioneCRUD)) {
  824.                             try {

  825.                                 this.accordoCooperazionePort.deleteById(new IdAccordoCooperazione(idAccordoCooperazione));

  826.                             } catch (Exception e) {
  827.                                 operazioneInGestione.error("Riscontrato errore di cancellazione accordo di cooperazione: " + e.toString(), e);
  828.                                 continue;
  829.                             }

  830.                         }
  831.                     }
  832.                    

  833.                     // Operazione che riguarda la pdd
  834.                     if (TipoOggettoDaSmistare.pdd.equals(tipoOggettoDaSmistare)) {

  835.                         String nomePortaDominio = operation.getParameterValue(OperationsParameter.PORTA_DOMINIO.getNome());
  836.                         IdPortaDominio idPortaDominio = new IdPortaDominio(nomePortaDominio);
  837.                         PortaDominio portaDominio = null;

  838.                         // CREAZIONE/MODIFICA
  839.                         if (Operazione.change.equals(tipoOperazioneCRUD) || Operazione.add.equals(tipoOperazioneCRUD)) {

  840.                             // Ottengo nuova immagine della porta di dominio
  841.                             try {
  842.                                 portaDominio = this.pddCore.getPortaDominio(nomePortaDominio);
  843.                             } catch (DriverRegistroServiziNotFound de) {
  844.                                 operazioneInGestione.waitBeforeInvalid("Porta di dominio non esistente nel database: " + de.toString());
  845.                                 continue;
  846.                             } catch (Exception e) {
  847.                                 operazioneInGestione.error("Riscontrato errore durante la get della porta di dominio: " + e.getMessage(), e);
  848.                                 continue;
  849.                             }

  850.                             // Controllo elementi obbligatori
  851.                             try {
  852.                                 this.validazionePortaDominio(portaDominio);
  853.                             } catch (Exception e) {
  854.                                 operazioneInGestione.invalid(e.getMessage());
  855.                                 continue;
  856.                             }

  857.                             if (Operazione.add.equals(tipoOperazioneCRUD)) {
  858.                                 try {
  859.                                     this.pddPort.create(portaDominio);
  860.                                 } catch (Exception e) {
  861.                                     operazioneInGestione.error("Riscontrato errore di creazione porta di dominio: " + e.getMessage(), e);
  862.                                     continue;
  863.                                 }
  864.                             } else if (Operazione.change.equals(tipoOperazioneCRUD)) {
  865.                                 try {
  866.                                    
  867.                                     this.pddPort.update(idPortaDominio, portaDominio);
  868.                                 } catch (Exception e) {
  869.                                     operazioneInGestione.error("Riscontrato errore di update porta di dominio: " + e.getMessage(), e);
  870.                                     continue;
  871.                                 }
  872.                             }
  873.                         }

  874.                         // ELIMINAZIONE
  875.                         else if (Operazione.del.equals(tipoOperazioneCRUD)) {
  876.                             try {
  877.                                 this.pddPort.deleteById(idPortaDominio);
  878.                             } catch (Exception e) {
  879.                                 operazioneInGestione.error("Riscontrato errore di eliminazione porta di dominio: " + e.getMessage(), e);
  880.                                 continue;
  881.                             }
  882.                         }
  883.                     }

  884.                     // Se arrivo qui, significa che l'operazione non ha dato
  885.                     // errore,
  886.                     // aggiorno il db
  887.                     operazioneInGestione.success("Done.");

  888.                 }

  889.                 this.log.info("GestoreRegistro: Operazione [" + idOperazione + "] completata"+statoOperazioneCancellata);

  890.             } catch (javax.jms.JMSException e) {
  891.                 try {

  892.                     this.qs.rollback();
  893.                 } catch (Exception er) {
  894.                 }
  895.                 this.log.error("GestoreRegistro: Riscontrato errore durante la gestione di una richiesta: " + e.toString(), e);
  896.                 try {
  897.                     Utilities.sleep(5000);
  898.                     this.log.debug("GestoreRegistro: Re-Inizializzazione Receiver ...");
  899.                     try {
  900.                         this.receiver.close();
  901.                     } catch (Exception eclose) {
  902.                     }
  903.                     try {
  904.                         this.qs.close();
  905.                     } catch (Exception eclose) {
  906.                     }
  907.                     try {
  908.                         this.qc.close();
  909.                     } catch (Exception eclose) {
  910.                     }
  911.                     this.qc = this.qcf.createQueueConnection();
  912.                     // Ripristino stato Exception Listener
  913.                     if (this.exceptionListenerJMS.isConnessioneCorrotta()) {
  914.                         this.exceptionListenerJMS.setConnessioneCorrotta(false);
  915.                         this.exceptionListenerJMS.setException(null);
  916.                     }
  917.                     this.qc.setExceptionListener(this.exceptionListenerJMS);
  918.                     this.qs = this.qc.createQueueSession(true, -1);
  919.                     this.receiver = this.qs.createReceiver(this.queue);
  920.                     this.qc.start();
  921.                     this.log.debug("GestoreRegistro: Re-Inizializzazione Receiver effettuata.");
  922.                     riconnessioneConErrore = false;
  923.                 } catch (Exception er) {
  924.                     this.log.error("GestoreRegistro: Re-Inizializzazione Receiver non effettuata:" + er.toString());
  925.                     riconnessioneConErrore = true;
  926.                 }
  927.             } catch (ClassQueueException e) {
  928.                 try {
  929.                     if(operation!=null) {
  930.                         operation.setStatus(OperationStatus.ERROR);
  931.                         operation.setDetails(e.toString());
  932.                         operation.setTimeExecute(new Timestamp(System.currentTimeMillis()));
  933.                         operationManager.updateOperation(operation);
  934.                     }
  935.                     this.qs.rollback();
  936.                 } catch (Exception er) {
  937.                 }
  938.                 this.log.error("GestoreRegistro: Riscontrato errore durante operazione sulla coda: " + e.toString(), e);
  939.             } catch (Exception e) {
  940.                 try {
  941.                     this.qs.rollback();
  942.                 } catch (Exception er) {
  943.                 }
  944.                 this.log.error("GestoreRegistro: Riscontrato errore durante la gestione di una richiesta: " + e.toString(), e);
  945.             } finally {
  946.                 try {
  947.                     this.dbm.releaseConnection(this.con);
  948.                 } catch (Exception eLogger) {
  949.                 }
  950.             }

  951.         }// CHIUDO WHILE

  952.         // Chiusura connessione
  953.         try {
  954.             if (this.receiver != null) {
  955.                 this.receiver.close();
  956.             }
  957.             if (this.qs != null) {
  958.                 this.qs.rollback();
  959.                 this.qs.close();
  960.             }
  961.             if (this.qc != null) {
  962.                 this.qc.stop();
  963.                 this.qc.close();
  964.             }
  965.         } catch (Exception e) {
  966.             try {
  967.                 this.log.error("GestoreRegistro: Riscontrato errore durante la chiusura del Thread: " + e.toString());
  968.             } catch (Exception eLogger) {
  969.             }
  970.         }
  971.        
  972.         this.isRunning = false;
  973.         this.log.debug("Thread terminato");
  974.     }

  975.     /**
  976.      * Inizializzazione Gestore
  977.      */
  978.     @Override
  979.     public void initGestore() throws Exception {
  980.        
  981.         // Controllo se dbmanager inizializzato
  982.         // Il DBManager viene inizializzato nell'InitListener
  983.         if (!DBManager.isInitialized()) {
  984.             this.log.info("Inizializzazione di " + this.getClass().getSimpleName() + " non riuscito perche' DBManager non INIZIALIZZATO");
  985.             throw new Exception("Inizializzazione di " + this.getClass().getSimpleName() + "FALLITA");
  986.         }
  987.        
  988.         this.log.debug("Lettura dei parametri da console.properties");
  989.         String registroServiziQueue = this.consoleProperties.getGestioneCentralizzataNomeCodaRegistroServizi();
  990.         boolean engineRegistro = this.consoleProperties.isGestioneCentralizzataSincronizzazioneRegistro();
  991.         this.singlePdD = this.consoleProperties.isSinglePdD();
  992.         boolean trovato = false;

  993.         if (engineRegistro == false) {
  994.             //this.log.info("Motore di sincronizzazione verso il Registro dei Servizi non attivo.");
  995.             throw new GestoreNonAttivoException("Motore di sincronizzazione verso il Registro dei Servizi non attivo.");
  996.         }

  997.         // Leggo informazioni per queue.properties
  998.         // Init JMS
  999.         // readQueueProperties(cfName, cfProp);
  1000.         QueueManager queueMan = QueueManager.getInstance();
  1001.         if (queueMan == null) {
  1002.             this.log.debug("Impossibile avviare " + this.getClass().getSimpleName() + "QueueManager non inizializzato.");
  1003.             throw new Exception("Impossibile avviare " + this.getClass().getSimpleName() + "QueueManager non inizializzato.");
  1004.         }

  1005.         trovato = false;
  1006.         int i = 0;
  1007.         this.log.debug("Inizializzazione Receiver ...");
  1008.         while (!trovato && (i < 600000)) {
  1009.             try {
  1010.                 // InitialContext ctx = new InitialContext(cfProp);
  1011.                 // queue = (Queue) ctx.lookup(registroServiziQueue);
  1012.                 // qcf = (QueueConnectionFactory) ctx.lookup(cfName);
  1013.                 this.qcf = queueMan.getQueueConnectionFactory();
  1014.                 this.queue = queueMan.getQueue(registroServiziQueue);

  1015.                 this.qc = this.qcf.createQueueConnection();
  1016.                 this.qc.setExceptionListener(this.exceptionListenerJMS);
  1017.                 this.qs = this.qc.createQueueSession(true, -1);
  1018.                 this.receiver = this.qs.createReceiver(this.queue);
  1019.                 this.qc.start();
  1020.                 // ctx.close();
  1021.                 this.log.debug("GestoreRegistro: Inizializzazione Receiver effettuata.");
  1022.                 trovato = true;
  1023.             } catch (Exception e) {
  1024.                 i = i + 10000;
  1025.                 Utilities.sleep(10000);
  1026.                 this.log.debug("Ritento Inizializzazione Receiver ... causa: " + e.getMessage());
  1027.             }
  1028.         }

  1029.         if (!trovato) {
  1030.             this.log.error("Inizializzazione Receiver non effettuata");
  1031.             throw new Exception("Inizializzazione Receiver non effettuata");
  1032.         }

  1033.         // Init WebServiceCore
  1034.         try {
  1035.             // ws
  1036.             this.accordoCooperazioneService = new AccordoCooperazioneSoap11Service();
  1037.             this.accordoServizioParteComuneService = new AccordoServizioParteComuneSoap11Service();
  1038.             this.accordoServizioParteSpecificaService = new AccordoServizioParteSpecificaSoap11Service();
  1039.             this.soggettoService = new SoggettoSoap11Service();
  1040.             this.pddService = new PortaDominioSoap11Service();
  1041.            
  1042.             this.accordoCooperazionePort = this.accordoCooperazioneService.getAccordoCooperazionePortSoap11();
  1043.             this.accordoServizioParteComunePort = this.accordoServizioParteComuneService.getAccordoServizioParteComunePortSoap11();
  1044.             this.accordoServizioParteSpecificaPort = this.accordoServizioParteSpecificaService.getAccordoServizioParteSpecificaPortSoap11();
  1045.             this.soggettoPort = this.soggettoService.getSoggettoPortSoap11();
  1046.             this.pddPort = this.pddService.getPortaDominioPortSoap11();
  1047.            
  1048.             ((BindingProvider)this.accordoCooperazionePort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  1049.                     this.consoleProperties.getGestioneCentralizzataWSRegistroServiziEndpointAccordoCooperazione());
  1050.             ((BindingProvider)this.accordoServizioParteComunePort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  1051.                     this.consoleProperties.getGestioneCentralizzataWSRegistroServiziEndpointAccordoServizioParteComune());
  1052.             ((BindingProvider)this.accordoServizioParteSpecificaPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  1053.                     this.consoleProperties.getGestioneCentralizzataWSRegistroServiziEndpointAccordoServizioParteSpecifica());
  1054.             ((BindingProvider)this.soggettoPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  1055.                     this.consoleProperties.getGestioneCentralizzataWSRegistroServiziEndpointSoggetto());
  1056.             ((BindingProvider)this.pddPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  1057.                     this.consoleProperties.getGestioneCentralizzataWSRegistroServiziEndpointPdd());
  1058.            
  1059.             ((BindingProvider)this.accordoCooperazionePort).getRequestContext().put("schema-validation-enabled", true);
  1060.             ((BindingProvider)this.accordoServizioParteComunePort).getRequestContext().put("schema-validation-enabled", true);
  1061.             ((BindingProvider)this.accordoServizioParteSpecificaPort).getRequestContext().put("schema-validation-enabled", true);
  1062.             ((BindingProvider)this.soggettoPort).getRequestContext().put("schema-validation-enabled", true);
  1063.             ((BindingProvider)this.pddPort).getRequestContext().put("schema-validation-enabled", true);
  1064.            
  1065.             String username = this.consoleProperties.getGestioneCentralizzataWSRegistroServiziCredenzialiBasicUsername();
  1066.             String password = this.consoleProperties.getGestioneCentralizzataWSRegistroServiziCredenzialiBasicPassword();
  1067.             if(username !=null && password!=null){
  1068.                 // to use Basic HTTP Authentication:
  1069.                
  1070.                 ((BindingProvider)this.accordoCooperazionePort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  1071.                 ((BindingProvider)this.accordoCooperazionePort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  1072.                
  1073.                 ((BindingProvider)this.accordoServizioParteComunePort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  1074.                 ((BindingProvider)this.accordoServizioParteComunePort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  1075.                
  1076.                 ((BindingProvider)this.accordoServizioParteSpecificaPort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  1077.                 ((BindingProvider)this.accordoServizioParteSpecificaPort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  1078.                
  1079.                 ((BindingProvider)this.soggettoPort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  1080.                 ((BindingProvider)this.soggettoPort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  1081.                
  1082.                 ((BindingProvider)this.pddPort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  1083.                 ((BindingProvider)this.pddPort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  1084.             }
  1085.            
  1086.             this.log.debug("GestoreRegistro: Inizializzato WebService. AccordoCooperazione: " + this.accordoCooperazioneService.getClass().getSimpleName());
  1087.             this.log.debug("GestoreRegistro: Inizializzato WebService. AccordoServizioParteComune: " + this.accordoServizioParteComuneService.getClass().getSimpleName());
  1088.             this.log.debug("GestoreRegistro: Inizializzato WebService. AccordoServizioParteSpecifica: " + this.accordoServizioParteSpecificaService.getClass().getSimpleName());
  1089.             this.log.debug("GestoreRegistro: Inizializzato WebService. Soggetto: " + this.soggettoService.getClass().getSimpleName());
  1090.             this.log.debug("GestoreRegistro: Inizializzato WebService. PortaDominio: " + this.pddService.getClass().getSimpleName());
  1091.            
  1092.         } catch (Exception e) {
  1093.             this.log.error("Riscontrato Errore durante la connessione al WebService.", e);
  1094.             this.log.info("GestoreRegistro non avviato.");
  1095.             throw new Exception("Riscontrato Errore durante la connessione al WebService.", e);
  1096.         }

  1097.         // Init ControlStationCore
  1098.         try {
  1099.             this.soggettiCore = new SoggettiCore();
  1100.             this.pddCore = new PddCore(this.soggettiCore);
  1101.             this.apcCore = new AccordiServizioParteComuneCore(this.soggettiCore);
  1102.             this.apsCore = new AccordiServizioParteSpecificaCore(this.soggettiCore);
  1103.             this.acCore = new AccordiCooperazioneCore(this.soggettiCore);

  1104.             this.log.debug("GestoreRegistro: Inizializzato Core. ");
  1105.            
  1106.         } catch (Exception e) {
  1107.             this.log.error("Riscontrato Errore durante l'inizializzazione di ControlStationCore.", e);
  1108.             this.log.info("GestoreRegistro non avviato.");
  1109.             throw new ControlStationCoreException("Riscontrato Errore durante l'inizializzazione di ControlStationCore.", e);
  1110.         }

  1111.     }

  1112.     @Override
  1113.     public void stopGestore() {
  1114.         this.stop = true;
  1115.        
  1116.         this.log.debug("Fermo il thread ...");
  1117.         int timeout = 60;
  1118.         for (int i = 0; i < timeout; i++) {
  1119.             if(this.isRunning()){
  1120.                 Utilities.sleep(1000);
  1121.             }
  1122.             else{
  1123.                 break;
  1124.             }
  1125.         }
  1126.         if(this.isRunning){
  1127.             this.log.debug("Sono trascorsi 60 secondi ed il thread non รจ ancora terminato??");
  1128.         }
  1129.     }

  1130.     @Override
  1131.     protected String getName() {
  1132.         return this.name;
  1133.     }

  1134.     private void validazionePortaDominio(PortaDominio pdd) throws Exception {

  1135.         if ((pdd.getNome() == null) || ("".equals(pdd.getNome()))) {
  1136.             throw new Exception("Riscontrato errore: Nome Porta di dominio, non definito");
  1137.         }

  1138.     }
  1139. }