DriverConfigurazioneDB_configDriver.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.core.config.driver.db;

  21. import java.sql.Connection;
  22. import java.sql.PreparedStatement;
  23. import java.sql.ResultSet;
  24. import java.sql.SQLException;
  25. import java.util.ArrayList;
  26. import java.util.List;

  27. import org.apache.commons.lang.StringUtils;
  28. import org.openspcoop2.core.byok.BYOKUtilities;
  29. import org.openspcoop2.core.byok.IDriverBYOK;
  30. import org.openspcoop2.core.commons.DBUtils;
  31. import org.openspcoop2.core.commons.IExtendedInfo;
  32. import org.openspcoop2.core.config.AccessoConfigurazione;
  33. import org.openspcoop2.core.config.AccessoDatiAttributeAuthority;
  34. import org.openspcoop2.core.config.AccessoDatiAutenticazione;
  35. import org.openspcoop2.core.config.AccessoDatiAutorizzazione;
  36. import org.openspcoop2.core.config.AccessoDatiConsegnaApplicativi;
  37. import org.openspcoop2.core.config.AccessoDatiGestioneToken;
  38. import org.openspcoop2.core.config.AccessoDatiKeystore;
  39. import org.openspcoop2.core.config.AccessoDatiRichieste;
  40. import org.openspcoop2.core.config.AccessoRegistro;
  41. import org.openspcoop2.core.config.AccessoRegistroRegistro;
  42. import org.openspcoop2.core.config.Attachments;
  43. import org.openspcoop2.core.config.Cache;
  44. import org.openspcoop2.core.config.CanaliConfigurazione;
  45. import org.openspcoop2.core.config.Configurazione;
  46. import org.openspcoop2.core.config.ConfigurazioneGeneraleHandler;
  47. import org.openspcoop2.core.config.ConfigurazioneGestioneErrore;
  48. import org.openspcoop2.core.config.ConfigurazioneMessageHandlers;
  49. import org.openspcoop2.core.config.ConfigurazioneMultitenant;
  50. import org.openspcoop2.core.config.ConfigurazioneServiceHandlers;
  51. import org.openspcoop2.core.config.ConfigurazioneTracciamentoPorta;
  52. import org.openspcoop2.core.config.ConfigurazioneUrlInvocazione;
  53. import org.openspcoop2.core.config.ConfigurazioneUrlInvocazioneRegola;
  54. import org.openspcoop2.core.config.CorsConfigurazione;
  55. import org.openspcoop2.core.config.Dump;
  56. import org.openspcoop2.core.config.DumpConfigurazione;
  57. import org.openspcoop2.core.config.GestioneErrore;
  58. import org.openspcoop2.core.config.IdSoggetto;
  59. import org.openspcoop2.core.config.IndirizzoRisposta;
  60. import org.openspcoop2.core.config.InoltroBusteNonRiscontrate;
  61. import org.openspcoop2.core.config.IntegrationManager;
  62. import org.openspcoop2.core.config.MessaggiDiagnostici;
  63. import org.openspcoop2.core.config.OpenspcoopAppender;
  64. import org.openspcoop2.core.config.OpenspcoopSorgenteDati;
  65. import org.openspcoop2.core.config.Property;
  66. import org.openspcoop2.core.config.ResponseCachingConfigurazione;
  67. import org.openspcoop2.core.config.ResponseCachingConfigurazioneGenerale;
  68. import org.openspcoop2.core.config.Risposte;
  69. import org.openspcoop2.core.config.RoutingTable;
  70. import org.openspcoop2.core.config.StatoServiziPdd;
  71. import org.openspcoop2.core.config.StatoServiziPddIntegrationManager;
  72. import org.openspcoop2.core.config.StatoServiziPddPortaApplicativa;
  73. import org.openspcoop2.core.config.StatoServiziPddPortaDelegata;
  74. import org.openspcoop2.core.config.SystemProperties;
  75. import org.openspcoop2.core.config.TipoFiltroAbilitazioneServizi;
  76. import org.openspcoop2.core.config.Tracciamento;
  77. import org.openspcoop2.core.config.TracciamentoConfigurazione;
  78. import org.openspcoop2.core.config.TracciamentoConfigurazioneFiletrace;
  79. import org.openspcoop2.core.config.Transazioni;
  80. import org.openspcoop2.core.config.ValidazioneBuste;
  81. import org.openspcoop2.core.config.ValidazioneContenutiApplicativi;
  82. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  83. import org.openspcoop2.core.config.constants.RegistroTipo;
  84. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  85. import org.openspcoop2.core.config.driver.DriverConfigurazioneException;
  86. import org.openspcoop2.core.config.driver.DriverConfigurazioneNotFound;
  87. import org.openspcoop2.core.config.driver.ExtendedInfoManager;
  88. import org.openspcoop2.core.constants.CostantiDB;
  89. import org.openspcoop2.core.id.IDSoggetto;
  90. import org.openspcoop2.utils.jdbc.JDBCUtilities;
  91. import org.openspcoop2.utils.sql.ISQLQueryObject;
  92. import org.openspcoop2.utils.sql.SQLObjectFactory;

  93. /**
  94.  * DriverConfigurazioneDB_configDriver
  95.  *
  96.  *
  97.  * @author Sandra Giangrandi (sandra@link.it)
  98.  * @author Stefano Corallo (corallo@link.it)
  99.  * @author $Author$
  100.  * @version $Rev$, $Date$
  101.  */
  102. public class DriverConfigurazioneDB_configDriver {

  103.     private DriverConfigurazioneDB driver = null;
  104.     private DriverConfigurazioneDB_porteDriver porteDriver = null;
  105.     private DriverConfigurazioneDB_gestioneErroreDriver gestioneErroreDriver = null;
  106.     private DriverConfigurazioneDB_routingTableDriver routingTableDriver = null;
  107.     private DriverConfigurazioneDB_genericPropertiesDriver genericPropertiesDriver = null;
  108.    
  109.    
  110.     protected DriverConfigurazioneDB_configDriver(DriverConfigurazioneDB driver) {
  111.         this.driver = driver;
  112.         this.porteDriver = new DriverConfigurazioneDB_porteDriver(driver);
  113.         this.gestioneErroreDriver = new DriverConfigurazioneDB_gestioneErroreDriver(driver);
  114.         this.routingTableDriver = new DriverConfigurazioneDB_routingTableDriver(driver);
  115.         this.genericPropertiesDriver = new DriverConfigurazioneDB_genericPropertiesDriver(driver);
  116.     }
  117.    
  118.     protected AccessoRegistro getAccessoRegistro() throws DriverConfigurazioneException, DriverConfigurazioneNotFound {

  119.         Connection con = null;
  120.         PreparedStatement stm = null;
  121.         ResultSet rs = null;
  122.         String sqlQuery = "";

  123.         if (this.driver.atomica) {
  124.             try {
  125.                 con = this.driver.getConnectionFromDatasource("getAccessoRegistro");

  126.             } catch (Exception e) {
  127.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoRegistro] Exception accedendo al datasource :" + e.getMessage(),e);

  128.             }

  129.         } else
  130.             con = this.driver.globalConnection;

  131.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  132.         try {
  133.             AccessoRegistro car = new AccessoRegistro();
  134.             Cache cache = null;

  135.             // aggiungo i registri
  136.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  137.             sqlQueryObject.addFromTable(CostantiDB.REGISTRI);
  138.             sqlQueryObject.addSelectField("*");
  139.             sqlQuery = sqlQueryObject.createSQLQuery();
  140.             stm = con.prepareStatement(sqlQuery);
  141.             rs = stm.executeQuery();

  142.             AccessoRegistroRegistro itemcar = null;

  143.             while (rs.next()) {
  144.                 itemcar = new AccessoRegistroRegistro();

  145.                 // TIPO
  146.                 RegistroTipo tipoReg = CostantiConfigurazione.REGISTRO_XML;
  147.                 String tmpTipo = rs.getString("tipo");
  148.                 if (tmpTipo.equals("uddi"))
  149.                     tipoReg = CostantiConfigurazione.REGISTRO_UDDI;
  150.                 else if (tmpTipo.equals("web"))
  151.                     tipoReg = CostantiConfigurazione.REGISTRO_WEB;
  152.                 else if (tmpTipo.equals("db"))
  153.                     tipoReg = CostantiConfigurazione.REGISTRO_DB;
  154.                 else if (tmpTipo.equals("ws"))
  155.                     tipoReg = CostantiConfigurazione.REGISTRO_WS;

  156.                 itemcar.setTipo(tipoReg);

  157.                 // nome
  158.                 itemcar.setNome(rs.getString("nome"));

  159.                 // location
  160.                 itemcar.setLocation(rs.getString("location"));

  161.                 // USER e PASSWORD
  162.                 String tmpUser = rs.getString("utente");
  163.                 String tmpPw = rs.getString("password");
  164.                 if ((tmpUser != null) && (tmpPw != null) && !tmpUser.equals("") && !tmpPw.equals("")) {
  165.                     itemcar.setUser(tmpUser);
  166.                     itemcar.setPassword(tmpPw);
  167.                 }

  168.                 car.addRegistro(itemcar);
  169.             }
  170.             rs.close();
  171.             stm.close();

  172.             //fix bug 23/11/07
  173.             //se nn trovo registri non va lanciata l'eccezione in quanto
  174.             //possono esistere variabili di configurazione successive che vanno lette
  175.             //se nn ho trovato registri allora lancio eccezione
  176.             //if(itemcar==null) throw new DriverConfigurazioneNotFound("Nessun registro trovato");

  177.             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  178.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE);
  179.             sqlQueryObject.addSelectField("*");
  180.             sqlQuery = sqlQueryObject.createSQLQuery();
  181.             stm = con.prepareStatement(sqlQuery);

  182.             this.driver.logDebug("eseguo query : " + sqlQuery);

  183.             rs = stm.executeQuery();

  184.             if (rs.next()) {
  185.                 String tmpCache = rs.getString("statocache");
  186.                 if (CostantiConfigurazione.ABILITATO.equals(tmpCache)) {
  187.                     cache = new Cache();

  188.                     String tmpDim = rs.getString("dimensionecache");
  189.                     if (tmpDim != null && !tmpDim.equals(""))
  190.                         cache.setDimensione(tmpDim);

  191.                     String tmpAlg = rs.getString("algoritmocache");
  192.                     if (tmpAlg.equalsIgnoreCase("LRU"))
  193.                         cache.setAlgoritmo(CostantiConfigurazione.CACHE_LRU);
  194.                     else
  195.                         cache.setAlgoritmo(CostantiConfigurazione.CACHE_MRU);

  196.                     String tmpIdle = rs.getString("idlecache");
  197.                     String tmpLife = rs.getString("lifecache");

  198.                     if (tmpIdle != null && !tmpIdle.equals(""))
  199.                         cache.setItemIdleTime(tmpIdle);
  200.                     if (tmpLife != null && !tmpLife.equals(""))
  201.                         cache.setItemLifeSecond(tmpLife);

  202.                     car.setCache(cache);

  203.                 }
  204.                 rs.close();
  205.                 stm.close();
  206.             }
  207.             //nel caso in cui non esiste nessuna configurazione non lancio eccezioni
  208.             //perche' possono essere presenti dei registri
  209.             /*else{
  210.                 rs.close();
  211.                 stm.close();
  212.                 throw new DriverConfigurazioneNotFound("Nessuna Configurazione trovata.");
  213.             }*/



  214.             return car;

  215.         } catch (SQLException se) {
  216.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoRegistro] SqlException: " + se.getMessage(),se);
  217.         }catch (Exception se) {
  218.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoRegistro] Exception: " + se.getMessage(),se);
  219.         } finally {
  220.             //Chiudo statement and resultset
  221.             JDBCUtilities.closeResources(rs, stm);
  222.             this.driver.closeConnection(con);
  223.         }
  224.     }

  225.     protected void createAccessoRegistro(AccessoRegistroRegistro registro) throws DriverConfigurazioneException {

  226.         Connection con = null;
  227.         boolean error = false;

  228.         if (this.driver.atomica) {
  229.             try {
  230.                 con = this.driver.getConnectionFromDatasource("createAccessoRegistro");
  231.                 con.setAutoCommit(false);
  232.             } catch (Exception e) {
  233.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createAccessoRegistro] Exception accedendo al datasource :" + e.getMessage(),e);

  234.             }

  235.         } else
  236.             con = this.driver.globalConnection;

  237.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  238.         try {
  239.             this.driver.logDebug("CRUDAccessoRegistro type = 1");
  240.             DriverConfigurazioneDB_configLIB.CRUDAccessoRegistro(1, registro, con);

  241.         } catch (Exception qe) {
  242.             error = true;
  243.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createAccessoRegistro] Errore durante la createAccessoRegistro : " + qe.getMessage(),qe);
  244.         } finally {

  245.             this.driver.closeConnection(error,con);
  246.         }
  247.     }

  248.     protected void updateAccessoRegistro(AccessoRegistroRegistro registro) throws DriverConfigurazioneException {
  249.         Connection con = null;
  250.         boolean error = false;

  251.         if (this.driver.atomica) {
  252.             try {
  253.                 con = this.driver.getConnectionFromDatasource("updateAccessoRegistro");
  254.                 con.setAutoCommit(false);
  255.             } catch (Exception e) {
  256.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateAccessoRegistro] Exception accedendo al datasource :" + e.getMessage(),e);

  257.             }

  258.         } else
  259.             con = this.driver.globalConnection;

  260.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  261.         try {
  262.             this.driver.logDebug("CRUDAccessoRegistro type = 2");
  263.             DriverConfigurazioneDB_configLIB.CRUDAccessoRegistro(2, registro, con);

  264.         } catch (Exception qe) {
  265.             error = true;
  266.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateAccessoRegistro] Errore durante la updateAccessoRegistro : " + qe.getMessage(),qe);
  267.         } finally {

  268.             this.driver.closeConnection(error,con);
  269.         }
  270.     }

  271.     protected void deleteAccessoRegistro(AccessoRegistroRegistro registro) throws DriverConfigurazioneException {
  272.         Connection con = null;
  273.         boolean error = false;

  274.         if (this.driver.atomica) {
  275.             try {
  276.                 con = this.driver.getConnectionFromDatasource("deleteAccessoRegistro");
  277.                 con.setAutoCommit(false);
  278.             } catch (Exception e) {
  279.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteAccessoRegistro] Exception accedendo al datasource :" + e.getMessage(),e);

  280.             }

  281.         } else
  282.             con = this.driver.globalConnection;

  283.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  284.         try {
  285.             this.driver.logDebug("CRUDAccessoRegistro type = 3");
  286.             DriverConfigurazioneDB_configLIB.CRUDAccessoRegistro(3, registro, con);

  287.         } catch (Exception qe) {
  288.             error = true;
  289.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteAccessoRegistro] Errore durante la deleteAccessoRegistro : " + qe.getMessage(),qe);
  290.         } finally {

  291.             this.driver.closeConnection(error,con);
  292.         }
  293.     }
  294.    
  295.    
  296.    
  297.    
  298.     protected AccessoConfigurazione getAccessoConfigurazione() throws DriverConfigurazioneException {

  299.         Connection con = null;
  300.         PreparedStatement stm = null;
  301.         ResultSet rs = null;
  302.         String sqlQuery = "";

  303.         if (this.driver.atomica) {
  304.             try {
  305.                 con = this.driver.getConnectionFromDatasource("getAccessoConfigurazione");

  306.             } catch (Exception e) {
  307.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoConfigurazione] Exception accedendo al datasource :" + e.getMessage(),e);

  308.             }

  309.         } else
  310.             con = this.driver.globalConnection;

  311.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  312.         try {
  313.             AccessoConfigurazione accessoConfigurazione = new AccessoConfigurazione();
  314.             Cache cache = null;

  315.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  316.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE);
  317.             sqlQueryObject.addSelectField("*");
  318.             sqlQuery = sqlQueryObject.createSQLQuery();
  319.             stm = con.prepareStatement(sqlQuery);

  320.             this.driver.logDebug("eseguo query : " + sqlQuery);

  321.             rs = stm.executeQuery();

  322.             if (rs.next()) {
  323.                 String tmpCache = rs.getString("config_statocache");
  324.                 if (CostantiConfigurazione.ABILITATO.equals(tmpCache)) {
  325.                     cache = new Cache();

  326.                     String tmpDim = rs.getString("config_dimensionecache");
  327.                     if (tmpDim != null && !tmpDim.equals(""))
  328.                         cache.setDimensione(tmpDim);

  329.                     String tmpAlg = rs.getString("config_algoritmocache");
  330.                     if (tmpAlg.equalsIgnoreCase("LRU"))
  331.                         cache.setAlgoritmo(CostantiConfigurazione.CACHE_LRU);
  332.                     else
  333.                         cache.setAlgoritmo(CostantiConfigurazione.CACHE_MRU);

  334.                     String tmpIdle = rs.getString("config_idlecache");
  335.                     String tmpLife = rs.getString("config_lifecache");

  336.                     if (tmpIdle != null && !tmpIdle.equals(""))
  337.                         cache.setItemIdleTime(tmpIdle);
  338.                     if (tmpLife != null && !tmpLife.equals(""))
  339.                         cache.setItemLifeSecond(tmpLife);

  340.                     accessoConfigurazione.setCache(cache);

  341.                 }
  342.                 rs.close();
  343.                 stm.close();
  344.             }

  345.             return accessoConfigurazione;

  346.         } catch (SQLException se) {
  347.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoConfigurazione] SqlException: " + se.getMessage(),se);
  348.         }catch (Exception se) {
  349.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoConfigurazione] Exception: " + se.getMessage(),se);
  350.         } finally {
  351.             //Chiudo statement and resultset
  352.             JDBCUtilities.closeResources(rs, stm);
  353.             this.driver.closeConnection(con);
  354.         }
  355.     }

  356.     protected void createAccessoConfigurazione(AccessoConfigurazione accessoConfigurazione) throws DriverConfigurazioneException {

  357.         Connection con = null;
  358.         boolean error = false;

  359.         if (this.driver.atomica) {
  360.             try {
  361.                 con = this.driver.getConnectionFromDatasource("createAccessoConfigurazione");
  362.                 con.setAutoCommit(false);
  363.             } catch (Exception e) {
  364.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createAccessoConfigurazione] Exception accedendo al datasource :" + e.getMessage(),e);

  365.             }

  366.         } else
  367.             con = this.driver.globalConnection;

  368.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  369.         try {
  370.             this.driver.logDebug("CRUDAccessoConfigurazione type = 1");
  371.             DriverConfigurazioneDB_configLIB.CRUDAccessoConfigurazione(1, accessoConfigurazione, con);

  372.         } catch (Exception qe) {
  373.             error = true;
  374.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createAccessoConfigurazione] Errore durante la createAccessoConfigurazione : " + qe.getMessage(),qe);
  375.         } finally {

  376.             this.driver.closeConnection(error,con);
  377.         }
  378.     }

  379.     protected void updateAccessoConfigurazione(AccessoConfigurazione accessoConfigurazione) throws DriverConfigurazioneException {
  380.         Connection con = null;
  381.         boolean error = false;

  382.         if (this.driver.atomica) {
  383.             try {
  384.                 con = this.driver.getConnectionFromDatasource("updateAccessoConfigurazione");
  385.                 con.setAutoCommit(false);
  386.             } catch (Exception e) {
  387.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateAccessoConfigurazione] Exception accedendo al datasource :" + e.getMessage(),e);

  388.             }

  389.         } else
  390.             con = this.driver.globalConnection;

  391.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  392.         try {
  393.             this.driver.logDebug("CRUDAccessoConfigurazione type = 2");
  394.             DriverConfigurazioneDB_configLIB.CRUDAccessoConfigurazione(2, accessoConfigurazione, con);

  395.         } catch (Exception qe) {
  396.             error = true;
  397.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateAccessoConfigurazione] Errore durante la updateAccessoConfigurazione : " + qe.getMessage(),qe);
  398.         } finally {

  399.             this.driver.closeConnection(error,con);
  400.         }
  401.     }

  402.     protected void deleteAccessoConfigurazione(AccessoConfigurazione accessoConfigurazione) throws DriverConfigurazioneException {
  403.         Connection con = null;
  404.         boolean error = false;

  405.         if (this.driver.atomica) {
  406.             try {
  407.                 con = this.driver.getConnectionFromDatasource("deleteAccessoConfigurazione");
  408.                 con.setAutoCommit(false);
  409.             } catch (Exception e) {
  410.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteAccessoConfigurazione] Exception accedendo al datasource :" + e.getMessage(),e);

  411.             }

  412.         } else
  413.             con = this.driver.globalConnection;

  414.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  415.         try {
  416.             this.driver.logDebug("CRUDAccessoConfigurazione type = 3");
  417.             DriverConfigurazioneDB_configLIB.CRUDAccessoConfigurazione(3, accessoConfigurazione, con);

  418.         } catch (Exception qe) {
  419.             error = true;
  420.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteAccessoConfigurazione] Errore durante la deleteAccessoConfigurazione : " + qe.getMessage(),qe);
  421.         } finally {

  422.             this.driver.closeConnection(error,con);
  423.         }
  424.     }
  425.    
  426.    
  427.    
  428.    
  429.    
  430.     protected AccessoDatiAutorizzazione getAccessoDatiAutorizzazione() throws DriverConfigurazioneException {

  431.         Connection con = null;
  432.         PreparedStatement stm = null;
  433.         ResultSet rs = null;
  434.         String sqlQuery = "";

  435.         if (this.driver.atomica) {
  436.             try {
  437.                 con = this.driver.getConnectionFromDatasource("getAccessoDatiAutorizzazione");

  438.             } catch (Exception e) {
  439.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiAutorizzazione] Exception accedendo al datasource :" + e.getMessage(),e);

  440.             }

  441.         } else
  442.             con = this.driver.globalConnection;

  443.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  444.         try {
  445.             AccessoDatiAutorizzazione accessoDatiAutorizzazione = new AccessoDatiAutorizzazione();
  446.            
  447.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  448.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE);
  449.             sqlQueryObject.addSelectField("*");
  450.             sqlQuery = sqlQueryObject.createSQLQuery();
  451.             stm = con.prepareStatement(sqlQuery);

  452.             this.driver.logDebug("eseguo query : " + sqlQuery);

  453.             rs = stm.executeQuery();

  454.             if (rs.next()) {
  455.                 readAccessoDatiAutorizzazione(rs, accessoDatiAutorizzazione);
  456.                 rs.close();
  457.                 stm.close();
  458.             }

  459.             return accessoDatiAutorizzazione;

  460.         } catch (SQLException se) {
  461.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiAutorizzazione] SqlException: " + se.getMessage(),se);
  462.         }catch (Exception se) {
  463.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiAutorizzazione] Exception: " + se.getMessage(),se);
  464.         } finally {
  465.             //Chiudo statement and resultset
  466.             JDBCUtilities.closeResources(rs, stm);
  467.             this.driver.closeConnection(con);
  468.         }
  469.     }
  470.     private void readAccessoDatiAutorizzazione(ResultSet rs, AccessoDatiAutorizzazione accessoDatiAutorizzazione) throws SQLException {
  471.         String tmpCache = rs.getString("auth_statocache");
  472.         if (CostantiConfigurazione.ABILITATO.equals(tmpCache)) {
  473.             Cache cache = new Cache();

  474.             String tmpDim = rs.getString("auth_dimensionecache");
  475.             if (tmpDim != null && !tmpDim.equals(""))
  476.                 cache.setDimensione(tmpDim);

  477.             String tmpAlg = rs.getString("auth_algoritmocache");
  478.             if (tmpAlg.equalsIgnoreCase("LRU"))
  479.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_LRU);
  480.             else
  481.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_MRU);

  482.             String tmpIdle = rs.getString("auth_idlecache");
  483.             String tmpLife = rs.getString("auth_lifecache");

  484.             if (tmpIdle != null && !tmpIdle.equals(""))
  485.                 cache.setItemIdleTime(tmpIdle);
  486.             if (tmpLife != null && !tmpLife.equals(""))
  487.                 cache.setItemLifeSecond(tmpLife);

  488.             accessoDatiAutorizzazione.setCache(cache);

  489.         }
  490.     }
  491.    
  492.    
  493.    
  494.     protected AccessoDatiAutenticazione getAccessoDatiAutenticazione() throws DriverConfigurazioneException {

  495.         Connection con = null;
  496.         PreparedStatement stm = null;
  497.         ResultSet rs = null;
  498.         String sqlQuery = "";

  499.         if (this.driver.atomica) {
  500.             try {
  501.                 con = this.driver.getConnectionFromDatasource("getAccessoDatiAutenticazione");

  502.             } catch (Exception e) {
  503.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiAutenticazione] Exception accedendo al datasource :" + e.getMessage(),e);

  504.             }

  505.         } else
  506.             con = this.driver.globalConnection;

  507.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  508.         try {
  509.             AccessoDatiAutenticazione accessoDatiAutenticazione = new AccessoDatiAutenticazione();
  510.            
  511.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  512.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE);
  513.             sqlQueryObject.addSelectField("*");
  514.             sqlQuery = sqlQueryObject.createSQLQuery();
  515.             stm = con.prepareStatement(sqlQuery);

  516.             this.driver.logDebug("eseguo query : " + sqlQuery);

  517.             rs = stm.executeQuery();

  518.             if (rs.next()) {
  519.                 readAccessoDatiAutenticazione(rs, accessoDatiAutenticazione);
  520.                 rs.close();
  521.                 stm.close();
  522.             }

  523.             return accessoDatiAutenticazione;

  524.         } catch (SQLException se) {
  525.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiAutenticazione] SqlException: " + se.getMessage(),se);
  526.         }catch (Exception se) {
  527.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiAutenticazione] Exception: " + se.getMessage(),se);
  528.         } finally {
  529.             //Chiudo statement and resultset
  530.             JDBCUtilities.closeResources(rs, stm);
  531.             this.driver.closeConnection(con);
  532.         }
  533.     }
  534.     private void readAccessoDatiAutenticazione(ResultSet rs, AccessoDatiAutenticazione accessoDatiAutenticazione) throws SQLException {
  535.         String tmpCache = rs.getString("authn_statocache");
  536.         if (CostantiConfigurazione.ABILITATO.equals(tmpCache)) {
  537.             Cache cache = new Cache();

  538.             String tmpDim = rs.getString("authn_dimensionecache");
  539.             if (tmpDim != null && !tmpDim.equals(""))
  540.                 cache.setDimensione(tmpDim);

  541.             String tmpAlg = rs.getString("authn_algoritmocache");
  542.             if (tmpAlg.equalsIgnoreCase("LRU"))
  543.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_LRU);
  544.             else
  545.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_MRU);

  546.             String tmpIdle = rs.getString("authn_idlecache");
  547.             String tmpLife = rs.getString("authn_lifecache");

  548.             if (tmpIdle != null && !tmpIdle.equals(""))
  549.                 cache.setItemIdleTime(tmpIdle);
  550.             if (tmpLife != null && !tmpLife.equals(""))
  551.                 cache.setItemLifeSecond(tmpLife);

  552.             accessoDatiAutenticazione.setCache(cache);

  553.         }
  554.     }
  555.    
  556.    
  557.     protected AccessoDatiGestioneToken getAccessoDatiGestioneToken() throws DriverConfigurazioneException {

  558.         Connection con = null;
  559.         PreparedStatement stm = null;
  560.         ResultSet rs = null;
  561.         String sqlQuery = "";

  562.         if (this.driver.atomica) {
  563.             try {
  564.                 con = this.driver.getConnectionFromDatasource("getAccessoDatiGestioneToken");

  565.             } catch (Exception e) {
  566.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiGestioneToken] Exception accedendo al datasource :" + e.getMessage(),e);

  567.             }

  568.         } else
  569.             con = this.driver.globalConnection;

  570.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  571.         try {
  572.             AccessoDatiGestioneToken accessoDatiGestioneToken = new AccessoDatiGestioneToken();
  573.            
  574.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  575.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE);
  576.             sqlQueryObject.addSelectField("*");
  577.             sqlQuery = sqlQueryObject.createSQLQuery();
  578.             stm = con.prepareStatement(sqlQuery);

  579.             this.driver.logDebug("eseguo query : " + sqlQuery);

  580.             rs = stm.executeQuery();

  581.             if (rs.next()) {
  582.                 readAccessoDatiGestioneToken(rs, accessoDatiGestioneToken);
  583.                 rs.close();
  584.                 stm.close();
  585.             }

  586.             return accessoDatiGestioneToken;

  587.         } catch (SQLException se) {
  588.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiGestioneToken] SqlException: " + se.getMessage(),se);
  589.         }catch (Exception se) {
  590.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiGestioneToken] Exception: " + se.getMessage(),se);
  591.         } finally {
  592.             //Chiudo statement and resultset
  593.             JDBCUtilities.closeResources(rs, stm);
  594.             this.driver.closeConnection(con);
  595.         }
  596.     }
  597.     private void readAccessoDatiGestioneToken(ResultSet rs, AccessoDatiGestioneToken accessoDatiGestioneToken) throws SQLException {
  598.         String tmpCache = rs.getString("token_statocache");
  599.         if (CostantiConfigurazione.ABILITATO.equals(tmpCache)) {
  600.             Cache cache = new Cache();

  601.             String tmpDim = rs.getString("token_dimensionecache");
  602.             if (tmpDim != null && !tmpDim.equals(""))
  603.                 cache.setDimensione(tmpDim);

  604.             String tmpAlg = rs.getString("token_algoritmocache");
  605.             if (tmpAlg.equalsIgnoreCase("LRU"))
  606.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_LRU);
  607.             else
  608.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_MRU);

  609.             String tmpIdle = rs.getString("token_idlecache");
  610.             String tmpLife = rs.getString("token_lifecache");

  611.             if (tmpIdle != null && !tmpIdle.equals(""))
  612.                 cache.setItemIdleTime(tmpIdle);
  613.             if (tmpLife != null && !tmpLife.equals(""))
  614.                 cache.setItemLifeSecond(tmpLife);

  615.             accessoDatiGestioneToken.setCache(cache);

  616.         }
  617.     }
  618.    
  619.    
  620.    
  621.    
  622.    
  623.    
  624.     protected AccessoDatiAttributeAuthority getAccessoDatiAttributeAuthority() throws DriverConfigurazioneException {

  625.         Connection con = null;
  626.         PreparedStatement stm = null;
  627.         ResultSet rs = null;
  628.         String sqlQuery = "";

  629.         if (this.driver.atomica) {
  630.             try {
  631.                 con = this.driver.getConnectionFromDatasource("getAccessoDatiAttributeAuthority");

  632.             } catch (Exception e) {
  633.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiAttributeAuthority] Exception accedendo al datasource :" + e.getMessage(),e);

  634.             }

  635.         } else
  636.             con = this.driver.globalConnection;

  637.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  638.         try {
  639.             AccessoDatiAttributeAuthority accessoDatiAttributeAuthority = new AccessoDatiAttributeAuthority();
  640.            
  641.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  642.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE);
  643.             sqlQueryObject.addSelectField("*");
  644.             sqlQuery = sqlQueryObject.createSQLQuery();
  645.             stm = con.prepareStatement(sqlQuery);

  646.             this.driver.logDebug("eseguo query : " + sqlQuery);

  647.             rs = stm.executeQuery();

  648.             if (rs.next()) {
  649.                 readAccessoDatiAttributeAuthority(rs, accessoDatiAttributeAuthority);
  650.                 rs.close();
  651.                 stm.close();
  652.             }

  653.             return accessoDatiAttributeAuthority;

  654.         } catch (SQLException se) {
  655.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiAttributeAuthority] SqlException: " + se.getMessage(),se);
  656.         }catch (Exception se) {
  657.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiAttributeAuthority] Exception: " + se.getMessage(),se);
  658.         } finally {
  659.             //Chiudo statement and resultset
  660.             JDBCUtilities.closeResources(rs, stm);
  661.             this.driver.closeConnection(con);
  662.         }
  663.     }
  664.     private void readAccessoDatiAttributeAuthority(ResultSet rs, AccessoDatiAttributeAuthority accessoDatiAttributeAuthority) throws SQLException {
  665.         String tmpCache = rs.getString("aa_statocache");
  666.         if (CostantiConfigurazione.ABILITATO.equals(tmpCache)) {
  667.             Cache cache = new Cache();

  668.             String tmpDim = rs.getString("aa_dimensionecache");
  669.             if (tmpDim != null && !tmpDim.equals(""))
  670.                 cache.setDimensione(tmpDim);

  671.             String tmpAlg = rs.getString("aa_algoritmocache");
  672.             if (tmpAlg.equalsIgnoreCase("LRU"))
  673.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_LRU);
  674.             else
  675.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_MRU);

  676.             String tmpIdle = rs.getString("aa_idlecache");
  677.             String tmpLife = rs.getString("aa_lifecache");

  678.             if (tmpIdle != null && !tmpIdle.equals(""))
  679.                 cache.setItemIdleTime(tmpIdle);
  680.             if (tmpLife != null && !tmpLife.equals(""))
  681.                 cache.setItemLifeSecond(tmpLife);

  682.             accessoDatiAttributeAuthority.setCache(cache);

  683.         }
  684.     }
  685.    
  686.    
  687.    
  688.    
  689.    
  690.    
  691.     protected AccessoDatiKeystore getAccessoDatiKeystore() throws DriverConfigurazioneException {

  692.         Connection con = null;
  693.         PreparedStatement stm = null;
  694.         ResultSet rs = null;
  695.         String sqlQuery = "";

  696.         if (this.driver.atomica) {
  697.             try {
  698.                 con = this.driver.getConnectionFromDatasource("getAccessoDatiKeystore");

  699.             } catch (Exception e) {
  700.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiKeystore] Exception accedendo al datasource :" + e.getMessage(),e);

  701.             }

  702.         } else
  703.             con = this.driver.globalConnection;

  704.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  705.         try {
  706.             AccessoDatiKeystore accessoDatiKeystore = new AccessoDatiKeystore();

  707.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  708.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE);
  709.             sqlQueryObject.addSelectField("*");
  710.             sqlQuery = sqlQueryObject.createSQLQuery();
  711.             stm = con.prepareStatement(sqlQuery);

  712.             this.driver.logDebug("eseguo query : " + sqlQuery);

  713.             rs = stm.executeQuery();

  714.             if (rs.next()) {
  715.                 readAccessoDatiKeystore(rs, accessoDatiKeystore);
  716.                 rs.close();
  717.                 stm.close();
  718.             }

  719.             return accessoDatiKeystore;

  720.         } catch (SQLException se) {
  721.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiKeystore] SqlException: " + se.getMessage(),se);
  722.         }catch (Exception se) {
  723.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiKeystore] Exception: " + se.getMessage(),se);
  724.         } finally {
  725.             //Chiudo statement and resultset
  726.             JDBCUtilities.closeResources(rs, stm);
  727.             this.driver.closeConnection(con);
  728.         }
  729.     }
  730.     private void readAccessoDatiKeystore(ResultSet rs, AccessoDatiKeystore accessoDatiKeystore) throws SQLException {
  731.         String tmpCache = rs.getString("keystore_statocache");
  732.         if (CostantiConfigurazione.ABILITATO.equals(tmpCache)) {
  733.             Cache cache = new Cache();

  734.             String tmpDim = rs.getString("keystore_dimensionecache");
  735.             if (tmpDim != null && !tmpDim.equals(""))
  736.                 cache.setDimensione(tmpDim);

  737.             String tmpAlg = rs.getString("keystore_algoritmocache");
  738.             if (tmpAlg.equalsIgnoreCase("LRU"))
  739.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_LRU);
  740.             else
  741.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_MRU);

  742.             String tmpIdle = rs.getString("keystore_idlecache");
  743.             String tmpLife = rs.getString("keystore_lifecache");
  744.            

  745.             if (tmpIdle != null && !tmpIdle.equals(""))
  746.                 cache.setItemIdleTime(tmpIdle);
  747.             if (tmpLife != null && !tmpLife.equals(""))
  748.                 cache.setItemLifeSecond(tmpLife);

  749.             accessoDatiKeystore.setCache(cache);
  750.            
  751.             readAccessoDatiKeystoreCrlLife(rs, accessoDatiKeystore);
  752.         }
  753.     }
  754.     private void readAccessoDatiKeystoreCrlLife(ResultSet rs, AccessoDatiKeystore accessoDatiKeystore) throws SQLException {
  755.         String tmpCrlLife = rs.getString("keystore_crl_lifecache");
  756.        
  757.         if (tmpCrlLife != null && !tmpCrlLife.equals(""))
  758.             accessoDatiKeystore.setCrlItemLifeSecond(tmpCrlLife);
  759.     }
  760.    
  761.    
  762.    
  763.     protected AccessoDatiConsegnaApplicativi getAccessoDatiConsegnaApplicativi() throws DriverConfigurazioneException {

  764.         Connection con = null;
  765.         PreparedStatement stm = null;
  766.         ResultSet rs = null;
  767.         String sqlQuery = "";

  768.         if (this.driver.atomica) {
  769.             try {
  770.                 con = this.driver.getConnectionFromDatasource("getAccessoDatiConsegnaApplicativi");

  771.             } catch (Exception e) {
  772.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiConsegnaApplicativi] Exception accedendo al datasource :" + e.getMessage(),e);

  773.             }

  774.         } else
  775.             con = this.driver.globalConnection;

  776.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  777.         try {
  778.             AccessoDatiConsegnaApplicativi accessoDatiConsegnaApplicativi = new AccessoDatiConsegnaApplicativi();
  779.            
  780.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  781.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE);
  782.             sqlQueryObject.addSelectField("*");
  783.             sqlQuery = sqlQueryObject.createSQLQuery();
  784.             stm = con.prepareStatement(sqlQuery);

  785.             this.driver.logDebug("eseguo query : " + sqlQuery);

  786.             rs = stm.executeQuery();

  787.             if (rs.next()) {
  788.                 readAccessoDatiConsegnaApplicativi(rs, accessoDatiConsegnaApplicativi);
  789.                 rs.close();
  790.                 stm.close();
  791.             }

  792.             return accessoDatiConsegnaApplicativi;

  793.         } catch (SQLException se) {
  794.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiConsegnaApplicativi] SqlException: " + se.getMessage(),se);
  795.         }catch (Exception se) {
  796.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiConsegnaApplicativi] Exception: " + se.getMessage(),se);
  797.         } finally {
  798.             //Chiudo statement and resultset
  799.             JDBCUtilities.closeResources(rs, stm);
  800.             this.driver.closeConnection(con);
  801.         }
  802.     }
  803.     private void readAccessoDatiConsegnaApplicativi(ResultSet rs, AccessoDatiConsegnaApplicativi accessoDatiConsegnaApplicativi) throws SQLException {
  804.         String tmpCache = rs.getString("consegna_statocache");
  805.         if (CostantiConfigurazione.ABILITATO.equals(tmpCache)) {
  806.             Cache cache = new Cache();

  807.             String tmpDim = rs.getString("consegna_dimensionecache");
  808.             if (tmpDim != null && !tmpDim.equals(""))
  809.                 cache.setDimensione(tmpDim);

  810.             String tmpAlg = rs.getString("consegna_algoritmocache");
  811.             if (tmpAlg.equalsIgnoreCase("LRU"))
  812.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_LRU);
  813.             else
  814.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_MRU);

  815.             String tmpIdle = rs.getString("consegna_idlecache");
  816.             String tmpLife = rs.getString("consegna_lifecache");
  817.            
  818.             if (tmpIdle != null && !tmpIdle.equals(""))
  819.                 cache.setItemIdleTime(tmpIdle);
  820.             if (tmpLife != null && !tmpLife.equals(""))
  821.                 cache.setItemLifeSecond(tmpLife);

  822.             accessoDatiConsegnaApplicativi.setCache(cache);
  823.            
  824.         }
  825.     }
  826.    
  827.    
  828.     protected AccessoDatiRichieste getAccessoDatiRichieste() throws DriverConfigurazioneException {

  829.         Connection con = null;
  830.         PreparedStatement stm = null;
  831.         ResultSet rs = null;
  832.         String sqlQuery = "";

  833.         if (this.driver.atomica) {
  834.             try {
  835.                 con = this.driver.getConnectionFromDatasource("getAccessoDatiRichieste");

  836.             } catch (Exception e) {
  837.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiRichieste] Exception accedendo al datasource :" + e.getMessage(),e);

  838.             }

  839.         } else
  840.             con = this.driver.globalConnection;

  841.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  842.         try {
  843.             AccessoDatiRichieste accessoDatiRichieste = new AccessoDatiRichieste();
  844.            
  845.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  846.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE);
  847.             sqlQueryObject.addSelectField("*");
  848.             sqlQuery = sqlQueryObject.createSQLQuery();
  849.             stm = con.prepareStatement(sqlQuery);

  850.             this.driver.logDebug("eseguo query : " + sqlQuery);

  851.             rs = stm.executeQuery();

  852.             if (rs.next()) {
  853.                 readAccessoDatiRichieste(rs, accessoDatiRichieste);
  854.                 rs.close();
  855.                 stm.close();
  856.             }

  857.             return accessoDatiRichieste;

  858.         } catch (SQLException se) {
  859.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiRichieste] SqlException: " + se.getMessage(),se);
  860.         }catch (Exception se) {
  861.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getAccessoDatiRichieste] Exception: " + se.getMessage(),se);
  862.         } finally {
  863.             //Chiudo statement and resultset
  864.             JDBCUtilities.closeResources(rs, stm);
  865.             this.driver.closeConnection(con);
  866.         }
  867.     }
  868.     private void readAccessoDatiRichieste(ResultSet rs, AccessoDatiRichieste accessoDatiRichieste) throws SQLException {
  869.         String tmpCache = rs.getString("dati_richieste_statocache");
  870.         if (CostantiConfigurazione.ABILITATO.equals(tmpCache)) {
  871.             Cache cache = new Cache();

  872.             String tmpDim = rs.getString("dati_richieste_dimensionecache");
  873.             if (tmpDim != null && !tmpDim.equals(""))
  874.                 cache.setDimensione(tmpDim);

  875.             String tmpAlg = rs.getString("dati_richieste_algoritmocache");
  876.             if (tmpAlg.equalsIgnoreCase("LRU"))
  877.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_LRU);
  878.             else
  879.                 cache.setAlgoritmo(CostantiConfigurazione.CACHE_MRU);

  880.             String tmpIdle = rs.getString("dati_richieste_idlecache");
  881.             String tmpLife = rs.getString("dati_richieste_lifecache");
  882.            
  883.             if (tmpIdle != null && !tmpIdle.equals(""))
  884.                 cache.setItemIdleTime(tmpIdle);
  885.             if (tmpLife != null && !tmpLife.equals(""))
  886.                 cache.setItemLifeSecond(tmpLife);

  887.             accessoDatiRichieste.setCache(cache);

  888.         }
  889.     }
  890.    
  891.    

  892.     protected void createAccessoDatiAutorizzazione(AccessoDatiAutorizzazione accessoDatiAutorizzazione) throws DriverConfigurazioneException {

  893.         Connection con = null;
  894.         boolean error = false;

  895.         if (this.driver.atomica) {
  896.             try {
  897.                 con = this.driver.getConnectionFromDatasource("createAccessoDatiAutorizzazione");
  898.                 con.setAutoCommit(false);
  899.             } catch (Exception e) {
  900.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createAccessoDatiAutorizzazione] Exception accedendo al datasource :" + e.getMessage(),e);

  901.             }

  902.         } else
  903.             con = this.driver.globalConnection;

  904.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  905.         try {
  906.             this.driver.logDebug("CRUDAccessoDatiAutorizzazione type = 1");
  907.             DriverConfigurazioneDB_configLIB.CRUDAccessoDatiAutorizzazione(1, accessoDatiAutorizzazione, con);

  908.         } catch (Exception qe) {
  909.             error = true;
  910.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createAccessoDatiAutorizzazione] Errore durante la createAccessoDatiAutorizzazione : " + qe.getMessage(),qe);
  911.         } finally {

  912.             this.driver.closeConnection(error,con);
  913.         }
  914.     }

  915.     protected void updateAccessoDatiAutorizzazione(AccessoDatiAutorizzazione accessoDatiAutorizzazione) throws DriverConfigurazioneException {
  916.         Connection con = null;
  917.         boolean error = false;

  918.         if (this.driver.atomica) {
  919.             try {
  920.                 con = this.driver.getConnectionFromDatasource("updateAccessoDatiAutorizzazione");
  921.                 con.setAutoCommit(false);
  922.             } catch (Exception e) {
  923.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateAccessoDatiAutorizzazione] Exception accedendo al datasource :" + e.getMessage(),e);

  924.             }

  925.         } else
  926.             con = this.driver.globalConnection;

  927.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  928.         try {
  929.             this.driver.logDebug("CRUDAccessoDatiAutorizzazione type = 2");
  930.             DriverConfigurazioneDB_configLIB.CRUDAccessoDatiAutorizzazione(2, accessoDatiAutorizzazione, con);

  931.         } catch (Exception qe) {
  932.             error = true;
  933.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateAccessoDatiAutorizzazione] Errore durante la updateAccessoDatiAutorizzazione : " + qe.getMessage(),qe);
  934.         } finally {

  935.             this.driver.closeConnection(error,con);
  936.         }
  937.     }

  938.     protected void deleteAccessoDatiAutorizzazione(AccessoDatiAutorizzazione accessoDatiAutorizzazione) throws DriverConfigurazioneException {
  939.         Connection con = null;
  940.         boolean error = false;

  941.         if (this.driver.atomica) {
  942.             try {
  943.                 con = this.driver.getConnectionFromDatasource("deleteAccessoDatiAutorizzazione");
  944.                 con.setAutoCommit(false);
  945.             } catch (Exception e) {
  946.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteAccessoDatiAutorizzazione] Exception accedendo al datasource :" + e.getMessage(),e);

  947.             }

  948.         } else
  949.             con = this.driver.globalConnection;

  950.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  951.         try {
  952.             this.driver.logDebug("CRUDAccessoDatiAutorizzazione type = 3");
  953.             DriverConfigurazioneDB_configLIB.CRUDAccessoDatiAutorizzazione(3, accessoDatiAutorizzazione, con);

  954.         } catch (Exception qe) {
  955.             error = true;
  956.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteAccessoDatiAutorizzazione] Errore durante la deleteAccessoDatiAutorizzazione : " + qe.getMessage(),qe);
  957.         } finally {

  958.             this.driver.closeConnection(error,con);
  959.         }
  960.     }
  961.    

  962.     /**
  963.      * Restituisce la gestione dell'errore di default definita nella Porta di
  964.      * Dominio
  965.      *
  966.      * @return La gestione dell'errore
  967.      *
  968.      */
  969.     protected StatoServiziPdd getStatoServiziPdD() throws DriverConfigurazioneException,DriverConfigurazioneNotFound{

  970.         Connection con = null;
  971.         PreparedStatement stm = null;
  972.         ResultSet rs = null;
  973.         PreparedStatement stmFiltri = null;
  974.         ResultSet rsFiltri = null;

  975.         String sqlQuery = "";

  976.         if (this.driver.atomica) {
  977.             try {
  978.                 con = this.driver.getConnectionFromDatasource("getStatoServiziPdD");
  979.             } catch (Exception e) {
  980.                 throw new DriverConfigurazioneException("[getServiziAttiviPdD] Exception accedendo al datasource :" + e.getMessage(),e);

  981.             }
  982.         } else
  983.             con = this.driver.globalConnection;

  984.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  985.         try {
  986.             StatoServiziPdd servizi = null;

  987.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  988.             sqlQueryObject.addFromTable(CostantiDB.SERVIZI_PDD);
  989.             sqlQuery = sqlQueryObject.createSQLQuery();

  990.             ISQLQueryObject sqlQueryObjectFiltri = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  991.             sqlQueryObjectFiltri.addFromTable(CostantiDB.SERVIZI_PDD_FILTRI);
  992.             sqlQueryObjectFiltri.addWhereCondition("id_servizio_pdd=?");
  993.             String sqlQueryFiltro = sqlQueryObjectFiltri.createSQLQuery();

  994.             this.driver.logDebug("eseguo query: " + DBUtils.formatSQLString(sqlQuery));
  995.             stm = con.prepareStatement(sqlQuery);
  996.             rs = stm.executeQuery();


  997.             while (rs.next()) {

  998.                 if(servizi==null){
  999.                     servizi = new StatoServiziPdd();
  1000.                 }

  1001.                 long id = rs.getLong("id");

  1002.                 String tipo = rs.getString("componente");

  1003.                 int servizio = rs.getInt("stato");
  1004.                 StatoFunzionalita stato = null;
  1005.                 if(servizio==0)
  1006.                     stato = CostantiConfigurazione.DISABILITATO;
  1007.                 else if(servizio==1)
  1008.                     stato = CostantiConfigurazione.ABILITATO;
  1009.                 else
  1010.                     stato = CostantiConfigurazione.ABILITATO; // default

  1011.                 if(CostantiDB.COMPONENTE_SERVIZIO_PD.equals(tipo)){

  1012.                     StatoServiziPddPortaDelegata sPD = new StatoServiziPddPortaDelegata();
  1013.                     sPD.setStato(stato);

  1014.                     this.driver.logDebug("eseguo query filtro: " + DBUtils.formatSQLString(sqlQueryFiltro,id));
  1015.                     stmFiltri = con.prepareStatement(sqlQueryFiltro);
  1016.                     stmFiltri.setLong(1, id);
  1017.                     rsFiltri = stmFiltri.executeQuery();
  1018.                     riempiFiltriServiziPdD(rsFiltri, sPD.getFiltroAbilitazioneList(), sPD.getFiltroDisabilitazioneList());
  1019.                     rsFiltri.close();
  1020.                     stmFiltri.close();

  1021.                     servizi.setPortaDelegata(sPD);
  1022.                 }
  1023.                 else if(CostantiDB.COMPONENTE_SERVIZIO_PA.equals(tipo)){

  1024.                     StatoServiziPddPortaApplicativa sPA = new StatoServiziPddPortaApplicativa();
  1025.                     sPA.setStato(stato);

  1026.                     this.driver.logDebug("eseguo query filtro: " + DBUtils.formatSQLString(sqlQueryFiltro,id));
  1027.                     stmFiltri = con.prepareStatement(sqlQueryFiltro);
  1028.                     stmFiltri.setLong(1, id);
  1029.                     rsFiltri = stmFiltri.executeQuery();
  1030.                     riempiFiltriServiziPdD(rsFiltri, sPA.getFiltroAbilitazioneList(), sPA.getFiltroDisabilitazioneList());
  1031.                     rsFiltri.close();
  1032.                     stmFiltri.close();

  1033.                     servizi.setPortaApplicativa(sPA);
  1034.                 }
  1035.                 else if(CostantiDB.COMPONENTE_SERVIZIO_IM.equals(tipo)){

  1036.                     StatoServiziPddIntegrationManager sIM = new StatoServiziPddIntegrationManager();
  1037.                     sIM.setStato(stato);

  1038.                     servizi.setIntegrationManager(sIM);
  1039.                 }
  1040.             }

  1041.             if(servizi==null)
  1042.                 throw new DriverConfigurazioneNotFound("Configurazione servizi attivi sulla PdD non presente");

  1043.             rs.close();
  1044.             stm.close();

  1045.             return servizi;

  1046.         } catch (SQLException se) {
  1047.             throw new DriverConfigurazioneException("[getServiziAttiviPdD]  SqlException: " + se.getMessage(),se);
  1048.         }catch (DriverConfigurazioneNotFound e) {
  1049.             throw new DriverConfigurazioneNotFound(e);
  1050.         }catch (Exception se) {
  1051.             throw new DriverConfigurazioneException("[getServiziAttiviPdD]  Exception: " + se.getMessage(),se);
  1052.         } finally {
  1053.             //Chiudo statement and resultset
  1054.             JDBCUtilities.closeResources(rsFiltri, stmFiltri);
  1055.             JDBCUtilities.closeResources(rs, stm);
  1056.             this.driver.closeConnection(con);
  1057.         }

  1058.     }

  1059.     private void riempiFiltriServiziPdD(ResultSet rsFiltri,List<TipoFiltroAbilitazioneServizi> listaAbilitazioni,List<TipoFiltroAbilitazioneServizi> listaDisabilitazioni) throws SQLException{
  1060.         while(rsFiltri.next()){

  1061.             String tipo = rsFiltri.getString("tipo_filtro");

  1062.             TipoFiltroAbilitazioneServizi tipoFiltro = new TipoFiltroAbilitazioneServizi();

  1063.             String tipoSoggettoFruitore = rsFiltri.getString("tipo_soggetto_fruitore");
  1064.             tipoFiltro.setTipoSoggettoFruitore(tipoSoggettoFruitore);
  1065.             String soggettoFruitore = rsFiltri.getString("soggetto_fruitore");
  1066.             tipoFiltro.setSoggettoFruitore(soggettoFruitore);
  1067.             String identificativoPortaFruitore = rsFiltri.getString("identificativo_porta_fruitore");
  1068.             tipoFiltro.setIdentificativoPortaFruitore(identificativoPortaFruitore);

  1069.             String tipoSoggettoErogatore = rsFiltri.getString("tipo_soggetto_erogatore");
  1070.             tipoFiltro.setTipoSoggettoErogatore(tipoSoggettoErogatore);
  1071.             String soggettoErogatore = rsFiltri.getString("soggetto_erogatore");
  1072.             tipoFiltro.setSoggettoErogatore(soggettoErogatore);
  1073.             String identificativoPortaErogatore = rsFiltri.getString("identificativo_porta_erogatore");
  1074.             tipoFiltro.setIdentificativoPortaErogatore(identificativoPortaErogatore);

  1075.             String tipoServizio = rsFiltri.getString("tipo_servizio");
  1076.             tipoFiltro.setTipoServizio(tipoServizio);
  1077.             String servizio = rsFiltri.getString("servizio");
  1078.             tipoFiltro.setServizio(servizio);
  1079.             Integer versioneServizio = rsFiltri.getInt("versione_servizio");
  1080.             if(rsFiltri.wasNull()==false){
  1081.                 tipoFiltro.setVersioneServizio(versioneServizio);
  1082.             }

  1083.             String azione = rsFiltri.getString("azione");
  1084.             tipoFiltro.setAzione(azione);

  1085.             if(CostantiDB.TIPO_FILTRO_ABILITAZIONE_SERVIZIO_PDD.equals(tipo)){
  1086.                 listaAbilitazioni.add(tipoFiltro);
  1087.             }
  1088.             else{
  1089.                 listaDisabilitazioni.add(tipoFiltro);
  1090.             }

  1091.         }
  1092.     }



  1093.     /**
  1094.      * Crea le informazioni sui servizi attivi della PdD
  1095.      *
  1096.      * @param servizi
  1097.      * @throws DriverConfigurazioneException
  1098.      */
  1099.     protected void createStatoServiziPdD(StatoServiziPdd servizi) throws DriverConfigurazioneException{
  1100.         Connection con = null;
  1101.         boolean error = false;

  1102.         if (this.driver.atomica) {
  1103.             try {
  1104.                 con = this.driver.getConnectionFromDatasource("createStatoServiziPdD");
  1105.                 con.setAutoCommit(false);
  1106.             } catch (Exception e) {
  1107.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createServiziAttiviPdD] Exception accedendo al datasource :" + e.getMessage(),e);

  1108.             }

  1109.         } else
  1110.             con = this.driver.globalConnection;

  1111.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1112.         try {
  1113.             this.driver.logDebug("createServiziAttiviPdD type = 1");
  1114.             DriverConfigurazioneDB_configLIB.CRUDServiziPdD(1, servizi, con);

  1115.         } catch (Exception qe) {
  1116.             error = true;
  1117.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createServiziAttiviPdD] Errore durante la createServiziAttiviPdD : " + qe.getMessage(),qe);
  1118.         } finally {

  1119.             this.driver.closeConnection(error,con);
  1120.         }
  1121.     }

  1122.     /**
  1123.      * Aggiorna le informazioni sui servizi attivi della PdD
  1124.      *
  1125.      * @param servizi
  1126.      * @throws DriverConfigurazioneException
  1127.      */
  1128.     protected void updateStatoServiziPdD(StatoServiziPdd servizi) throws DriverConfigurazioneException{
  1129.         Connection con = null;
  1130.         boolean error = false;

  1131.         if (this.driver.atomica) {
  1132.             try {
  1133.                 con = this.driver.getConnectionFromDatasource("updateStatoServiziPdD");
  1134.                 con.setAutoCommit(false);
  1135.             } catch (Exception e) {
  1136.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateServiziAttiviPdD] Exception accedendo al datasource :" + e.getMessage(),e);

  1137.             }

  1138.         } else
  1139.             con = this.driver.globalConnection;

  1140.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1141.         try {
  1142.             this.driver.logDebug("createServiziAttiviPdD type = 2");
  1143.             DriverConfigurazioneDB_configLIB.CRUDServiziPdD(2, servizi, con);

  1144.         } catch (Exception qe) {
  1145.             error = true;
  1146.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateServiziAttiviPdD] Errore durante la updateServiziAttiviPdD : " + qe.getMessage(),qe);
  1147.         } finally {

  1148.             this.driver.closeConnection(error,con);
  1149.         }
  1150.     }


  1151.     /**
  1152.      * Elimina le informazioni sui servizi attivi della PdD
  1153.      *
  1154.      * @param servizi
  1155.      * @throws DriverConfigurazioneException
  1156.      */
  1157.     protected void deleteStatoServiziPdD(StatoServiziPdd servizi) throws DriverConfigurazioneException{
  1158.         Connection con = null;
  1159.         boolean error = false;

  1160.         if (this.driver.atomica) {
  1161.             try {
  1162.                 con = this.driver.getConnectionFromDatasource("deleteStatoServiziPdD");
  1163.                 con.setAutoCommit(false);
  1164.             } catch (Exception e) {
  1165.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteServiziAttiviPdD] Exception accedendo al datasource :" + e.getMessage(),e);

  1166.             }

  1167.         } else
  1168.             con = this.driver.globalConnection;

  1169.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1170.         try {
  1171.             this.driver.logDebug("createServiziAttiviPdD type = 3");
  1172.             DriverConfigurazioneDB_configLIB.CRUDServiziPdD(3, servizi, con);

  1173.         } catch (Exception qe) {
  1174.             error = true;
  1175.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteServiziAttiviPdD] Errore durante la deleteServiziAttiviPdD : " + qe.getMessage(),qe);
  1176.         } finally {

  1177.             this.driver.closeConnection(error,con);
  1178.         }
  1179.     }





  1180.    


  1181.     /**
  1182.      * Restituisce le proprieta' di sistema utilizzate dalla PdD
  1183.      *
  1184.      * @return proprieta' di sistema
  1185.      *
  1186.      */
  1187.     protected SystemProperties getSystemPropertiesPdD() throws DriverConfigurazioneException,DriverConfigurazioneNotFound{
  1188.         IDriverBYOK driverBYOK = this.driver.getDriverUnwrapBYOK();
  1189.         return getSystemPropertiesPdDEngine(driverBYOK);
  1190.     }
  1191.     protected SystemProperties getSystemPropertiesPdDWithoutBIOK() throws DriverConfigurazioneException,DriverConfigurazioneNotFound{
  1192.         return getSystemPropertiesPdDEngine(null);
  1193.     }
  1194.     private SystemProperties getSystemPropertiesPdDEngine(IDriverBYOK driverBYOK) throws DriverConfigurazioneException,DriverConfigurazioneNotFound{

  1195.         Connection con = null;
  1196.         PreparedStatement stm = null;
  1197.         ResultSet rs = null;

  1198.         String sqlQuery = "";

  1199.         if (this.driver.atomica) {
  1200.             try {
  1201.                 con = this.driver.getConnectionFromDatasource("getSystemPropertiesPdD");
  1202.             } catch (Exception e) {
  1203.                 throw new DriverConfigurazioneException("[getSystemPropertiesPdD] Exception accedendo al datasource :" + e.getMessage(),e);

  1204.             }
  1205.         } else
  1206.             con = this.driver.globalConnection;

  1207.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1208.         try {
  1209.             SystemProperties systemProperties = null;

  1210.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1211.             sqlQueryObject.addFromTable(CostantiDB.SYSTEM_PROPERTIES_PDD);
  1212.             sqlQuery = sqlQueryObject.createSQLQuery();

  1213.             this.driver.logDebug("eseguo query: " + DBUtils.formatSQLString(sqlQuery));
  1214.             stm = con.prepareStatement(sqlQuery);
  1215.             rs = stm.executeQuery();


  1216.             while (rs.next()) {

  1217.                 if(systemProperties==null){
  1218.                     systemProperties = new SystemProperties();
  1219.                 }

  1220.                 long id = rs.getLong("id");

  1221.                 String nome = rs.getString(CostantiDB.SYSTEM_PROPERTIES_PDD_COLUMN_NOME);
  1222.                
  1223.                 Property sp = new Property();
  1224.                 sp.setNome(nome);
  1225.                                
  1226.                 String plainValue = rs.getString(CostantiDB.SYSTEM_PROPERTIES_PDD_COLUMN_VALUE);
  1227.                 String encValue = rs.getString(CostantiDB.SYSTEM_PROPERTIES_PDD_COLUMN_ENC_VALUE);
  1228.                 if(encValue!=null && StringUtils.isNotEmpty(encValue)) {
  1229.                     if(driverBYOK!=null) {
  1230.                         sp.setValore(driverBYOK.unwrapAsString(encValue));
  1231.                     }
  1232.                     else {
  1233.                         sp.setValore(encValue);
  1234.                     }
  1235.                 }
  1236.                 else {
  1237.                     sp.setValore(plainValue);
  1238.                 }

  1239.                 sp.setId(id);
  1240.                 systemProperties.addSystemProperty(sp);

  1241.             }

  1242.             if(systemProperties==null)
  1243.                 throw new DriverConfigurazioneNotFound("System Properties non presenti");

  1244.             rs.close();
  1245.             stm.close();

  1246.             return systemProperties;

  1247.         } catch (SQLException se) {
  1248.             throw new DriverConfigurazioneException("[getSystemPropertiesPdD]  SqlException: " + se.getMessage(),se);
  1249.         }catch (DriverConfigurazioneNotFound e) {
  1250.             throw new DriverConfigurazioneNotFound(e);
  1251.         }catch (Exception se) {
  1252.             throw new DriverConfigurazioneException("[getSystemPropertiesPdD]  Exception: " + se.getMessage(),se);
  1253.         } finally {
  1254.             //Chiudo statement and resultset
  1255.             JDBCUtilities.closeResources(rs, stm);
  1256.             this.driver.closeConnection(con);
  1257.         }

  1258.     }
  1259.     protected List<String> getEncryptedSystemPropertiesPdD() throws DriverConfigurazioneException {
  1260.         List<String> l = new ArrayList<>();
  1261.         try {
  1262.             SystemProperties s = getSystemPropertiesPdDEngine(null);
  1263.             if(s!=null && s.sizeSystemPropertyList()>0) {
  1264.                 for (Property p : s.getSystemPropertyList()) {
  1265.                     if(p.getValore()!=null && StringUtils.isNotEmpty(p.getValore()) && BYOKUtilities.isWrappedValue(p.getValore())) {
  1266.                         l.add(p.getNome());
  1267.                     }
  1268.                 }
  1269.             }
  1270.         }catch(DriverConfigurazioneNotFound notFound) {
  1271.             // ignore
  1272.         }
  1273.         return l;
  1274.     }
  1275.    
  1276.     protected void createSystemPropertiesPdD(SystemProperties systemProperties) throws DriverConfigurazioneException{
  1277.         Connection con = null;
  1278.         boolean error = false;

  1279.         if (this.driver.atomica) {
  1280.             try {
  1281.                 con = this.driver.getConnectionFromDatasource("createSystemPropertiesPdD");
  1282.                 con.setAutoCommit(false);
  1283.             } catch (Exception e) {
  1284.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createSystemPropertiesPdD] Exception accedendo al datasource :" + e.getMessage(),e);

  1285.             }

  1286.         } else
  1287.             con = this.driver.globalConnection;

  1288.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1289.         try {
  1290.             this.driver.logDebug("createSystemPropertiesPdD type = 1");
  1291.             DriverConfigurazioneDB_configLIB.CRUDSystemPropertiesPdD(1, systemProperties, con, this.driver.getDriverWrapBYOK());

  1292.         } catch (Exception qe) {
  1293.             error = true;
  1294.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createSystemPropertiesPdD] Errore durante la createSystemPropertiesPdD : " + qe.getMessage(),qe);
  1295.         } finally {

  1296.             this.driver.closeConnection(error,con);
  1297.         }
  1298.     }

  1299.     /**
  1300.      * Aggiorna le informazioni sulle proprieta' di sistema utilizzate dalla PdD
  1301.      *
  1302.      * @param systemProperties
  1303.      * @throws DriverConfigurazioneException
  1304.      */
  1305.     protected void updateSystemPropertiesPdD(SystemProperties systemProperties) throws DriverConfigurazioneException{
  1306.         Connection con = null;
  1307.         boolean error = false;

  1308.         if (this.driver.atomica) {
  1309.             try {
  1310.                 con = this.driver.getConnectionFromDatasource("updateSystemPropertiesPdD");
  1311.                 con.setAutoCommit(false);
  1312.             } catch (Exception e) {
  1313.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateSystemPropertiesPdD] Exception accedendo al datasource :" + e.getMessage(),e);

  1314.             }

  1315.         } else
  1316.             con = this.driver.globalConnection;

  1317.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1318.         try {
  1319.             this.driver.logDebug("updateSystemPropertiesPdD type = 2");
  1320.             DriverConfigurazioneDB_configLIB.CRUDSystemPropertiesPdD(2, systemProperties, con, this.driver.getDriverWrapBYOK());

  1321.         } catch (Exception qe) {
  1322.             error = true;
  1323.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateSystemPropertiesPdD] Errore durante la updateSystemPropertiesPdD : " + qe.getMessage(),qe);
  1324.         } finally {

  1325.             this.driver.closeConnection(error,con);
  1326.         }
  1327.     }


  1328.     /**
  1329.      * Elimina le informazioni sulle proprieta' di sistema utilizzate dalla PdD
  1330.      *
  1331.      * @param systemProperties
  1332.      * @throws DriverConfigurazioneException
  1333.      */
  1334.     protected void deleteSystemPropertiesPdD(SystemProperties systemProperties) throws DriverConfigurazioneException{
  1335.         Connection con = null;
  1336.         boolean error = false;

  1337.         if (this.driver.atomica) {
  1338.             try {
  1339.                 con = this.driver.getConnectionFromDatasource("deleteSystemPropertiesPdD");
  1340.                 con.setAutoCommit(false);
  1341.             } catch (Exception e) {
  1342.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteSystemPropertiesPdD] Exception accedendo al datasource :" + e.getMessage(),e);

  1343.             }

  1344.         } else
  1345.             con = this.driver.globalConnection;

  1346.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1347.         try {
  1348.             this.driver.logDebug("deleteSystemPropertiesPdD type = 3");
  1349.             DriverConfigurazioneDB_configLIB.CRUDSystemPropertiesPdD(3, systemProperties, con, this.driver.getDriverWrapBYOK());

  1350.         } catch (Exception qe) {
  1351.             error = true;
  1352.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteSystemPropertiesPdD] Errore durante la deleteSystemPropertiesPdD : " + qe.getMessage(),qe);
  1353.         } finally {

  1354.             this.driver.closeConnection(error,con);
  1355.         }
  1356.     }
  1357.    
  1358.     protected ConfigurazioneUrlInvocazioneRegola getUrlInvocazioneRegola(String nome) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1359.         Connection con = null;
  1360.         PreparedStatement stm = null;
  1361.         ResultSet rs = null;
  1362.        
  1363.         String sqlQuery = "";

  1364.         if (this.driver.atomica) {
  1365.             try {
  1366.                 con = this.driver.getConnectionFromDatasource("getUrlInvocazioneRegola");
  1367.             } catch (Exception e) {
  1368.                 throw new DriverConfigurazioneException("[getUrlInvocazioneRegola] Exception accedendo al datasource :" + e.getMessage(),e);

  1369.             }
  1370.         } else
  1371.             con = this.driver.globalConnection;

  1372.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1373.         ConfigurazioneUrlInvocazioneRegola regola = null;
  1374.        
  1375.         try {
  1376.            
  1377.             if(nome==null) {
  1378.                 throw new DriverConfigurazioneException("Nome regola non indicato");
  1379.             }
  1380.            
  1381.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1382.             sqlQueryObject.addFromTable(CostantiDB.CONFIG_URL_REGOLE);
  1383.             sqlQueryObject.addSelectField("*");
  1384.             sqlQueryObject.addWhereCondition("nome=?");
  1385.             sqlQueryObject.addOrderBy("nome");
  1386.             sqlQueryObject.setSortType(true);  
  1387.             sqlQuery = sqlQueryObject.createSQLQuery();
  1388.             stm = con.prepareStatement(sqlQuery);
  1389.             stm.setString(1, nome);
  1390.             rs = stm.executeQuery();
  1391.             while(rs.next()){
  1392.                
  1393.                 regola = new ConfigurazioneUrlInvocazioneRegola();
  1394.                 readRegola(regola, rs);
  1395.                
  1396.             }
  1397.             rs.close();
  1398.             stm.close();

  1399.    
  1400.         }catch (DriverConfigurazioneNotFound notFound) {
  1401.             throw notFound;
  1402.         }catch (SQLException se) {
  1403.             throw new DriverConfigurazioneException("[getUrlInvocazioneRegola]  SqlException: " + se.getMessage(),se);
  1404.         }catch (Exception se) {
  1405.             throw new DriverConfigurazioneException("[getUrlInvocazioneRegolas]  Exception: " + se.getMessage(),se);
  1406.         }
  1407.         finally {
  1408.             JDBCUtilities.closeResources(rs, stm);
  1409.             this.driver.closeConnection(con);
  1410.         }

  1411.         if(regola!=null) {
  1412.             return regola;
  1413.         }
  1414.         throw new DriverConfigurazioneNotFound("Regola '"+nome+"' non esistente");
  1415.     }
  1416.    
  1417.     protected boolean existsUrlInvocazioneRegola(String nome) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1418.         Connection con = null;
  1419.         PreparedStatement stm = null;
  1420.         ResultSet rs = null;
  1421.        
  1422.         String sqlQuery = "";

  1423.         if (this.driver.atomica) {
  1424.             try {
  1425.                 con = this.driver.getConnectionFromDatasource("existsUrlInvocazioneRegola");
  1426.             } catch (Exception e) {
  1427.                 throw new DriverConfigurazioneException("[existsUrlInvocazioneRegola] Exception accedendo al datasource :" + e.getMessage(),e);

  1428.             }
  1429.         } else
  1430.             con = this.driver.globalConnection;

  1431.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1432.         try {
  1433.            
  1434.             if(nome==null) {
  1435.                 throw new DriverConfigurazioneException("Nome regola non indicato");
  1436.             }
  1437.            
  1438.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1439.             sqlQueryObject.addFromTable(CostantiDB.CONFIG_URL_REGOLE);
  1440.             sqlQueryObject.addSelectField("*");
  1441.             sqlQueryObject.addWhereCondition("nome=?");
  1442.             sqlQueryObject.addOrderBy("nome");
  1443.             sqlQueryObject.setSortType(true);  
  1444.             sqlQuery = sqlQueryObject.createSQLQuery();
  1445.             stm = con.prepareStatement(sqlQuery);
  1446.             stm.setString(1, nome);
  1447.             rs = stm.executeQuery();
  1448.             while(rs.next()){
  1449.                
  1450.                 return true;
  1451.                
  1452.             }
  1453.             rs.close();
  1454.             stm.close();

  1455.    
  1456.         }catch (SQLException se) {
  1457.             throw new DriverConfigurazioneException("[existsUrlInvocazioneRegola]  SqlException: " + se.getMessage(),se);
  1458.         }catch (Exception se) {
  1459.             throw new DriverConfigurazioneException("[existsUrlInvocazioneRegola]  Exception: " + se.getMessage(),se);
  1460.         }
  1461.         finally {
  1462.             JDBCUtilities.closeResources(rs, stm);
  1463.             this.driver.closeConnection(con);
  1464.         }

  1465.         return false;
  1466.     }

  1467.     private void readRegola(ConfigurazioneUrlInvocazioneRegola regola, ResultSet rs) throws Exception {
  1468.         regola.setId(rs.getLong("id"));
  1469.         regola.setNome(rs.getString("nome"));
  1470.         regola.setPosizione(rs.getInt("posizione"));
  1471.         regola.setStato(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(rs.getString("stato")));
  1472.         regola.setDescrizione(rs.getString("descrizione"));
  1473.         if(rs.getInt("regexpr") == CostantiDB.TRUE) {
  1474.             regola.setRegexpr(true);
  1475.         }else {
  1476.             regola.setRegexpr(false);
  1477.         }
  1478.         regola.setRegola(rs.getString("regola"));
  1479.         // Fix stringa vuota in Oracle, impostato dalla console e non accettato da Oracle che lo traduce in null e fa schiantare per via del NOT NULL sul db
  1480.         String s = rs.getString("contesto_esterno");
  1481.         if(CostantiConfigurazione.REGOLA_PROXY_PASS_CONTESTO_VUOTO.equals(s)) {
  1482.             s = "";
  1483.         }
  1484.         regola.setContestoEsterno(s);
  1485.         regola.setBaseUrl(rs.getString("base_url"));
  1486.         regola.setProtocollo(rs.getString("protocollo"));
  1487.         regola.setRuolo(DriverConfigurazioneDBLib.getEnumRuoloContesto(rs.getString("ruolo")));
  1488.         regola.setServiceBinding(DriverConfigurazioneDBLib.getEnumServiceBinding(rs.getString("service_binding")));
  1489.         String tipoSoggetto = rs.getString("tipo_soggetto");
  1490.         String nomeSoggetto = rs.getString("nome_soggetto");
  1491.         if(tipoSoggetto!=null && !"".equals(tipoSoggetto) && nomeSoggetto!=null && !"".equals(nomeSoggetto)) {
  1492.             regola.setSoggetto(new IdSoggetto(new IDSoggetto(tipoSoggetto, nomeSoggetto)));
  1493.         }
  1494.     }

  1495.     protected void createUrlInvocazioneRegola(ConfigurazioneUrlInvocazioneRegola regola) throws DriverConfigurazioneException{
  1496.         Connection con = null;
  1497.         boolean error = false;

  1498.         if (this.driver.atomica) {
  1499.             try {
  1500.                 con = this.driver.getConnectionFromDatasource("createUrlInvocazioneRegola");
  1501.                 con.setAutoCommit(false);
  1502.             } catch (Exception e) {
  1503.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createUrlInvocazioneRegola] Exception accedendo al datasource :" + e.getMessage(),e);

  1504.             }

  1505.         } else
  1506.             con = this.driver.globalConnection;

  1507.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1508.         try {
  1509.             this.driver.logDebug("CRUDUrlInvocazioneRegola type = 1");
  1510.             DriverConfigurazioneDB_configLIB.CRUDUrlInvocazioneRegola(1, regola, con);

  1511.         } catch (Exception qe) {
  1512.             error = true;
  1513.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createUrlInvocazioneRegola] Errore durante la create : " + qe.getMessage(),qe);
  1514.         } finally {

  1515.             this.driver.closeConnection(error,con);
  1516.         }
  1517.     }

  1518.     protected void updateUrlInvocazioneRegola(ConfigurazioneUrlInvocazioneRegola regola) throws DriverConfigurazioneException{
  1519.         Connection con = null;
  1520.         boolean error = false;

  1521.         if (this.driver.atomica) {
  1522.             try {
  1523.                 con = this.driver.getConnectionFromDatasource("updateUrlInvocazioneRegola");
  1524.                 con.setAutoCommit(false);
  1525.             } catch (Exception e) {
  1526.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateUrlInvocazioneRegola] Exception accedendo al datasource :" + e.getMessage(),e);

  1527.             }

  1528.         } else
  1529.             con = this.driver.globalConnection;

  1530.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1531.         try {
  1532.             this.driver.logDebug("CRUDUrlInvocazioneRegola type = 2");
  1533.             DriverConfigurazioneDB_configLIB.CRUDUrlInvocazioneRegola(2, regola, con);

  1534.         } catch (Exception qe) {
  1535.             error = true;
  1536.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateUrlInvocazioneRegola] Errore durante l'aggiornamento : " + qe.getMessage(),qe);
  1537.         } finally {

  1538.             this.driver.closeConnection(error,con);
  1539.         }
  1540.     }

  1541.     protected void deleteUrlInvocazioneRegola(ConfigurazioneUrlInvocazioneRegola regola) throws DriverConfigurazioneException{
  1542.         Connection con = null;
  1543.         boolean error = false;

  1544.         if (this.driver.atomica) {
  1545.             try {
  1546.                 con = this.driver.getConnectionFromDatasource("deleteUrlInvocazioneRegola");
  1547.                 con.setAutoCommit(false);
  1548.             } catch (Exception e) {
  1549.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteUrlInvocazioneRegola] Exception accedendo al datasource :" + e.getMessage(),e);

  1550.             }

  1551.         } else
  1552.             con = this.driver.globalConnection;

  1553.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1554.         try {
  1555.             this.driver.logDebug("CRUDUrlInvocazioneRegola type = 3");
  1556.             DriverConfigurazioneDB_configLIB.CRUDUrlInvocazioneRegola(3, regola, con);

  1557.         } catch (Exception qe) {
  1558.             error = true;
  1559.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteUrlInvocazioneRegola] Errore durante l'eliminazione : " + qe.getMessage(),qe);
  1560.         } finally {

  1561.             this.driver.closeConnection(error,con);
  1562.         }
  1563.     }
  1564.    
  1565.    
  1566.    
  1567.    
  1568.    
  1569.    
  1570.    
  1571.     /**
  1572.      * Restituisce la configurazione generale della Porta di Dominio
  1573.      *
  1574.      * @return Configurazione
  1575.      *
  1576.      */
  1577.     protected Configurazione getConfigurazioneGenerale() throws DriverConfigurazioneException,DriverConfigurazioneNotFound {
  1578.         // ritorna la configurazione generale della PdD

  1579.         Connection con = null;
  1580.         PreparedStatement stm = null;
  1581.         ResultSet rs = null;
  1582.         PreparedStatement stm1 = null;
  1583.         ResultSet rs1 = null;
  1584.         PreparedStatement stm2 = null;
  1585.         ResultSet rs2 = null;

  1586.         String sqlQuery = "";

  1587.         if (this.driver.atomica) {
  1588.             try {
  1589.                 con = this.driver.getConnectionFromDatasource("getConfigurazioneGenerale");

  1590.             } catch (Exception e) {
  1591.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getConfigurazioneGenerale] Exception accedendo al datasource :" + e.getMessage(),e);

  1592.             }

  1593.         } else
  1594.             con = this.driver.globalConnection;

  1595.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);
  1596.         Configurazione config = new Configurazione();
  1597.         try {
  1598.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1599.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE);
  1600.             sqlQueryObject.addSelectField("*");
  1601.             sqlQuery = sqlQueryObject.createSQLQuery();

  1602.             this.driver.logDebug("eseguo query: " + DBUtils.formatSQLString(sqlQuery));
  1603.             stm = con.prepareStatement(sqlQuery);
  1604.             rs = stm.executeQuery();

  1605.             if (rs.next()) {

  1606.                 Attachments attachments = new Attachments();
  1607.                 attachments.setGestioneManifest(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(rs.getString("gestione_manifest")));
  1608.                 config.setAttachments(attachments);

  1609.                 //config.setId(rs.getLong("id"));

  1610.                 IndirizzoRisposta indirizzoRisposta = new IndirizzoRisposta();
  1611.                 indirizzoRisposta.setUtilizzo(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(rs.getString("indirizzo_telematico")));
  1612.                 config.setIndirizzoRisposta(indirizzoRisposta);

  1613.                 String cadenza_inoltro = rs.getString("cadenza_inoltro");
  1614.                 InoltroBusteNonRiscontrate inoltroBusteNonRiscontrate = new InoltroBusteNonRiscontrate();
  1615.                 inoltroBusteNonRiscontrate.setCadenza(cadenza_inoltro);
  1616.                 config.setInoltroBusteNonRiscontrate(inoltroBusteNonRiscontrate);

  1617.                 String autenticazione = rs.getString("auth_integration_manager");
  1618.                 IntegrationManager integrationManager = new IntegrationManager();
  1619.                 integrationManager.setAutenticazione(autenticazione);
  1620.                 config.setIntegrationManager(integrationManager);

  1621.                 //String stato_cache = rs.getString("statocache");
  1622.                 //String dim_cache = rs.getString("dimensionecache");
  1623.                 //String alog_cache = rs.getString("algoritmocache");
  1624.                 //String idle_cache = rs.getString("idlecache");
  1625.                 //String life_cache = rs.getString("lifecache");


  1626.                 boolean routingEnabled =  false;
  1627.                 if(CostantiConfigurazione.ABILITATO.equals(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(rs.getString("routing_enabled"))))
  1628.                     routingEnabled = true;
  1629.                 RoutingTable rt = new RoutingTable();
  1630.                 rt.setAbilitata(routingEnabled);
  1631.                 config.setRoutingTable(rt);


  1632.                 String validazioneContenuti_stato = rs.getString("validazione_contenuti_stato");
  1633.                 String validazioneContenuti_tipo = rs.getString("validazione_contenuti_tipo");
  1634.                 String validazioneContenuti_acceptMtomMessage = rs.getString("validazione_contenuti_mtom");
  1635.                 if(  (validazioneContenuti_stato!=null && !validazioneContenuti_stato.equals(""))  
  1636.                         ||
  1637.                         (validazioneContenuti_tipo!=null && !validazioneContenuti_tipo.equals(""))  
  1638.                         ||
  1639.                         (validazioneContenuti_acceptMtomMessage!=null && !validazioneContenuti_acceptMtomMessage.equals("")))
  1640.                 {
  1641.                     ValidazioneContenutiApplicativi val = new ValidazioneContenutiApplicativi();
  1642.                     if((validazioneContenuti_stato!=null && !validazioneContenuti_stato.equals(""))  )
  1643.                         val.setStato(DriverConfigurazioneDBLib.getEnumStatoFunzionalitaConWarning(validazioneContenuti_stato));
  1644.                     if((validazioneContenuti_tipo!=null && !validazioneContenuti_tipo.equals(""))  )
  1645.                         val.setTipo(DriverConfigurazioneDBLib.getEnumValidazioneContenutiApplicativiTipo(validazioneContenuti_tipo));
  1646.                     if((validazioneContenuti_acceptMtomMessage!=null && !validazioneContenuti_acceptMtomMessage.equals(""))  )
  1647.                         val.setAcceptMtomMessage(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(validazioneContenuti_acceptMtomMessage));
  1648.                     config.setValidazioneContenutiApplicativi(val);
  1649.                 }


  1650.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1651.                 sqlQueryObject.addFromTable(CostantiDB.CONFIG_URL_INVOCAZIONE);
  1652.                 sqlQueryObject.addSelectField("*");
  1653.                 sqlQuery = sqlQueryObject.createSQLQuery();
  1654.                 stm1 = con.prepareStatement(sqlQuery);
  1655.                 rs1 = stm1.executeQuery();
  1656.                 if(rs1.next()){
  1657.                     ConfigurazioneUrlInvocazione configurazioneUrlInvocazione = new ConfigurazioneUrlInvocazione();
  1658.                     configurazioneUrlInvocazione.setBaseUrl(rs1.getString("base_url"));
  1659.                     configurazioneUrlInvocazione.setBaseUrlFruizione(rs1.getString("base_url_fruizione"));
  1660.                     config.setUrlInvocazione(configurazioneUrlInvocazione);
  1661.                 }
  1662.                 rs1.close();
  1663.                 stm1.close();
  1664.                
  1665.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1666.                 sqlQueryObject.addFromTable(CostantiDB.CONFIG_URL_REGOLE);
  1667.                 sqlQueryObject.addSelectField("*");
  1668.                 sqlQueryObject.addOrderBy("posizione");
  1669.                 sqlQueryObject.addOrderBy("nome");
  1670.                 sqlQueryObject.setSortType(true);  
  1671.                 sqlQuery = sqlQueryObject.createSQLQuery();
  1672.                 stm1 = con.prepareStatement(sqlQuery);
  1673.                 rs1 = stm1.executeQuery();
  1674.                 while(rs1.next()){
  1675.                    
  1676.                     if(config.getUrlInvocazione()==null) {
  1677.                         config.setUrlInvocazione(new ConfigurazioneUrlInvocazione());
  1678.                     }
  1679.                    
  1680.                     ConfigurazioneUrlInvocazioneRegola regola = new ConfigurazioneUrlInvocazioneRegola();
  1681.                     readRegola(regola, rs1);
  1682.                     config.getUrlInvocazione().addRegola(regola);
  1683.                 }
  1684.                 rs1.close();
  1685.                 stm1.close();

  1686.                
  1687.                 String multitenantStato = rs.getString("multitenant_stato");
  1688.                 String multitenantStatoSoggettiFruitori = rs.getString("multitenant_fruizioni");
  1689.                 String multitenantStatoSoggettiErogatori = rs.getString("multitenant_erogazioni");
  1690.                 config.setMultitenant(new ConfigurazioneMultitenant());
  1691.                 config.getMultitenant().setStato(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(multitenantStato));
  1692.                 config.getMultitenant().setFruizioneSceltaSoggettiErogatori(DriverConfigurazioneDBLib.getEnumPortaDelegataSoggettiErogatori(multitenantStatoSoggettiFruitori));
  1693.                 config.getMultitenant().setErogazioneSceltaSoggettiFruitori(DriverConfigurazioneDBLib.getEnumPortaApplicativaSoggettiFruitori(multitenantStatoSoggettiErogatori));

  1694.                 String msg_diag_severita = rs.getString("msg_diag_severita");
  1695.                 String msg_diag_severita_log4j = rs.getString("msg_diag_severita_log4j");
  1696.                 MessaggiDiagnostici messaggiDiagnostici = new MessaggiDiagnostici();
  1697.                 messaggiDiagnostici.setSeveritaLog4j(DriverConfigurazioneDBLib.getEnumSeverita(msg_diag_severita_log4j));
  1698.                 messaggiDiagnostici.setSeverita(DriverConfigurazioneDBLib.getEnumSeverita(msg_diag_severita));
  1699.                 //messaggi diagnostici appender
  1700.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1701.                 sqlQueryObject.addFromTable(CostantiDB.MSG_DIAGN_APPENDER);
  1702.                 sqlQueryObject.addSelectField("*");
  1703.                 sqlQuery = sqlQueryObject.createSQLQuery();
  1704.                 stm1 = con.prepareStatement(sqlQuery);
  1705.                 rs1 = stm1.executeQuery();

  1706.                 while(rs1.next()){
  1707.                     OpenspcoopAppender appender = new OpenspcoopAppender();
  1708.                     //tipo appender
  1709.                     appender.setTipo(rs1.getString("tipo"));
  1710.                     long idAppender = rs1.getLong("id");
  1711.                     appender.setId(idAppender);
  1712.                     //prendo le proprieta
  1713.                     sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1714.                     sqlQueryObject.addFromTable(CostantiDB.MSG_DIAGN_APPENDER_PROP);
  1715.                     sqlQueryObject.addSelectField("*");
  1716.                     sqlQueryObject.addWhereCondition("id_appender = ?");
  1717.                     sqlQuery = sqlQueryObject.createSQLQuery();
  1718.                     stm2 = con.prepareStatement(sqlQuery);
  1719.                     stm2.setLong(1, idAppender);
  1720.                     rs2 = stm2.executeQuery();
  1721.                     Property appender_prop = null;
  1722.                     while(rs2.next())
  1723.                     {
  1724.                         appender_prop = new Property();
  1725.                         //proprieta
  1726.                         appender_prop.setId(rs2.getLong("id"));
  1727.                         appender_prop.setNome(rs2.getString("nome"));
  1728.                         appender_prop.setValore(rs2.getString("valore"));
  1729.                         appender.addProperty(appender_prop);
  1730.                     }
  1731.                     rs2.close();
  1732.                     stm2.close();
  1733.                     messaggiDiagnostici.addOpenspcoopAppender(appender);
  1734.                 }
  1735.                 rs1.close();
  1736.                 stm1.close();

  1737.                 //messaggi diagnostici datasource
  1738.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1739.                 sqlQueryObject.addFromTable(CostantiDB.MSG_DIAGN_DS);
  1740.                 sqlQueryObject.addSelectField("*");
  1741.                 sqlQuery = sqlQueryObject.createSQLQuery();
  1742.                 stm1 = con.prepareStatement(sqlQuery);
  1743.                 rs1 = stm1.executeQuery();

  1744.                 while(rs1.next()){
  1745.                     OpenspcoopSorgenteDati openspcoopDS = new OpenspcoopSorgenteDati();
  1746.                     openspcoopDS.setNome(rs1.getString("nome"));
  1747.                     openspcoopDS.setNomeJndi(rs1.getString("nome_jndi"));
  1748.                     openspcoopDS.setTipoDatabase(rs1.getString("tipo_database"));
  1749.                     long idDS = rs1.getLong("id");
  1750.                     openspcoopDS.setId(idDS);
  1751.                     //prendo le proprieta
  1752.                     sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1753.                     sqlQueryObject.addFromTable(CostantiDB.MSG_DIAGN_DS_PROP);
  1754.                     sqlQueryObject.addSelectField("*");
  1755.                     sqlQueryObject.addWhereCondition("id_prop = ?");
  1756.                     sqlQuery = sqlQueryObject.createSQLQuery();
  1757.                     stm2 = con.prepareStatement(sqlQuery);
  1758.                     stm2.setLong(1, idDS);
  1759.                     rs2 = stm2.executeQuery();
  1760.                     Property ds_prop = null;
  1761.                     while(rs2.next())
  1762.                     {
  1763.                         ds_prop = new Property();
  1764.                         //proprieta
  1765.                         ds_prop.setId(rs2.getLong("id"));
  1766.                         ds_prop.setNome(rs2.getString("nome"));
  1767.                         ds_prop.setValore(rs2.getString("valore"));
  1768.                         openspcoopDS.addProperty(ds_prop);
  1769.                     }
  1770.                     rs2.close();
  1771.                     stm2.close();
  1772.                     messaggiDiagnostici.addOpenspcoopSorgenteDati(openspcoopDS);
  1773.                 }
  1774.                 rs1.close();
  1775.                 stm1.close();

  1776.                 config.setMessaggiDiagnostici(messaggiDiagnostici);

  1777.                
  1778.                
  1779.                 //Tracciamento
  1780.                 Tracciamento tracciamento = new Tracciamento();
  1781.                                
  1782.                 String traccBuste = rs.getString("tracciamento_buste");
  1783.                 tracciamento.setStato(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(traccBuste));
  1784.                
  1785.                            
  1786.                 // porta applicativa
  1787.                 String traccEsitiPA = rs.getString("tracciamento_esiti");
  1788.                 String transazioniTempiElaborazionePA = rs.getString("transazioni_tempi");
  1789.                 String transazioniTokenPA = rs.getString("transazioni_token");
  1790.                 TracciamentoConfigurazione tracciamentoDatabasePA = DriverConfigurazioneDBTracciamentoLIB.readTracciamentoConfigurazione(con, null,
  1791.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA,
  1792.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_DB);
  1793.                 TracciamentoConfigurazione tracciamentoFiletracePA = DriverConfigurazioneDBTracciamentoLIB.readTracciamentoConfigurazione(con, null,
  1794.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA,
  1795.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_FILETRACE);
  1796.                 TracciamentoConfigurazioneFiletrace tracciamentoFiletraceDetailsPA = DriverConfigurazioneDBTracciamentoLIB.readTracciamentoConfigurazioneFiletrace(con, null,
  1797.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA);
  1798.                 if(
  1799.                         (traccEsitiPA!=null && StringUtils.isNotEmpty(traccEsitiPA))
  1800.                         ||
  1801.                         (transazioniTempiElaborazionePA!=null && StringUtils.isNotEmpty(transazioniTempiElaborazionePA))
  1802.                         ||
  1803.                         (transazioniTokenPA!=null && StringUtils.isNotEmpty(transazioniTokenPA))
  1804.                         ||
  1805.                         tracciamentoDatabasePA!=null
  1806.                         ||
  1807.                         tracciamentoFiletracePA!=null
  1808.                         ||
  1809.                         tracciamentoFiletraceDetailsPA!=null
  1810.                         ) {
  1811.                     tracciamento.setPortaApplicativa(new ConfigurazioneTracciamentoPorta());
  1812.                     tracciamento.getPortaApplicativa().setEsiti(traccEsitiPA);
  1813.                     if(
  1814.                             (transazioniTempiElaborazionePA!=null && StringUtils.isNotEmpty(transazioniTempiElaborazionePA))
  1815.                             ||
  1816.                             (transazioniTokenPA!=null && StringUtils.isNotEmpty(transazioniTokenPA))
  1817.                             ) {
  1818.                         tracciamento.getPortaApplicativa().setTransazioni(new Transazioni());
  1819.                         tracciamento.getPortaApplicativa().getTransazioni().setTempiElaborazione(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(transazioniTempiElaborazionePA));
  1820.                         tracciamento.getPortaApplicativa().getTransazioni().setToken(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(transazioniTokenPA));
  1821.                     }
  1822.                     tracciamento.getPortaApplicativa().setDatabase(tracciamentoDatabasePA);
  1823.                     tracciamento.getPortaApplicativa().setFiletrace(tracciamentoFiletracePA);
  1824.                     tracciamento.getPortaApplicativa().setFiletraceConfig(tracciamentoFiletraceDetailsPA);
  1825.                 }

  1826.                
  1827.                 // porta delegata
  1828.                 String traccEsitiPD = rs.getString("tracciamento_esiti_pd");
  1829.                 String transazioniTempiElaborazionePD = rs.getString("transazioni_tempi_pd");
  1830.                 String transazioniTokenPD = rs.getString("transazioni_token_pd");
  1831.                 TracciamentoConfigurazione tracciamentoDatabasePD = DriverConfigurazioneDBTracciamentoLIB.readTracciamentoConfigurazione(con, null,
  1832.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD,
  1833.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_DB);
  1834.                 TracciamentoConfigurazione tracciamentoFiletracePD = DriverConfigurazioneDBTracciamentoLIB.readTracciamentoConfigurazione(con, null,
  1835.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD,
  1836.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_FILETRACE);
  1837.                 TracciamentoConfigurazioneFiletrace tracciamentoFiletraceDetailsPD = DriverConfigurazioneDBTracciamentoLIB.readTracciamentoConfigurazioneFiletrace(con, null,
  1838.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD);
  1839.                 if(
  1840.                         (traccEsitiPD!=null && StringUtils.isNotEmpty(traccEsitiPD))
  1841.                         ||
  1842.                         (transazioniTempiElaborazionePD!=null && StringUtils.isNotEmpty(transazioniTempiElaborazionePD))
  1843.                         ||
  1844.                         (transazioniTokenPD!=null && StringUtils.isNotEmpty(transazioniTokenPD))
  1845.                         ||
  1846.                         tracciamentoDatabasePD!=null
  1847.                         ||
  1848.                         tracciamentoFiletracePD!=null
  1849.                         ||
  1850.                         tracciamentoFiletraceDetailsPD!=null
  1851.                         ) {
  1852.                     tracciamento.setPortaDelegata(new ConfigurazioneTracciamentoPorta());
  1853.                     tracciamento.getPortaDelegata().setEsiti(traccEsitiPD);
  1854.                     if(
  1855.                             (transazioniTempiElaborazionePD!=null && StringUtils.isNotEmpty(transazioniTempiElaborazionePD))
  1856.                             ||
  1857.                             (transazioniTokenPD!=null && StringUtils.isNotEmpty(transazioniTokenPD))
  1858.                             ) {
  1859.                         tracciamento.getPortaDelegata().setTransazioni(new Transazioni());
  1860.                         tracciamento.getPortaDelegata().getTransazioni().setTempiElaborazione(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(transazioniTempiElaborazionePD));
  1861.                         tracciamento.getPortaDelegata().getTransazioni().setToken(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(transazioniTokenPD));
  1862.                     }
  1863.                     tracciamento.getPortaDelegata().setDatabase(tracciamentoDatabasePD);
  1864.                     tracciamento.getPortaDelegata().setFiletrace(tracciamentoFiletracePD);
  1865.                     tracciamento.getPortaDelegata().setFiletraceConfig(tracciamentoFiletraceDetailsPD);
  1866.                 }
  1867.                
  1868.                
  1869.                
  1870.                
  1871.                 //appender tracciamento
  1872.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1873.                 sqlQueryObject.addFromTable(CostantiDB.TRACCIAMENTO_APPENDER);
  1874.                 sqlQueryObject.addSelectField("*");
  1875.                 sqlQuery = sqlQueryObject.createSQLQuery();

  1876.                 stm1 = con.prepareStatement(sqlQuery);
  1877.                 rs1 = stm1.executeQuery();
  1878.                 //recuper tutti gli appender e le prop di ogni appender
  1879.                 while(rs1.next()){
  1880.                     OpenspcoopAppender trac_appender = new OpenspcoopAppender();
  1881.                     //tipo appender
  1882.                     trac_appender.setTipo(rs1.getString("tipo"));
  1883.                     long idAppenderTrac = rs1.getLong("id");
  1884.                     trac_appender.setId(idAppenderTrac);
  1885.                     //prendo le proprieta
  1886.                     sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1887.                     sqlQueryObject.addFromTable(CostantiDB.TRACCIAMENTO_APPENDER_PROP);
  1888.                     sqlQueryObject.addSelectField("*");
  1889.                     sqlQueryObject.addWhereCondition("id_appender = ?");
  1890.                     sqlQuery = sqlQueryObject.createSQLQuery();
  1891.                     stm2 = con.prepareStatement(sqlQuery);
  1892.                     stm2.setLong(1, idAppenderTrac);
  1893.                     rs2 = stm2.executeQuery();
  1894.                     Property trac_appender_prop = null;
  1895.                     while(rs2.next())
  1896.                     {
  1897.                         //setto le prop di questo appender
  1898.                         trac_appender_prop = new Property();
  1899.                         //proprieta
  1900.                         trac_appender_prop.setId(rs2.getLong("id"));
  1901.                         trac_appender_prop.setNome(rs2.getString("nome"));
  1902.                         trac_appender_prop.setValore(rs2.getString("valore"));
  1903.                         //aggiungo la prop all'appender
  1904.                         trac_appender.addProperty(trac_appender_prop);
  1905.                     }
  1906.                     rs2.close();
  1907.                     stm2.close();
  1908.                     tracciamento.addOpenspcoopAppender(trac_appender);
  1909.                 }
  1910.                 rs1.close();
  1911.                 stm1.close();

  1912.                 //datasource tracciamento
  1913.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1914.                 sqlQueryObject.addFromTable(CostantiDB.TRACCIAMENTO_DS);
  1915.                 sqlQueryObject.addSelectField("*");
  1916.                 sqlQuery = sqlQueryObject.createSQLQuery();

  1917.                 stm1 = con.prepareStatement(sqlQuery);
  1918.                 rs1 = stm1.executeQuery();
  1919.                 //recuper tutti i datasource e le prop di ogni datasource
  1920.                 while(rs1.next()){
  1921.                     OpenspcoopSorgenteDati trac_ds = new OpenspcoopSorgenteDati();
  1922.                     trac_ds.setNome(rs1.getString("nome"));
  1923.                     trac_ds.setNomeJndi(rs1.getString("nome_jndi"));
  1924.                     trac_ds.setTipoDatabase(rs1.getString("tipo_database"));
  1925.                     long idDsTrac = rs1.getLong("id");
  1926.                     trac_ds.setId(idDsTrac);
  1927.                     //prendo le proprieta
  1928.                     sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1929.                     sqlQueryObject.addFromTable(CostantiDB.TRACCIAMENTO_DS_PROP);
  1930.                     sqlQueryObject.addSelectField("*");
  1931.                     sqlQueryObject.addWhereCondition("id_prop = ?");
  1932.                     sqlQuery = sqlQueryObject.createSQLQuery();
  1933.                     stm2 = con.prepareStatement(sqlQuery);
  1934.                     stm2.setLong(1, idDsTrac);
  1935.                     rs2 = stm2.executeQuery();
  1936.                     Property trac_ds_prop = null;
  1937.                     while(rs2.next())
  1938.                     {
  1939.                         //setto le prop di questo datasource
  1940.                         trac_ds_prop = new Property();
  1941.                         //proprieta
  1942.                         trac_ds_prop.setId(rs2.getLong("id"));
  1943.                         trac_ds_prop.setNome(rs2.getString("nome"));
  1944.                         trac_ds_prop.setValore(rs2.getString("valore"));
  1945.                         //aggiungo la prop al datasource
  1946.                         trac_ds.addProperty(trac_ds_prop);
  1947.                     }
  1948.                     rs2.close();
  1949.                     stm2.close();
  1950.                     tracciamento.addOpenspcoopSorgenteDati(trac_ds);
  1951.                 }
  1952.                 rs1.close();
  1953.                 stm1.close();

  1954.                 config.setTracciamento(tracciamento);

  1955.                
  1956.                
  1957.                 // Dump
  1958.                 String dump_stato = rs.getString("dump");
  1959.                 String dump_pd = rs.getString("dump_bin_pd");
  1960.                 String dump_pa = rs.getString("dump_bin_pa");
  1961.                 Dump dump = new Dump();
  1962.                 dump.setStato(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(dump_stato));
  1963.                 dump.setDumpBinarioPortaDelegata(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(dump_pd));
  1964.                 if(dump.getDumpBinarioPortaDelegata()==null){
  1965.                     dump.setDumpBinarioPortaDelegata(StatoFunzionalita.DISABILITATO); // default
  1966.                 }
  1967.                 dump.setDumpBinarioPortaApplicativa(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(dump_pa));
  1968.                 if(dump.getDumpBinarioPortaApplicativa()==null){
  1969.                     dump.setDumpBinarioPortaApplicativa(StatoFunzionalita.DISABILITATO); // default
  1970.                 }
  1971.                 //appender dump
  1972.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1973.                 sqlQueryObject.addFromTable(CostantiDB.DUMP_APPENDER);
  1974.                 sqlQueryObject.addSelectField("*");
  1975.                 sqlQuery = sqlQueryObject.createSQLQuery();

  1976.                 stm1 = con.prepareStatement(sqlQuery);
  1977.                 rs1 = stm1.executeQuery();
  1978.                 //recuper tutti gli appender e le prop di ogni appender
  1979.                 while(rs1.next()){
  1980.                     OpenspcoopAppender dump_appender = new OpenspcoopAppender();
  1981.                     //tipo appender
  1982.                     dump_appender.setTipo(rs1.getString("tipo"));
  1983.                     long idAppenderDump = rs1.getLong("id");
  1984.                     dump_appender.setId(idAppenderDump);
  1985.                     //prendo le proprieta
  1986.                     sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1987.                     sqlQueryObject.addFromTable(CostantiDB.DUMP_APPENDER_PROP);
  1988.                     sqlQueryObject.addSelectField("*");
  1989.                     sqlQueryObject.addWhereCondition("id_appender = ?");
  1990.                     sqlQuery = sqlQueryObject.createSQLQuery();
  1991.                     stm2 = con.prepareStatement(sqlQuery);
  1992.                     stm2.setLong(1, idAppenderDump);
  1993.                     rs2 = stm2.executeQuery();
  1994.                     Property dump_appender_prop = null;
  1995.                     while(rs2.next())
  1996.                     {
  1997.                         //setto le prop di questo appender
  1998.                         dump_appender_prop = new Property();
  1999.                         //proprieta
  2000.                         dump_appender_prop.setId(rs2.getLong("id"));
  2001.                         dump_appender_prop.setNome(rs2.getString("nome"));
  2002.                         dump_appender_prop.setValore(rs2.getString("valore"));
  2003.                         //aggiungo la prop all'appender
  2004.                         dump_appender.addProperty(dump_appender_prop);
  2005.                     }
  2006.                     rs2.close();
  2007.                     stm2.close();
  2008.                     dump.addOpenspcoopAppender(dump_appender);
  2009.                 }
  2010.                 rs1.close();
  2011.                 stm1.close();

  2012.                 // dump_config
  2013.                 DumpConfigurazione dumpConfig = DriverConfigurazioneDB_dumpLIB.readDumpConfigurazione(con, null, CostantiDB.OLD_BACKWARD_COMPATIBILITY_DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG);
  2014.                 if(dumpConfig!=null) {
  2015.                     // backward compatibility, lo uso sia per erogazione che per fruizione
  2016.                     dump.setConfigurazionePortaApplicativa(dumpConfig);
  2017.                     dump.setConfigurazionePortaDelegata(dumpConfig);
  2018.                 }
  2019.                 else {
  2020.                     DumpConfigurazione dumpConfigPA = DriverConfigurazioneDB_dumpLIB.readDumpConfigurazione(con, null, CostantiDB.DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA);
  2021.                     dump.setConfigurazionePortaApplicativa(dumpConfigPA);
  2022.                    
  2023.                     DumpConfigurazione dumpConfigPD = DriverConfigurazioneDB_dumpLIB.readDumpConfigurazione(con, null, CostantiDB.DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD);
  2024.                     dump.setConfigurazionePortaDelegata(dumpConfigPD);
  2025.                 }
  2026.                
  2027.                
  2028.                 config.setDump(dump);
  2029.                
  2030.                
  2031.                 Risposte risposte = new Risposte();
  2032.                 risposte.setConnessione(DriverConfigurazioneDBLib.getEnumTipoConnessioneRisposte(rs.getString("mod_risposta")));
  2033.                 config.setRisposte(risposte);

  2034.                 String val_controllo = rs.getString("validazione_controllo");
  2035.                 String val_stato = rs.getString("validazione_stato");
  2036.                 String val_manifest = rs.getString("validazione_manifest");
  2037.                 String val_profilo = rs.getString("validazione_profilo");
  2038.                 ValidazioneBuste validazioneBuste = new ValidazioneBuste();
  2039.                 validazioneBuste.setControllo(DriverConfigurazioneDBLib.getEnumValidazioneBusteTipoControllo(val_controllo));
  2040.                 validazioneBuste.setManifestAttachments(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(val_manifest));
  2041.                 validazioneBuste.setProfiloCollaborazione(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(val_profilo));
  2042.                 validazioneBuste.setStato(DriverConfigurazioneDBLib.getEnumStatoFunzionalitaConWarning(val_stato));
  2043.                 config.setValidazioneBuste(validazioneBuste);

  2044.                 // Gestione CORS
  2045.                 config.setGestioneCors(new CorsConfigurazione());
  2046.                 this.porteDriver.readConfigurazioneCors(config.getGestioneCors(), rs);
  2047.                
  2048.                 // Gestione CacheResponse
  2049.                 config.setResponseCaching(new ResponseCachingConfigurazioneGenerale());
  2050.                
  2051.                 config.getResponseCaching().setConfigurazione(new ResponseCachingConfigurazione());
  2052.                 this.porteDriver.readResponseCaching(null, true, false, config.getResponseCaching().getConfigurazione(), rs, con);
  2053.                
  2054.                 String tmpCache = rs.getString("response_cache_statocache");
  2055.                 if (CostantiConfigurazione.ABILITATO.equals(tmpCache)) {
  2056.                     Cache cache = new Cache();

  2057.                     String tmpDim = rs.getString("response_cache_dimensionecache");
  2058.                     if (tmpDim != null && !tmpDim.equals(""))
  2059.                         cache.setDimensione(tmpDim);

  2060.                     String tmpAlg = rs.getString("response_cache_algoritmocache");
  2061.                     if (tmpAlg.equalsIgnoreCase("LRU"))
  2062.                         cache.setAlgoritmo(CostantiConfigurazione.CACHE_LRU);
  2063.                     else
  2064.                         cache.setAlgoritmo(CostantiConfigurazione.CACHE_MRU);

  2065.                     String tmpIdle = rs.getString("response_cache_idlecache");
  2066.                     String tmpLife = rs.getString("response_cache_lifecache");

  2067.                     if (tmpIdle != null && !tmpIdle.equals(""))
  2068.                         cache.setItemIdleTime(tmpIdle);
  2069.                     if (tmpLife != null && !tmpLife.equals(""))
  2070.                         cache.setItemLifeSecond(tmpLife);

  2071.                     config.getResponseCaching().setCache(cache);

  2072.                 }
  2073.                
  2074.                 // Canali
  2075.                 String canali_stato = rs.getString("canali_stato");
  2076.                 config.setGestioneCanali(new CanaliConfigurazione());
  2077.                 config.getGestioneCanali().setStato(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(canali_stato));
  2078.                 if(StatoFunzionalita.ABILITATO.equals(config.getGestioneCanali().getStato())) {
  2079.                     DriverConfigurazioneDB_canaliLIB.readCanaliConfigurazione(con, config.getGestioneCanali(), true);
  2080.                 }
  2081.                
  2082.                 // Handlers
  2083.                 ConfigurazioneMessageHandlers requestHandlers = DriverConfigurazioneDB_handlerLIB.readConfigurazioneMessageHandlers(con, null, null, true);
  2084.                 ConfigurazioneMessageHandlers responseHandlers = DriverConfigurazioneDB_handlerLIB.readConfigurazioneMessageHandlers(con, null, null, false);
  2085.                 ConfigurazioneServiceHandlers serviceHandlers = DriverConfigurazioneDB_handlerLIB.readConfigurazioneServiceHandlers(con, null, null, false);
  2086.                 if(requestHandlers!=null || responseHandlers!=null || serviceHandlers!=null) {
  2087.                     config.setConfigurazioneHandler(new ConfigurazioneGeneraleHandler());
  2088.                     config.getConfigurazioneHandler().setRequest(requestHandlers);
  2089.                     config.getConfigurazioneHandler().setResponse(responseHandlers);
  2090.                     config.getConfigurazioneHandler().setService(serviceHandlers);
  2091.                 }
  2092.                
  2093.                 ExtendedInfoManager extInfoManager = ExtendedInfoManager.getInstance();
  2094.                 IExtendedInfo extInfoConfigurazioneDriver = extInfoManager.newInstanceExtendedInfoConfigurazione();
  2095.                 if(extInfoConfigurazioneDriver!=null){
  2096.                     List<Object> list = extInfoConfigurazioneDriver.getAllExtendedInfo(con, this.driver.log, config);
  2097.                     if(list!=null && !list.isEmpty()){
  2098.                         config.setExtendedInfoList(list);
  2099.                     }
  2100.                 }
  2101.                
  2102.             } else {
  2103.                 throw new DriverConfigurazioneNotFound("[DriverConfigurazioneDB::getConfigurazioneGenerale] Configurazione non presente.");
  2104.             }

  2105.         } catch (DriverConfigurazioneNotFound e) {
  2106.             throw e;
  2107.         }catch (Exception se) {
  2108.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getConfigurazioneGenerale] Exception: " + se.getMessage(),se);
  2109.         } finally {
  2110.             //Chiudo statement and resultset
  2111.             JDBCUtilities.closeResources(rs, stm);
  2112.             JDBCUtilities.closeResources(rs1, stm1);
  2113.             JDBCUtilities.closeResources(rs2, stm2);
  2114.             this.driver.closeConnection(con);
  2115.         }


  2116.         // Altre parti di configurazione. Le prendo dopo aver rilasciato la connessione, per permettere di far funzionare il driver anche con pool di una sola connessione.

  2117.         // - GestioneErrore
  2118.         ConfigurazioneGestioneErrore cge = null;

  2119.         try{
  2120.             GestioneErrore ge = this.gestioneErroreDriver.getGestioneErroreComponenteIntegrazione();

  2121.             if(ge!=null){
  2122.                 if(cge==null) cge = new ConfigurazioneGestioneErrore();
  2123.                 cge.setComponenteIntegrazione(ge);
  2124.             }
  2125.         }catch (Exception e) {
  2126.             // ignore
  2127.         }

  2128.         try{
  2129.             GestioneErrore ge = this.gestioneErroreDriver.getGestioneErroreComponenteCooperazione();
  2130.             if(ge!=null){
  2131.                 if(cge==null) cge = new ConfigurazioneGestioneErrore();
  2132.                 cge.setComponenteCooperazione(ge);
  2133.             }
  2134.         }catch (Exception e) {
  2135.             // ignore
  2136.         }

  2137.         if(cge!=null) config.setGestioneErrore(cge);

  2138.         // - AccessoRegistro
  2139.         try{
  2140.             config.setAccessoRegistro(getAccessoRegistro());
  2141.         }catch (Exception e) {
  2142.             // ignore
  2143.         }
  2144.        
  2145.         // - AccessoConfigurazione
  2146.         try{
  2147.             config.setAccessoConfigurazione(getAccessoConfigurazione());
  2148.         }catch (Exception e) {
  2149.             // ignore
  2150.         }
  2151.        
  2152.         // - AccessoDatiAutorizzazione
  2153.         try{
  2154.             config.setAccessoDatiAutorizzazione(getAccessoDatiAutorizzazione());
  2155.         }catch (Exception e) {
  2156.             // ignore
  2157.         }
  2158.        
  2159.         // - AccessoDatiAutenticazione
  2160.         try{
  2161.             config.setAccessoDatiAutenticazione(getAccessoDatiAutenticazione());
  2162.         }catch (Exception e) {
  2163.             // ignore
  2164.         }
  2165.        
  2166.         // - AccessoDatiGestioneToken
  2167.         try{
  2168.             config.setAccessoDatiGestioneToken(getAccessoDatiGestioneToken());
  2169.         }catch (Exception e) {
  2170.             // ignore
  2171.         }
  2172.        
  2173.         // - AccessoDatiAttributeAuthority
  2174.         try{
  2175.             config.setAccessoDatiAttributeAuthority(getAccessoDatiAttributeAuthority());
  2176.         }catch (Exception e) {
  2177.             // ignore
  2178.         }
  2179.        
  2180.         // - AccessoDatiKeystore
  2181.         try{
  2182.             config.setAccessoDatiKeystore(getAccessoDatiKeystore());
  2183.         }catch (Exception e) {
  2184.             // ignore
  2185.         }
  2186.        
  2187.         // - AccessoDatiConsegnaApplicativi
  2188.         try{
  2189.             config.setAccessoDatiConsegnaApplicativi(getAccessoDatiConsegnaApplicativi());
  2190.         }catch (Exception e) {
  2191.             // ignore
  2192.         }
  2193.        
  2194.         // - AccessoDatiRichieste
  2195.         try{
  2196.             config.setAccessoDatiRichieste(getAccessoDatiRichieste());
  2197.         }catch (Exception e) {
  2198.             // ignore
  2199.         }

  2200.         // - RoutingTable
  2201.         try{
  2202.             config.setRoutingTable(this.routingTableDriver.getRoutingTable());
  2203.         }catch (Exception e) {
  2204.             // ignore
  2205.         }

  2206.         // - ServiziPdD
  2207.         try{
  2208.             config.setStatoServiziPdd(getStatoServiziPdD());
  2209.         }catch (Exception e) {
  2210.             // ignore
  2211.         }

  2212.         // - SystemProperties
  2213.         try{
  2214.             config.setSystemProperties(getSystemPropertiesPdD());
  2215.         }catch (Exception e) {
  2216.             // ignore
  2217.         }

  2218.         // - GenericProperties
  2219.         try{
  2220.             config.getGenericPropertiesList().addAll(this.genericPropertiesDriver.getGenericProperties());
  2221.         }catch (Exception e) {
  2222.             // ignore
  2223.         }

  2224.         return config;
  2225.     }

  2226.    
  2227.    
  2228.    
  2229.    
  2230.     protected Object getConfigurazioneExtended(Configurazione config, String idExtendedConfiguration) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  2231.         Connection con = null;
  2232.        
  2233.         if (this.driver.atomica) {
  2234.             try {
  2235.                 con = this.driver.getConnectionFromDatasource("getConfigurazioneExtended");

  2236.             } catch (Exception e) {
  2237.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getConfigurazioneExtended] Exception accedendo al datasource :" + e.getMessage(),e);

  2238.             }

  2239.         } else
  2240.             con = this.driver.globalConnection;
  2241.        
  2242.         try {
  2243.            
  2244.             this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);
  2245.            
  2246.             this.driver.logDebug("getConfigurazioneExtended("+idExtendedConfiguration+")");
  2247.            
  2248.             ExtendedInfoManager extInfoManager = ExtendedInfoManager.getInstance();
  2249.             IExtendedInfo extInfoConfigurazioneDriver = extInfoManager.newInstanceExtendedInfoConfigurazione();
  2250.             if(extInfoConfigurazioneDriver!=null){
  2251.                
  2252.                 Object o = extInfoConfigurazioneDriver.getExtendedInfo(con, this.driver.log, config, idExtendedConfiguration);
  2253.                 if(o==null){
  2254.                     throw new DriverConfigurazioneNotFound("Oggetto non esistente");
  2255.                 }
  2256.                 return o;
  2257.                
  2258.             }  
  2259.            
  2260.             throw new DriverConfigurazioneException("Driver non inizializzato");

  2261.         }
  2262.         catch (DriverConfigurazioneNotFound dNot) {
  2263.             throw dNot;
  2264.         }
  2265.         catch (Exception qe) {
  2266.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getConfigurazioneExtended] Errore: " + qe.getMessage(),qe);
  2267.         }
  2268.         finally {
  2269.            
  2270.             this.driver.closeConnection(con);
  2271.         }
  2272.     }
  2273.    


  2274.     protected void createConfigurazione(Configurazione configurazione) throws DriverConfigurazioneException {
  2275.         Connection con = null;
  2276.         boolean error = false;

  2277.         if (this.driver.atomica) {
  2278.             try {
  2279.                 con = this.driver.getConnectionFromDatasource("createConfigurazione");
  2280.                 con.setAutoCommit(false);
  2281.             } catch (Exception e) {
  2282.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createConfigurazioneGenerale] Exception accedendo al datasource :" + e.getMessage(),e);

  2283.             }

  2284.         } else
  2285.             con = this.driver.globalConnection;

  2286.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2287.         try {
  2288.             this.driver.logDebug("CRUDConfigurazioneGenerale type = 1");
  2289.             DriverConfigurazioneDB_configLIB.CRUDConfigurazioneGenerale(1, configurazione, con);

  2290.         } catch (Exception qe) {
  2291.             error = true;
  2292.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createConfigurazioneGenerale] Errore durante la create ConfigurazioneGenerale : " + qe.getMessage(),qe);
  2293.         } finally {

  2294.             this.driver.closeConnection(error,con);
  2295.         }
  2296.     }

  2297.    
  2298.     protected void updateConfigurazione(Configurazione configurazione) throws DriverConfigurazioneException {
  2299.         Connection con = null;
  2300.         boolean error = false;

  2301.         if (this.driver.atomica) {
  2302.             try {
  2303.                 con = this.driver.getConnectionFromDatasource("updateConfigurazione");
  2304.                 con.setAutoCommit(false);
  2305.             } catch (Exception e) {
  2306.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateConfigurazioneGenerale] Exception accedendo al datasource :" + e.getMessage(),e);

  2307.             }

  2308.         } else
  2309.             con = this.driver.globalConnection;

  2310.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2311.         try {
  2312.             this.driver.logDebug("CRUDConfigurazioneGenerale type = 2");
  2313.             DriverConfigurazioneDB_configLIB.CRUDConfigurazioneGenerale(2, configurazione, con);

  2314.         } catch (Exception qe) {
  2315.             error = true;
  2316.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateConfigurazioneGenerale] Errore durante la update ConfigurazioneGenerale : " + qe.getMessage(),qe);
  2317.         } finally {

  2318.             this.driver.closeConnection(error,con);
  2319.         }
  2320.     }

  2321.    
  2322.     protected void deleteConfigurazione(Configurazione configurazione) throws DriverConfigurazioneException {
  2323.         Connection con = null;
  2324.         boolean error = false;

  2325.         if (this.driver.atomica) {
  2326.             try {
  2327.                 con = this.driver.getConnectionFromDatasource("deleteConfigurazione");
  2328.                 con.setAutoCommit(false);
  2329.             } catch (Exception e) {
  2330.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteConfigurazioneGenerale] Exception accedendo al datasource :" + e.getMessage(),e);

  2331.             }

  2332.         } else
  2333.             con = this.driver.globalConnection;

  2334.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2335.         try {
  2336.             this.driver.logDebug("CRUDConfigurazioneGenerale type = 3");
  2337.             DriverConfigurazioneDB_configLIB.CRUDConfigurazioneGenerale(CostantiDB.DELETE, configurazione, con);

  2338.         } catch (Exception qe) {
  2339.             error = true;
  2340.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteConfigurazioneGenerale] Errore durante la delete ConfigurazioneGenerale : " + qe.getMessage(),qe);
  2341.         } finally {

  2342.             this.driver.closeConnection(error,con);
  2343.         }
  2344.     }
  2345.    

  2346.     // ACCESSO REGISTRO

  2347.     /**
  2348.      * Crea le informazioni per l'accesso ai registri
  2349.      *
  2350.      * @param registro
  2351.      * @throws DriverConfigurazioneException
  2352.      */

  2353.     protected void createAccessoRegistro(AccessoRegistro registro) throws DriverConfigurazioneException {
  2354.         Connection con = null;
  2355.         boolean error = false;

  2356.         if (this.driver.atomica) {
  2357.             try {
  2358.                 con = this.driver.getConnectionFromDatasource("createAccessoRegistro");
  2359.                 con.setAutoCommit(false);
  2360.             } catch (Exception e) {
  2361.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createAccessoRegistro] Exception accedendo al datasource :" + e.getMessage(),e);

  2362.             }

  2363.         } else
  2364.             con = this.driver.globalConnection;

  2365.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2366.         try {
  2367.             this.driver.logDebug("CRUDAccessoRegistro type = 1");
  2368.             DriverConfigurazioneDB_configLIB.CRUDAccessoRegistro(1, registro, con);

  2369.         } catch (Exception qe) {
  2370.             error = true;
  2371.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::createAccessoRegistro] Errore durante la updateAccessoRegistro : " + qe.getMessage(),qe);
  2372.         } finally {

  2373.             this.driver.closeConnection(error,con);
  2374.         }
  2375.     }

  2376.     /**
  2377.      * Aggiorna le informazioni per l'accesso ai registri
  2378.      *
  2379.      * @param registro
  2380.      * @throws DriverConfigurazioneException
  2381.      */
  2382.     protected void updateAccessoRegistro(AccessoRegistro registro) throws DriverConfigurazioneException {
  2383.         Connection con = null;
  2384.         boolean error = false;

  2385.         if (this.driver.atomica) {
  2386.             try {
  2387.                 con = this.driver.getConnectionFromDatasource("updateAccessoRegistro");
  2388.                 con.setAutoCommit(false);
  2389.             } catch (Exception e) {
  2390.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateAccessoRegistro] Exception accedendo al datasource :" + e.getMessage(),e);

  2391.             }

  2392.         } else
  2393.             con = this.driver.globalConnection;

  2394.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2395.         try {
  2396.             this.driver.logDebug("CRUDAccessoRegistro type = 2");
  2397.             DriverConfigurazioneDB_configLIB.CRUDAccessoRegistro(2, registro, con);

  2398.         } catch (Exception qe) {
  2399.             error = true;
  2400.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::updateAccessoRegistro] Errore durante la updateAccessoRegistro : " + qe.getMessage(),qe);
  2401.         } finally {

  2402.             this.driver.closeConnection(error,con);
  2403.         }
  2404.     }

  2405.     /**
  2406.      * Elimina le informazioni per l'accesso ai registri
  2407.      *
  2408.      * @param registro
  2409.      * @throws DriverConfigurazioneException
  2410.      */
  2411.     protected void deleteAccessoRegistro(AccessoRegistro registro) throws DriverConfigurazioneException {
  2412.         Connection con = null;
  2413.         boolean error = false;

  2414.         if (this.driver.atomica) {
  2415.             try {
  2416.                 con = this.driver.getConnectionFromDatasource("deleteAccessoRegistro");
  2417.                 con.setAutoCommit(false);
  2418.             } catch (Exception e) {
  2419.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteAccessoRegistro] Exception accedendo al datasource :" + e.getMessage(),e);

  2420.             }

  2421.         } else
  2422.             con = this.driver.globalConnection;

  2423.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2424.         try {
  2425.             this.driver.logDebug("CRUDAccessoRegistro type = 3");
  2426.             DriverConfigurazioneDB_configLIB.CRUDAccessoRegistro(3, registro, con);

  2427.         } catch (Exception qe) {
  2428.             error = true;
  2429.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::deleteAccessoRegistro] Errore durante la updateAccessoRegistro : " + qe.getMessage(),qe);
  2430.         } finally {

  2431.             this.driver.closeConnection(error,con);
  2432.         }
  2433.     }
  2434.    
  2435.     protected boolean existsResponseCachingConfigurazioneRegola(Integer statusMin, Integer statusMax, boolean fault) throws DriverConfigurazioneException {
  2436.         String nomeMetodo = "existsResponseCachingConfigurazioneRegola";

  2437.         Connection con = null;
  2438.         PreparedStatement stmt=null;
  2439.         ResultSet risultato=null;
  2440.         String queryString;

  2441.         if (this.driver.atomica) {
  2442.             try {
  2443.                 con = this.driver.getConnectionFromDatasource("existsResponseCachingConfigurazioneRegola");
  2444.             } catch (Exception e) {
  2445.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2446.             }

  2447.         } else
  2448.             con = this.driver.globalConnection;

  2449.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2450.         try {

  2451.             int count = 0;
  2452.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2453.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE_CACHE_REGOLE);
  2454.             sqlQueryObject.addSelectCountField("*", "cont");
  2455.             sqlQueryObject.setANDLogicOperator(true);
  2456.            
  2457.             if(statusMin != null) {
  2458.                 sqlQueryObject.addWhereCondition("status_min = ?");
  2459.             } else {
  2460.                 sqlQueryObject.addWhereIsNullCondition("status_min");
  2461.             }
  2462.            
  2463.             if(statusMax != null) {
  2464.                 sqlQueryObject.addWhereCondition("status_max = ?");
  2465.             } else {
  2466.                 sqlQueryObject.addWhereIsNullCondition("status_max");
  2467.             }
  2468.            
  2469.             //if(fault) {
  2470.             //  sqlQueryObject.addWhereCondition("fault = ?");
  2471.             //} else {
  2472.             sqlQueryObject.addWhereCondition("fault = ?");
  2473.             //}
  2474.            
  2475.             queryString = sqlQueryObject.createSQLQuery();
  2476.             stmt = con.prepareStatement(queryString);
  2477.             int parameterIndex = 1;
  2478.             if(statusMin != null)
  2479.                 stmt.setInt(parameterIndex ++, statusMin);
  2480.             if(statusMax != null)
  2481.                 stmt.setInt(parameterIndex ++, statusMax);
  2482.             if(fault) {
  2483.                 stmt.setInt(parameterIndex ++, CostantiDB.TRUE);
  2484.             } else {
  2485.                 stmt.setInt(parameterIndex ++, CostantiDB.FALSE);
  2486.             }
  2487.            
  2488.             risultato = stmt.executeQuery();
  2489.             if (risultato.next())
  2490.                 count = risultato.getInt(1);
  2491.             risultato.close();
  2492.             stmt.close();

  2493.             return count > 0;

  2494.         } catch (Exception qe) {
  2495.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2496.         } finally {

  2497.             //Chiudo statement and resultset
  2498.             JDBCUtilities.closeResources(risultato, stmt);

  2499.             this.driver.closeConnection(con);
  2500.         }
  2501.     }
  2502.    
  2503.     protected boolean existsProxyPassConfigurazioneRegola(String nome) throws DriverConfigurazioneException {
  2504.         String nomeMetodo = "existsResponseCachingConfigurazioneRegola";

  2505.         Connection con = null;
  2506.         PreparedStatement stmt=null;
  2507.         ResultSet risultato=null;
  2508.         String queryString;

  2509.         if (this.driver.atomica) {
  2510.             try {
  2511.                 con = this.driver.getConnectionFromDatasource("existsResponseCachingConfigurazioneRegola");
  2512.             } catch (Exception e) {
  2513.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2514.             }

  2515.         } else
  2516.             con = this.driver.globalConnection;

  2517.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2518.         try {

  2519.             int count = 0;
  2520.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2521.             sqlQueryObject.addFromTable(CostantiDB.CONFIG_URL_REGOLE);
  2522.             sqlQueryObject.addSelectCountField("*", "cont");
  2523.             sqlQueryObject.setANDLogicOperator(true);
  2524.             sqlQueryObject.addWhereCondition("nome = ?");
  2525.            
  2526.             queryString = sqlQueryObject.createSQLQuery();
  2527.             stmt = con.prepareStatement(queryString);
  2528.             int parameterIndex = 1;
  2529.             stmt.setString(parameterIndex ++, nome);
  2530.            
  2531.             risultato = stmt.executeQuery();
  2532.             if (risultato.next())
  2533.                 count = risultato.getInt(1);
  2534.             risultato.close();
  2535.             stmt.close();

  2536.             return count > 0;

  2537.         } catch (Exception qe) {
  2538.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2539.         } finally {

  2540.             //Chiudo statement and resultset
  2541.             JDBCUtilities.closeResources(risultato, stmt);

  2542.             this.driver.closeConnection(con);
  2543.         }
  2544.     }
  2545.    
  2546.     protected boolean existsCanale(String nome) throws DriverConfigurazioneException {
  2547.         String nomeMetodo = "existsCanale";

  2548.         Connection con = null;
  2549.         PreparedStatement stmt=null;
  2550.         ResultSet risultato=null;
  2551.         String queryString;

  2552.         if (this.driver.atomica) {
  2553.             try {
  2554.                 con = this.driver.getConnectionFromDatasource(nomeMetodo);
  2555.             } catch (Exception e) {
  2556.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2557.             }

  2558.         } else
  2559.             con = this.driver.globalConnection;

  2560.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2561.         try {

  2562.             int count = 0;
  2563.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2564.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE_CANALI);
  2565.             sqlQueryObject.addSelectCountField("*", "cont");
  2566.             sqlQueryObject.setANDLogicOperator(true);
  2567.             sqlQueryObject.addWhereCondition("nome = ?");
  2568.            
  2569.             queryString = sqlQueryObject.createSQLQuery();
  2570.             stmt = con.prepareStatement(queryString);
  2571.             int parameterIndex = 1;
  2572.             stmt.setString(parameterIndex ++, nome);
  2573.            
  2574.             risultato = stmt.executeQuery();
  2575.             if (risultato.next())
  2576.                 count = risultato.getInt(1);
  2577.             risultato.close();
  2578.             stmt.close();

  2579.             return count > 0;

  2580.         } catch (Exception qe) {
  2581.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2582.         } finally {

  2583.             //Chiudo statement and resultset
  2584.             JDBCUtilities.closeResources(risultato, stmt);

  2585.             this.driver.closeConnection(con);
  2586.         }
  2587.     }
  2588.    
  2589.     protected boolean existsCanaleNodo(String nome) throws DriverConfigurazioneException {
  2590.         String nomeMetodo = "existsCanaleNodo";

  2591.         Connection con = null;
  2592.         PreparedStatement stmt=null;
  2593.         ResultSet risultato=null;
  2594.         String queryString;

  2595.         if (this.driver.atomica) {
  2596.             try {
  2597.                 con = this.driver.getConnectionFromDatasource(nomeMetodo);
  2598.             } catch (Exception e) {
  2599.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2600.             }

  2601.         } else
  2602.             con = this.driver.globalConnection;

  2603.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2604.         try {

  2605.             int count = 0;
  2606.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2607.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE_CANALI_NODI);
  2608.             sqlQueryObject.addSelectCountField("*", "cont");
  2609.             sqlQueryObject.setANDLogicOperator(true);
  2610.             sqlQueryObject.addWhereCondition("nome = ?");
  2611.            
  2612.             queryString = sqlQueryObject.createSQLQuery();
  2613.             stmt = con.prepareStatement(queryString);
  2614.             int parameterIndex = 1;
  2615.             stmt.setString(parameterIndex ++, nome);
  2616.            
  2617.             risultato = stmt.executeQuery();
  2618.             if (risultato.next())
  2619.                 count = risultato.getInt(1);
  2620.             risultato.close();
  2621.             stmt.close();

  2622.             return count > 0;

  2623.         } catch (Exception qe) {
  2624.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2625.         } finally {

  2626.             //Chiudo statement and resultset
  2627.             JDBCUtilities.closeResources(risultato, stmt);

  2628.             this.driver.closeConnection(con);
  2629.         }
  2630.     }
  2631.    
  2632.     /**
  2633.      * Restituisce la configurazione dei canali
  2634.      *
  2635.      * @return Configurazione
  2636.      *
  2637.      */
  2638.     protected CanaliConfigurazione getCanaliConfigurazione() throws DriverConfigurazioneException,DriverConfigurazioneNotFound {
  2639.         return this.getCanaliConfigurazione(true);
  2640.     }
  2641.     protected CanaliConfigurazione getCanaliConfigurazione(boolean readNodi) throws DriverConfigurazioneException,DriverConfigurazioneNotFound {
  2642.    
  2643.         // ritorna la configurazione generale della PdD

  2644.         Connection con = null;
  2645.         PreparedStatement stm = null;
  2646.         ResultSet rs = null;
  2647.         PreparedStatement stm1 = null;
  2648.         ResultSet rs1 = null;
  2649.         PreparedStatement stm2 = null;
  2650.         ResultSet rs2 = null;

  2651.         String sqlQuery = "";

  2652.         if (this.driver.atomica) {
  2653.             try {
  2654.                 con = this.driver.getConnectionFromDatasource("getCanaliConfigurazione");

  2655.             } catch (Exception e) {
  2656.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getCanaliConfigurazione] Exception accedendo al datasource :" + e.getMessage(),e);

  2657.             }

  2658.         } else
  2659.             con = this.driver.globalConnection;

  2660.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);
  2661.         CanaliConfigurazione config = new CanaliConfigurazione();
  2662.         config.setStato(StatoFunzionalita.DISABILITATO);
  2663.         try {
  2664.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2665.             sqlQueryObject.addFromTable(CostantiDB.CONFIGURAZIONE);
  2666.             sqlQueryObject.addSelectField(CostantiDB.CONFIGURAZIONE + ".canali_stato");
  2667.             sqlQuery = sqlQueryObject.createSQLQuery();

  2668.             this.driver.logDebug("eseguo query: " + DBUtils.formatSQLString(sqlQuery));
  2669.             stm = con.prepareStatement(sqlQuery);
  2670.             rs = stm.executeQuery();

  2671.             if (rs.next()) {

  2672.                 // Canali
  2673.                 String canali_stato = rs.getString("canali_stato");
  2674.                 config.setStato(DriverConfigurazioneDBLib.getEnumStatoFunzionalita(canali_stato));
  2675.                 if(config.getStato()==null) {
  2676.                     config.setStato(StatoFunzionalita.DISABILITATO);
  2677.                 }
  2678.                 if(StatoFunzionalita.ABILITATO.equals(config.getStato())) {
  2679.                     DriverConfigurazioneDB_canaliLIB.readCanaliConfigurazione(con, config, false);
  2680.                 }
  2681.             } else {
  2682.                 throw new DriverConfigurazioneNotFound("[DriverConfigurazioneDB::getCanaliConfigurazione] Configurazione non presente.");
  2683.             }

  2684.         } catch (DriverConfigurazioneNotFound e) {
  2685.             throw e;
  2686.         }catch (Exception se) {
  2687.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::getCanaliConfigurazione] Exception: " + se.getMessage(),se);
  2688.         } finally {
  2689.             //Chiudo statement and resultset
  2690.             JDBCUtilities.closeResources(rs, stm);
  2691.             JDBCUtilities.closeResources(rs1, stm1);
  2692.             JDBCUtilities.closeResources(rs2, stm2);
  2693.             this.driver.closeConnection(con);
  2694.         }
  2695.         return config;
  2696.     }
  2697. }