DriverConfigurazioneDB_configLIB.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 static org.openspcoop2.core.constants.CostantiDB.CREATE;
  22. import static org.openspcoop2.core.constants.CostantiDB.DELETE;
  23. import static org.openspcoop2.core.constants.CostantiDB.UPDATE;

  24. import java.sql.Connection;
  25. import java.sql.PreparedStatement;
  26. import java.sql.ResultSet;
  27. import java.sql.SQLException;
  28. import java.sql.Timestamp;
  29. import java.util.ArrayList;
  30. import java.util.List;

  31. import org.openspcoop2.core.byok.BYOKUtilities;
  32. import org.openspcoop2.core.byok.BYOKWrappedValue;
  33. import org.openspcoop2.core.byok.IDriverBYOK;
  34. import org.openspcoop2.core.commons.DBUtils;
  35. import org.openspcoop2.core.commons.IExtendedInfo;
  36. import org.openspcoop2.core.config.AccessoConfigurazione;
  37. import org.openspcoop2.core.config.AccessoDatiAttributeAuthority;
  38. import org.openspcoop2.core.config.AccessoDatiAutenticazione;
  39. import org.openspcoop2.core.config.AccessoDatiAutorizzazione;
  40. import org.openspcoop2.core.config.AccessoDatiGestioneToken;
  41. import org.openspcoop2.core.config.AccessoDatiKeystore;
  42. import org.openspcoop2.core.config.AccessoDatiRichieste;
  43. import org.openspcoop2.core.config.AccessoRegistro;
  44. import org.openspcoop2.core.config.AccessoRegistroRegistro;
  45. import org.openspcoop2.core.config.Attachments;
  46. import org.openspcoop2.core.config.Cache;
  47. import org.openspcoop2.core.config.CanaliConfigurazione;
  48. import org.openspcoop2.core.config.Configurazione;
  49. import org.openspcoop2.core.config.ConfigurazioneGeneraleHandler;
  50. import org.openspcoop2.core.config.ConfigurazioneMultitenant;
  51. import org.openspcoop2.core.config.ConfigurazioneTracciamentoPorta;
  52. import org.openspcoop2.core.config.ConfigurazioneUrlInvocazioneRegola;
  53. import org.openspcoop2.core.config.CorsConfigurazione;
  54. import org.openspcoop2.core.config.Dump;
  55. import org.openspcoop2.core.config.DumpConfigurazione;
  56. import org.openspcoop2.core.config.GenericProperties;
  57. import org.openspcoop2.core.config.IndirizzoRisposta;
  58. import org.openspcoop2.core.config.InoltroBusteNonRiscontrate;
  59. import org.openspcoop2.core.config.IntegrationManager;
  60. import org.openspcoop2.core.config.MessaggiDiagnostici;
  61. import org.openspcoop2.core.config.OpenspcoopAppender;
  62. import org.openspcoop2.core.config.OpenspcoopSorgenteDati;
  63. import org.openspcoop2.core.config.Property;
  64. import org.openspcoop2.core.config.ResponseCachingConfigurazioneGenerale;
  65. import org.openspcoop2.core.config.ResponseCachingConfigurazioneRegola;
  66. import org.openspcoop2.core.config.Risposte;
  67. import org.openspcoop2.core.config.StatoServiziPdd;
  68. import org.openspcoop2.core.config.StatoServiziPddIntegrationManager;
  69. import org.openspcoop2.core.config.StatoServiziPddPortaApplicativa;
  70. import org.openspcoop2.core.config.StatoServiziPddPortaDelegata;
  71. import org.openspcoop2.core.config.SystemProperties;
  72. import org.openspcoop2.core.config.TipoFiltroAbilitazioneServizi;
  73. import org.openspcoop2.core.config.Tracciamento;
  74. import org.openspcoop2.core.config.TracciamentoConfigurazione;
  75. import org.openspcoop2.core.config.TracciamentoConfigurazioneFiletrace;
  76. import org.openspcoop2.core.config.Transazioni;
  77. import org.openspcoop2.core.config.ValidazioneBuste;
  78. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  79. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  80. import org.openspcoop2.core.config.constants.StatoFunzionalitaCacheDigestQueryParameter;
  81. import org.openspcoop2.core.config.driver.DriverConfigurazioneException;
  82. import org.openspcoop2.core.config.driver.ExtendedInfoManager;
  83. import org.openspcoop2.core.constants.CRUDType;
  84. import org.openspcoop2.core.constants.CostantiDB;
  85. import org.openspcoop2.utils.TipiDatabase;
  86. import org.openspcoop2.utils.date.DateManager;
  87. import org.openspcoop2.utils.jdbc.CustomKeyGeneratorObject;
  88. import org.openspcoop2.utils.jdbc.InsertAndGeneratedKey;
  89. import org.openspcoop2.utils.jdbc.InsertAndGeneratedKeyJDBCType;
  90. import org.openspcoop2.utils.jdbc.InsertAndGeneratedKeyObject;
  91. import org.openspcoop2.utils.jdbc.JDBCUtilities;
  92. import org.openspcoop2.utils.sql.ISQLQueryObject;
  93. import org.openspcoop2.utils.sql.SQLObjectFactory;
  94. import org.openspcoop2.utils.sql.SQLQueryObjectException;

  95. /**
  96.  * DriverConfigurazioneDB_configLIB
  97.  *
  98.  * @author Stefano Corallo - corallo@link.it
  99.  * @author $Author$
  100.  * @version $Rev$, $Date$
  101.  */
  102. public class DriverConfigurazioneDB_configLIB {


  103.     public static long CRUDAccessoRegistro(int type, AccessoRegistroRegistro registro, Connection con) throws DriverConfigurazioneException {
  104.         if (registro == null)
  105.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoRegistro] Il servizio non puo essere NULL");
  106.         PreparedStatement updateStmt = null;
  107.         String updateQuery = "";
  108.         PreparedStatement selectStmt = null;
  109.         String selectQuery = "";
  110.         ResultSet selectRS = null;

  111.         long idRegistro = 0;
  112.         int n = 0;
  113.         String nome = registro.getNome();
  114.         String location = registro.getLocation();
  115.         String tipo = registro.getTipo().toString();
  116.         String user = registro.getUser();
  117.         String password = registro.getPassword();

  118.         try {
  119.             switch (type) {
  120.             case CREATE:
  121.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  122.                 sqlQueryObject.addInsertTable(CostantiDB.REGISTRI);
  123.                 sqlQueryObject.addInsertField("nome", "?");
  124.                 sqlQueryObject.addInsertField("location", "?");
  125.                 sqlQueryObject.addInsertField("tipo", "?");
  126.                 sqlQueryObject.addInsertField("utente", "?");
  127.                 sqlQueryObject.addInsertField("password", "?");
  128.                 updateQuery = sqlQueryObject.createSQLInsert();
  129.                 updateStmt = con.prepareStatement(updateQuery);

  130.                 updateStmt.setString(1, nome);
  131.                 updateStmt.setString(2, location);
  132.                 updateStmt.setString(3, tipo);
  133.                 updateStmt.setString(4, user);
  134.                 updateStmt.setString(5, password);

  135.                 DriverConfigurazioneDBLib.logDebug("eseguo query: " + DBUtils.formatSQLString(updateQuery, nome, location, tipo, user, password));

  136.                 n = updateStmt.executeUpdate();

  137.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  138.                 sqlQueryObject.addFromTable(CostantiDB.REGISTRI);
  139.                 sqlQueryObject.addSelectField("id");
  140.                 sqlQueryObject.addWhereCondition("nome = ?");
  141.                 sqlQueryObject.addWhereCondition("location = ?");
  142.                 sqlQueryObject.setANDLogicOperator(true);
  143.                 selectQuery = sqlQueryObject.createSQLQuery();
  144.                 selectStmt = con.prepareStatement(selectQuery);
  145.                 selectStmt.setString(1, nome);
  146.                 selectStmt.setString(2, location);
  147.                 selectRS = selectStmt.executeQuery();
  148.                 if (selectRS.next()) {
  149.                     idRegistro = selectRS.getLong("id");
  150.                     registro.setId(idRegistro);
  151.                 }

  152.                 break;
  153.             case UPDATE:

  154.                 if (registro.getId() == null || registro.getId() <= 0)
  155.                     throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoRegistro(UPDATE)] L'id del Servizio e' necessario.");
  156.                 idRegistro = registro.getId();

  157.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  158.                 sqlQueryObject.addUpdateTable(CostantiDB.ROUTING);
  159.                 sqlQueryObject.addUpdateField("nome", "?");
  160.                 sqlQueryObject.addUpdateField("location", "?");
  161.                 sqlQueryObject.addUpdateField("tipo", "?");
  162.                 sqlQueryObject.addUpdateField("utente", "?");
  163.                 sqlQueryObject.addUpdateField("password", "?");
  164.                 sqlQueryObject.addWhereCondition("id=?");
  165.                 updateQuery = sqlQueryObject.createSQLUpdate();
  166.                 updateStmt = con.prepareStatement(updateQuery);

  167.                 updateStmt.setString(1, registro.getNome());
  168.                 updateStmt.setString(2, registro.getLocation());
  169.                 updateStmt.setString(3, registro.getTipo().toString());
  170.                 updateStmt.setString(4, registro.getUser());
  171.                 updateStmt.setString(5, registro.getPassword());
  172.                 updateStmt.setLong(6, idRegistro);

  173.                 DriverConfigurazioneDBLib.logDebug("eseguo query: " + DBUtils.formatSQLString(updateQuery, nome, location, tipo, user, password, idRegistro));
  174.                 n = updateStmt.executeUpdate();

  175.                 break;
  176.             case DELETE:
  177.                 if (registro.getId() == null || registro.getId() <= 0)
  178.                     throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoRegistro(DELETE)] L'id del Servizio e' necessario.");
  179.                 idRegistro = registro.getId();

  180.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  181.                 sqlQueryObject.addDeleteTable(CostantiDB.REGISTRI);
  182.                 sqlQueryObject.addWhereCondition("id=?");
  183.                 String sqlQuery = sqlQueryObject.createSQLDelete();
  184.                 updateStmt = con.prepareStatement(sqlQuery);
  185.                 updateStmt.setLong(1, idRegistro);
  186.                 DriverConfigurazioneDBLib.logDebug("eseguo query: " + DBUtils.formatSQLString(updateQuery, idRegistro));
  187.                 n=updateStmt.executeUpdate();
  188.                 updateStmt.close();

  189.                 break;
  190.             }

  191.             if (type == CostantiDB.CREATE)
  192.                 return idRegistro;
  193.             else
  194.                 return n;

  195.         } catch (SQLException se) {
  196.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoRegistro] SQLException [" + se.getMessage() + "].",se);
  197.         }catch (Exception se) {
  198.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoRegistro] Exception [" + se.getMessage() + "].",se);
  199.         } finally {

  200.             JDBCUtilities.closeResources(selectRS, selectStmt);
  201.             JDBCUtilities.closeResources(updateStmt);

  202.         }

  203.     }

  204.     public static long CRUDAccessoRegistro(int type, AccessoRegistro registro, Connection con) throws DriverConfigurazioneException {
  205.         if (registro == null)
  206.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoRegistro] Il registro non può essere NULL");
  207.         PreparedStatement updateStmt = null;
  208.         String updateQuery = "";
  209.         PreparedStatement selectStmt = null;
  210.         ResultSet selectRS = null;

  211.         long idRegistro = 0;
  212.         int n = 0;
  213.         Cache arc = registro.getCache();
  214.         String statoCache = "disabilitato";
  215.         String dimensionecache = null;
  216.         String algoritmocache = null;
  217.         String idlecache = null;
  218.         String lifecache = null;
  219.         if (arc != null) {
  220.             statoCache = "abilitato";
  221.             dimensionecache = arc.getDimensione();
  222.             if(arc.getAlgoritmo()!=null){
  223.                 algoritmocache = arc.getAlgoritmo().toString();
  224.             }
  225.             idlecache = arc.getItemIdleTime();
  226.             lifecache = arc.getItemLifeSecond();
  227.         }

  228.         try {
  229.             switch (type) {
  230.             case CREATE:
  231.             case UPDATE:

  232.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  233.                 sqlQueryObject.addUpdateTable(CostantiDB.CONFIGURAZIONE);
  234.                 sqlQueryObject.addUpdateField("statocache", "?");
  235.                 sqlQueryObject.addUpdateField("dimensionecache", "?");
  236.                 sqlQueryObject.addUpdateField("algoritmocache", "?");
  237.                 sqlQueryObject.addUpdateField("idlecache", "?");
  238.                 sqlQueryObject.addUpdateField("lifecache", "?");
  239.                 updateQuery = sqlQueryObject.createSQLUpdate();
  240.                 updateStmt = con.prepareStatement(updateQuery);

  241.                 updateStmt.setString(1, statoCache);
  242.                 updateStmt.setString(2, dimensionecache);
  243.                 updateStmt.setString(3, algoritmocache);
  244.                 updateStmt.setString(4, idlecache);
  245.                 updateStmt.setString(5, lifecache);

  246.                 DriverConfigurazioneDBLib.logDebug("eseguo query :" + DBUtils.formatSQLString(updateQuery, statoCache, dimensionecache, algoritmocache, idlecache, lifecache));

  247.                 n = updateStmt.executeUpdate();
  248.                 updateStmt.close();

  249.                 // Elimino i registri e li ricreo
  250.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  251.                 sqlQueryObject.addDeleteTable(CostantiDB.REGISTRI);
  252.                 String sqlQuery = sqlQueryObject.createSQLDelete();
  253.                 updateStmt = con.prepareStatement(sqlQuery);
  254.                 DriverConfigurazioneDBLib.logDebug("eseguo query: " + DBUtils.formatSQLString(updateQuery));
  255.                 int risultato = updateStmt.executeUpdate();
  256.                 DriverConfigurazioneDBLib.logDebug("eseguo query risultato["+risultato+"]: " + DBUtils.formatSQLString(updateQuery));
  257.                 updateStmt.close();

  258.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  259.                 sqlQueryObject.addInsertTable(CostantiDB.REGISTRI);
  260.                 sqlQueryObject.addInsertField("nome", "?");
  261.                 sqlQueryObject.addInsertField("location", "?");
  262.                 sqlQueryObject.addInsertField("tipo", "?");
  263.                 sqlQueryObject.addInsertField("utente", "?");
  264.                 sqlQueryObject.addInsertField("password", "?");
  265.                 updateQuery = sqlQueryObject.createSQLInsert();
  266.                 for (int i = 0; i < registro.sizeRegistroList(); i++) {
  267.                     updateStmt = con.prepareStatement(updateQuery);
  268.                     AccessoRegistroRegistro arr = registro.getRegistro(i);
  269.                     String nome = arr.getNome();
  270.                     String location = arr.getLocation();
  271.                     String tipo = arr.getTipo().toString();
  272.                     String utente = arr.getUser();
  273.                     String password = arr.getPassword();

  274.                     updateStmt.setString(1, nome);
  275.                     updateStmt.setString(2, location);
  276.                     updateStmt.setString(3, tipo);
  277.                     updateStmt.setString(4, utente);
  278.                     updateStmt.setString(5, password);
  279.                     DriverConfigurazioneDBLib.logDebug("eseguo query INSERT INTO " + CostantiDB.REGISTRI + "(nome, location, tipo, utente, password) VALUES ("+
  280.                             nome+", "+location+", "+tipo+", "+utente+", "+password+")");
  281.                     updateStmt.executeUpdate();
  282.                     updateStmt.close();
  283.                 }

  284.                 break;
  285.             case DELETE:
  286.                 // non rimuovo nulla in quanto la tabella configurazione
  287.                 // contiene solo una riga con i valori
  288.                 // che vanno modificati con la update
  289.                 break;
  290.             }

  291.             if (type == CostantiDB.CREATE)
  292.                 return idRegistro;
  293.             else
  294.                 return n;

  295.         } catch (SQLException se) {
  296.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoRegistro] SQLException [" + se.getMessage() + "].",se);
  297.         }catch (Exception se) {
  298.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoRegistro] Exception [" + se.getMessage() + "].",se);
  299.         } finally {

  300.             JDBCUtilities.closeResources(selectRS, selectStmt);
  301.             JDBCUtilities.closeResources(updateStmt);
  302.            
  303.         }

  304.     }
  305.    
  306.    
  307.    
  308.     public static long CRUDAccessoConfigurazione(int type, AccessoConfigurazione accessoConfigurazione, Connection con) throws DriverConfigurazioneException {
  309.         if (accessoConfigurazione == null)
  310.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoConfigurazione] Parametro accessoConfigurazione non può essere NULL");
  311.         PreparedStatement updateStmt = null;
  312.         String updateQuery = "";

  313.         int n = 0;
  314.         Cache cache = accessoConfigurazione.getCache();
  315.         String statoCache = "disabilitato";
  316.         String dimensionecache = null;
  317.         String algoritmocache = null;
  318.         String idlecache = null;
  319.         String lifecache = null;
  320.         if (cache != null) {
  321.             statoCache = "abilitato";
  322.             dimensionecache = cache.getDimensione();
  323.             if(cache.getAlgoritmo()!=null){
  324.                 algoritmocache = cache.getAlgoritmo().toString();
  325.             }
  326.             idlecache = cache.getItemIdleTime();
  327.             lifecache = cache.getItemLifeSecond();
  328.         }

  329.         try {
  330.             switch (type) {
  331.             case CREATE:
  332.             case UPDATE:

  333.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  334.                 sqlQueryObject.addUpdateTable(CostantiDB.CONFIGURAZIONE);
  335.                 sqlQueryObject.addUpdateField("config_statocache", "?");
  336.                 sqlQueryObject.addUpdateField("config_dimensionecache", "?");
  337.                 sqlQueryObject.addUpdateField("config_algoritmocache", "?");
  338.                 sqlQueryObject.addUpdateField("config_idlecache", "?");
  339.                 sqlQueryObject.addUpdateField("config_lifecache", "?");
  340.                 updateQuery = sqlQueryObject.createSQLUpdate();
  341.                 updateStmt = con.prepareStatement(updateQuery);

  342.                 updateStmt.setString(1, statoCache);
  343.                 updateStmt.setString(2, dimensionecache);
  344.                 updateStmt.setString(3, algoritmocache);
  345.                 updateStmt.setString(4, idlecache);
  346.                 updateStmt.setString(5, lifecache);

  347.                 DriverConfigurazioneDBLib.logDebug("eseguo query :" + DBUtils.formatSQLString(updateQuery, statoCache, dimensionecache, algoritmocache, idlecache, lifecache));

  348.                 n = updateStmt.executeUpdate();
  349.                 updateStmt.close();

  350.                 break;
  351.             case DELETE:
  352.                 // non rimuovo nulla in quanto la tabella configurazione
  353.                 // contiene solo una riga con i valori
  354.                 // che vanno modificati con la update
  355.                 break;
  356.             }

  357.             return n;

  358.         } catch (SQLException se) {
  359.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoConfigurazione] SQLException [" + se.getMessage() + "].",se);
  360.         }catch (Exception se) {
  361.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoConfigurazione] Exception [" + se.getMessage() + "].",se);
  362.         } finally {
  363.             JDBCUtilities.closeResources(updateStmt);
  364.         }

  365.     }
  366.    
  367.    
  368.    
  369.     public static long CRUDAccessoDatiAutorizzazione(int type, AccessoDatiAutorizzazione accessoDatiAutorizzazione, Connection con) throws DriverConfigurazioneException {
  370.         if (accessoDatiAutorizzazione == null)
  371.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoDatiAutorizzazione] Parametro accessoDatiAutorizzazione non può essere NULL");
  372.         PreparedStatement updateStmt = null;
  373.         String updateQuery = "";

  374.         int n = 0;
  375.         Cache cache = accessoDatiAutorizzazione.getCache();
  376.         String statoCache = "disabilitato";
  377.         String dimensionecache = null;
  378.         String algoritmocache = null;
  379.         String idlecache = null;
  380.         String lifecache = null;
  381.         if (cache != null) {
  382.             statoCache = "abilitato";
  383.             dimensionecache = cache.getDimensione();
  384.             if(cache.getAlgoritmo()!=null){
  385.                 algoritmocache = cache.getAlgoritmo().toString();
  386.             }
  387.             idlecache = cache.getItemIdleTime();
  388.             lifecache = cache.getItemLifeSecond();
  389.         }

  390.         try {
  391.             switch (type) {
  392.             case CREATE:
  393.             case UPDATE:

  394.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  395.                 sqlQueryObject.addUpdateTable(CostantiDB.CONFIGURAZIONE);
  396.                 sqlQueryObject.addUpdateField("auth_statocache", "?");
  397.                 sqlQueryObject.addUpdateField("auth_dimensionecache", "?");
  398.                 sqlQueryObject.addUpdateField("auth_algoritmocache", "?");
  399.                 sqlQueryObject.addUpdateField("auth_idlecache", "?");
  400.                 sqlQueryObject.addUpdateField("auth_lifecache", "?");
  401.                 updateQuery = sqlQueryObject.createSQLUpdate();
  402.                 updateStmt = con.prepareStatement(updateQuery);

  403.                 updateStmt.setString(1, statoCache);
  404.                 updateStmt.setString(2, dimensionecache);
  405.                 updateStmt.setString(3, algoritmocache);
  406.                 updateStmt.setString(4, idlecache);
  407.                 updateStmt.setString(5, lifecache);

  408.                 DriverConfigurazioneDBLib.logDebug("eseguo query :" + DBUtils.formatSQLString(updateQuery, statoCache, dimensionecache, algoritmocache, idlecache, lifecache));

  409.                 n = updateStmt.executeUpdate();
  410.                 updateStmt.close();

  411.                 break;
  412.             case DELETE:
  413.                 // non rimuovo nulla in quanto la tabella configurazione
  414.                 // contiene solo una riga con i valori
  415.                 // che vanno modificati con la update
  416.                 break;
  417.             }

  418.             return n;

  419.         } catch (SQLException se) {
  420.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoDatiAutorizzazione] SQLException [" + se.getMessage() + "].",se);
  421.         }catch (Exception se) {
  422.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoDatiAutorizzazione] Exception [" + se.getMessage() + "].",se);
  423.         } finally {
  424.             JDBCUtilities.closeResources(updateStmt);
  425.         }

  426.     }
  427.    
  428.    
  429.     public static void CRUDServiziPdD(int type, StatoServiziPdd statoServiziPdD, Connection con) throws DriverConfigurazioneException {
  430.         if (statoServiziPdD == null)
  431.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDServiziPdD] Le configurazioni del servizio non possono essere NULL");
  432.         PreparedStatement updateStmt = null;
  433.         String updateQuery = "";
  434.         PreparedStatement selectStmt = null;
  435.         ResultSet selectRS = null;
  436.        

  437.         try {
  438.             switch (type) {
  439.             case CREATE:
  440.             case UPDATE:

  441.                 // Elimino le configurazioni e le ricreo
  442.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  443.                 sqlQueryObject.addDeleteTable(CostantiDB.SERVIZI_PDD_FILTRI);
  444.                 String sqlQuery = sqlQueryObject.createSQLDelete();
  445.                 updateStmt = con.prepareStatement(sqlQuery);
  446.                 DriverConfigurazioneDBLib.logDebug("eseguo query: " + DBUtils.formatSQLString(updateQuery));
  447.                 int risultato = updateStmt.executeUpdate();
  448.                 DriverConfigurazioneDBLib.logDebug("eseguo query risultato["+risultato+"]: " + DBUtils.formatSQLString(updateQuery));
  449.                 updateStmt.close();

  450.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  451.                 sqlQueryObject.addDeleteTable(CostantiDB.SERVIZI_PDD);
  452.                 sqlQuery = sqlQueryObject.createSQLDelete();
  453.                 updateStmt = con.prepareStatement(sqlQuery);
  454.                 DriverConfigurazioneDBLib.logDebug("eseguo query: " + DBUtils.formatSQLString(updateQuery));
  455.                 risultato = updateStmt.executeUpdate();
  456.                 DriverConfigurazioneDBLib.logDebug("eseguo query risultato["+risultato+"]: " + DBUtils.formatSQLString(updateQuery));
  457.                 updateStmt.close();
  458.                
  459.                 // Ricreo
  460.                 if(statoServiziPdD.getPortaDelegata()!=null){
  461.                
  462.                     StatoServiziPddPortaDelegata sPD = statoServiziPdD.getPortaDelegata();
  463.                    
  464.                     int stato = CostantiDB.TRUE;
  465.                     if(sPD.getStato()!=null){
  466.                         stato = CostantiConfigurazione.DISABILITATO.equals(sPD.getStato()) ? CostantiDB.FALSE : CostantiDB.TRUE;
  467.                     }
  468.                    
  469.                     DriverConfigurazioneDB_configLIB.registraComponentePdD(CostantiDB.COMPONENTE_SERVIZIO_PD, stato, con, sPD.getFiltroAbilitazioneList(), sPD.getFiltroDisabilitazioneList());
  470.                    
  471.                 }
  472.                 if(statoServiziPdD.getPortaApplicativa()!=null){
  473.                    
  474.                     StatoServiziPddPortaApplicativa sPA = statoServiziPdD.getPortaApplicativa();
  475.                    
  476.                     int stato = CostantiDB.TRUE;
  477.                     if(sPA.getStato()!=null){
  478.                         stato = CostantiConfigurazione.DISABILITATO.equals(sPA.getStato()) ? CostantiDB.FALSE : CostantiDB.TRUE;
  479.                     }
  480.                    
  481.                     DriverConfigurazioneDB_configLIB.registraComponentePdD(CostantiDB.COMPONENTE_SERVIZIO_PA, stato, con, sPA.getFiltroAbilitazioneList(), sPA.getFiltroDisabilitazioneList());
  482.                    
  483.                 }
  484.                 if(statoServiziPdD.getIntegrationManager()!=null){
  485.                    
  486.                     StatoServiziPddIntegrationManager sIM = statoServiziPdD.getIntegrationManager();
  487.                    
  488.                     int stato = CostantiDB.TRUE;
  489.                     if(sIM.getStato()!=null){
  490.                         stato = CostantiConfigurazione.DISABILITATO.equals(sIM.getStato()) ? CostantiDB.FALSE : CostantiDB.TRUE;
  491.                     }
  492.                    
  493.                     DriverConfigurazioneDB_configLIB.registraComponentePdD(CostantiDB.COMPONENTE_SERVIZIO_IM, stato, con, null, null);
  494.                    
  495.                 }
  496.                

  497.                 break;
  498.             case DELETE:
  499.                 // non rimuovo nulla in quanto la tabella configurazione
  500.                 // contiene solo una riga con i valori
  501.                 // che vanno modificati con la update
  502.                 break;
  503.             }


  504.         } catch (SQLException se) {
  505.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoRegistro] SQLException [" + se.getMessage() + "].",se);
  506.         }catch (Exception se) {
  507.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoRegistro] Exception [" + se.getMessage() + "].",se);
  508.         } finally {

  509.             JDBCUtilities.closeResources(selectRS, selectStmt);
  510.             JDBCUtilities.closeResources(updateStmt);
  511.            
  512.         }

  513.     }

  514.     private static void registraComponentePdD(String componente,int stato,Connection con,
  515.             List<TipoFiltroAbilitazioneServizi> abilitazioni,
  516.             List<TipoFiltroAbilitazioneServizi> disabilitazioni) throws Exception{
  517.         PreparedStatement updateStmt = null;
  518.         String updateQuery = "";
  519.         PreparedStatement selectStmt = null;
  520.         ResultSet selectRS = null;
  521.        

  522.         try {
  523.            
  524.             // registro componente
  525.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  526.             sqlQueryObject.addInsertTable(CostantiDB.SERVIZI_PDD);
  527.             sqlQueryObject.addInsertField("componente", "?");
  528.             sqlQueryObject.addInsertField("stato", "?");
  529.             updateQuery = sqlQueryObject.createSQLInsert();
  530.             updateStmt = con.prepareStatement(updateQuery);
  531.             DriverConfigurazioneDBLib.logDebug("eseguo query INSERT INTO " + CostantiDB.SERVIZI_PDD + "(componente, stato) VALUES ('"+
  532.                     componente+"', "+stato+")");
  533.             updateStmt.setString(1, componente);
  534.             updateStmt.setInt(2, stato);
  535.             updateStmt.executeUpdate();
  536.             updateStmt.close();
  537.            
  538.             // recuper id del componente
  539.             long idComponente = -1;
  540.             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  541.             sqlQueryObject.addFromTable(CostantiDB.SERVIZI_PDD);
  542.             sqlQueryObject.addSelectField("id");
  543.             sqlQueryObject.addWhereCondition("componente=?");
  544.             updateQuery = sqlQueryObject.createSQLQuery();
  545.             selectStmt = con.prepareStatement(updateQuery);
  546.             DriverConfigurazioneDBLib.logDebug("eseguo query ["+updateQuery+"] per il componente ["+componente+"]");
  547.             selectStmt.setString(1, componente);
  548.             selectRS = selectStmt.executeQuery();
  549.             if(selectRS.next()){
  550.                 idComponente = selectRS.getLong("id");
  551.             }else{
  552.                 throw new Exception("Query ["+updateQuery+"] per il componente ["+componente+"] non ha ritornato risultati");
  553.             }
  554.             selectRS.close();
  555.             selectStmt.close();
  556.            
  557.             // registro i filtri
  558.            
  559.             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  560.             sqlQueryObject.addInsertTable(CostantiDB.SERVIZI_PDD_FILTRI);
  561.             sqlQueryObject.addInsertField("id_servizio_pdd", "?");
  562.             sqlQueryObject.addInsertField("tipo_filtro", "?");
  563.             sqlQueryObject.addInsertField("tipo_soggetto_fruitore", "?");
  564.             sqlQueryObject.addInsertField("soggetto_fruitore", "?");
  565.             sqlQueryObject.addInsertField("identificativo_porta_fruitore", "?");
  566.             sqlQueryObject.addInsertField("tipo_soggetto_erogatore", "?");
  567.             sqlQueryObject.addInsertField("soggetto_erogatore", "?");
  568.             sqlQueryObject.addInsertField("identificativo_porta_erogatore", "?");
  569.             sqlQueryObject.addInsertField("tipo_servizio", "?");
  570.             sqlQueryObject.addInsertField("servizio", "?");
  571.             sqlQueryObject.addInsertField("versione_servizio", "?");
  572.             sqlQueryObject.addInsertField("azione", "?");
  573.             updateQuery = sqlQueryObject.createSQLInsert();
  574.            
  575.             if(abilitazioni!=null){
  576.                 for (TipoFiltroAbilitazioneServizi filtro : abilitazioni) {
  577.            
  578.                     updateStmt = con.prepareStatement(updateQuery);
  579.                     int index = 1;
  580.                    
  581.                     updateStmt.setLong(index++, idComponente);
  582.                     updateStmt.setString(index++,CostantiDB.TIPO_FILTRO_ABILITAZIONE_SERVIZIO_PDD);
  583.                    
  584.                     updateStmt.setString(index++,filtro.getTipoSoggettoFruitore());
  585.                     updateStmt.setString(index++,filtro.getSoggettoFruitore());
  586.                     updateStmt.setString(index++,filtro.getIdentificativoPortaFruitore());
  587.                    
  588.                     updateStmt.setString(index++,filtro.getTipoSoggettoErogatore());
  589.                     updateStmt.setString(index++,filtro.getSoggettoErogatore());
  590.                     updateStmt.setString(index++,filtro.getIdentificativoPortaErogatore());
  591.                    
  592.                     updateStmt.setString(index++,filtro.getTipoServizio());
  593.                     updateStmt.setString(index++,filtro.getServizio());
  594.                     if(filtro.getVersioneServizio()!=null){
  595.                         updateStmt.setInt(index++,filtro.getVersioneServizio());
  596.                     }
  597.                     else{
  598.                         updateStmt.setNull(index++, java.sql.Types.INTEGER);
  599.                     }
  600.                    
  601.                     updateStmt.setString(index++,filtro.getAzione());
  602.                    
  603.                     updateStmt.executeUpdate();
  604.                     updateStmt.close();
  605.                    
  606.                 }
  607.             }
  608.            
  609.             if(disabilitazioni!=null){
  610.                 for (TipoFiltroAbilitazioneServizi filtro : disabilitazioni) {
  611.            
  612.                     updateStmt = con.prepareStatement(updateQuery);
  613.                     int index = 1;
  614.                    
  615.                     updateStmt.setLong(index++, idComponente);
  616.                     updateStmt.setString(index++,CostantiDB.TIPO_FILTRO_DISABILITAZIONE_SERVIZIO_PDD);
  617.                    
  618.                     updateStmt.setString(index++,filtro.getTipoSoggettoFruitore());
  619.                     updateStmt.setString(index++,filtro.getSoggettoFruitore());
  620.                     updateStmt.setString(index++,filtro.getIdentificativoPortaFruitore());
  621.                    
  622.                     updateStmt.setString(index++,filtro.getTipoSoggettoErogatore());
  623.                     updateStmt.setString(index++,filtro.getSoggettoErogatore());
  624.                     updateStmt.setString(index++,filtro.getIdentificativoPortaErogatore());
  625.                    
  626.                     updateStmt.setString(index++,filtro.getTipoServizio());
  627.                     updateStmt.setString(index++,filtro.getServizio());
  628.                     if(filtro.getVersioneServizio()!=null){
  629.                         updateStmt.setInt(index++,filtro.getVersioneServizio());
  630.                     }
  631.                     else{
  632.                         updateStmt.setNull(index++, java.sql.Types.INTEGER);
  633.                     }
  634.                    
  635.                     updateStmt.setString(index++,filtro.getAzione());
  636.                    
  637.                     updateStmt.executeUpdate();
  638.                     updateStmt.close();
  639.                    
  640.                 }
  641.             }
  642.              
  643.         } finally {

  644.             JDBCUtilities.closeResources(selectRS, selectStmt);
  645.             JDBCUtilities.closeResources(updateStmt);
  646.            
  647.         }
  648.     }
  649.    
  650.    
  651.    
  652.     public static void CRUDSystemPropertiesPdD(int type, SystemProperties systemProperties, Connection con, IDriverBYOK driverBYOK) throws DriverConfigurazioneException {
  653.         if (systemProperties == null)
  654.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDSystemPropertiesPdD] Le configurazioni per le system properties non possono essere NULL");
  655.         PreparedStatement updateStmt = null;
  656.         String updateQuery = "";
  657.         PreparedStatement selectStmt = null;
  658.         ResultSet selectRS = null;
  659.        

  660.         try {
  661.            
  662.             // Elimino le configurazioni e le ricreo per insert e update
  663.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  664.             sqlQueryObject.addDeleteTable(CostantiDB.SYSTEM_PROPERTIES_PDD);
  665.             String sqlQuery = sqlQueryObject.createSQLDelete();
  666.             updateStmt = con.prepareStatement(sqlQuery);
  667.             DriverConfigurazioneDBLib.logDebug("eseguo query: " + DBUtils.formatSQLString(updateQuery));
  668.             int risultato = updateStmt.executeUpdate();
  669.             DriverConfigurazioneDBLib.logDebug("eseguo query risultato["+risultato+"]: " + DBUtils.formatSQLString(updateQuery));
  670.             updateStmt.close();
  671.            
  672.             switch (type) {
  673.             case CREATE:
  674.             case UPDATE:
  675.        
  676.                 for (int i = 0; i < systemProperties.sizeSystemPropertyList(); i++) {
  677.                
  678.                     Property sp = systemProperties.getSystemProperty(i);
  679.                     String nome = sp.getNome();
  680.                    
  681.                     // Riga
  682.                     // registro componente
  683.                     sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  684.                     sqlQueryObject.addInsertTable(CostantiDB.SYSTEM_PROPERTIES_PDD);
  685.                     sqlQueryObject.addInsertField("nome", "?");
  686.                     sqlQueryObject.addInsertField("valore", "?");
  687.                     sqlQueryObject.addInsertField("enc_value", "?");
  688.                     updateQuery = sqlQueryObject.createSQLInsert();
  689.                     updateStmt = con.prepareStatement(updateQuery);

  690.                     int index = 1;
  691.                     updateStmt.setString(index++, nome);
  692.                    
  693.                     String plainValue = sp.getValore();
  694.                     String encValue = null;
  695.                     if(driverBYOK!=null && BYOKUtilities.isWrappedValue(plainValue) ) {
  696.                         BYOKWrappedValue byokValue = driverBYOK.wrap(plainValue);
  697.                         if(byokValue!=null) {
  698.                             encValue = byokValue.getWrappedValue();
  699.                             plainValue = byokValue.getWrappedPlainValue();
  700.                         }
  701.                     }
  702.                    
  703.                     updateStmt.setString(index++, plainValue);
  704.                     updateStmt.setString(index++, encValue);
  705.                    
  706.                     DriverConfigurazioneDBLib.logDebug("eseguo query INSERT INTO " + CostantiDB.SYSTEM_PROPERTIES_PDD + "(nome, valore) VALUES ('"+
  707.                             nome+"', "+plainValue+")");
  708.                     updateStmt.executeUpdate();
  709.                     updateStmt.close();
  710.                    
  711.                     // recuper id del componente
  712.                     long idComponente = -1;
  713.                     sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  714.                     sqlQueryObject.addFromTable(CostantiDB.SYSTEM_PROPERTIES_PDD);
  715.                     sqlQueryObject.addSelectField("id");
  716.                     sqlQueryObject.setANDLogicOperator(true);
  717.                     sqlQueryObject.addWhereCondition("nome=?");
  718.                     sqlQueryObject.addWhereCondition("valore=?");
  719.                     updateQuery = sqlQueryObject.createSQLQuery();
  720.                     selectStmt = con.prepareStatement(updateQuery);
  721.                     DriverConfigurazioneDBLib.logDebug("eseguo query ["+updateQuery+"] per la prop nome["+nome+"] valore["+plainValue+"]");
  722.                     selectStmt.setString(1, nome);
  723.                     selectStmt.setString(2, plainValue);
  724.                     selectRS = selectStmt.executeQuery();
  725.                     if(selectRS.next()){
  726.                         idComponente = selectRS.getLong("id");
  727.                     }else{
  728.                         throw new DriverConfigurazioneException("Query ["+updateQuery+"] per la prop nome["+nome+"] valore["+plainValue+"] non ha ritornato risultati");
  729.                     }
  730.                     selectRS.close();
  731.                     selectStmt.close();
  732.                    
  733.                     sp.setId(idComponente);
  734.                 }

  735.                 break;
  736.             case DELETE:
  737.                 // non rimuovo in quanto gia fatto sopra.
  738.                 break;
  739.             }


  740.         } catch (SQLException se) {
  741.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoRegistro] SQLException [" + se.getMessage() + "].",se);
  742.         }catch (Exception se) {
  743.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDAccessoRegistro] Exception [" + se.getMessage() + "].",se);
  744.         } finally {

  745.             JDBCUtilities.closeResources(selectRS, selectStmt);
  746.             JDBCUtilities.closeResources(updateStmt);
  747.            
  748.         }

  749.     }
  750.    
  751.    
  752.    
  753.    
  754.     public static void CRUDGenericProperties(int type, GenericProperties genericProperties, Connection con, IDriverBYOK driverBYOK) throws DriverConfigurazioneException {
  755.         if (genericProperties == null)
  756.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDGenericProperties] Le configurazioni per le generic properties non possono essere NULL");
  757.         PreparedStatement updateStmt = null;
  758.         String updateQuery = "";
  759.         PreparedStatement selectStmt = null;
  760.         ResultSet selectRS = null;
  761.        

  762.         try {
  763.            
  764.             if(genericProperties.getNome()==null) {
  765.                 throw new DriverConfigurazioneException("Nome non fornito");
  766.             }
  767.             if(genericProperties.getTipologia()==null) {
  768.                 throw new DriverConfigurazioneException("Tipologia non fornita");
  769.             }
  770.            
  771.             // Recupero id generic properties
  772.             long idParent = -1;
  773.             if(type == CostantiDB.UPDATE || type == CostantiDB.DELETE) {
  774.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  775.                 sqlQueryObject.addFromTable(CostantiDB.CONFIG_GENERIC_PROPERTIES);
  776.                 sqlQueryObject.addSelectField("*");
  777.                 sqlQueryObject.addWhereCondition("nome=?");
  778.                 sqlQueryObject.addWhereCondition("tipologia=?");
  779.                 sqlQueryObject.setANDLogicOperator(true);
  780.                 String sqlQuery = sqlQueryObject.createSQLQuery();
  781.                 selectStmt = con.prepareStatement(sqlQuery);
  782.                 selectStmt.setString(1, genericProperties.getNome());
  783.                 selectStmt.setString(2, genericProperties.getTipologia());
  784.                 selectRS = selectStmt.executeQuery();
  785.                
  786.                 if(selectRS.next()) {
  787.                     idParent = selectRS.getLong("id");
  788.                 }
  789.                 selectRS.close();
  790.                 selectStmt.close();
  791.                
  792.                 if(idParent<=0) {
  793.                     throw new DriverConfigurazioneException("Configuration Property non trovato con nome ["+genericProperties.getNome()+"] e tipologia ["+genericProperties.getTipologia()+"]");
  794.                 }
  795.                
  796.                 // Elimino anche le configurazioni (nell'update le ricreo)
  797.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  798.                 sqlQueryObject.addDeleteTable(CostantiDB.CONFIG_GENERIC_PROPERTY);
  799.                 sqlQueryObject.addWhereCondition("id_props=?");
  800.                 sqlQueryObject.setANDLogicOperator(true);
  801.                 updateQuery = sqlQueryObject.createSQLDelete();
  802.                 updateStmt = con.prepareStatement(updateQuery);
  803.                 updateStmt.setLong(1, idParent);
  804.                 updateStmt.executeUpdate();
  805.                 updateStmt.close();

  806.                 // delete
  807.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  808.                 sqlQueryObject.addDeleteTable(CostantiDB.CONFIG_GENERIC_PROPERTIES);
  809.                 sqlQueryObject.addWhereCondition("id=?");
  810.                 updateQuery = sqlQueryObject.createSQLDelete();
  811.                 updateStmt = con.prepareStatement(updateQuery);
  812.                 updateStmt.setLong(1, idParent);
  813.                 updateStmt.executeUpdate();
  814.                 updateStmt.close();
  815.             }

  816.             String utenteRichiedente = null;
  817.             Timestamp dataCreazione = null;
  818.             if(type == CostantiDB.CREATE || type == CostantiDB.UPDATE) {
  819.                 if(genericProperties.getProprietaOggetto()!=null && genericProperties.getProprietaOggetto().getUtenteRichiedente()!=null) {
  820.                     utenteRichiedente = genericProperties.getProprietaOggetto().getUtenteRichiedente();
  821.                 }
  822.                
  823.                 if(genericProperties.getProprietaOggetto()!=null && genericProperties.getProprietaOggetto().getDataCreazione()!=null) {
  824.                     dataCreazione = new Timestamp(genericProperties.getProprietaOggetto().getDataCreazione().getTime());
  825.                 }
  826.                 else {
  827.                     dataCreazione = DateManager.getTimestamp();
  828.                 }
  829.             }
  830.            
  831.             String utenteUltimaModifica = null;
  832.             Timestamp dataUltimaModifica = null;
  833.             if(type == CostantiDB.UPDATE) {
  834.                 if(genericProperties.getProprietaOggetto()!=null && genericProperties.getProprietaOggetto().getUtenteUltimaModifica()!=null) {
  835.                     utenteUltimaModifica = genericProperties.getProprietaOggetto().getUtenteUltimaModifica();
  836.                 }
  837.                
  838.                 if(genericProperties.getProprietaOggetto()!=null && genericProperties.getProprietaOggetto().getDataUltimaModifica()!=null) {
  839.                     dataUltimaModifica = new Timestamp(genericProperties.getProprietaOggetto().getDataUltimaModifica().getTime());
  840.                 }
  841.                 else {
  842.                     dataUltimaModifica = DateManager.getTimestamp();
  843.                 }
  844.             }

  845.             switch (type) {
  846.             case CREATE:
  847.             case UPDATE:
  848.        
  849.                 // insert

  850.                 List<InsertAndGeneratedKeyObject> listInsertAndGeneratedKeyObject = new ArrayList<>();
  851.                 listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("nome", genericProperties.getNome() , InsertAndGeneratedKeyJDBCType.STRING) );
  852.                 listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("descrizione", genericProperties.getDescrizione() , InsertAndGeneratedKeyJDBCType.STRING) );
  853.                 listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("tipologia", genericProperties.getTipologia() , InsertAndGeneratedKeyJDBCType.STRING) );
  854.                 listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("tipo", genericProperties.getTipo() , InsertAndGeneratedKeyJDBCType.STRING) );
  855.                
  856.                 if(type == CostantiDB.CREATE || type == CostantiDB.UPDATE) {
  857.                     if(utenteRichiedente!=null) {
  858.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject(CostantiDB.PROPRIETA_OGGETTO_UTENTE_RICHIEDENTE, utenteRichiedente , InsertAndGeneratedKeyJDBCType.STRING) );
  859.                     }
  860.                     if(dataCreazione!=null) {
  861.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject(CostantiDB.PROPRIETA_OGGETTO_DATA_CREAZIONE, dataCreazione , InsertAndGeneratedKeyJDBCType.TIMESTAMP) );
  862.                     }
  863.                 }
  864.                 if(type == CostantiDB.UPDATE) {
  865.                     if(utenteUltimaModifica!=null) {
  866.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject(CostantiDB.PROPRIETA_OGGETTO_UTENTE_ULTIMA_MODIFICA, utenteUltimaModifica , InsertAndGeneratedKeyJDBCType.STRING) );
  867.                     }
  868.                     if(dataUltimaModifica!=null) {
  869.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject(CostantiDB.PROPRIETA_OGGETTO_DATA_ULTIMA_MODIFICA, dataUltimaModifica , InsertAndGeneratedKeyJDBCType.TIMESTAMP) );
  870.                     }
  871.                 }
  872.                
  873.                 long idProperties = InsertAndGeneratedKey.insertAndReturnGeneratedKey(con, TipiDatabase.toEnumConstant(DriverConfigurazioneDBLib.tipoDB),
  874.                         new CustomKeyGeneratorObject(CostantiDB.CONFIG_GENERIC_PROPERTIES, CostantiDB.CONFIG_GENERIC_PROPERTIES_COLUMN_ID,
  875.                                 CostantiDB.CONFIG_GENERIC_PROPERTIES_SEQUENCE, CostantiDB.CONFIG_GENERIC_PROPERTIES_TABLE_FOR_ID),
  876.                         listInsertAndGeneratedKeyObject.toArray(new InsertAndGeneratedKeyObject[1]));
  877.                 if(idProperties<=0){
  878.                     throw new DriverConfigurazioneException("ID (Generic Properties) autoincrementale non ottenuto");
  879.                 }

  880.                 for(int l=0; l<genericProperties.sizePropertyList();l++){
  881.                     ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  882.                     sqlQueryObject.addInsertTable(CostantiDB.CONFIG_GENERIC_PROPERTY);
  883.                     sqlQueryObject.addInsertField("id_props", "?");
  884.                     sqlQueryObject.addInsertField("nome", "?");
  885.                     sqlQueryObject.addInsertField("valore", "?");
  886.                     sqlQueryObject.addInsertField("enc_value", "?");
  887.                     updateQuery = sqlQueryObject.createSQLInsert();
  888.                     updateStmt = con.prepareStatement(updateQuery);
  889.                     int index = 1;
  890.                     updateStmt.setLong(index++, idProperties);
  891.                     updateStmt.setString(index++, genericProperties.getProperty(l).getNome());
  892.                    
  893.                     String plainValue = genericProperties.getProperty(l).getValore();
  894.                     String encValue = null;
  895.                     if(driverBYOK!=null && DriverConfigurazioneDB_genericPropertiesDriver.isConfidentialProperty(genericProperties.getTipo(), genericProperties.getProperty(l).getNome())) {
  896.                         BYOKWrappedValue byokValue = driverBYOK.wrap(plainValue);
  897.                         if(byokValue!=null) {
  898.                             encValue = byokValue.getWrappedValue();
  899.                             plainValue = byokValue.getWrappedPlainValue();
  900.                         }
  901.                     }
  902.                    
  903.                     updateStmt.setString(index++, plainValue);
  904.                     updateStmt.setString(index++, encValue);
  905.                    
  906.                     updateStmt.executeUpdate();
  907.                     updateStmt.close();
  908.                 }

  909.                 break;
  910.             case DELETE:
  911.                 // non rimuovo in quanto gia fatto sopra.
  912.                 break;
  913.             }


  914.         } catch (SQLException se) {
  915.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDGenericProperties] SQLException [" + se.getMessage() + "].",se);
  916.         }catch (Exception se) {
  917.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDGenericProperties] Exception [" + se.getMessage() + "].",se);
  918.         } finally {

  919.             JDBCUtilities.closeResources(selectRS, selectStmt);
  920.             JDBCUtilities.closeResources(updateStmt);
  921.            
  922.         }

  923.     }
  924.    

  925.     private static void createUrlInvocazioneRegolaEngine(ConfigurazioneUrlInvocazioneRegola regola, Connection con) throws SQLQueryObjectException, SQLException {
  926.         PreparedStatement updateStmt = null;
  927.        

  928.         try {
  929.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  930.             sqlQueryObject.addInsertTable(CostantiDB.CONFIG_URL_REGOLE);
  931.             sqlQueryObject.addInsertField("nome", "?");
  932.             sqlQueryObject.addInsertField("posizione", "?");
  933.             sqlQueryObject.addInsertField("stato", "?");
  934.             sqlQueryObject.addInsertField("descrizione", "?");
  935.             sqlQueryObject.addInsertField("regexpr", "?");
  936.             sqlQueryObject.addInsertField("regola", "?");
  937.             sqlQueryObject.addInsertField("contesto_esterno", "?");
  938.             sqlQueryObject.addInsertField("base_url", "?");
  939.             sqlQueryObject.addInsertField("protocollo", "?");
  940.             sqlQueryObject.addInsertField("ruolo", "?");
  941.             sqlQueryObject.addInsertField("service_binding", "?");
  942.             sqlQueryObject.addInsertField("tipo_soggetto", "?");
  943.             sqlQueryObject.addInsertField("nome_soggetto", "?");
  944.             String updateQuery = sqlQueryObject.createSQLInsert();
  945.             updateStmt = con.prepareStatement(updateQuery);
  946.             int indexP = 1;
  947.             updateStmt.setString(indexP++, regola.getNome());
  948.             updateStmt.setInt(indexP++, regola.getPosizione());
  949.             updateStmt.setString(indexP++, DriverConfigurazioneDBLib.getValue(regola.getStato()));
  950.             updateStmt.setString(indexP++, regola.getDescrizione());
  951.             updateStmt.setInt(indexP++, regola.isRegexpr() ? CostantiDB.TRUE : CostantiDB.FALSE);
  952.             updateStmt.setString(indexP++, regola.getRegola());
  953.             // 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
  954.             String s = regola.getContestoEsterno();
  955.             if("".equals(s)) {
  956.                 s = CostantiConfigurazione.REGOLA_PROXY_PASS_CONTESTO_VUOTO;
  957.             }
  958.             updateStmt.setString(indexP++, s);
  959.             updateStmt.setString(indexP++, regola.getBaseUrl());
  960.             updateStmt.setString(indexP++, regola.getProtocollo());
  961.             updateStmt.setString(indexP++, DriverConfigurazioneDBLib.getValue(regola.getRuolo()));
  962.             updateStmt.setString(indexP++, DriverConfigurazioneDBLib.getValue(regola.getServiceBinding()));
  963.             updateStmt.setString(indexP++, regola.getSoggetto()!=null ? regola.getSoggetto().getTipo() : null);
  964.             updateStmt.setString(indexP++, regola.getSoggetto()!=null ? regola.getSoggetto().getNome() : null);
  965.             updateStmt.executeUpdate();
  966.             updateStmt.close();
  967.            
  968.         } finally {
  969.             JDBCUtilities.closeResources(updateStmt);
  970.         }
  971.     }
  972.    
  973.     public static void CRUDUrlInvocazioneRegola(int type, ConfigurazioneUrlInvocazioneRegola regola, Connection con) throws DriverConfigurazioneException {
  974.         if (regola == null)
  975.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDUrlInvocazioneRegola] La regola non può essere NULL");
  976.         PreparedStatement updateStmt = null;
  977.         String updateQuery = "";
  978.        

  979.         try {
  980.            
  981.             if(regola.getNome()==null) {
  982.                 throw new DriverConfigurazioneException("Nome non fornito");
  983.             }
  984.            
  985.             // Recupero id generic properties
  986.             long idParent = -1;
  987.             if(type == CostantiDB.UPDATE || type == CostantiDB.DELETE) {
  988.                
  989.                 String oldNome = regola.getNome();
  990.                 if(type == CostantiDB.UPDATE && regola.getOldNome()!=null) {
  991.                     oldNome = regola.getOldNome();
  992.                 }
  993.                
  994.                 idParent = DBUtils.getUrlInvocazioneRegola(oldNome, con, DriverConfigurazioneDBLib.tipoDB);
  995.                 if(idParent<=0) {
  996.                     throw new DriverConfigurazioneException("Regola con nome '"+regola.getNome()+"' non trovata");
  997.                 }

  998.                 // delete
  999.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  1000.                 sqlQueryObject.addDeleteTable(CostantiDB.CONFIG_URL_REGOLE);
  1001.                 sqlQueryObject.addWhereCondition("id=?");
  1002.                 updateQuery = sqlQueryObject.createSQLDelete();
  1003.                 updateStmt = con.prepareStatement(updateQuery);
  1004.                 updateStmt.setLong(1, idParent);
  1005.                 updateStmt.executeUpdate();
  1006.                 updateStmt.close();
  1007.             }
  1008.            

  1009.             switch (type) {
  1010.             case CREATE:
  1011.             case UPDATE:
  1012.        
  1013.                 // insert

  1014.                 createUrlInvocazioneRegolaEngine(regola, con);

  1015.                 break;
  1016.             case DELETE:
  1017.                 // non rimuovo in quanto gia fatto sopra.
  1018.                 break;
  1019.             default:
  1020.                 break;
  1021.             }


  1022.         } catch (SQLException se) {
  1023.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDRegistroPlugin] SQLException [" + se.getMessage() + "].",se);
  1024.         }catch (Exception se) {
  1025.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDRegistroPlugin] Exception [" + se.getMessage() + "].",se);
  1026.         } finally {
  1027.             JDBCUtilities.closeResources(updateStmt);
  1028.         }

  1029.     }
  1030.    
  1031.    
  1032.    
  1033.    
  1034.     public static long CRUDConfigurazioneGenerale(int type, Configurazione config, Connection con) throws DriverConfigurazioneException {
  1035.        
  1036.         if(config.sizeExtendedInfoList()>0 &&
  1037.                 config.getRoutingTable()==null &&
  1038.                 config.getAccessoRegistro()==null &&
  1039.                 config.getAccessoConfigurazione()==null &&
  1040.                 config.getAccessoDatiAutorizzazione()==null &&
  1041.                 config.getAccessoDatiAutenticazione()==null &&
  1042.                 config.getMultitenant()==null &&
  1043.                 config.getUrlInvocazione()==null &&
  1044.                 config.getValidazioneBuste()==null &&
  1045.                 config.getValidazioneContenutiApplicativi()==null &&
  1046.                 config.getIndirizzoRisposta()==null &&  
  1047.                 config.getAttachments()==null &&
  1048.                 config.getRisposte()==null &&
  1049.                 config.getInoltroBusteNonRiscontrate()==null &&
  1050.                 config.getMessaggiDiagnostici()==null &&
  1051.                 config.getTracciamento()==null &&
  1052.                 config.getTransazioni()==null &&
  1053.                 config.getDump()==null &&      
  1054.                 config.getGestioneErrore()==null &&
  1055.                 config.getIntegrationManager()==null &&
  1056.                 config.getStatoServiziPdd()==null &&
  1057.                 config.getSystemProperties()==null &&
  1058.                 (config.getGenericPropertiesList()==null || config.getGenericPropertiesList().isEmpty()) &&
  1059.                 config.getGestioneCors()==null &&
  1060.                 config.getResponseCaching()==null &&
  1061.                 config.getGestioneCanali()==null &&
  1062.                 config.getRegistroPlugins()==null &&
  1063.                 config.getConfigurazioneHandler()==null) {
  1064.                        
  1065.             // caso speciale extended info
  1066.             ExtendedInfoManager extInfoManager = ExtendedInfoManager.getInstance();
  1067.             IExtendedInfo extInfoConfigurazioneDriver = extInfoManager.newInstanceExtendedInfoConfigurazione();
  1068.             if(extInfoConfigurazioneDriver!=null){
  1069.            
  1070.                 try{
  1071.                     CRUDType crudType = null;
  1072.                     switch (type) {
  1073.                     case CREATE:
  1074.                         crudType = CRUDType.CREATE;
  1075.                         break;
  1076.                     case UPDATE:
  1077.                         crudType = CRUDType.UPDATE;
  1078.                         break;
  1079.                     case DELETE:
  1080.                         crudType = CRUDType.DELETE;
  1081.                         break;
  1082.                     default:
  1083.                         break;
  1084.                     }
  1085.                    
  1086.                     switch (type) {
  1087.                     case CREATE:
  1088.                     case UPDATE:
  1089.                         if(config.sizeExtendedInfoList()>0){
  1090.                             for(int l=0; l<config.sizeExtendedInfoList();l++){
  1091.                                 extInfoConfigurazioneDriver.deleteExtendedInfo(con, DriverConfigurazioneDBLib.log,  config, config.getExtendedInfo(l), crudType);
  1092.                                 extInfoConfigurazioneDriver.createExtendedInfo(con, DriverConfigurazioneDBLib.log,  config, config.getExtendedInfo(l), crudType);
  1093.                             }
  1094.                         }
  1095.                         break;
  1096.                     case DELETE:
  1097.                         if(config.sizeExtendedInfoList()>0){
  1098.                             for(int l=0; l<config.sizeExtendedInfoList();l++){
  1099.                                 extInfoConfigurazioneDriver.deleteExtendedInfo(con, DriverConfigurazioneDBLib.log,  config, config.getExtendedInfo(l), crudType);
  1100.                             }
  1101.                         }
  1102.                         break;
  1103.                     default:
  1104.                         break;
  1105.                     }
  1106.                 }catch (Exception se) {
  1107.                     throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDConfigurazioneGenerale-Extended] Exception [" + se.getMessage() + "].",se);
  1108.                 }
  1109.                
  1110.             }
  1111.            
  1112.             return -1;
  1113.            
  1114.         }
  1115.         else{
  1116.            
  1117.             return engineCRUDConfigurazioneGenerale(type, config, con);
  1118.            
  1119.         }
  1120.        
  1121.     }

  1122.     @SuppressWarnings("deprecation")
  1123.     private static DumpConfigurazione getDumpConfigurazioneDeprecated(Dump dump) {
  1124.         return dump.getConfigurazione();
  1125.     }
  1126.    
  1127.     private static long engineCRUDConfigurazioneGenerale(int type, Configurazione config, Connection con) throws DriverConfigurazioneException {
  1128.         PreparedStatement updateStmt = null;
  1129.         String updateQuery = "";
  1130.         PreparedStatement selectStmt = null;
  1131.         ResultSet selectRS = null;
  1132.         int n = 0;
  1133.         long idConfigurazione = 0;

  1134.         IndirizzoRisposta indirizzoPerRisposta = config.getIndirizzoRisposta();
  1135.         InoltroBusteNonRiscontrate inoltroBusteNonRiscontrate = config.getInoltroBusteNonRiscontrate();
  1136.         IntegrationManager integrationManager = config.getIntegrationManager();
  1137.         MessaggiDiagnostici messaggiDiagnostici = config.getMessaggiDiagnostici();
  1138.         Risposte risposte = config.getRisposte();
  1139.         ValidazioneBuste validazioneBuste = config.getValidazioneBuste();
  1140.         AccessoRegistro car = config.getAccessoRegistro();
  1141.         AccessoConfigurazione aConfig = config.getAccessoConfigurazione();
  1142.         AccessoDatiAutorizzazione aDatiAuthz = config.getAccessoDatiAutorizzazione();
  1143.         AccessoDatiAutenticazione aDatiAuthn = config.getAccessoDatiAutenticazione();
  1144.         AccessoDatiGestioneToken aDatiGestioneToken = config.getAccessoDatiGestioneToken();
  1145.         AccessoDatiAttributeAuthority aDatiAttributeAuthority = config.getAccessoDatiAttributeAuthority();
  1146.         AccessoDatiKeystore aDatiKeystore = config.getAccessoDatiKeystore();
  1147.         AccessoDatiRichieste aDatiRichieste = config.getAccessoDatiRichieste();
  1148.         Attachments att = config.getAttachments();

  1149.         ConfigurazioneMultitenant multitenant = config.getMultitenant();
  1150.        
  1151.         CorsConfigurazione corsConfigurazione = config.getGestioneCors();
  1152.         String corsStato = null;
  1153.         String corsTipo = null;
  1154.         String corsAllAllowOrigins = null;
  1155.         String corsAllAllowMethods = null;
  1156.         String corsAllAllowHeaders = null;
  1157.         String corsAllowCredentials = null;
  1158.         int corsAllowMaxAge = CostantiDB.FALSE;
  1159.         Integer corsAllowMaxAgeSeconds = null;
  1160.         String corsAllowOrigins = null;
  1161.         String corsAllowHeaders = null;
  1162.         String corsAllowMethods = null;
  1163.         String corsAllowExposeHeaders = null;
  1164.         if(corsConfigurazione!=null) {
  1165.             corsStato = DriverConfigurazioneDBLib.getValue(corsConfigurazione.getStato());
  1166.             corsTipo = DriverConfigurazioneDBLib.getValue(corsConfigurazione.getTipo());
  1167.             corsAllAllowOrigins = DriverConfigurazioneDBLib.getValue(corsConfigurazione.getAccessControlAllAllowOrigins());
  1168.             corsAllAllowMethods = DriverConfigurazioneDBLib.getValue(corsConfigurazione.getAccessControlAllAllowMethods());
  1169.             corsAllAllowHeaders = DriverConfigurazioneDBLib.getValue(corsConfigurazione.getAccessControlAllAllowHeaders());
  1170.             corsAllowCredentials = DriverConfigurazioneDBLib.getValue(corsConfigurazione.getAccessControlAllowCredentials());
  1171.             if(corsConfigurazione.getAccessControlMaxAge()!=null) {
  1172.                 corsAllowMaxAge = CostantiDB.TRUE;
  1173.                 corsAllowMaxAgeSeconds = corsConfigurazione.getAccessControlMaxAge();  
  1174.             }
  1175.             if(corsConfigurazione.getAccessControlAllowOrigins()!=null && corsConfigurazione.getAccessControlAllowOrigins().sizeOriginList()>0) {
  1176.                 StringBuilder bf = new StringBuilder();
  1177.                 for (int i = 0; i < corsConfigurazione.getAccessControlAllowOrigins().sizeOriginList(); i++) {
  1178.                     if(i>0) {
  1179.                         bf.append(",");
  1180.                     }
  1181.                     bf.append(corsConfigurazione.getAccessControlAllowOrigins().getOrigin(i));
  1182.                 }
  1183.                 corsAllowOrigins = bf.toString();
  1184.             }
  1185.             if(corsConfigurazione.getAccessControlAllowHeaders()!=null && corsConfigurazione.getAccessControlAllowHeaders().sizeHeaderList()>0) {
  1186.                 StringBuilder bf = new StringBuilder();
  1187.                 for (int i = 0; i < corsConfigurazione.getAccessControlAllowHeaders().sizeHeaderList(); i++) {
  1188.                     if(i>0) {
  1189.                         bf.append(",");
  1190.                     }
  1191.                     bf.append(corsConfigurazione.getAccessControlAllowHeaders().getHeader(i));
  1192.                 }
  1193.                 corsAllowHeaders = bf.toString();
  1194.             }
  1195.             if(corsConfigurazione.getAccessControlAllowMethods()!=null && corsConfigurazione.getAccessControlAllowMethods().sizeMethodList()>0) {
  1196.                 StringBuilder bf = new StringBuilder();
  1197.                 for (int i = 0; i < corsConfigurazione.getAccessControlAllowMethods().sizeMethodList(); i++) {
  1198.                     if(i>0) {
  1199.                         bf.append(",");
  1200.                     }
  1201.                     bf.append(corsConfigurazione.getAccessControlAllowMethods().getMethod(i));
  1202.                 }
  1203.                 corsAllowMethods = bf.toString();
  1204.             }
  1205.             if(corsConfigurazione.getAccessControlExposeHeaders()!=null && corsConfigurazione.getAccessControlExposeHeaders().sizeHeaderList()>0) {
  1206.                 StringBuilder bf = new StringBuilder();
  1207.                 for (int i = 0; i < corsConfigurazione.getAccessControlExposeHeaders().sizeHeaderList(); i++) {
  1208.                     if(i>0) {
  1209.                         bf.append(",");
  1210.                     }
  1211.                     bf.append(corsConfigurazione.getAccessControlExposeHeaders().getHeader(i));
  1212.                 }
  1213.                 corsAllowExposeHeaders = bf.toString();
  1214.             }
  1215.         }
  1216.        
  1217.         ResponseCachingConfigurazioneGenerale responseCachingConfigurazione = config.getResponseCaching();
  1218.        
  1219.         String responseCacheStato = null;
  1220.         Integer responseCacheSeconds = null;
  1221.         Long responseCacheMaxMsgSize = null;
  1222.         String responseCacheHashUrl = null;
  1223.         String responseCacheHashQuery = null;
  1224.         String responseCacheHashQueryList = null;
  1225.         String responseCacheHashHeaders = null;
  1226.         String responseCacheHashHeadersList = null;
  1227.         String responseCacheHashPayload = null;
  1228.         boolean responseCacheNoCache = true;
  1229.         boolean responseCacheMaxAge = true;
  1230.         boolean responseCacheNoStore = true;
  1231.         List<ResponseCachingConfigurazioneRegola> responseCacheRegole = null;
  1232.         if(responseCachingConfigurazione!=null && responseCachingConfigurazione.getConfigurazione()!=null) {
  1233.             responseCacheStato = DriverConfigurazioneDBLib.getValue(responseCachingConfigurazione.getConfigurazione().getStato());
  1234.             responseCacheSeconds = responseCachingConfigurazione.getConfigurazione().getCacheTimeoutSeconds();
  1235.             responseCacheMaxMsgSize = responseCachingConfigurazione.getConfigurazione().getMaxMessageSize();
  1236.             if(responseCachingConfigurazione.getConfigurazione().getControl()!=null) {
  1237.                 responseCacheNoCache = responseCachingConfigurazione.getConfigurazione().getControl().getNoCache();
  1238.                 responseCacheMaxAge = responseCachingConfigurazione.getConfigurazione().getControl().getMaxAge();
  1239.                 responseCacheNoStore = responseCachingConfigurazione.getConfigurazione().getControl().getNoStore();
  1240.             }
  1241.             if(responseCachingConfigurazione.getConfigurazione().getHashGenerator()!=null) {
  1242.                 responseCacheHashUrl = DriverConfigurazioneDBLib.getValue(responseCachingConfigurazione.getConfigurazione().getHashGenerator().getRequestUri());
  1243.                
  1244.                 responseCacheHashQuery = DriverConfigurazioneDBLib.getValue(responseCachingConfigurazione.getConfigurazione().getHashGenerator().getQueryParameters());
  1245.                 if(StatoFunzionalitaCacheDigestQueryParameter.SELEZIONE_PUNTUALE.equals(responseCachingConfigurazione.getConfigurazione().getHashGenerator().getQueryParameters()) &&
  1246.                     (responseCachingConfigurazione.getConfigurazione().getHashGenerator().getQueryParameterList()!=null && responseCachingConfigurazione.getConfigurazione().getHashGenerator().sizeQueryParameterList()>0)
  1247.                     ){
  1248.                     StringBuilder bf = new StringBuilder();
  1249.                     for (int i = 0; i < responseCachingConfigurazione.getConfigurazione().getHashGenerator().sizeQueryParameterList(); i++) {
  1250.                         if(i>0) {
  1251.                             bf.append(",");
  1252.                         }
  1253.                         bf.append(responseCachingConfigurazione.getConfigurazione().getHashGenerator().getQueryParameter(i));
  1254.                     }
  1255.                     responseCacheHashQueryList = bf.toString();
  1256.                 }
  1257.                
  1258.                 responseCacheHashHeaders = DriverConfigurazioneDBLib.getValue(responseCachingConfigurazione.getConfigurazione().getHashGenerator().getHeaders());
  1259.                 if(StatoFunzionalita.ABILITATO.equals(responseCachingConfigurazione.getConfigurazione().getHashGenerator().getHeaders()) &&
  1260.                     (responseCachingConfigurazione.getConfigurazione().getHashGenerator().getHeaderList()!=null && responseCachingConfigurazione.getConfigurazione().getHashGenerator().sizeHeaderList()>0)
  1261.                     ){
  1262.                     StringBuilder bf = new StringBuilder();
  1263.                     for (int i = 0; i < responseCachingConfigurazione.getConfigurazione().getHashGenerator().sizeHeaderList(); i++) {
  1264.                         if(i>0) {
  1265.                             bf.append(",");
  1266.                         }
  1267.                         bf.append(responseCachingConfigurazione.getConfigurazione().getHashGenerator().getHeader(i));
  1268.                     }
  1269.                     responseCacheHashHeadersList = bf.toString();
  1270.                 }
  1271.                
  1272.                 responseCacheHashPayload = DriverConfigurazioneDBLib.getValue(responseCachingConfigurazione.getConfigurazione().getHashGenerator().getPayload());
  1273.             }
  1274.             responseCacheRegole = responseCachingConfigurazione.getConfigurazione().getRegolaList();
  1275.         }
  1276.        
  1277.         Cache responseCachingCache = null;
  1278.         String responseCachingDimensioneCache = null;
  1279.         String responseCachingAlgoritmoCache = null;
  1280.         String responseCachingIdleCache = null;
  1281.         String responseCachingLifeCache = null;
  1282.         String responseCachingStatoCache = null;
  1283.         if(responseCachingConfigurazione !=null){
  1284.             responseCachingCache = responseCachingConfigurazione.getCache();

  1285.         }
  1286.         responseCachingStatoCache = (responseCachingCache != null ? CostantiConfigurazione.ABILITATO.toString() : CostantiConfigurazione.DISABILITATO.toString());
  1287.         if (responseCachingStatoCache.equals(CostantiConfigurazione.ABILITATO.toString())) {
  1288.             responseCachingDimensioneCache = responseCachingCache.getDimensione();
  1289.             responseCachingAlgoritmoCache = DriverConfigurazioneDBLib.getValue(responseCachingCache.getAlgoritmo());
  1290.             responseCachingIdleCache = responseCachingCache.getItemIdleTime();
  1291.             responseCachingLifeCache = responseCachingCache.getItemLifeSecond();
  1292.         }
  1293.        
  1294.        
  1295.         Cache consegnaCache = null;
  1296.         String consegnaDimensioneCache = null;
  1297.         String consegnaAlgoritmoCache = null;
  1298.         String consegnaIdleCache = null;
  1299.         String consegnaLifeCache = null;
  1300.         String consegnaStatoCache = null;
  1301.         if(config.getAccessoDatiConsegnaApplicativi() !=null){
  1302.             consegnaCache = config.getAccessoDatiConsegnaApplicativi().getCache();

  1303.         }
  1304.         consegnaStatoCache = (consegnaCache != null ? CostantiConfigurazione.ABILITATO.toString() : CostantiConfigurazione.DISABILITATO.toString());
  1305.         if (consegnaStatoCache.equals(CostantiConfigurazione.ABILITATO.toString())) {
  1306.             consegnaDimensioneCache = consegnaCache.getDimensione();
  1307.             consegnaAlgoritmoCache = DriverConfigurazioneDBLib.getValue(consegnaCache.getAlgoritmo());
  1308.             consegnaIdleCache = consegnaCache.getItemIdleTime();
  1309.             consegnaLifeCache = consegnaCache.getItemLifeSecond();
  1310.         }
  1311.        
  1312.         String utilizzoIndTelematico = null;
  1313.         if(indirizzoPerRisposta!=null){
  1314.             utilizzoIndTelematico = DriverConfigurazioneDBLib.getValue(indirizzoPerRisposta.getUtilizzo());
  1315.         }
  1316.         String cadenzaInoltro = null;
  1317.         if(inoltroBusteNonRiscontrate!=null){
  1318.             cadenzaInoltro = inoltroBusteNonRiscontrate.getCadenza();
  1319.         }
  1320.         String autenticazione = null;
  1321.         if(integrationManager!=null){
  1322.             autenticazione = integrationManager.getAutenticazione();
  1323.         }
  1324.         String msgDiagSeverita = null;
  1325.         String msgDiagSeveritaLog4j = null;
  1326.         if(messaggiDiagnostici!=null){
  1327.             msgDiagSeverita = DriverConfigurazioneDBLib.getValue(messaggiDiagnostici.getSeverita());
  1328.             msgDiagSeveritaLog4j = DriverConfigurazioneDBLib.getValue(messaggiDiagnostici.getSeveritaLog4j());
  1329.         }
  1330.         String valControllo = null;
  1331.         String valStato = null;
  1332.         String valManifest = null;
  1333.         String valProfiloCollaborazione = null;
  1334.         if(validazioneBuste!=null){
  1335.             valControllo = DriverConfigurazioneDBLib.getValue(validazioneBuste.getControllo());
  1336.             valStato = DriverConfigurazioneDBLib.getValue(validazioneBuste.getStato());
  1337.             valManifest = DriverConfigurazioneDBLib.getValue(validazioneBuste.getManifestAttachments());
  1338.             valProfiloCollaborazione = DriverConfigurazioneDBLib.getValue(validazioneBuste.getProfiloCollaborazione());
  1339.         }

  1340.         String gestioneManifest = null;
  1341.         if(att!=null){
  1342.             gestioneManifest = DriverConfigurazioneDBLib.getValue(att.getGestioneManifest());
  1343.         }

  1344.         Cache registroCache = null;
  1345.         String registroDimensioneCache = null;
  1346.         String registroAlgoritmoCache = null;
  1347.         String registroIdleCache = null;
  1348.         String registroLifeCache = null;
  1349.         String registroStatoCache = null;
  1350.         if(car !=null){
  1351.             registroCache = car.getCache();

  1352.         }
  1353.         registroStatoCache = (registroCache != null ? CostantiConfigurazione.ABILITATO.toString() : CostantiConfigurazione.DISABILITATO.toString());
  1354.         if (registroStatoCache.equals(CostantiConfigurazione.ABILITATO.toString())) {
  1355.             registroDimensioneCache = registroCache.getDimensione();
  1356.             registroAlgoritmoCache = DriverConfigurazioneDBLib.getValue(registroCache.getAlgoritmo());
  1357.             registroIdleCache = registroCache.getItemIdleTime();
  1358.             registroLifeCache = registroCache.getItemLifeSecond();
  1359.         }
  1360.        
  1361.         Cache configCache = null;
  1362.         String configDimensioneCache = null;
  1363.         String configAlgoritmoCache = null;
  1364.         String configIdleCache = null;
  1365.         String configLifeCache = null;
  1366.         String configStatoCache = null;
  1367.         if(aConfig !=null){
  1368.             configCache = aConfig.getCache();

  1369.         }
  1370.         configStatoCache = (configCache != null ? CostantiConfigurazione.ABILITATO.toString() : CostantiConfigurazione.DISABILITATO.toString());
  1371.         if (configStatoCache.equals(CostantiConfigurazione.ABILITATO.toString())) {
  1372.             configDimensioneCache = configCache.getDimensione();
  1373.             configAlgoritmoCache = DriverConfigurazioneDBLib.getValue(configCache.getAlgoritmo());
  1374.             configIdleCache = configCache.getItemIdleTime();
  1375.             configLifeCache = configCache.getItemLifeSecond();
  1376.         }
  1377.        
  1378.         Cache authzCache = null;
  1379.         String authzDimensioneCache = null;
  1380.         String authzAlgoritmoCache = null;
  1381.         String authzIdleCache = null;
  1382.         String authzLifeCache = null;
  1383.         String authzStatoCache = null;
  1384.         if(aDatiAuthz !=null){
  1385.             authzCache = aDatiAuthz.getCache();

  1386.         }
  1387.         authzStatoCache = (authzCache != null ? CostantiConfigurazione.ABILITATO.toString() : CostantiConfigurazione.DISABILITATO.toString());
  1388.         if (authzStatoCache.equals(CostantiConfigurazione.ABILITATO.toString())) {
  1389.             authzDimensioneCache = authzCache.getDimensione();
  1390.             authzAlgoritmoCache = DriverConfigurazioneDBLib.getValue(authzCache.getAlgoritmo());
  1391.             authzIdleCache = authzCache.getItemIdleTime();
  1392.             authzLifeCache = authzCache.getItemLifeSecond();
  1393.         }
  1394.        
  1395.         Cache authnCache = null;
  1396.         String authnDimensioneCache = null;
  1397.         String authnAlgoritmoCache = null;
  1398.         String authnIdleCache = null;
  1399.         String authnLifeCache = null;
  1400.         String authnStatoCache = null;
  1401.         if(aDatiAuthn !=null){
  1402.             authnCache = aDatiAuthn.getCache();

  1403.         }
  1404.         authnStatoCache = (authnCache != null ? CostantiConfigurazione.ABILITATO.toString() : CostantiConfigurazione.DISABILITATO.toString());
  1405.         if (authnStatoCache.equals(CostantiConfigurazione.ABILITATO.toString())) {
  1406.             authnDimensioneCache = authnCache.getDimensione();
  1407.             authnAlgoritmoCache = DriverConfigurazioneDBLib.getValue(authnCache.getAlgoritmo());
  1408.             authnIdleCache = authnCache.getItemIdleTime();
  1409.             authnLifeCache = authnCache.getItemLifeSecond();
  1410.         }
  1411.        
  1412.         Cache tokenCache = null;
  1413.         String tokenDimensioneCache = null;
  1414.         String tokenAlgoritmoCache = null;
  1415.         String tokenIdleCache = null;
  1416.         String tokenLifeCache = null;
  1417.         String tokenStatoCache = null;
  1418.         if(aDatiGestioneToken !=null){
  1419.             tokenCache = aDatiGestioneToken.getCache();
  1420.         }
  1421.         tokenStatoCache = (tokenCache != null ? CostantiConfigurazione.ABILITATO.toString() : CostantiConfigurazione.DISABILITATO.toString());
  1422.         if (tokenStatoCache.equals(CostantiConfigurazione.ABILITATO.toString())) {
  1423.             tokenDimensioneCache = tokenCache.getDimensione();
  1424.             tokenAlgoritmoCache = DriverConfigurazioneDBLib.getValue(tokenCache.getAlgoritmo());
  1425.             tokenIdleCache = tokenCache.getItemIdleTime();
  1426.             tokenLifeCache = tokenCache.getItemLifeSecond();
  1427.         }
  1428.        
  1429.         Cache aaCache = null;
  1430.         String aaDimensioneCache = null;
  1431.         String aaAlgoritmoCache = null;
  1432.         String aaIdleCache = null;
  1433.         String aaLifeCache = null;
  1434.         String aaStatoCache = null;
  1435.         if(aDatiAttributeAuthority !=null){
  1436.             aaCache = aDatiAttributeAuthority.getCache();
  1437.         }
  1438.         aaStatoCache = (aaCache != null ? CostantiConfigurazione.ABILITATO.toString() : CostantiConfigurazione.DISABILITATO.toString());
  1439.         if (aaStatoCache.equals(CostantiConfigurazione.ABILITATO.toString())) {
  1440.             aaDimensioneCache = aaCache.getDimensione();
  1441.             aaAlgoritmoCache = DriverConfigurazioneDBLib.getValue(aaCache.getAlgoritmo());
  1442.             aaIdleCache = aaCache.getItemIdleTime();
  1443.             aaLifeCache = aaCache.getItemLifeSecond();
  1444.         }
  1445.        
  1446.         Cache keystoreCache = null;
  1447.         String keystoreDimensioneCache = null;
  1448.         String keystoreAlgoritmoCache = null;
  1449.         String keystoreIdleCache = null;
  1450.         String keystoreLifeCache = null;
  1451.         String keystoreStatoCache = null;
  1452.         String keystoreCrlLifeCache = null;
  1453.         if(aDatiKeystore !=null){
  1454.             keystoreCache = aDatiKeystore.getCache();
  1455.             keystoreCrlLifeCache = aDatiKeystore.getCrlItemLifeSecond();

  1456.         }
  1457.         keystoreStatoCache = (keystoreCache != null ? CostantiConfigurazione.ABILITATO.toString() : CostantiConfigurazione.DISABILITATO.toString());
  1458.         if (keystoreStatoCache.equals(CostantiConfigurazione.ABILITATO.toString())) {
  1459.             keystoreDimensioneCache = keystoreCache.getDimensione();
  1460.             keystoreAlgoritmoCache = DriverConfigurazioneDBLib.getValue(keystoreCache.getAlgoritmo());
  1461.             keystoreIdleCache = keystoreCache.getItemIdleTime();
  1462.             keystoreLifeCache = keystoreCache.getItemLifeSecond();
  1463.         }
  1464.        
  1465.         Cache datiRichiesteCache = null;
  1466.         String datiRichiesteDimensioneCache = null;
  1467.         String datiRichiesteAlgoritmoCache = null;
  1468.         String datiRichiesteIdleCache = null;
  1469.         String datiRichiesteLifeCache = null;
  1470.         String datiRichiesteStatoCache = null;
  1471.         if(aDatiRichieste !=null){
  1472.             datiRichiesteCache = aDatiRichieste.getCache();
  1473.         }
  1474.         datiRichiesteStatoCache = (datiRichiesteCache != null ? CostantiConfigurazione.ABILITATO.toString() : CostantiConfigurazione.DISABILITATO.toString());
  1475.         if (datiRichiesteStatoCache.equals(CostantiConfigurazione.ABILITATO.toString())) {
  1476.             datiRichiesteDimensioneCache = datiRichiesteCache.getDimensione();
  1477.             datiRichiesteAlgoritmoCache = DriverConfigurazioneDBLib.getValue(datiRichiesteCache.getAlgoritmo());
  1478.             datiRichiesteIdleCache = datiRichiesteCache.getItemIdleTime();
  1479.             datiRichiesteLifeCache = datiRichiesteCache.getItemLifeSecond();
  1480.         }

  1481.         Tracciamento t = config.getTracciamento();
  1482.         String tracciamentoBuste = null;
  1483.         if (t != null) {
  1484.             tracciamentoBuste = DriverConfigurazioneDBLib.getValue(t.getStato());          
  1485.         }
  1486.        
  1487.         String tracciamentoEsitiPD = null;
  1488.         String transazioniTempiElaborazionePD = null;
  1489.         String transazioniTokenPD = null;
  1490.         ConfigurazioneTracciamentoPorta tracciamentoPD = null;
  1491.         if (t != null) {
  1492.             tracciamentoPD =t.getPortaDelegata();
  1493.         }
  1494.         TracciamentoConfigurazione tracciamentoConfigurazioneDatabasePD = null;
  1495.         TracciamentoConfigurazione tracciamentoConfigurazioneFiletracePD = null;
  1496.         TracciamentoConfigurazioneFiletrace tracciamentoConfigurazioneFiletraceDetailsPD = null;
  1497.         if(tracciamentoPD!=null) {
  1498.             tracciamentoEsitiPD = tracciamentoPD.getEsiti();
  1499.             if(tracciamentoPD.getTransazioni()!=null) {
  1500.                 transazioniTempiElaborazionePD = DriverConfigurazioneDBLib.getValue(tracciamentoPD.getTransazioni().getTempiElaborazione());
  1501.                 transazioniTokenPD = DriverConfigurazioneDBLib.getValue(tracciamentoPD.getTransazioni().getToken());
  1502.             }
  1503.             tracciamentoConfigurazioneDatabasePD = tracciamentoPD.getDatabase();
  1504.             tracciamentoConfigurazioneFiletracePD = tracciamentoPD.getFiletrace();
  1505.             tracciamentoConfigurazioneFiletraceDetailsPD = tracciamentoPD.getFiletraceConfig();
  1506.         }
  1507.         else {
  1508.             // backward compatibility, lo uso sia per erogazione che per fruizione (per import package)
  1509.            
  1510.             if (t != null) {
  1511.                 tracciamentoEsitiPD = t.getEsiti();
  1512.             }
  1513.            
  1514.             Transazioni transazioni = config.getTransazioni();
  1515.             if(transazioni!=null) {
  1516.                 transazioniTempiElaborazionePD = DriverConfigurazioneDBLib.getValue(transazioni.getTempiElaborazione());
  1517.                 transazioniTokenPD = DriverConfigurazioneDBLib.getValue(transazioni.getToken());
  1518.             }
  1519.         }
  1520.        
  1521.         String tracciamentoEsitiPA = null;
  1522.         String transazioniTempiElaborazionePA = null;
  1523.         String transazioniTokenPA = null;
  1524.         ConfigurazioneTracciamentoPorta tracciamentoPA = null;
  1525.         if (t != null) {
  1526.             tracciamentoPA = t.getPortaApplicativa();
  1527.         }
  1528.         TracciamentoConfigurazione tracciamentoConfigurazioneDatabasePA = null;
  1529.         TracciamentoConfigurazione tracciamentoConfigurazioneFiletracePA = null;
  1530.         TracciamentoConfigurazioneFiletrace tracciamentoConfigurazioneFiletraceDetailsPA = null;
  1531.         if(tracciamentoPA!=null) {
  1532.             tracciamentoEsitiPA = tracciamentoPA.getEsiti();
  1533.             if(tracciamentoPA.getTransazioni()!=null) {
  1534.                 transazioniTempiElaborazionePA = DriverConfigurazioneDBLib.getValue(tracciamentoPA.getTransazioni().getTempiElaborazione());
  1535.                 transazioniTokenPA = DriverConfigurazioneDBLib.getValue(tracciamentoPA.getTransazioni().getToken());
  1536.             }
  1537.             tracciamentoConfigurazioneDatabasePA = tracciamentoPA.getDatabase();
  1538.             tracciamentoConfigurazioneFiletracePA = tracciamentoPA.getFiletrace();
  1539.             tracciamentoConfigurazioneFiletraceDetailsPA = tracciamentoPA.getFiletraceConfig();
  1540.         }
  1541.         else {
  1542.             // backward compatibility, lo uso sia per erogazione che per fruizione (per import package)
  1543.            
  1544.             if (t != null) {
  1545.                 tracciamentoEsitiPA = t.getEsiti();
  1546.             }
  1547.            
  1548.             Transazioni transazioni = config.getTransazioni();
  1549.             if(transazioni!=null) {
  1550.                 transazioniTempiElaborazionePA = DriverConfigurazioneDBLib.getValue(transazioni.getTempiElaborazione());
  1551.                 transazioniTokenPA = DriverConfigurazioneDBLib.getValue(transazioni.getToken());
  1552.             }
  1553.         }
  1554.        

  1555.        
  1556.         Dump d = config.getDump();
  1557.         String dumpApplicativo = null;
  1558.         String dumpPD = null;
  1559.         String dumpPA = null;
  1560.         DumpConfigurazione dumpConfigPA = null;
  1561.         DumpConfigurazione dumpConfigPD = null;
  1562.         if (d != null) {
  1563.             dumpApplicativo = DriverConfigurazioneDBLib.getValue(d.getStato());
  1564.             dumpPD = DriverConfigurazioneDBLib.getValue(d.getDumpBinarioPortaDelegata());
  1565.             dumpPA = DriverConfigurazioneDBLib.getValue(d.getDumpBinarioPortaApplicativa());
  1566.            
  1567.             DumpConfigurazione dumpConfig = getDumpConfigurazioneDeprecated(d);
  1568.             if(dumpConfig!=null) {
  1569.                 // backward compatibility, lo uso sia per erogazione che per fruizione (per import package)
  1570.                 dumpConfigPA = dumpConfig;
  1571.                 dumpConfigPD = dumpConfig;
  1572.             }
  1573.             else {
  1574.                 dumpConfigPA = d.getConfigurazionePortaApplicativa();
  1575.                 dumpConfigPD = d.getConfigurazionePortaDelegata();
  1576.             }
  1577.         }
  1578.        
  1579.         String modRisposta = CostantiConfigurazione.CONNECTION_REPLY.toString();
  1580.         if(risposte!=null){
  1581.             modRisposta = (risposte.getConnessione().equals(CostantiConfigurazione.CONNECTION_REPLY) ?
  1582.                     CostantiConfigurazione.CONNECTION_REPLY.toString() : CostantiConfigurazione.NEW_CONNECTION.toString());
  1583.         }
  1584.         String routingEnabled =  CostantiConfigurazione.DISABILITATO.toString();
  1585.         if(config.getRoutingTable()!=null &&
  1586.             (config.getRoutingTable().getAbilitata()!=null && config.getRoutingTable().getAbilitata())
  1587.             ){
  1588.             routingEnabled =  CostantiConfigurazione.ABILITATO.toString();
  1589.         }
  1590.        
  1591.         String validazioneContenutiStato = null;
  1592.         String validazioneContenutiTipo = null;
  1593.         String validazioneContenutiAcceptMtomMessage = null;
  1594.         if(config.getValidazioneContenutiApplicativi()!=null){
  1595.             validazioneContenutiStato = DriverConfigurazioneDBLib.getValue(config.getValidazioneContenutiApplicativi().getStato());
  1596.             validazioneContenutiTipo = DriverConfigurazioneDBLib.getValue(config.getValidazioneContenutiApplicativi().getTipo());
  1597.             validazioneContenutiAcceptMtomMessage = DriverConfigurazioneDBLib.getValue(config.getValidazioneContenutiApplicativi().getAcceptMtomMessage());
  1598.         }

  1599.         CanaliConfigurazione configurazioneCanali = config.getGestioneCanali();
  1600.         String configurazioneCanaliStato = null;
  1601.         if(configurazioneCanali!=null) {
  1602.             configurazioneCanaliStato = DriverConfigurazioneDBLib.getValue(configurazioneCanali.getStato());
  1603.         }
  1604.        
  1605.         ConfigurazioneGeneraleHandler configHandlers = config.getConfigurazioneHandler();
  1606.        
  1607.         ExtendedInfoManager extInfoManager = ExtendedInfoManager.getInstance();
  1608.         IExtendedInfo extInfoConfigurazioneDriver = extInfoManager.newInstanceExtendedInfoConfigurazione();
  1609.                                    
  1610.         try {
  1611.             switch (type) {
  1612.             case CREATE:
  1613.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  1614.                 sqlQueryObject.addInsertTable(CostantiDB.CONFIGURAZIONE);
  1615.                 sqlQueryObject.addInsertField("cadenza_inoltro", "?");
  1616.                
  1617.                 sqlQueryObject.addInsertField("validazione_stato", "?");
  1618.                 sqlQueryObject.addInsertField("validazione_controllo", "?");
  1619.                
  1620.                 sqlQueryObject.addInsertField("msg_diag_severita", "?");
  1621.                 sqlQueryObject.addInsertField("msg_diag_severita_log4j", "?");
  1622.                 sqlQueryObject.addInsertField("auth_integration_manager", "?");
  1623.                 sqlQueryObject.addInsertField("validazione_profilo", "?");
  1624.                 sqlQueryObject.addInsertField("mod_risposta", "?");
  1625.                 sqlQueryObject.addInsertField("indirizzo_telematico", "?");
  1626.                 sqlQueryObject.addInsertField("routing_enabled", "?");
  1627.                 sqlQueryObject.addInsertField("gestione_manifest", "?");
  1628.                 sqlQueryObject.addInsertField("validazione_manifest", "?");
  1629.                 sqlQueryObject.addInsertField("tracciamento_buste", "?");
  1630.                 // tracciamento
  1631.                 sqlQueryObject.addInsertField("tracciamento_esiti", "?");
  1632.                 sqlQueryObject.addInsertField("tracciamento_esiti_pd", "?");
  1633.                 sqlQueryObject.addInsertField("transazioni_tempi", "?");
  1634.                 sqlQueryObject.addInsertField("transazioni_tempi_pd", "?");
  1635.                 sqlQueryObject.addInsertField("transazioni_token", "?");
  1636.                 sqlQueryObject.addInsertField("transazioni_token_pd", "?");
  1637.                 // dump
  1638.                 sqlQueryObject.addInsertField("dump", "?");
  1639.                 sqlQueryObject.addInsertField("dump_bin_pd", "?");
  1640.                 sqlQueryObject.addInsertField("dump_bin_pa", "?");
  1641.                 // validazione
  1642.                 sqlQueryObject.addInsertField("validazione_contenuti_stato", "?");
  1643.                 sqlQueryObject.addInsertField("validazione_contenuti_tipo", "?");
  1644.                 sqlQueryObject.addInsertField("validazione_contenuti_mtom", "?");
  1645.                 // registro cache
  1646.                 sqlQueryObject.addInsertField("statocache", "?");
  1647.                 sqlQueryObject.addInsertField("dimensionecache", "?");
  1648.                 sqlQueryObject.addInsertField("algoritmocache", "?");
  1649.                 sqlQueryObject.addInsertField("idlecache", "?");
  1650.                 sqlQueryObject.addInsertField("lifecache", "?");
  1651.                 // config cache
  1652.                 sqlQueryObject.addInsertField("config_statocache", "?");
  1653.                 sqlQueryObject.addInsertField("config_dimensionecache", "?");
  1654.                 sqlQueryObject.addInsertField("config_algoritmocache", "?");
  1655.                 sqlQueryObject.addInsertField("config_idlecache", "?");
  1656.                 sqlQueryObject.addInsertField("config_lifecache", "?");
  1657.                 // authz cache
  1658.                 sqlQueryObject.addInsertField("auth_statocache", "?");
  1659.                 sqlQueryObject.addInsertField("auth_dimensionecache", "?");
  1660.                 sqlQueryObject.addInsertField("auth_algoritmocache", "?");
  1661.                 sqlQueryObject.addInsertField("auth_idlecache", "?");
  1662.                 sqlQueryObject.addInsertField("auth_lifecache", "?");
  1663.                 // authn cache
  1664.                 sqlQueryObject.addInsertField("authn_statocache", "?");
  1665.                 sqlQueryObject.addInsertField("authn_dimensionecache", "?");
  1666.                 sqlQueryObject.addInsertField("authn_algoritmocache", "?");
  1667.                 sqlQueryObject.addInsertField("authn_idlecache", "?");
  1668.                 sqlQueryObject.addInsertField("authn_lifecache", "?");
  1669.                 // gestione token cache
  1670.                 sqlQueryObject.addInsertField("token_statocache", "?");
  1671.                 sqlQueryObject.addInsertField("token_dimensionecache", "?");
  1672.                 sqlQueryObject.addInsertField("token_algoritmocache", "?");
  1673.                 sqlQueryObject.addInsertField("token_idlecache", "?");
  1674.                 sqlQueryObject.addInsertField("token_lifecache", "?");
  1675.                 // gestione aa cache
  1676.                 sqlQueryObject.addInsertField("aa_statocache", "?");
  1677.                 sqlQueryObject.addInsertField("aa_dimensionecache", "?");
  1678.                 sqlQueryObject.addInsertField("aa_algoritmocache", "?");
  1679.                 sqlQueryObject.addInsertField("aa_idlecache", "?");
  1680.                 sqlQueryObject.addInsertField("aa_lifecache", "?");
  1681.                 // keystore cache
  1682.                 sqlQueryObject.addInsertField("keystore_statocache", "?");
  1683.                 sqlQueryObject.addInsertField("keystore_dimensionecache", "?");
  1684.                 sqlQueryObject.addInsertField("keystore_algoritmocache", "?");
  1685.                 sqlQueryObject.addInsertField("keystore_idlecache", "?");
  1686.                 sqlQueryObject.addInsertField("keystore_lifecache", "?");
  1687.                 sqlQueryObject.addInsertField("keystore_crl_lifecache", "?");
  1688.                 // multitenant
  1689.                 sqlQueryObject.addInsertField("multitenant_stato", "?");
  1690.                 sqlQueryObject.addInsertField("multitenant_fruizioni", "?");
  1691.                 sqlQueryObject.addInsertField("multitenant_erogazioni", "?");
  1692.                 // cors
  1693.                 sqlQueryObject.addInsertField("cors_stato", "?");
  1694.                 sqlQueryObject.addInsertField("cors_tipo", "?");
  1695.                 sqlQueryObject.addInsertField("cors_all_allow_origins", "?");
  1696.                 sqlQueryObject.addInsertField("cors_all_allow_methods", "?");
  1697.                 sqlQueryObject.addInsertField("cors_all_allow_headers", "?");
  1698.                 sqlQueryObject.addInsertField("cors_allow_credentials", "?");
  1699.                 sqlQueryObject.addInsertField("cors_allow_max_age", "?");
  1700.                 sqlQueryObject.addInsertField("cors_allow_max_age_seconds", "?");
  1701.                 sqlQueryObject.addInsertField("cors_allow_origins", "?");
  1702.                 sqlQueryObject.addInsertField("cors_allow_headers", "?");
  1703.                 sqlQueryObject.addInsertField("cors_allow_methods", "?");
  1704.                 sqlQueryObject.addInsertField("cors_allow_expose_headers", "?");
  1705.                 // responseCaching
  1706.                 sqlQueryObject.addInsertField("response_cache_stato", "?");
  1707.                 sqlQueryObject.addInsertField("response_cache_seconds", "?");
  1708.                 sqlQueryObject.addInsertField("response_cache_max_msg_size", "?");
  1709.                 sqlQueryObject.addInsertField("response_cache_control_nocache", "?");
  1710.                 sqlQueryObject.addInsertField("response_cache_control_maxage", "?");
  1711.                 sqlQueryObject.addInsertField("response_cache_control_nostore", "?");
  1712.                 sqlQueryObject.addInsertField("response_cache_hash_url", "?");
  1713.                 sqlQueryObject.addInsertField("response_cache_hash_query", "?");
  1714.                 sqlQueryObject.addInsertField("response_cache_hash_query_list", "?");
  1715.                 sqlQueryObject.addInsertField("response_cache_hash_headers", "?");
  1716.                 sqlQueryObject.addInsertField("response_cache_hash_hdr_list", "?");
  1717.                 sqlQueryObject.addInsertField("response_cache_hash_payload", "?");
  1718.                 // responseCaching cache
  1719.                 sqlQueryObject.addInsertField("response_cache_statocache", "?");
  1720.                 sqlQueryObject.addInsertField("response_cache_dimensionecache", "?");
  1721.                 sqlQueryObject.addInsertField("response_cache_algoritmocache", "?");
  1722.                 sqlQueryObject.addInsertField("response_cache_idlecache", "?");
  1723.                 sqlQueryObject.addInsertField("response_cache_lifecache", "?");
  1724.                 // consegna applicativi cache
  1725.                 sqlQueryObject.addInsertField("consegna_statocache", "?");
  1726.                 sqlQueryObject.addInsertField("consegna_dimensionecache", "?");
  1727.                 sqlQueryObject.addInsertField("consegna_algoritmocache", "?");
  1728.                 sqlQueryObject.addInsertField("consegna_idlecache", "?");
  1729.                 sqlQueryObject.addInsertField("consegna_lifecache", "?");
  1730.                 // canali
  1731.                 sqlQueryObject.addInsertField("canali_stato", "?");
  1732.                 // dati richieste cache
  1733.                 sqlQueryObject.addInsertField("dati_richieste_statocache", "?");
  1734.                 sqlQueryObject.addInsertField("dati_richieste_dimensionecache", "?");
  1735.                 sqlQueryObject.addInsertField("dati_richieste_algoritmocache", "?");
  1736.                 sqlQueryObject.addInsertField("dati_richieste_idlecache", "?");
  1737.                 sqlQueryObject.addInsertField("dati_richieste_lifecache", "?");

  1738.                 updateQuery = sqlQueryObject.createSQLInsert();
  1739.                 updateStmt = con.prepareStatement(updateQuery);

  1740.                 int index = 1;
  1741.                
  1742.                 updateStmt.setString(index++, cadenzaInoltro);
  1743.                 updateStmt.setString(index++, valStato);
  1744.                 updateStmt.setString(index++, valControllo);
  1745.                 updateStmt.setString(index++, msgDiagSeverita);
  1746.                 updateStmt.setString(index++, msgDiagSeveritaLog4j);
  1747.                 updateStmt.setString(index++, autenticazione);
  1748.                 updateStmt.setString(index++, valProfiloCollaborazione);
  1749.                 updateStmt.setString(index++, modRisposta);
  1750.                 updateStmt.setString(index++, utilizzoIndTelematico);
  1751.                 updateStmt.setString(index++, routingEnabled);
  1752.                 updateStmt.setString(index++, gestioneManifest);
  1753.                 updateStmt.setString(index++, valManifest);
  1754.                 updateStmt.setString(index++, tracciamentoBuste);
  1755.                 // tracciamento
  1756.                 updateStmt.setString(index++, tracciamentoEsitiPA);
  1757.                 updateStmt.setString(index++, tracciamentoEsitiPD);
  1758.                 updateStmt.setString(index++, transazioniTempiElaborazionePA);
  1759.                 updateStmt.setString(index++, transazioniTempiElaborazionePD);
  1760.                 updateStmt.setString(index++, transazioniTokenPA);
  1761.                 updateStmt.setString(index++, transazioniTokenPD);
  1762.                 // dump
  1763.                 updateStmt.setString(index++, dumpApplicativo);
  1764.                 updateStmt.setString(index++, dumpPD);
  1765.                 updateStmt.setString(index++, dumpPA);
  1766.                 // validazione
  1767.                 updateStmt.setString(index++, validazioneContenutiStato);
  1768.                 updateStmt.setString(index++, validazioneContenutiTipo);
  1769.                 updateStmt.setString(index++, validazioneContenutiAcceptMtomMessage);
  1770.                 // registro cache
  1771.                 updateStmt.setString(index++, registroStatoCache);
  1772.                 updateStmt.setString(index++, registroDimensioneCache);
  1773.                 updateStmt.setString(index++, registroAlgoritmoCache);
  1774.                 updateStmt.setString(index++, registroIdleCache);
  1775.                 updateStmt.setString(index++, registroLifeCache);
  1776.                 // config cache
  1777.                 updateStmt.setString(index++, configStatoCache);
  1778.                 updateStmt.setString(index++, configDimensioneCache);
  1779.                 updateStmt.setString(index++, configAlgoritmoCache);
  1780.                 updateStmt.setString(index++, configIdleCache);
  1781.                 updateStmt.setString(index++, configLifeCache);
  1782.                 // authz cache
  1783.                 updateStmt.setString(index++, authzStatoCache);
  1784.                 updateStmt.setString(index++, authzDimensioneCache);
  1785.                 updateStmt.setString(index++, authzAlgoritmoCache);
  1786.                 updateStmt.setString(index++, authzIdleCache);
  1787.                 updateStmt.setString(index++, authzLifeCache);
  1788.                 // authn cache
  1789.                 updateStmt.setString(index++, authnStatoCache);
  1790.                 updateStmt.setString(index++, authnDimensioneCache);
  1791.                 updateStmt.setString(index++, authnAlgoritmoCache);
  1792.                 updateStmt.setString(index++, authnIdleCache);
  1793.                 updateStmt.setString(index++, authnLifeCache);
  1794.                 // token cache
  1795.                 updateStmt.setString(index++, tokenStatoCache);
  1796.                 updateStmt.setString(index++, tokenDimensioneCache);
  1797.                 updateStmt.setString(index++, tokenAlgoritmoCache);
  1798.                 updateStmt.setString(index++, tokenIdleCache);
  1799.                 updateStmt.setString(index++, tokenLifeCache);
  1800.                 // aa cache
  1801.                 updateStmt.setString(index++, aaStatoCache);
  1802.                 updateStmt.setString(index++, aaDimensioneCache);
  1803.                 updateStmt.setString(index++, aaAlgoritmoCache);
  1804.                 updateStmt.setString(index++, aaIdleCache);
  1805.                 updateStmt.setString(index++, aaLifeCache);
  1806.                 // keystore cache
  1807.                 updateStmt.setString(index++, keystoreStatoCache);
  1808.                 updateStmt.setString(index++, keystoreDimensioneCache);
  1809.                 updateStmt.setString(index++, keystoreAlgoritmoCache);
  1810.                 updateStmt.setString(index++, keystoreIdleCache);
  1811.                 updateStmt.setString(index++, keystoreLifeCache);
  1812.                 updateStmt.setString(index++, keystoreCrlLifeCache);
  1813.                 // multitenant
  1814.                 updateStmt.setString(index++, multitenant!=null ? DriverConfigurazioneDBLib.getValue(multitenant.getStato()) : null);
  1815.                 updateStmt.setString(index++, multitenant!=null ? DriverConfigurazioneDBLib.getValue(multitenant.getFruizioneSceltaSoggettiErogatori()) : null);
  1816.                 updateStmt.setString(index++, multitenant!=null ? DriverConfigurazioneDBLib.getValue(multitenant.getErogazioneSceltaSoggettiFruitori()) : null);
  1817.                 // cors
  1818.                 updateStmt.setString(index++, corsStato);
  1819.                 updateStmt.setString(index++, corsTipo);
  1820.                 updateStmt.setString(index++, corsAllAllowOrigins);
  1821.                 updateStmt.setString(index++, corsAllAllowMethods);
  1822.                 updateStmt.setString(index++, corsAllAllowHeaders);
  1823.                 updateStmt.setString(index++, corsAllowCredentials);
  1824.                 updateStmt.setInt(index++, corsAllowMaxAge);
  1825.                 if(corsAllowMaxAgeSeconds!=null) {
  1826.                     updateStmt.setInt(index++, corsAllowMaxAgeSeconds);
  1827.                 }
  1828.                 else {
  1829.                     updateStmt.setNull(index++, java.sql.Types.INTEGER);
  1830.                 }
  1831.                 updateStmt.setString(index++, corsAllowOrigins);
  1832.                 updateStmt.setString(index++, corsAllowHeaders);
  1833.                 updateStmt.setString(index++, corsAllowMethods);
  1834.                 updateStmt.setString(index++, corsAllowExposeHeaders);              
  1835.                 // responseCaching
  1836.                 updateStmt.setString(index++, responseCacheStato);
  1837.                 if(responseCacheSeconds!=null) {
  1838.                     updateStmt.setInt(index++, responseCacheSeconds);
  1839.                 }
  1840.                 else {
  1841.                     updateStmt.setNull(index++, java.sql.Types.INTEGER);
  1842.                 }
  1843.                 if(responseCacheMaxMsgSize!=null) {
  1844.                     updateStmt.setLong(index++, responseCacheMaxMsgSize);
  1845.                 }
  1846.                 else {
  1847.                     updateStmt.setNull(index++, java.sql.Types.BIGINT);
  1848.                 }
  1849.                 updateStmt.setInt(index++, responseCacheNoCache ? CostantiDB.TRUE : CostantiDB.FALSE);
  1850.                 updateStmt.setInt(index++, responseCacheMaxAge ? CostantiDB.TRUE : CostantiDB.FALSE);
  1851.                 updateStmt.setInt(index++, responseCacheNoStore ? CostantiDB.TRUE : CostantiDB.FALSE);
  1852.                 updateStmt.setString(index++, responseCacheHashUrl);
  1853.                 updateStmt.setString(index++, responseCacheHashQuery);
  1854.                 updateStmt.setString(index++, responseCacheHashQueryList);
  1855.                 updateStmt.setString(index++, responseCacheHashHeaders);
  1856.                 updateStmt.setString(index++, responseCacheHashHeadersList);
  1857.                 updateStmt.setString(index++, responseCacheHashPayload);
  1858.                 // responseCaching cache
  1859.                 updateStmt.setString(index++, responseCachingStatoCache);
  1860.                 updateStmt.setString(index++, responseCachingDimensioneCache);
  1861.                 updateStmt.setString(index++, responseCachingAlgoritmoCache);
  1862.                 updateStmt.setString(index++, responseCachingIdleCache);
  1863.                 updateStmt.setString(index++, responseCachingLifeCache);
  1864.                 // consegna applicativi cache
  1865.                 updateStmt.setString(index++, consegnaStatoCache);
  1866.                 updateStmt.setString(index++, consegnaDimensioneCache);
  1867.                 updateStmt.setString(index++, consegnaAlgoritmoCache);
  1868.                 updateStmt.setString(index++, consegnaIdleCache);
  1869.                 updateStmt.setString(index++, consegnaLifeCache);
  1870.                 // canali
  1871.                 updateStmt.setString(index++, configurazioneCanaliStato);
  1872.                 // dati richieste cache
  1873.                 updateStmt.setString(index++, datiRichiesteStatoCache);
  1874.                 updateStmt.setString(index++, datiRichiesteDimensioneCache);
  1875.                 updateStmt.setString(index++, datiRichiesteAlgoritmoCache);
  1876.                 updateStmt.setString(index++, datiRichiesteIdleCache);
  1877.                 updateStmt.setString(index++, datiRichiesteLifeCache);

  1878.                 String msgDebug = "eseguo query :" +
  1879.                         DBUtils.formatSQLString(updateQuery,
  1880.                                 cadenzaInoltro,
  1881.                                 valStato, valControllo,
  1882.                                 msgDiagSeverita, msgDiagSeveritaLog4j,
  1883.                                 autenticazione,
  1884.                                 valProfiloCollaborazione,
  1885.                                 modRisposta, utilizzoIndTelematico,
  1886.                                 routingEnabled, gestioneManifest,
  1887.                                 valManifest,
  1888.                                 tracciamentoBuste,
  1889.                                 tracciamentoEsitiPA, tracciamentoEsitiPD,
  1890.                                 transazioniTempiElaborazionePA, transazioniTempiElaborazionePD,
  1891.                                 transazioniTokenPA, transazioniTokenPD,
  1892.                                 dumpApplicativo, dumpPD, dumpPA,
  1893.                                 validazioneContenutiStato,validazioneContenutiTipo,validazioneContenutiAcceptMtomMessage,
  1894.                                 registroStatoCache, registroDimensioneCache, registroAlgoritmoCache, registroIdleCache, registroLifeCache,
  1895.                                 configStatoCache, configDimensioneCache, configAlgoritmoCache, configIdleCache, configLifeCache,
  1896.                                 authzStatoCache, authzDimensioneCache, authzAlgoritmoCache, authzIdleCache, authzLifeCache,
  1897.                                 authnStatoCache, authnDimensioneCache, authnAlgoritmoCache, authnIdleCache, authnLifeCache,
  1898.                                 tokenStatoCache, tokenDimensioneCache, tokenAlgoritmoCache, tokenIdleCache, tokenLifeCache,
  1899.                                 aaStatoCache, aaDimensioneCache, aaAlgoritmoCache, aaIdleCache, aaLifeCache,
  1900.                                 keystoreStatoCache, keystoreDimensioneCache, keystoreAlgoritmoCache, keystoreIdleCache, keystoreLifeCache, keystoreCrlLifeCache,
  1901.                                 (multitenant!=null ? DriverConfigurazioneDBLib.getValue(multitenant.getStato()) : null),
  1902.                                 (multitenant!=null ? DriverConfigurazioneDBLib.getValue(multitenant.getFruizioneSceltaSoggettiErogatori()) : null),
  1903.                                 (multitenant!=null ? DriverConfigurazioneDBLib.getValue(multitenant.getErogazioneSceltaSoggettiFruitori()) : null),
  1904.                                 corsStato, corsTipo, corsAllAllowOrigins, corsAllAllowMethods, corsAllAllowHeaders, corsAllowCredentials, corsAllowMaxAge, corsAllowMaxAgeSeconds,
  1905.                                 corsAllowOrigins, corsAllowHeaders, corsAllowMethods, corsAllowExposeHeaders,
  1906.                                 responseCacheStato, responseCacheSeconds, responseCacheMaxMsgSize,
  1907.                                 (responseCacheNoCache ? CostantiDB.TRUE : CostantiDB.FALSE),
  1908.                                 (responseCacheMaxAge ? CostantiDB.TRUE : CostantiDB.FALSE),
  1909.                                 (responseCacheNoStore ? CostantiDB.TRUE : CostantiDB.FALSE),
  1910.                                 responseCacheHashUrl, responseCacheHashQuery, responseCacheHashQueryList, responseCacheHashHeaders, responseCacheHashHeadersList, responseCacheHashPayload,
  1911.                                 responseCachingStatoCache, responseCachingDimensioneCache, responseCachingAlgoritmoCache, responseCachingIdleCache, responseCachingLifeCache,
  1912.                                 consegnaStatoCache, consegnaDimensioneCache, consegnaAlgoritmoCache, consegnaIdleCache, consegnaLifeCache,
  1913.                                 configurazioneCanaliStato,
  1914.                                 datiRichiesteStatoCache, datiRichiesteDimensioneCache, datiRichiesteAlgoritmoCache, datiRichiesteIdleCache, datiRichiesteLifeCache
  1915.                                 );
  1916.                 DriverConfigurazioneDBLib.logDebug(msgDebug);

  1917.                 n = updateStmt.executeUpdate();
  1918.                 updateStmt.close();

  1919.                 // delete from config_url_invocazione
  1920.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  1921.                 sqlQueryObject.addDeleteTable(CostantiDB.CONFIG_URL_REGOLE);
  1922.                 updateQuery = sqlQueryObject.createSQLDelete();
  1923.                 updateStmt = con.prepareStatement(updateQuery);
  1924.                 updateStmt.executeUpdate();
  1925.                 updateStmt.close();
  1926.                
  1927.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  1928.                 sqlQueryObject.addDeleteTable(CostantiDB.CONFIG_URL_INVOCAZIONE);
  1929.                 updateQuery = sqlQueryObject.createSQLDelete();
  1930.                 updateStmt = con.prepareStatement(updateQuery);
  1931.                 updateStmt.executeUpdate();
  1932.                 updateStmt.close();
  1933.                
  1934.                 // insert into config_protocolli
  1935.                 if(config.getUrlInvocazione()!=null){
  1936.                    
  1937.                     sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  1938.                     sqlQueryObject.addInsertTable(CostantiDB.CONFIG_URL_INVOCAZIONE);
  1939.                     sqlQueryObject.addInsertField("base_url", "?");
  1940.                     sqlQueryObject.addInsertField("base_url_fruizione", "?");
  1941.                     updateQuery = sqlQueryObject.createSQLInsert();
  1942.                     updateStmt = con.prepareStatement(updateQuery);
  1943.                     int indexP = 1;
  1944.                     updateStmt.setString(indexP++, config.getUrlInvocazione().getBaseUrl());
  1945.                     updateStmt.setString(indexP++, config.getUrlInvocazione().getBaseUrlFruizione());
  1946.                     updateStmt.executeUpdate();
  1947.                     updateStmt.close();
  1948.                    
  1949.                     if(config.getUrlInvocazione().sizeRegolaList()>0){
  1950.                         for(int k=0; k<config.getUrlInvocazione().sizeRegolaList();k++){
  1951.                             ConfigurazioneUrlInvocazioneRegola configUrlInvocazioneRegola = config.getUrlInvocazione().getRegola(k);
  1952.                             createUrlInvocazioneRegolaEngine(configUrlInvocazioneRegola, con);
  1953.                         }
  1954.                     }
  1955.                 }
  1956.                
  1957.                 // delete from msg diag appender
  1958.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  1959.                 sqlQueryObject.addDeleteTable(CostantiDB.MSG_DIAGN_APPENDER_PROP);
  1960.                 updateQuery = sqlQueryObject.createSQLDelete();
  1961.                 updateStmt = con.prepareStatement(updateQuery);
  1962.                 updateStmt.executeUpdate();
  1963.                 updateStmt.close();

  1964.                 // delete from msg diag appender
  1965.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  1966.                 sqlQueryObject.addDeleteTable(CostantiDB.MSG_DIAGN_APPENDER);
  1967.                 updateQuery = sqlQueryObject.createSQLDelete();
  1968.                 updateStmt = con.prepareStatement(updateQuery);
  1969.                 updateStmt.executeUpdate();
  1970.                 updateStmt.close();

  1971.                 // insert into msg diag appender
  1972.                 if(config.getMessaggiDiagnostici()!=null){
  1973.                     for(int k=0; k<config.getMessaggiDiagnostici().sizeOpenspcoopAppenderList();k++){
  1974.                         OpenspcoopAppender appender = config.getMessaggiDiagnostici().getOpenspcoopAppender(k);
  1975.                        
  1976.                         List<InsertAndGeneratedKeyObject> listInsertAndGeneratedKeyObject = new ArrayList<>();
  1977.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("tipo", appender.getTipo() , InsertAndGeneratedKeyJDBCType.STRING) );
  1978.                        
  1979.                         long idMsgDiagAppender = InsertAndGeneratedKey.insertAndReturnGeneratedKey(con, TipiDatabase.toEnumConstant(DriverConfigurazioneDBLib.tipoDB),
  1980.                                 new CustomKeyGeneratorObject(CostantiDB.MSG_DIAGN_APPENDER, CostantiDB.MSG_DIAGN_APPENDER_COLUMN_ID,
  1981.                                         CostantiDB.MSG_DIAGN_APPENDER_SEQUENCE, CostantiDB.MSG_DIAGN_APPENDER_TABLE_FOR_ID),
  1982.                                 listInsertAndGeneratedKeyObject.toArray(new InsertAndGeneratedKeyObject[1]));
  1983.                         if(idMsgDiagAppender<=0){
  1984.                             throw new DriverConfigurazioneException("ID (msg diag appender) autoincrementale non ottenuto");
  1985.                         }
  1986.                        
  1987.                         for(int l=0; l<appender.sizePropertyList();l++){
  1988.                             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  1989.                             sqlQueryObject.addInsertTable(CostantiDB.MSG_DIAGN_APPENDER_PROP);
  1990.                             sqlQueryObject.addInsertField("id_appender", "?");
  1991.                             sqlQueryObject.addInsertField("nome", "?");
  1992.                             sqlQueryObject.addInsertField("valore", "?");
  1993.                             updateQuery = sqlQueryObject.createSQLInsert();
  1994.                             updateStmt = con.prepareStatement(updateQuery);
  1995.                             updateStmt.setLong(1, idMsgDiagAppender);
  1996.                             updateStmt.setString(2, appender.getProperty(l).getNome());
  1997.                             updateStmt.setString(3, appender.getProperty(l).getValore());
  1998.                             updateStmt.executeUpdate();
  1999.                             updateStmt.close();
  2000.                         }

  2001.                     }
  2002.                 }

  2003.                 // delete from tracciamento appender
  2004.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2005.                 sqlQueryObject.addDeleteTable(CostantiDB.TRACCIAMENTO_APPENDER_PROP);
  2006.                 updateQuery = sqlQueryObject.createSQLDelete();
  2007.                 updateStmt = con.prepareStatement(updateQuery);
  2008.                 updateStmt.executeUpdate();
  2009.                 updateStmt.close();

  2010.                 // delete from tracciamento appender
  2011.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2012.                 sqlQueryObject.addDeleteTable(CostantiDB.TRACCIAMENTO_APPENDER);
  2013.                 updateQuery = sqlQueryObject.createSQLDelete();
  2014.                 updateStmt = con.prepareStatement(updateQuery);
  2015.                 updateStmt.executeUpdate();
  2016.                 updateStmt.close();

  2017.                 // insert into tracciamento appender
  2018.                 if(config.getTracciamento()!=null){
  2019.                     for(int k=0; k<config.getTracciamento().sizeOpenspcoopAppenderList();k++){
  2020.                         OpenspcoopAppender appender = config.getTracciamento().getOpenspcoopAppender(k);
  2021.                        
  2022.                         List<InsertAndGeneratedKeyObject> listInsertAndGeneratedKeyObject = new ArrayList<>();
  2023.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("tipo", appender.getTipo() , InsertAndGeneratedKeyJDBCType.STRING) );
  2024.                        
  2025.                         long idTracceAppender = InsertAndGeneratedKey.insertAndReturnGeneratedKey(con, TipiDatabase.toEnumConstant(DriverConfigurazioneDBLib.tipoDB),
  2026.                                 new CustomKeyGeneratorObject(CostantiDB.TRACCIAMENTO_APPENDER, CostantiDB.TRACCIAMENTO_APPENDER_COLUMN_ID,
  2027.                                         CostantiDB.TRACCIAMENTO_APPENDER_SEQUENCE, CostantiDB.TRACCIAMENTO_APPENDER_TABLE_FOR_ID),
  2028.                                 listInsertAndGeneratedKeyObject.toArray(new InsertAndGeneratedKeyObject[1]));
  2029.                         if(idTracceAppender<=0){
  2030.                             throw new DriverConfigurazioneException("ID (tracce appender) autoincrementale non ottenuto");
  2031.                         }

  2032.                         for(int l=0; l<appender.sizePropertyList();l++){
  2033.                             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2034.                             sqlQueryObject.addInsertTable(CostantiDB.TRACCIAMENTO_APPENDER_PROP);
  2035.                             sqlQueryObject.addInsertField("id_appender", "?");
  2036.                             sqlQueryObject.addInsertField("nome", "?");
  2037.                             sqlQueryObject.addInsertField("valore", "?");
  2038.                             updateQuery = sqlQueryObject.createSQLInsert();
  2039.                             updateStmt = con.prepareStatement(updateQuery);
  2040.                             updateStmt.setLong(1, idTracceAppender);
  2041.                             updateStmt.setString(2, appender.getProperty(l).getNome());
  2042.                             updateStmt.setString(3, appender.getProperty(l).getValore());
  2043.                             updateStmt.executeUpdate();
  2044.                             updateStmt.close();
  2045.                         }

  2046.                     }
  2047.                 }
  2048.                
  2049.                
  2050.                 // tracciamentoConfigurazione
  2051.                
  2052.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazione(type, con, tracciamentoConfigurazioneDatabasePA, null,
  2053.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA,
  2054.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_DB);
  2055.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazione(type, con, tracciamentoConfigurazioneDatabasePD, null,
  2056.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD,
  2057.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_DB);
  2058.                
  2059.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazione(type, con, tracciamentoConfigurazioneFiletracePA, null,
  2060.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA,
  2061.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_FILETRACE);
  2062.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazione(type, con, tracciamentoConfigurazioneFiletracePD, null,
  2063.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD,
  2064.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_FILETRACE);
  2065.                
  2066.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazioneFiletrace(type, con, tracciamentoConfigurazioneFiletraceDetailsPA, null,
  2067.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA);
  2068.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazioneFiletrace(type, con, tracciamentoConfigurazioneFiletraceDetailsPD, null,
  2069.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD);
  2070.                
  2071.                
  2072.                
  2073.                
  2074.                
  2075.                 // delete from dump appender_prop
  2076.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2077.                 sqlQueryObject.addDeleteTable(CostantiDB.DUMP_APPENDER_PROP);
  2078.                 updateQuery = sqlQueryObject.createSQLDelete();
  2079.                 updateStmt = con.prepareStatement(updateQuery);
  2080.                 updateStmt.executeUpdate();
  2081.                 updateStmt.close();

  2082.                 // delete from dump appender
  2083.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2084.                 sqlQueryObject.addDeleteTable(CostantiDB.DUMP_APPENDER);
  2085.                 updateQuery = sqlQueryObject.createSQLDelete();
  2086.                 updateStmt = con.prepareStatement(updateQuery);
  2087.                 updateStmt.executeUpdate();
  2088.                 updateStmt.close();

  2089.                 // insert into dump appender
  2090.                 if(config.getDump()!=null){
  2091.                     for(int k=0; k<config.getDump().sizeOpenspcoopAppenderList();k++){
  2092.                         OpenspcoopAppender appender = config.getDump().getOpenspcoopAppender(k);
  2093.                        
  2094.                         List<InsertAndGeneratedKeyObject> listInsertAndGeneratedKeyObject = new ArrayList<>();
  2095.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("tipo", appender.getTipo() , InsertAndGeneratedKeyJDBCType.STRING) );
  2096.                        
  2097.                         long idDumpAppender = InsertAndGeneratedKey.insertAndReturnGeneratedKey(con, TipiDatabase.toEnumConstant(DriverConfigurazioneDBLib.tipoDB),
  2098.                                 new CustomKeyGeneratorObject(CostantiDB.DUMP_APPENDER, CostantiDB.DUMP_APPENDER_COLUMN_ID,
  2099.                                         CostantiDB.DUMP_APPENDER_SEQUENCE, CostantiDB.DUMP_APPENDER_TABLE_FOR_ID),
  2100.                                 listInsertAndGeneratedKeyObject.toArray(new InsertAndGeneratedKeyObject[1]));
  2101.                         if(idDumpAppender<=0){
  2102.                             throw new DriverConfigurazioneException("ID (dump appender) autoincrementale non ottenuto");
  2103.                         }

  2104.                         for(int l=0; l<appender.sizePropertyList();l++){
  2105.                             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2106.                             sqlQueryObject.addInsertTable(CostantiDB.DUMP_APPENDER_PROP);
  2107.                             sqlQueryObject.addInsertField("id_appender", "?");
  2108.                             sqlQueryObject.addInsertField("nome", "?");
  2109.                             sqlQueryObject.addInsertField("valore", "?");
  2110.                             updateQuery = sqlQueryObject.createSQLInsert();
  2111.                             updateStmt = con.prepareStatement(updateQuery);
  2112.                             updateStmt.setLong(1, idDumpAppender);
  2113.                             updateStmt.setString(2, appender.getProperty(l).getNome());
  2114.                             updateStmt.setString(3, appender.getProperty(l).getValore());
  2115.                             updateStmt.executeUpdate();
  2116.                             updateStmt.close();
  2117.                         }

  2118.                     }
  2119.                 }
  2120.                
  2121.                                
  2122.                 // Cache Regole
  2123.                 n=0;
  2124.                 if(responseCacheRegole!=null && !responseCacheRegole.isEmpty()){
  2125.                     for (int j = 0; j < responseCacheRegole.size(); j++) {
  2126.                         ResponseCachingConfigurazioneRegola regola = responseCacheRegole.get(j);
  2127.                         sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2128.                         sqlQueryObject.addInsertTable(CostantiDB.CONFIGURAZIONE_CACHE_REGOLE);
  2129.                         if(regola.getReturnCodeMin()!=null && regola.getReturnCodeMin()>0) {
  2130.                             sqlQueryObject.addInsertField("status_min", "?");
  2131.                         }
  2132.                         if(regola.getReturnCodeMax()!=null && regola.getReturnCodeMax()>0) {
  2133.                             sqlQueryObject.addInsertField("status_max", "?");
  2134.                         }
  2135.                         sqlQueryObject.addInsertField("fault", "?");
  2136.                         if(regola.getCacheTimeoutSeconds()!=null && regola.getCacheTimeoutSeconds()>0) {
  2137.                             sqlQueryObject.addInsertField("cache_seconds", "?");
  2138.                         }
  2139.                         String sqlQuery = sqlQueryObject.createSQLInsert();
  2140.                         updateStmt = con.prepareStatement(sqlQuery);
  2141.                         int indexCR = 1;
  2142.                         if(regola.getReturnCodeMin()!=null && regola.getReturnCodeMin()>0) {
  2143.                             updateStmt.setInt(indexCR++, regola.getReturnCodeMin());
  2144.                         }
  2145.                         if(regola.getReturnCodeMax()!=null && regola.getReturnCodeMax()>0) {
  2146.                             updateStmt.setInt(indexCR++, regola.getReturnCodeMax());
  2147.                         }
  2148.                         updateStmt.setInt(indexCR++, regola.getFault() ? CostantiDB.TRUE : CostantiDB.FALSE);
  2149.                         if(regola.getCacheTimeoutSeconds()!=null && regola.getCacheTimeoutSeconds()>0) {
  2150.                             updateStmt.setInt(indexCR++, regola.getCacheTimeoutSeconds());
  2151.                         }
  2152.                         updateStmt.executeUpdate();
  2153.                         updateStmt.close();
  2154.                         n++;
  2155.                         DriverConfigurazioneDBLib.logDebug("Aggiunta regola di cache");
  2156.                     }
  2157.                 }
  2158.                
  2159.                 DriverConfigurazioneDBLib.logDebug("Aggiunte " + n + " regole di cache");
  2160.                
  2161.                 // dumpConfigurazione
  2162.                
  2163.                 // per backward compatibility elimino una config esistente
  2164.                 DumpConfigurazione dumpConfigOldBackwardCompatibility = DriverConfigurazioneDB_dumpLIB.readDumpConfigurazione(con, null, CostantiDB.OLD_BACKWARD_COMPATIBILITY_DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG);
  2165.                 if(dumpConfigOldBackwardCompatibility!=null) {
  2166.                     DriverConfigurazioneDB_dumpLIB.CRUDDumpConfigurazione(DELETE, con, dumpConfigOldBackwardCompatibility, null, CostantiDB.OLD_BACKWARD_COMPATIBILITY_DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG);
  2167.                 }
  2168.                
  2169.                 DriverConfigurazioneDB_dumpLIB.CRUDDumpConfigurazione(type, con, dumpConfigPA, null, CostantiDB.DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA);
  2170.                 DriverConfigurazioneDB_dumpLIB.CRUDDumpConfigurazione(type, con, dumpConfigPD, null, CostantiDB.DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD);
  2171.                

  2172.                 // delete from msgdiag ds prop
  2173.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2174.                 sqlQueryObject.addDeleteTable(CostantiDB.MSG_DIAGN_DS_PROP);
  2175.                 updateQuery = sqlQueryObject.createSQLDelete();
  2176.                 updateStmt = con.prepareStatement(updateQuery);
  2177.                 updateStmt.executeUpdate();
  2178.                 updateStmt.close();

  2179.                 // delete from msgdiag ds
  2180.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2181.                 sqlQueryObject.addDeleteTable(CostantiDB.MSG_DIAGN_DS);
  2182.                 updateQuery = sqlQueryObject.createSQLDelete();
  2183.                 updateStmt = con.prepareStatement(updateQuery);
  2184.                 updateStmt.executeUpdate();
  2185.                 updateStmt.close();

  2186.                 // insert into msgdiag ds
  2187.                 if(config.getMessaggiDiagnostici()!=null){
  2188.                     for(int k=0; k<config.getMessaggiDiagnostici().sizeOpenspcoopSorgenteDatiList();k++){
  2189.                         OpenspcoopSorgenteDati ds = config.getMessaggiDiagnostici().getOpenspcoopSorgenteDati(k);
  2190.                        
  2191.                         List<InsertAndGeneratedKeyObject> listInsertAndGeneratedKeyObject = new ArrayList<>();
  2192.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("nome", ds.getNome() , InsertAndGeneratedKeyJDBCType.STRING) );
  2193.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("nome_jndi", ds.getNomeJndi() , InsertAndGeneratedKeyJDBCType.STRING) );
  2194.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("tipo_database", ds.getTipoDatabase() , InsertAndGeneratedKeyJDBCType.STRING) );
  2195.                        
  2196.                         long idMsgDsAppender = InsertAndGeneratedKey.insertAndReturnGeneratedKey(con, TipiDatabase.toEnumConstant(DriverConfigurazioneDBLib.tipoDB),
  2197.                                 new CustomKeyGeneratorObject(CostantiDB.MSG_DIAGN_DS, CostantiDB.MSG_DIAGN_DS_COLUMN_ID,
  2198.                                         CostantiDB.MSG_DIAGN_DS_SEQUENCE, CostantiDB.MSG_DIAGN_DS_TABLE_FOR_ID),
  2199.                                 listInsertAndGeneratedKeyObject.toArray(new InsertAndGeneratedKeyObject[1]));
  2200.                         if(idMsgDsAppender<=0){
  2201.                             throw new DriverConfigurazioneException("ID (msgdiag ds appender) autoincrementale non ottenuto");
  2202.                         }

  2203.                         for(int l=0; l<ds.sizePropertyList();l++){
  2204.                             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2205.                             sqlQueryObject.addInsertTable(CostantiDB.MSG_DIAGN_DS_PROP);
  2206.                             sqlQueryObject.addInsertField("id_prop", "?");
  2207.                             sqlQueryObject.addInsertField("nome", "?");
  2208.                             sqlQueryObject.addInsertField("valore", "?");
  2209.                             updateQuery = sqlQueryObject.createSQLInsert();
  2210.                             updateStmt = con.prepareStatement(updateQuery);
  2211.                             updateStmt.setLong(1, idMsgDsAppender);
  2212.                             updateStmt.setString(2, ds.getProperty(l).getNome());
  2213.                             updateStmt.setString(3, ds.getProperty(l).getValore());
  2214.                             updateStmt.executeUpdate();
  2215.                             updateStmt.close();
  2216.                         }

  2217.                     }
  2218.                 }

  2219.                 // delete from tracce ds prop
  2220.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2221.                 sqlQueryObject.addDeleteTable(CostantiDB.TRACCIAMENTO_DS_PROP);
  2222.                 updateQuery = sqlQueryObject.createSQLDelete();
  2223.                 updateStmt = con.prepareStatement(updateQuery);
  2224.                 updateStmt.executeUpdate();
  2225.                 updateStmt.close();

  2226.                 // delete from tracce ds
  2227.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2228.                 sqlQueryObject.addDeleteTable(CostantiDB.TRACCIAMENTO_DS);
  2229.                 updateQuery = sqlQueryObject.createSQLDelete();
  2230.                 updateStmt = con.prepareStatement(updateQuery);
  2231.                 updateStmt.executeUpdate();
  2232.                 updateStmt.close();

  2233.                 // insert into tracce ds
  2234.                 if(config.getTracciamento()!=null){
  2235.                     for(int k=0; k<config.getTracciamento().sizeOpenspcoopSorgenteDatiList();k++){
  2236.                         OpenspcoopSorgenteDati ds = config.getTracciamento().getOpenspcoopSorgenteDati(k);
  2237.                        
  2238.                         List<InsertAndGeneratedKeyObject> listInsertAndGeneratedKeyObject = new ArrayList<>();
  2239.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("nome", ds.getNome() , InsertAndGeneratedKeyJDBCType.STRING) );
  2240.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("nome_jndi", ds.getNomeJndi() , InsertAndGeneratedKeyJDBCType.STRING) );
  2241.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("tipo_database", ds.getTipoDatabase() , InsertAndGeneratedKeyJDBCType.STRING) );
  2242.                        
  2243.                         long idTracceDsAppender = InsertAndGeneratedKey.insertAndReturnGeneratedKey(con, TipiDatabase.toEnumConstant(DriverConfigurazioneDBLib.tipoDB),
  2244.                                 new CustomKeyGeneratorObject(CostantiDB.TRACCIAMENTO_DS, CostantiDB.TRACCIAMENTO_DS_COLUMN_ID,
  2245.                                         CostantiDB.TRACCIAMENTO_DS_SEQUENCE, CostantiDB.TRACCIAMENTO_DS_TABLE_FOR_ID),
  2246.                                 listInsertAndGeneratedKeyObject.toArray(new InsertAndGeneratedKeyObject[1]));
  2247.                         if(idTracceDsAppender<=0){
  2248.                             throw new DriverConfigurazioneException("ID (tracciamento ds appender) autoincrementale non ottenuto");
  2249.                         }

  2250.                         for(int l=0; l<ds.sizePropertyList();l++){
  2251.                             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2252.                             sqlQueryObject.addInsertTable(CostantiDB.TRACCIAMENTO_DS_PROP);
  2253.                             sqlQueryObject.addInsertField("id_prop", "?");
  2254.                             sqlQueryObject.addInsertField("nome", "?");
  2255.                             sqlQueryObject.addInsertField("valore", "?");
  2256.                             updateQuery = sqlQueryObject.createSQLInsert();
  2257.                             updateStmt = con.prepareStatement(updateQuery);
  2258.                             updateStmt.setLong(1, idTracceDsAppender);
  2259.                             updateStmt.setString(2, ds.getProperty(l).getNome());
  2260.                             updateStmt.setString(3, ds.getProperty(l).getValore());
  2261.                             updateStmt.executeUpdate();
  2262.                             updateStmt.close();
  2263.                         }

  2264.                     }
  2265.                 }
  2266.                
  2267.                 // canali
  2268.                 if(configurazioneCanali!=null) {
  2269.                     DriverConfigurazioneDB_canaliLIB.CRUDCanaliConfigurazione(type, con, configurazioneCanali);
  2270.                 }
  2271.                
  2272.                 // handlers
  2273.                 if(configHandlers!=null) {
  2274.                     if(configHandlers.getRequest()!=null) {
  2275.                         DriverConfigurazioneDB_handlerLIB.CRUDConfigurazioneMessageHandlers(type, con, null, null, true, configHandlers.getRequest());
  2276.                     }
  2277.                     if(configHandlers.getResponse()!=null) {
  2278.                         DriverConfigurazioneDB_handlerLIB.CRUDConfigurazioneMessageHandlers(type, con, null, null, false, configHandlers.getResponse());
  2279.                     }
  2280.                     if(configHandlers.getService()!=null) {
  2281.                         DriverConfigurazioneDB_handlerLIB.CRUDConfigurazioneServiceHandlers(type, con, null, null, false, configHandlers.getService());
  2282.                     }
  2283.                 }
  2284.                
  2285.                 // ExtendedInfo
  2286.                 if(extInfoConfigurazioneDriver!=null &&        
  2287.                     config.sizeExtendedInfoList()>0){
  2288.                     for(int l=0; l<config.sizeExtendedInfoList();l++){
  2289.                         extInfoConfigurazioneDriver.deleteExtendedInfo(con, DriverConfigurazioneDBLib.log,  config, config.getExtendedInfo(l), CRUDType.CREATE);
  2290.                         extInfoConfigurazioneDriver.createExtendedInfo(con, DriverConfigurazioneDBLib.log,  config, config.getExtendedInfo(l), CRUDType.CREATE);
  2291.                     }
  2292.                 }


  2293.                 break;
  2294.             case UPDATE:
  2295.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2296.                 sqlQueryObject.addUpdateTable(CostantiDB.CONFIGURAZIONE);
  2297.                 sqlQueryObject.addUpdateField("cadenza_inoltro", "?");
  2298.                 sqlQueryObject.addUpdateField("validazione_stato", "?");
  2299.                 sqlQueryObject.addUpdateField("validazione_controllo", "?");
  2300.                 sqlQueryObject.addUpdateField("msg_diag_severita", "?");
  2301.                 sqlQueryObject.addUpdateField("msg_diag_severita_log4j", "?");
  2302.                 sqlQueryObject.addUpdateField("auth_integration_manager", "?");
  2303.                 sqlQueryObject.addUpdateField("validazione_profilo", "?");
  2304.                 sqlQueryObject.addUpdateField("mod_risposta", "?");
  2305.                 sqlQueryObject.addUpdateField("indirizzo_telematico", "?");
  2306.                 sqlQueryObject.addUpdateField("routing_enabled", "?");
  2307.                 sqlQueryObject.addUpdateField("gestione_manifest", "?");
  2308.                 sqlQueryObject.addUpdateField("validazione_manifest", "?");
  2309.                 sqlQueryObject.addUpdateField("tracciamento_buste", "?");
  2310.                 // tracciamento
  2311.                 sqlQueryObject.addUpdateField("tracciamento_esiti", "?");
  2312.                 sqlQueryObject.addUpdateField("tracciamento_esiti_pd", "?");
  2313.                 sqlQueryObject.addUpdateField("transazioni_tempi", "?");
  2314.                 sqlQueryObject.addUpdateField("transazioni_tempi_pd", "?");
  2315.                 sqlQueryObject.addUpdateField("transazioni_token", "?");
  2316.                 sqlQueryObject.addUpdateField("transazioni_token_pd", "?");
  2317.                 // dump
  2318.                 sqlQueryObject.addUpdateField("dump", "?");
  2319.                 sqlQueryObject.addUpdateField("dump_bin_pd", "?");
  2320.                 sqlQueryObject.addUpdateField("dump_bin_pa", "?");
  2321.                 // validazione
  2322.                 sqlQueryObject.addUpdateField("validazione_contenuti_stato", "?");
  2323.                 sqlQueryObject.addUpdateField("validazione_contenuti_tipo", "?");
  2324.                 sqlQueryObject.addUpdateField("validazione_contenuti_mtom", "?");
  2325.                 // registro cache
  2326.                 sqlQueryObject.addUpdateField("statocache", "?");
  2327.                 sqlQueryObject.addUpdateField("dimensionecache", "?");
  2328.                 sqlQueryObject.addUpdateField("algoritmocache", "?");
  2329.                 sqlQueryObject.addUpdateField("idlecache", "?");
  2330.                 sqlQueryObject.addUpdateField("lifecache", "?");
  2331.                 // config cache
  2332.                 sqlQueryObject.addUpdateField("config_statocache", "?");
  2333.                 sqlQueryObject.addUpdateField("config_dimensionecache", "?");
  2334.                 sqlQueryObject.addUpdateField("config_algoritmocache", "?");
  2335.                 sqlQueryObject.addUpdateField("config_idlecache", "?");
  2336.                 sqlQueryObject.addUpdateField("config_lifecache", "?");
  2337.                 // authz cache
  2338.                 sqlQueryObject.addUpdateField("auth_statocache", "?");
  2339.                 sqlQueryObject.addUpdateField("auth_dimensionecache", "?");
  2340.                 sqlQueryObject.addUpdateField("auth_algoritmocache", "?");
  2341.                 sqlQueryObject.addUpdateField("auth_idlecache", "?");
  2342.                 sqlQueryObject.addUpdateField("auth_lifecache", "?");
  2343.                 // authn cache
  2344.                 sqlQueryObject.addUpdateField("authn_statocache", "?");
  2345.                 sqlQueryObject.addUpdateField("authn_dimensionecache", "?");
  2346.                 sqlQueryObject.addUpdateField("authn_algoritmocache", "?");
  2347.                 sqlQueryObject.addUpdateField("authn_idlecache", "?");
  2348.                 sqlQueryObject.addUpdateField("authn_lifecache", "?");
  2349.                 // token cache
  2350.                 sqlQueryObject.addUpdateField("token_statocache", "?");
  2351.                 sqlQueryObject.addUpdateField("token_dimensionecache", "?");
  2352.                 sqlQueryObject.addUpdateField("token_algoritmocache", "?");
  2353.                 sqlQueryObject.addUpdateField("token_idlecache", "?");
  2354.                 sqlQueryObject.addUpdateField("token_lifecache", "?");
  2355.                 // aa cache
  2356.                 sqlQueryObject.addUpdateField("aa_statocache", "?");
  2357.                 sqlQueryObject.addUpdateField("aa_dimensionecache", "?");
  2358.                 sqlQueryObject.addUpdateField("aa_algoritmocache", "?");
  2359.                 sqlQueryObject.addUpdateField("aa_idlecache", "?");
  2360.                 sqlQueryObject.addUpdateField("aa_lifecache", "?");
  2361.                 // keystore cache
  2362.                 sqlQueryObject.addUpdateField("keystore_statocache", "?");
  2363.                 sqlQueryObject.addUpdateField("keystore_dimensionecache", "?");
  2364.                 sqlQueryObject.addUpdateField("keystore_algoritmocache", "?");
  2365.                 sqlQueryObject.addUpdateField("keystore_idlecache", "?");
  2366.                 sqlQueryObject.addUpdateField("keystore_lifecache", "?");
  2367.                 sqlQueryObject.addUpdateField("keystore_crl_lifecache", "?");
  2368.                 // multitenant
  2369.                 sqlQueryObject.addUpdateField("multitenant_stato", "?");
  2370.                 sqlQueryObject.addUpdateField("multitenant_fruizioni", "?");
  2371.                 sqlQueryObject.addUpdateField("multitenant_erogazioni", "?");
  2372.                 // cors
  2373.                 sqlQueryObject.addUpdateField("cors_stato", "?");
  2374.                 sqlQueryObject.addUpdateField("cors_tipo", "?");
  2375.                 sqlQueryObject.addUpdateField("cors_all_allow_origins", "?");
  2376.                 sqlQueryObject.addUpdateField("cors_all_allow_methods", "?");
  2377.                 sqlQueryObject.addUpdateField("cors_all_allow_headers", "?");
  2378.                 sqlQueryObject.addUpdateField("cors_allow_credentials", "?");
  2379.                 sqlQueryObject.addUpdateField("cors_allow_max_age", "?");
  2380.                 sqlQueryObject.addUpdateField("cors_allow_max_age_seconds", "?");
  2381.                 sqlQueryObject.addUpdateField("cors_allow_origins", "?");
  2382.                 sqlQueryObject.addUpdateField("cors_allow_headers", "?");
  2383.                 sqlQueryObject.addUpdateField("cors_allow_methods", "?");
  2384.                 sqlQueryObject.addUpdateField("cors_allow_expose_headers", "?");
  2385.                 // responseCaching
  2386.                 sqlQueryObject.addUpdateField("response_cache_stato", "?");
  2387.                 sqlQueryObject.addUpdateField("response_cache_seconds", "?");
  2388.                 sqlQueryObject.addUpdateField("response_cache_max_msg_size", "?");
  2389.                 sqlQueryObject.addUpdateField("response_cache_control_nocache", "?");
  2390.                 sqlQueryObject.addUpdateField("response_cache_control_maxage", "?");
  2391.                 sqlQueryObject.addUpdateField("response_cache_control_nostore", "?");
  2392.                 sqlQueryObject.addUpdateField("response_cache_hash_url", "?");
  2393.                 sqlQueryObject.addUpdateField("response_cache_hash_query", "?");
  2394.                 sqlQueryObject.addUpdateField("response_cache_hash_query_list", "?");
  2395.                 sqlQueryObject.addUpdateField("response_cache_hash_headers", "?");
  2396.                 sqlQueryObject.addUpdateField("response_cache_hash_hdr_list", "?");
  2397.                 sqlQueryObject.addUpdateField("response_cache_hash_payload", "?");
  2398.                 // responseCaching cache
  2399.                 sqlQueryObject.addUpdateField("response_cache_statocache", "?");
  2400.                 sqlQueryObject.addUpdateField("response_cache_dimensionecache", "?");
  2401.                 sqlQueryObject.addUpdateField("response_cache_algoritmocache", "?");
  2402.                 sqlQueryObject.addUpdateField("response_cache_idlecache", "?");
  2403.                 sqlQueryObject.addUpdateField("response_cache_lifecache", "?");
  2404.                 // consegna applicativi cache
  2405.                 sqlQueryObject.addUpdateField("consegna_statocache", "?");
  2406.                 sqlQueryObject.addUpdateField("consegna_dimensionecache", "?");
  2407.                 sqlQueryObject.addUpdateField("consegna_algoritmocache", "?");
  2408.                 sqlQueryObject.addUpdateField("consegna_idlecache", "?");
  2409.                 sqlQueryObject.addUpdateField("consegna_lifecache", "?");
  2410.                 // canali
  2411.                 sqlQueryObject.addUpdateField("canali_stato", "?");
  2412.                 // dati richieste cache
  2413.                 sqlQueryObject.addUpdateField("dati_richieste_statocache", "?");
  2414.                 sqlQueryObject.addUpdateField("dati_richieste_dimensionecache", "?");
  2415.                 sqlQueryObject.addUpdateField("dati_richieste_algoritmocache", "?");
  2416.                 sqlQueryObject.addUpdateField("dati_richieste_idlecache", "?");
  2417.                 sqlQueryObject.addUpdateField("dati_richieste_lifecache", "?");

  2418.                 updateQuery = sqlQueryObject.createSQLUpdate();
  2419.                 updateStmt = con.prepareStatement(updateQuery);
  2420.                
  2421.                 index = 1;
  2422.                
  2423.                 updateStmt.setString(index++, cadenzaInoltro);
  2424.                 updateStmt.setString(index++, valStato);
  2425.                 updateStmt.setString(index++, valControllo);
  2426.                 updateStmt.setString(index++, msgDiagSeverita);
  2427.                 updateStmt.setString(index++, msgDiagSeveritaLog4j);
  2428.                 updateStmt.setString(index++, autenticazione);
  2429.                 updateStmt.setString(index++, valProfiloCollaborazione);
  2430.                 updateStmt.setString(index++, modRisposta);
  2431.                 updateStmt.setString(index++, utilizzoIndTelematico);
  2432.                 updateStmt.setString(index++, routingEnabled);
  2433.                 updateStmt.setString(index++, gestioneManifest);
  2434.                 updateStmt.setString(index++, valManifest);
  2435.                 updateStmt.setString(index++, tracciamentoBuste);
  2436.                 // tracciamento
  2437.                 updateStmt.setString(index++, tracciamentoEsitiPA);
  2438.                 updateStmt.setString(index++, tracciamentoEsitiPD);
  2439.                 updateStmt.setString(index++, transazioniTempiElaborazionePA);
  2440.                 updateStmt.setString(index++, transazioniTempiElaborazionePD);
  2441.                 updateStmt.setString(index++, transazioniTokenPA);
  2442.                 updateStmt.setString(index++, transazioniTokenPD);
  2443.                 // dump
  2444.                 updateStmt.setString(index++, dumpApplicativo);
  2445.                 updateStmt.setString(index++, dumpPD);
  2446.                 updateStmt.setString(index++, dumpPA);
  2447.                 // validazione
  2448.                 updateStmt.setString(index++, validazioneContenutiStato);
  2449.                 updateStmt.setString(index++, validazioneContenutiTipo);
  2450.                 updateStmt.setString(index++, validazioneContenutiAcceptMtomMessage);
  2451.                 // registro cache
  2452.                 updateStmt.setString(index++, registroStatoCache);
  2453.                 updateStmt.setString(index++, registroDimensioneCache);
  2454.                 updateStmt.setString(index++, registroAlgoritmoCache);
  2455.                 updateStmt.setString(index++, registroIdleCache);
  2456.                 updateStmt.setString(index++, registroLifeCache);
  2457.                 // config cache
  2458.                 updateStmt.setString(index++, configStatoCache);
  2459.                 updateStmt.setString(index++, configDimensioneCache);
  2460.                 updateStmt.setString(index++, configAlgoritmoCache);
  2461.                 updateStmt.setString(index++, configIdleCache);
  2462.                 updateStmt.setString(index++, configLifeCache);
  2463.                 // authz cache
  2464.                 updateStmt.setString(index++, authzStatoCache);
  2465.                 updateStmt.setString(index++, authzDimensioneCache);
  2466.                 updateStmt.setString(index++, authzAlgoritmoCache);
  2467.                 updateStmt.setString(index++, authzIdleCache);
  2468.                 updateStmt.setString(index++, authzLifeCache);
  2469.                 // authn cache
  2470.                 updateStmt.setString(index++, authnStatoCache);
  2471.                 updateStmt.setString(index++, authnDimensioneCache);
  2472.                 updateStmt.setString(index++, authnAlgoritmoCache);
  2473.                 updateStmt.setString(index++, authnIdleCache);
  2474.                 updateStmt.setString(index++, authnLifeCache);
  2475.                 // token cache
  2476.                 updateStmt.setString(index++, tokenStatoCache);
  2477.                 updateStmt.setString(index++, tokenDimensioneCache);
  2478.                 updateStmt.setString(index++, tokenAlgoritmoCache);
  2479.                 updateStmt.setString(index++, tokenIdleCache);
  2480.                 updateStmt.setString(index++, tokenLifeCache);
  2481.                 // aa cache
  2482.                 updateStmt.setString(index++, aaStatoCache);
  2483.                 updateStmt.setString(index++, aaDimensioneCache);
  2484.                 updateStmt.setString(index++, aaAlgoritmoCache);
  2485.                 updateStmt.setString(index++, aaIdleCache);
  2486.                 updateStmt.setString(index++, aaLifeCache);
  2487.                 // keystore cache
  2488.                 updateStmt.setString(index++, keystoreStatoCache);
  2489.                 updateStmt.setString(index++, keystoreDimensioneCache);
  2490.                 updateStmt.setString(index++, keystoreAlgoritmoCache);
  2491.                 updateStmt.setString(index++, keystoreIdleCache);
  2492.                 updateStmt.setString(index++, keystoreLifeCache);
  2493.                 updateStmt.setString(index++, keystoreCrlLifeCache);
  2494.                 // multitenant
  2495.                 updateStmt.setString(index++, multitenant!=null ? DriverConfigurazioneDBLib.getValue(multitenant.getStato()) : null);
  2496.                 updateStmt.setString(index++, multitenant!=null ? DriverConfigurazioneDBLib.getValue(multitenant.getFruizioneSceltaSoggettiErogatori()) : null);
  2497.                 updateStmt.setString(index++, multitenant!=null ? DriverConfigurazioneDBLib.getValue(multitenant.getErogazioneSceltaSoggettiFruitori()) : null);
  2498.                 // cors
  2499.                 updateStmt.setString(index++, corsStato);
  2500.                 updateStmt.setString(index++, corsTipo);
  2501.                 updateStmt.setString(index++, corsAllAllowOrigins);
  2502.                 updateStmt.setString(index++, corsAllAllowMethods);
  2503.                 updateStmt.setString(index++, corsAllAllowHeaders);
  2504.                 updateStmt.setString(index++, corsAllowCredentials);
  2505.                 updateStmt.setInt(index++, corsAllowMaxAge);
  2506.                 if(corsAllowMaxAgeSeconds!=null) {
  2507.                     updateStmt.setInt(index++, corsAllowMaxAgeSeconds);
  2508.                 }
  2509.                 else {
  2510.                     updateStmt.setNull(index++, java.sql.Types.INTEGER);
  2511.                 }
  2512.                 updateStmt.setString(index++, corsAllowOrigins);
  2513.                 updateStmt.setString(index++, corsAllowHeaders);
  2514.                 updateStmt.setString(index++, corsAllowMethods);
  2515.                 updateStmt.setString(index++, corsAllowExposeHeaders);              
  2516.                 // responseCaching
  2517.                 updateStmt.setString(index++, responseCacheStato);
  2518.                 if(responseCacheSeconds!=null) {
  2519.                     updateStmt.setInt(index++, responseCacheSeconds);
  2520.                 }
  2521.                 else {
  2522.                     updateStmt.setNull(index++, java.sql.Types.INTEGER);
  2523.                 }
  2524.                 if(responseCacheMaxMsgSize!=null) {
  2525.                     updateStmt.setLong(index++, responseCacheMaxMsgSize);
  2526.                 }
  2527.                 else {
  2528.                     updateStmt.setNull(index++, java.sql.Types.BIGINT);
  2529.                 }
  2530.                 updateStmt.setInt(index++, responseCacheNoCache ? CostantiDB.TRUE : CostantiDB.FALSE);
  2531.                 updateStmt.setInt(index++, responseCacheMaxAge ? CostantiDB.TRUE : CostantiDB.FALSE);
  2532.                 updateStmt.setInt(index++, responseCacheNoStore ? CostantiDB.TRUE : CostantiDB.FALSE);
  2533.                 updateStmt.setString(index++, responseCacheHashUrl);
  2534.                 updateStmt.setString(index++, responseCacheHashQuery);
  2535.                 updateStmt.setString(index++, responseCacheHashQueryList);
  2536.                 updateStmt.setString(index++, responseCacheHashHeaders);
  2537.                 updateStmt.setString(index++, responseCacheHashHeadersList);
  2538.                 updateStmt.setString(index++, responseCacheHashPayload);
  2539.                 // responseCaching cache
  2540.                 updateStmt.setString(index++, responseCachingStatoCache);
  2541.                 updateStmt.setString(index++, responseCachingDimensioneCache);
  2542.                 updateStmt.setString(index++, responseCachingAlgoritmoCache);
  2543.                 updateStmt.setString(index++, responseCachingIdleCache);
  2544.                 updateStmt.setString(index++, responseCachingLifeCache);
  2545.                 // consegna applicativi cache
  2546.                 updateStmt.setString(index++, consegnaStatoCache);
  2547.                 updateStmt.setString(index++, consegnaDimensioneCache);
  2548.                 updateStmt.setString(index++, consegnaAlgoritmoCache);
  2549.                 updateStmt.setString(index++, consegnaIdleCache);
  2550.                 updateStmt.setString(index++, consegnaLifeCache);
  2551.                 // canali
  2552.                 updateStmt.setString(index++, configurazioneCanaliStato);
  2553.                 // dati richieste cache
  2554.                 updateStmt.setString(index++, datiRichiesteStatoCache);
  2555.                 updateStmt.setString(index++, datiRichiesteDimensioneCache);
  2556.                 updateStmt.setString(index++, datiRichiesteAlgoritmoCache);
  2557.                 updateStmt.setString(index++, datiRichiesteIdleCache);
  2558.                 updateStmt.setString(index++, datiRichiesteLifeCache);
  2559.                
  2560.                 DriverConfigurazioneDBLib.logDebug("eseguo query :" +
  2561.                         DBUtils.formatSQLString(updateQuery,
  2562.                                 cadenzaInoltro,
  2563.                                 valStato, valControllo,
  2564.                                 msgDiagSeverita, msgDiagSeveritaLog4j,
  2565.                                 autenticazione,
  2566.                                 valProfiloCollaborazione,
  2567.                                 modRisposta, utilizzoIndTelematico,
  2568.                                 routingEnabled, gestioneManifest,
  2569.                                 valManifest,
  2570.                                 tracciamentoBuste,
  2571.                                 tracciamentoEsitiPA, tracciamentoEsitiPD,
  2572.                                 transazioniTempiElaborazionePA, transazioniTempiElaborazionePD,
  2573.                                 transazioniTokenPA, transazioniTokenPD,
  2574.                                 dumpApplicativo, dumpPD, dumpPA,
  2575.                                 validazioneContenutiStato,validazioneContenutiTipo,
  2576.                                 registroStatoCache, registroDimensioneCache, registroAlgoritmoCache, registroIdleCache, registroLifeCache,
  2577.                                 configStatoCache, configDimensioneCache, configAlgoritmoCache, configIdleCache, configLifeCache,
  2578.                                 authzStatoCache, authzDimensioneCache, authzAlgoritmoCache, authzIdleCache, authzLifeCache,
  2579.                                 authnStatoCache, authnDimensioneCache, authnAlgoritmoCache, authnIdleCache, authnLifeCache,
  2580.                                 tokenStatoCache, tokenDimensioneCache, tokenAlgoritmoCache, tokenIdleCache, tokenLifeCache,
  2581.                                 keystoreStatoCache, keystoreDimensioneCache, keystoreAlgoritmoCache, keystoreIdleCache, keystoreLifeCache, keystoreCrlLifeCache,
  2582.                                 (multitenant!=null ? DriverConfigurazioneDBLib.getValue(multitenant.getStato()) : null),
  2583.                                 (multitenant!=null ? DriverConfigurazioneDBLib.getValue(multitenant.getFruizioneSceltaSoggettiErogatori()) : null),
  2584.                                 (multitenant!=null ? DriverConfigurazioneDBLib.getValue(multitenant.getErogazioneSceltaSoggettiFruitori()) : null),
  2585.                                 corsStato, corsTipo, corsAllAllowOrigins, corsAllAllowMethods, corsAllAllowHeaders, corsAllowCredentials, corsAllowMaxAge, corsAllowMaxAgeSeconds,
  2586.                                 corsAllowOrigins, corsAllowHeaders, corsAllowMethods, corsAllowExposeHeaders,
  2587.                                 responseCacheStato, responseCacheSeconds, responseCacheMaxMsgSize,
  2588.                                 responseCacheHashUrl, responseCacheHashQuery, responseCacheHashQueryList, responseCacheHashHeaders, responseCacheHashHeadersList, responseCacheHashPayload,
  2589.                                 responseCachingStatoCache, responseCachingDimensioneCache, responseCachingAlgoritmoCache, responseCachingIdleCache, responseCachingLifeCache,
  2590.                                 consegnaStatoCache, consegnaDimensioneCache, consegnaAlgoritmoCache, consegnaIdleCache, consegnaLifeCache,
  2591.                                 configurazioneCanaliStato,
  2592.                                 datiRichiesteStatoCache, datiRichiesteDimensioneCache, datiRichiesteAlgoritmoCache, datiRichiesteIdleCache, datiRichiesteLifeCache
  2593.                                 ));

  2594.                 n = updateStmt.executeUpdate();
  2595.                 updateStmt.close();

  2596.                 // delete from config_url_invocazione
  2597.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2598.                 sqlQueryObject.addDeleteTable(CostantiDB.CONFIG_URL_REGOLE);
  2599.                 updateQuery = sqlQueryObject.createSQLDelete();
  2600.                 updateStmt = con.prepareStatement(updateQuery);
  2601.                 updateStmt.executeUpdate();
  2602.                 updateStmt.close();
  2603.                
  2604.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2605.                 sqlQueryObject.addDeleteTable(CostantiDB.CONFIG_URL_INVOCAZIONE);
  2606.                 updateQuery = sqlQueryObject.createSQLDelete();
  2607.                 updateStmt = con.prepareStatement(updateQuery);
  2608.                 updateStmt.executeUpdate();
  2609.                 updateStmt.close();
  2610.                
  2611.                 // insert into config_protocolli
  2612.                 if(config.getUrlInvocazione()!=null){
  2613.                    
  2614.                     sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2615.                     sqlQueryObject.addInsertTable(CostantiDB.CONFIG_URL_INVOCAZIONE);
  2616.                     sqlQueryObject.addInsertField("base_url", "?");
  2617.                     sqlQueryObject.addInsertField("base_url_fruizione", "?");
  2618.                     updateQuery = sqlQueryObject.createSQLInsert();
  2619.                     updateStmt = con.prepareStatement(updateQuery);
  2620.                     int indexP = 1;
  2621.                     updateStmt.setString(indexP++, config.getUrlInvocazione().getBaseUrl());
  2622.                     updateStmt.setString(indexP++, config.getUrlInvocazione().getBaseUrlFruizione());
  2623.                     updateStmt.executeUpdate();
  2624.                     updateStmt.close();
  2625.                    
  2626.                     if(config.getUrlInvocazione().sizeRegolaList()>0){
  2627.                         for(int k=0; k<config.getUrlInvocazione().sizeRegolaList();k++){
  2628.                             ConfigurazioneUrlInvocazioneRegola configUrlInvocazioneRegola = config.getUrlInvocazione().getRegola(k);
  2629.                             createUrlInvocazioneRegolaEngine(configUrlInvocazioneRegola, con);
  2630.                         }
  2631.                     }
  2632.                 }
  2633.                
  2634.                 // delete from msg diag appender
  2635.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2636.                 sqlQueryObject.addDeleteTable(CostantiDB.MSG_DIAGN_APPENDER_PROP);
  2637.                 updateQuery = sqlQueryObject.createSQLDelete();
  2638.                 updateStmt = con.prepareStatement(updateQuery);
  2639.                 updateStmt.executeUpdate();
  2640.                 updateStmt.close();

  2641.                 // delete from msg diag appender
  2642.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2643.                 sqlQueryObject.addDeleteTable(CostantiDB.MSG_DIAGN_APPENDER);
  2644.                 updateQuery = sqlQueryObject.createSQLDelete();
  2645.                 updateStmt = con.prepareStatement(updateQuery);
  2646.                 updateStmt.executeUpdate();
  2647.                 updateStmt.close();

  2648.                 // insert into msg diag appender
  2649.                 if(config.getMessaggiDiagnostici()!=null){
  2650.                     for(int k=0; k<config.getMessaggiDiagnostici().sizeOpenspcoopAppenderList();k++){
  2651.                         OpenspcoopAppender appender = config.getMessaggiDiagnostici().getOpenspcoopAppender(k);
  2652.                        
  2653.                         List<InsertAndGeneratedKeyObject> listInsertAndGeneratedKeyObject = new ArrayList<>();
  2654.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("tipo", appender.getTipo() , InsertAndGeneratedKeyJDBCType.STRING) );
  2655.                        
  2656.                         long idMsgDiagAppender = InsertAndGeneratedKey.insertAndReturnGeneratedKey(con, TipiDatabase.toEnumConstant(DriverConfigurazioneDBLib.tipoDB),
  2657.                                 new CustomKeyGeneratorObject(CostantiDB.MSG_DIAGN_APPENDER, CostantiDB.MSG_DIAGN_APPENDER_COLUMN_ID,
  2658.                                         CostantiDB.MSG_DIAGN_APPENDER_SEQUENCE, CostantiDB.MSG_DIAGN_APPENDER_TABLE_FOR_ID),
  2659.                                 listInsertAndGeneratedKeyObject.toArray(new InsertAndGeneratedKeyObject[1]));
  2660.                         if(idMsgDiagAppender<=0){
  2661.                             throw new DriverConfigurazioneException("ID (msg diag appender) autoincrementale non ottenuto");
  2662.                         }

  2663.                         for(int l=0; l<appender.sizePropertyList();l++){
  2664.                             DriverConfigurazioneDBLib.logDebug("INSERT INTO "+CostantiDB.MSG_DIAGN_APPENDER_PROP+" (id_appender,nome,valore) VALUES ("+idMsgDiagAppender+","+appender.getProperty(l).getNome()+","+appender.getProperty(l).getValore()+")");
  2665.                             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2666.                             sqlQueryObject.addInsertTable(CostantiDB.MSG_DIAGN_APPENDER_PROP);
  2667.                             sqlQueryObject.addInsertField("id_appender", "?");
  2668.                             sqlQueryObject.addInsertField("nome", "?");
  2669.                             sqlQueryObject.addInsertField("valore", "?");
  2670.                             updateQuery = sqlQueryObject.createSQLInsert();
  2671.                             updateStmt = con.prepareStatement(updateQuery);
  2672.                             updateStmt.setLong(1, idMsgDiagAppender);
  2673.                             updateStmt.setString(2, appender.getProperty(l).getNome());
  2674.                             updateStmt.setString(3, appender.getProperty(l).getValore());
  2675.                             updateStmt.executeUpdate();
  2676.                             updateStmt.close();
  2677.                         }

  2678.                     }
  2679.                 }

  2680.                 // delete from tracciamento appender
  2681.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2682.                 sqlQueryObject.addDeleteTable(CostantiDB.TRACCIAMENTO_APPENDER_PROP);
  2683.                 updateQuery = sqlQueryObject.createSQLDelete();
  2684.                 updateStmt = con.prepareStatement(updateQuery);
  2685.                 updateStmt.executeUpdate();
  2686.                 updateStmt.close();

  2687.                 // delete from tracciamento appender
  2688.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2689.                 sqlQueryObject.addDeleteTable(CostantiDB.TRACCIAMENTO_APPENDER);
  2690.                 updateQuery = sqlQueryObject.createSQLDelete();
  2691.                 updateStmt = con.prepareStatement(updateQuery);
  2692.                 updateStmt.executeUpdate();
  2693.                 updateStmt.close();

  2694.                 // insert into tracciamento appender
  2695.                 if(config.getTracciamento()!=null){
  2696.                     for(int k=0; k<config.getTracciamento().sizeOpenspcoopAppenderList();k++){
  2697.                         OpenspcoopAppender appender = config.getTracciamento().getOpenspcoopAppender(k);
  2698.                        
  2699.                         List<InsertAndGeneratedKeyObject> listInsertAndGeneratedKeyObject = new ArrayList<>();
  2700.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("tipo", appender.getTipo() , InsertAndGeneratedKeyJDBCType.STRING) );
  2701.                        
  2702.                         long idTracceAppender = InsertAndGeneratedKey.insertAndReturnGeneratedKey(con, TipiDatabase.toEnumConstant(DriverConfigurazioneDBLib.tipoDB),
  2703.                                 new CustomKeyGeneratorObject(CostantiDB.TRACCIAMENTO_APPENDER, CostantiDB.TRACCIAMENTO_APPENDER_COLUMN_ID,
  2704.                                         CostantiDB.TRACCIAMENTO_APPENDER_SEQUENCE, CostantiDB.TRACCIAMENTO_APPENDER_TABLE_FOR_ID),
  2705.                                 listInsertAndGeneratedKeyObject.toArray(new InsertAndGeneratedKeyObject[1]));
  2706.                         if(idTracceAppender<=0){
  2707.                             throw new DriverConfigurazioneException("ID (tracce appender) autoincrementale non ottenuto");
  2708.                         }

  2709.                         for(int l=0; l<appender.sizePropertyList();l++){
  2710.                             DriverConfigurazioneDBLib.logDebug("INSERT INTO "+CostantiDB.TRACCIAMENTO_APPENDER_PROP+" (id_appender,nome,valore) VALUES ("+idTracceAppender+","+appender.getProperty(l).getNome()+","+appender.getProperty(l).getValore()+")");
  2711.                             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2712.                             sqlQueryObject.addInsertTable(CostantiDB.TRACCIAMENTO_APPENDER_PROP);
  2713.                             sqlQueryObject.addInsertField("id_appender", "?");
  2714.                             sqlQueryObject.addInsertField("nome", "?");
  2715.                             sqlQueryObject.addInsertField("valore", "?");
  2716.                             updateQuery = sqlQueryObject.createSQLInsert();
  2717.                             updateStmt = con.prepareStatement(updateQuery);
  2718.                             updateStmt.setLong(1, idTracceAppender);
  2719.                             updateStmt.setString(2, appender.getProperty(l).getNome());
  2720.                             updateStmt.setString(3, appender.getProperty(l).getValore());
  2721.                             updateStmt.executeUpdate();
  2722.                             updateStmt.close();
  2723.                         }

  2724.                     }
  2725.                 }
  2726.                
  2727.                
  2728.                 // tracciamentoConfigurazione
  2729.                
  2730.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazione(type, con, tracciamentoConfigurazioneDatabasePA, null,
  2731.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA,
  2732.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_DB);
  2733.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazione(type, con, tracciamentoConfigurazioneDatabasePD, null,
  2734.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD,
  2735.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_DB);
  2736.                
  2737.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazione(type, con, tracciamentoConfigurazioneFiletracePA, null,
  2738.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA,
  2739.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_FILETRACE);
  2740.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazione(type, con, tracciamentoConfigurazioneFiletracePD, null,
  2741.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD,
  2742.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_FILETRACE);
  2743.                
  2744.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazioneFiletrace(type, con, tracciamentoConfigurazioneFiletraceDetailsPA, null,
  2745.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA);
  2746.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazioneFiletrace(type, con, tracciamentoConfigurazioneFiletraceDetailsPD, null,
  2747.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD);
  2748.                
  2749.    
  2750.                 // delete from dump appender_prop
  2751.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2752.                 sqlQueryObject.addDeleteTable(CostantiDB.DUMP_APPENDER_PROP);
  2753.                 updateQuery = sqlQueryObject.createSQLDelete();
  2754.                 updateStmt = con.prepareStatement(updateQuery);
  2755.                 updateStmt.executeUpdate();
  2756.                 updateStmt.close();

  2757.                 // delete from dump appender
  2758.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2759.                 sqlQueryObject.addDeleteTable(CostantiDB.DUMP_APPENDER);
  2760.                 updateQuery = sqlQueryObject.createSQLDelete();
  2761.                 updateStmt = con.prepareStatement(updateQuery);
  2762.                 updateStmt.executeUpdate();
  2763.                 updateStmt.close();

  2764.                 // insert into dump appender
  2765.                 if(config.getDump()!=null){
  2766.                     for(int k=0; k<config.getDump().sizeOpenspcoopAppenderList();k++){
  2767.                         OpenspcoopAppender appender = config.getDump().getOpenspcoopAppender(k);
  2768.                        
  2769.                         List<InsertAndGeneratedKeyObject> listInsertAndGeneratedKeyObject = new ArrayList<>();
  2770.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("tipo", appender.getTipo() , InsertAndGeneratedKeyJDBCType.STRING) );
  2771.                        
  2772.                         long idDumpAppender = InsertAndGeneratedKey.insertAndReturnGeneratedKey(con, TipiDatabase.toEnumConstant(DriverConfigurazioneDBLib.tipoDB),
  2773.                                 new CustomKeyGeneratorObject(CostantiDB.DUMP_APPENDER, CostantiDB.DUMP_APPENDER_COLUMN_ID,
  2774.                                         CostantiDB.DUMP_APPENDER_SEQUENCE, CostantiDB.DUMP_APPENDER_TABLE_FOR_ID),
  2775.                                 listInsertAndGeneratedKeyObject.toArray(new InsertAndGeneratedKeyObject[1]));
  2776.                         if(idDumpAppender<=0){
  2777.                             throw new DriverConfigurazioneException("ID (dump appender) autoincrementale non ottenuto");
  2778.                         }

  2779.                         for(int l=0; l<appender.sizePropertyList();l++){
  2780.                             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2781.                             sqlQueryObject.addInsertTable(CostantiDB.DUMP_APPENDER_PROP);
  2782.                             sqlQueryObject.addInsertField("id_appender", "?");
  2783.                             sqlQueryObject.addInsertField("nome", "?");
  2784.                             sqlQueryObject.addInsertField("valore", "?");
  2785.                             updateQuery = sqlQueryObject.createSQLInsert();
  2786.                             updateStmt = con.prepareStatement(updateQuery);
  2787.                             updateStmt.setLong(1, idDumpAppender);
  2788.                             updateStmt.setString(2, appender.getProperty(l).getNome());
  2789.                             updateStmt.setString(3, appender.getProperty(l).getValore());
  2790.                             updateStmt.executeUpdate();
  2791.                             updateStmt.close();
  2792.                         }

  2793.                     }
  2794.                 }
  2795.                
  2796.                 // Cache Regole
  2797.                
  2798.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2799.                 sqlQueryObject.addDeleteTable(CostantiDB.CONFIGURAZIONE_CACHE_REGOLE);
  2800.                 String sqlQuery = sqlQueryObject.createSQLDelete();
  2801.                 updateStmt = con.prepareStatement(sqlQuery);
  2802.                 n=updateStmt.executeUpdate();
  2803.                 updateStmt.close();
  2804.                 DriverConfigurazioneDBLib.logDebug("Cancellati "+n+" regole di cache");
  2805.                
  2806.                 n=0;
  2807.                 if(responseCacheRegole!=null && !responseCacheRegole.isEmpty()){
  2808.                     for (int j = 0; j < responseCacheRegole.size(); j++) {
  2809.                         ResponseCachingConfigurazioneRegola regola = responseCacheRegole.get(j);
  2810.                         sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2811.                         sqlQueryObject.addInsertTable(CostantiDB.CONFIGURAZIONE_CACHE_REGOLE);
  2812.                         if(regola.getReturnCodeMin()!=null && regola.getReturnCodeMin()>0) {
  2813.                             sqlQueryObject.addInsertField("status_min", "?");
  2814.                         }
  2815.                         if(regola.getReturnCodeMax()!=null && regola.getReturnCodeMax()>0) {
  2816.                             sqlQueryObject.addInsertField("status_max", "?");
  2817.                         }
  2818.                         sqlQueryObject.addInsertField("fault", "?");
  2819.                         if(regola.getCacheTimeoutSeconds()!=null && regola.getCacheTimeoutSeconds()>0) {
  2820.                             sqlQueryObject.addInsertField("cache_seconds", "?");
  2821.                         }
  2822.                         sqlQuery = sqlQueryObject.createSQLInsert();
  2823.                         updateStmt = con.prepareStatement(sqlQuery);
  2824.                         int indexCR = 1;
  2825.                         if(regola.getReturnCodeMin()!=null && regola.getReturnCodeMin()>0) {
  2826.                             updateStmt.setInt(indexCR++, regola.getReturnCodeMin());
  2827.                         }
  2828.                         if(regola.getReturnCodeMax()!=null && regola.getReturnCodeMax()>0) {
  2829.                             updateStmt.setInt(indexCR++, regola.getReturnCodeMax());
  2830.                         }
  2831.                         updateStmt.setInt(indexCR++, regola.getFault() ? CostantiDB.TRUE : CostantiDB.FALSE);
  2832.                         if(regola.getCacheTimeoutSeconds()!=null && regola.getCacheTimeoutSeconds()>0) {
  2833.                             updateStmt.setInt(indexCR++, regola.getCacheTimeoutSeconds());
  2834.                         }
  2835.                         updateStmt.executeUpdate();
  2836.                         updateStmt.close();
  2837.                         n++;
  2838.                         DriverConfigurazioneDBLib.logDebug("Aggiunta regola di cache");
  2839.                     }
  2840.                 }
  2841.                
  2842.                 DriverConfigurazioneDBLib.logDebug("Aggiunte " + n + " regole di cache");
  2843.                
  2844.                 // dumpConfigurazione
  2845.                
  2846.                 // per backward compatibility elimino una config esistente
  2847.                 dumpConfigOldBackwardCompatibility = DriverConfigurazioneDB_dumpLIB.readDumpConfigurazione(con, null, CostantiDB.OLD_BACKWARD_COMPATIBILITY_DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG);
  2848.                 if(dumpConfigOldBackwardCompatibility!=null) {
  2849.                     DriverConfigurazioneDB_dumpLIB.CRUDDumpConfigurazione(DELETE, con, dumpConfigOldBackwardCompatibility, null, CostantiDB.OLD_BACKWARD_COMPATIBILITY_DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG);
  2850.                 }
  2851.                
  2852.                 DriverConfigurazioneDB_dumpLIB.CRUDDumpConfigurazione(type, con, dumpConfigPA, null, CostantiDB.DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA);
  2853.                 DriverConfigurazioneDB_dumpLIB.CRUDDumpConfigurazione(type, con, dumpConfigPD, null, CostantiDB.DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD);
  2854.                

  2855.                 // delete from msgdiag ds prop
  2856.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2857.                 sqlQueryObject.addDeleteTable(CostantiDB.MSG_DIAGN_DS_PROP);
  2858.                 updateQuery = sqlQueryObject.createSQLDelete();
  2859.                 updateStmt = con.prepareStatement(updateQuery);
  2860.                 updateStmt.executeUpdate();
  2861.                 updateStmt.close();

  2862.                 // delete from msgdiag ds
  2863.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2864.                 sqlQueryObject.addDeleteTable(CostantiDB.MSG_DIAGN_DS);
  2865.                 updateQuery = sqlQueryObject.createSQLDelete();
  2866.                 updateStmt = con.prepareStatement(updateQuery);
  2867.                 updateStmt.executeUpdate();
  2868.                 updateStmt.close();

  2869.                 // insert into msgdiag ds
  2870.                 if(config.getMessaggiDiagnostici()!=null){
  2871.                     for(int k=0; k<config.getMessaggiDiagnostici().sizeOpenspcoopSorgenteDatiList();k++){
  2872.                         OpenspcoopSorgenteDati ds = config.getMessaggiDiagnostici().getOpenspcoopSorgenteDati(k);
  2873.                        
  2874.                         List<InsertAndGeneratedKeyObject> listInsertAndGeneratedKeyObject = new ArrayList<>();
  2875.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("nome", ds.getNome() , InsertAndGeneratedKeyJDBCType.STRING) );
  2876.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("nome_jndi", ds.getNomeJndi() , InsertAndGeneratedKeyJDBCType.STRING) );
  2877.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("tipo_database", ds.getTipoDatabase() , InsertAndGeneratedKeyJDBCType.STRING) );
  2878.                        
  2879.                         long idMsgDsAppender = InsertAndGeneratedKey.insertAndReturnGeneratedKey(con, TipiDatabase.toEnumConstant(DriverConfigurazioneDBLib.tipoDB),
  2880.                                 new CustomKeyGeneratorObject(CostantiDB.MSG_DIAGN_DS, CostantiDB.MSG_DIAGN_DS_COLUMN_ID,
  2881.                                         CostantiDB.MSG_DIAGN_DS_SEQUENCE, CostantiDB.MSG_DIAGN_DS_TABLE_FOR_ID),
  2882.                                 listInsertAndGeneratedKeyObject.toArray(new InsertAndGeneratedKeyObject[1]));
  2883.                         if(idMsgDsAppender<=0){
  2884.                             throw new DriverConfigurazioneException("ID (msgdiag ds appender) autoincrementale non ottenuto");
  2885.                         }

  2886.                         for(int l=0; l<ds.sizePropertyList();l++){
  2887.                             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2888.                             sqlQueryObject.addInsertTable(CostantiDB.MSG_DIAGN_DS_PROP);
  2889.                             sqlQueryObject.addInsertField("id_prop", "?");
  2890.                             sqlQueryObject.addInsertField("nome", "?");
  2891.                             sqlQueryObject.addInsertField("valore", "?");
  2892.                             updateQuery = sqlQueryObject.createSQLInsert();
  2893.                             updateStmt = con.prepareStatement(updateQuery);
  2894.                             updateStmt.setLong(1, idMsgDsAppender);
  2895.                             updateStmt.setString(2, ds.getProperty(l).getNome());
  2896.                             updateStmt.setString(3, ds.getProperty(l).getValore());
  2897.                             updateStmt.executeUpdate();
  2898.                             updateStmt.close();
  2899.                         }

  2900.                     }
  2901.                 }

  2902.                 // delete from tracce ds prop
  2903.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2904.                 sqlQueryObject.addDeleteTable(CostantiDB.TRACCIAMENTO_DS_PROP);
  2905.                 updateQuery = sqlQueryObject.createSQLDelete();
  2906.                 updateStmt = con.prepareStatement(updateQuery);
  2907.                 updateStmt.executeUpdate();
  2908.                 updateStmt.close();

  2909.                 // delete from tracce ds
  2910.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2911.                 sqlQueryObject.addDeleteTable(CostantiDB.TRACCIAMENTO_DS);
  2912.                 updateQuery = sqlQueryObject.createSQLDelete();
  2913.                 updateStmt = con.prepareStatement(updateQuery);
  2914.                 updateStmt.executeUpdate();
  2915.                 updateStmt.close();

  2916.                 // insert into tracce ds
  2917.                 if(config.getTracciamento()!=null){
  2918.                     for(int k=0; k<config.getTracciamento().sizeOpenspcoopSorgenteDatiList();k++){
  2919.                         OpenspcoopSorgenteDati ds = config.getTracciamento().getOpenspcoopSorgenteDati(k);
  2920.                        
  2921.                         List<InsertAndGeneratedKeyObject> listInsertAndGeneratedKeyObject = new ArrayList<>();
  2922.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("nome", ds.getNome() , InsertAndGeneratedKeyJDBCType.STRING) );
  2923.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("nome_jndi", ds.getNomeJndi() , InsertAndGeneratedKeyJDBCType.STRING) );
  2924.                         listInsertAndGeneratedKeyObject.add( new InsertAndGeneratedKeyObject("tipo_database", ds.getTipoDatabase() , InsertAndGeneratedKeyJDBCType.STRING) );
  2925.                        
  2926.                         long idTracceDsAppender = InsertAndGeneratedKey.insertAndReturnGeneratedKey(con, TipiDatabase.toEnumConstant(DriverConfigurazioneDBLib.tipoDB),
  2927.                                 new CustomKeyGeneratorObject(CostantiDB.TRACCIAMENTO_DS, CostantiDB.TRACCIAMENTO_DS_COLUMN_ID,
  2928.                                         CostantiDB.TRACCIAMENTO_DS_SEQUENCE, CostantiDB.TRACCIAMENTO_DS_TABLE_FOR_ID),
  2929.                                 listInsertAndGeneratedKeyObject.toArray(new InsertAndGeneratedKeyObject[1]));
  2930.                         if(idTracceDsAppender<=0){
  2931.                             throw new DriverConfigurazioneException("ID (tracciamento ds appender) autoincrementale non ottenuto");
  2932.                         }

  2933.                         for(int l=0; l<ds.sizePropertyList();l++){
  2934.                             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  2935.                             sqlQueryObject.addInsertTable(CostantiDB.TRACCIAMENTO_DS_PROP);
  2936.                             sqlQueryObject.addInsertField("id_prop", "?");
  2937.                             sqlQueryObject.addInsertField("nome", "?");
  2938.                             sqlQueryObject.addInsertField("valore", "?");
  2939.                             updateQuery = sqlQueryObject.createSQLInsert();
  2940.                             updateStmt = con.prepareStatement(updateQuery);
  2941.                             updateStmt.setLong(1, idTracceDsAppender);
  2942.                             updateStmt.setString(2, ds.getProperty(l).getNome());
  2943.                             updateStmt.setString(3, ds.getProperty(l).getValore());
  2944.                             updateStmt.executeUpdate();
  2945.                             updateStmt.close();
  2946.                         }

  2947.                     }
  2948.                 }

  2949.                 // Canali
  2950.                 DriverConfigurazioneDB_canaliLIB.CRUDCanaliConfigurazione(type, con, configurazioneCanali);
  2951.                
  2952.                
  2953.                 // Handlers
  2954.                 DriverConfigurazioneDB_handlerLIB.CRUDConfigurazioneMessageHandlers(type, con, null, null, true, (configHandlers!=null) ? configHandlers.getRequest() : null);
  2955.                 DriverConfigurazioneDB_handlerLIB.CRUDConfigurazioneMessageHandlers(type, con, null, null, false, (configHandlers!=null) ? configHandlers.getResponse() : null);
  2956.                 DriverConfigurazioneDB_handlerLIB.CRUDConfigurazioneServiceHandlers(type, con, null, null, false, (configHandlers!=null) ? configHandlers.getService() : null);

  2957.                
  2958.                 // ExtendedInfo
  2959.                 if(extInfoConfigurazioneDriver!=null &&
  2960.                         config.sizeExtendedInfoList()>0){
  2961.                     for(int l=0; l<config.sizeExtendedInfoList();l++){
  2962.                         extInfoConfigurazioneDriver.deleteExtendedInfo(con, DriverConfigurazioneDBLib.log,  config, config.getExtendedInfo(l), CRUDType.UPDATE);
  2963.                         extInfoConfigurazioneDriver.createExtendedInfo(con, DriverConfigurazioneDBLib.log,  config, config.getExtendedInfo(l), CRUDType.UPDATE);
  2964.                     }
  2965.                 }
  2966.                

  2967.                 break;

  2968.             case DELETE:
  2969.                
  2970.                 if(config.sizeExtendedInfoList()>0){
  2971.                     for(int l=0; l<config.sizeExtendedInfoList();l++){
  2972.                         extInfoConfigurazioneDriver.deleteExtendedInfo(con, DriverConfigurazioneDBLib.log,  config, config.getExtendedInfo(l), CRUDType.UPDATE);
  2973.                         extInfoConfigurazioneDriver.createExtendedInfo(con, DriverConfigurazioneDBLib.log,  config, config.getExtendedInfo(l), CRUDType.UPDATE);
  2974.                     }
  2975.                 }
  2976.                
  2977.                 // Canali
  2978.                 DriverConfigurazioneDB_canaliLIB.CRUDCanaliConfigurazione(type, con, configurazioneCanali);
  2979.                
  2980.                 // Handlers
  2981.                 DriverConfigurazioneDB_handlerLIB.CRUDConfigurazioneMessageHandlers(type, con, null, null, true, (configHandlers!=null) ? configHandlers.getRequest() : null);
  2982.                 DriverConfigurazioneDB_handlerLIB.CRUDConfigurazioneMessageHandlers(type, con, null, null, false, (configHandlers!=null) ? configHandlers.getResponse() : null);
  2983.                 DriverConfigurazioneDB_handlerLIB.CRUDConfigurazioneServiceHandlers(type, con, null, null, false, (configHandlers!=null) ? configHandlers.getService() : null);
  2984.                
  2985.                 // Tracciamento

  2986.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazione(type, con, tracciamentoConfigurazioneDatabasePA, null,
  2987.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA,
  2988.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_DB);
  2989.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazione(type, con, tracciamentoConfigurazioneDatabasePD, null,
  2990.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD,
  2991.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_DB);
  2992.                
  2993.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazione(type, con, tracciamentoConfigurazioneFiletracePA, null,
  2994.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA,
  2995.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_FILETRACE);
  2996.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazione(type, con, tracciamentoConfigurazioneFiletracePD, null,
  2997.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD,
  2998.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_TIPO_FILETRACE);
  2999.                
  3000.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazioneFiletrace(type, con, tracciamentoConfigurazioneFiletraceDetailsPA, null,
  3001.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA);
  3002.                 DriverConfigurazioneDBTracciamentoLIB.crudTracciamentoConfigurazioneFiletrace(type, con, tracciamentoConfigurazioneFiletraceDetailsPD, null,
  3003.                         CostantiDB.TRACCIAMENTO_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD);
  3004.                
  3005.                 // Dump
  3006.                 if(config.getDump()!=null) {
  3007.                     if(config.getDump().getConfigurazionePortaApplicativa()!=null) {
  3008.                         DriverConfigurazioneDB_dumpLIB.CRUDDumpConfigurazione(DELETE, con, config.getDump().getConfigurazionePortaApplicativa(), null, CostantiDB.DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PA);
  3009.                     }
  3010.                     if(config.getDump().getConfigurazionePortaDelegata()!=null) {
  3011.                         DriverConfigurazioneDB_dumpLIB.CRUDDumpConfigurazione(DELETE, con, config.getDump().getConfigurazionePortaApplicativa(), null, CostantiDB.DUMP_CONFIGURAZIONE_PROPRIETARIO_CONFIG_PD);
  3012.                     }
  3013.                 }
  3014.                
  3015.                 // Cache
  3016.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  3017.                 sqlQueryObject.addDeleteTable(CostantiDB.CONFIGURAZIONE_CACHE_REGOLE);
  3018.                 updateQuery = sqlQueryObject.createSQLDelete();
  3019.                 updateStmt = con.prepareStatement(updateQuery);
  3020.                 updateStmt.executeUpdate();
  3021.                 updateStmt.close();
  3022.                
  3023.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(DriverConfigurazioneDBLib.tipoDB);
  3024.                 sqlQueryObject.addDeleteTable(CostantiDB.CONFIGURAZIONE);
  3025.                 updateQuery = sqlQueryObject.createSQLDelete();
  3026.                 updateStmt = con.prepareStatement(updateQuery);
  3027.                 updateStmt.executeUpdate();
  3028.                 updateStmt.close();
  3029.                 break;

  3030.             }

  3031.             if (type == CostantiDB.CREATE)
  3032.                 return idConfigurazione;
  3033.             else
  3034.                 return n;

  3035.         } catch (SQLException se) {
  3036.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDConfigurazioneGenerale] SQLException [" + se.getMessage() + "].",se);
  3037.         }catch (Exception se) {
  3038.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB_LIB::CRUDConfigurazioneGenerale] Exception [" + se.getMessage() + "].",se);
  3039.         } finally {
  3040.             JDBCUtilities.closeResources(selectRS, selectStmt);
  3041.             JDBCUtilities.closeResources(updateStmt);
  3042.         }
  3043.     }

  3044.    
  3045. }