DriverControlStationDB.java

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


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

  21. import java.sql.Connection;
  22. import java.sql.Date;
  23. import java.sql.PreparedStatement;
  24. import java.sql.ResultSet;
  25. import java.sql.SQLException;
  26. import java.util.ArrayList;
  27. import java.util.List;
  28. import java.util.Map;
  29. import java.util.Properties;

  30. import javax.sql.DataSource;

  31. import org.openspcoop2.core.allarmi.Allarme;
  32. import org.openspcoop2.core.allarmi.AllarmeHistory;
  33. import org.openspcoop2.core.allarmi.constants.RuoloPorta;
  34. import org.openspcoop2.core.allarmi.constants.TipoAllarme;
  35. import org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils;
  36. import org.openspcoop2.core.commons.DBUtils;
  37. import org.openspcoop2.core.commons.ErrorsHandlerCostant;
  38. import org.openspcoop2.core.commons.ISearch;
  39. import org.openspcoop2.core.commons.Liste;
  40. import org.openspcoop2.core.commons.search.utils.RegistroCore;
  41. import org.openspcoop2.core.config.Proprieta;
  42. import org.openspcoop2.core.config.driver.DriverConfigurazioneException;
  43. import org.openspcoop2.core.config.driver.DriverConfigurazioneNotFound;
  44. import org.openspcoop2.core.config.driver.db.DriverConfigurazioneDB;
  45. import org.openspcoop2.core.constants.CostantiDB;
  46. import org.openspcoop2.core.constants.TipoPdD;
  47. import org.openspcoop2.core.controllo_traffico.AttivazionePolicy;
  48. import org.openspcoop2.core.controllo_traffico.AttivazionePolicyFiltro;
  49. import org.openspcoop2.core.controllo_traffico.AttivazionePolicyRaggruppamento;
  50. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  51. import org.openspcoop2.core.controllo_traffico.ConfigurazionePolicy;
  52. import org.openspcoop2.core.controllo_traffico.beans.InfoPolicy;
  53. import org.openspcoop2.core.controllo_traffico.constants.RuoloPolicy;
  54. import org.openspcoop2.core.controllo_traffico.constants.TipoRisorsaPolicyAttiva;
  55. import org.openspcoop2.core.controllo_traffico.dao.jdbc.JDBCServiceManager;
  56. import org.openspcoop2.core.controllo_traffico.utils.ControlloTrafficoDriverUtils;
  57. import org.openspcoop2.core.id.IDAccordo;
  58. import org.openspcoop2.core.id.IDFruizione;
  59. import org.openspcoop2.core.id.IDGruppo;
  60. import org.openspcoop2.core.id.IDPortType;
  61. import org.openspcoop2.core.id.IDPortTypeAzione;
  62. import org.openspcoop2.core.id.IDPortaApplicativa;
  63. import org.openspcoop2.core.id.IDPortaDelegata;
  64. import org.openspcoop2.core.id.IDResource;
  65. import org.openspcoop2.core.id.IDRuolo;
  66. import org.openspcoop2.core.id.IDScope;
  67. import org.openspcoop2.core.id.IDServizio;
  68. import org.openspcoop2.core.id.IDServizioApplicativo;
  69. import org.openspcoop2.core.id.IDSoggetto;
  70. import org.openspcoop2.core.mapping.DBMappingUtils;
  71. import org.openspcoop2.core.mapping.MappingErogazionePortaApplicativa;
  72. import org.openspcoop2.core.mapping.MappingFruizionePortaDelegata;
  73. import org.openspcoop2.core.plugins.Plugin;
  74. import org.openspcoop2.core.plugins.constants.TipoPlugin;
  75. import org.openspcoop2.core.plugins.utils.PluginsDriverUtils;
  76. import org.openspcoop2.core.plugins.utils.handlers.ConfigurazioneHandlerBean;
  77. import org.openspcoop2.core.plugins.utils.handlers.HandlersDriverUtils;
  78. import org.openspcoop2.core.registry.AccordoCooperazione;
  79. import org.openspcoop2.core.registry.AccordoServizioParteComune;
  80. import org.openspcoop2.core.registry.Soggetto;
  81. import org.openspcoop2.core.registry.driver.DriverRegistroServiziException;
  82. import org.openspcoop2.core.registry.driver.IDAccordoCooperazioneFactory;
  83. import org.openspcoop2.core.registry.driver.IDAccordoFactory;
  84. import org.openspcoop2.core.registry.driver.db.DriverRegistroServiziDB;
  85. import org.openspcoop2.core.registry.driver.db.DriverRegistroServiziDB_LIB;
  86. import org.openspcoop2.generic_project.exception.NotFoundException;
  87. import org.openspcoop2.generic_project.utils.ServiceManagerProperties;
  88. import org.openspcoop2.monitor.engine.alarm.wrapper.ConfigurazioneAllarmeBean;
  89. import org.openspcoop2.monitor.engine.alarm.wrapper.ConfigurazioneAllarmeHistoryBean;
  90. import org.openspcoop2.protocol.engine.archive.UtilitiesMappingFruizioneErogazione;
  91. import org.openspcoop2.protocol.engine.utils.DBOggettiInUsoUtils;
  92. import org.openspcoop2.utils.BooleanNullable;
  93. import org.openspcoop2.utils.jdbc.JDBCUtilities;
  94. import org.openspcoop2.utils.sql.ISQLQueryObject;
  95. import org.openspcoop2.utils.sql.SQLObjectFactory;
  96. import org.openspcoop2.web.ctrlstat.config.ConsoleProperties;
  97. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  98. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  99. import org.openspcoop2.web.ctrlstat.core.ControlStationLogger;
  100. import org.openspcoop2.web.ctrlstat.dao.PdDControlStation;
  101. import org.openspcoop2.web.ctrlstat.dao.SoggettoCtrlStat;
  102. import org.openspcoop2.web.lib.audit.DriverAudit;
  103. import org.openspcoop2.web.lib.audit.DriverAuditDBAppender;
  104. import org.openspcoop2.web.lib.users.DriverUsersDB;
  105. import org.slf4j.Logger;

  106. /**
  107.  * DriverControlStationDB
  108.  *
  109.  * @author Andrea Poli (apoli@link.it)
  110.  * @author Stefano Corallo (corallo@link.it)
  111.  * @author Sandra Giangrandi (sandra@link.it)
  112.  * @author $Author$
  113.  * @version $Rev$, $Date$
  114.  *
  115.  */
  116. public class DriverControlStationDB  {

  117.     private static Logger checkLogger = null;
  118.     private static boolean checkIsClosed = true;
  119.     private static boolean checkAutocommit = true;
  120.     public static boolean isCheckIsClosed() {
  121.         return checkIsClosed;
  122.     }
  123.     public static void setCheckIsClosed(boolean checkIsClosed) {
  124.         DriverControlStationDB.checkIsClosed = checkIsClosed;
  125.     }
  126.     public static boolean isCheckAutocommit() {
  127.         return checkAutocommit;
  128.     }
  129.     public static void setCheckAutocommit(boolean checkAutocommit) {
  130.         DriverControlStationDB.checkAutocommit = checkAutocommit;
  131.     }
  132.     public static Logger getCheckLogger() {
  133.         return checkLogger;
  134.     }
  135.     public static void setCheckLogger(Logger checkLogger) {
  136.         DriverControlStationDB.checkLogger = checkLogger;
  137.     }
  138.    
  139.     /*  F I E L D S P R I V A T I */

  140.     /** Indicazione di una corretta creazione */
  141.     public boolean create = false;

  142.     // Datasource per la connessione al DB
  143.     public DataSource datasource = null;
  144.     public void setDatasource(DataSource datasource) {
  145.         this.datasource = datasource;
  146.     }

  147.     // Connection passata al momento della creazione dell'oggetto
  148.     private Connection globalConnection = null;
  149.     // Variabile di controllo del tipo di operazione da effettuare
  150.     // l'autoCommit viene gestito internamente a questa classe
  151.     private boolean atomica = true;

  152.     /** Logger utilizzato per debug. */
  153.     private org.slf4j.Logger log = null;
  154.     public void logDebug(String msg) {
  155.         if(this.log!=null) {
  156.             this.log.debug(msg);
  157.         }
  158.     }
  159.     public void logDebug(String msg, Exception e) {
  160.         if(this.log!=null) {
  161.             this.log.debug(msg,e);
  162.         }
  163.     }

  164.     // Tipo database passato al momento della creazione dell'oggetto
  165.     private String tipoDB = null;

  166.     /**
  167.      * Questo driver incapsula i driver DriverConfiguarazioneDB e
  168.      * DriverRegistroDB utilizza i loro metodi e ne implementa di nuovi
  169.      */

  170.     private DriverConfigurazioneDB configDB = null;
  171.     private DriverRegistroServiziDB regservDB = null;
  172.     private DriverUsersDB usersDB = null;
  173.     private DriverAudit auditDB = null;
  174.     private DriverAuditDBAppender auditDBappender = null;
  175.     private JDBCServiceManager jdbcServiceManagerControlloTraffico = null;
  176.     private org.openspcoop2.core.plugins.dao.jdbc.JDBCServiceManager jdbcServiceManagerPlugins;
  177.     private org.openspcoop2.core.allarmi.dao.jdbc.JDBCServiceManager jdbcServiceManagerAllarmi;

  178.     private IDAccordoFactory idAccordoFactory = null;
  179. //  @SuppressWarnings("unused")
  180.     private IDAccordoCooperazioneFactory idAccordoCooperazioneFactory = null;
  181.    
  182.     public String getTipoDatabase() {
  183.         return this.tipoDB;
  184.     }

  185.     public DriverConfigurazioneDB getDriverConfigurazioneDB() {
  186.         return this.configDB;
  187.     }

  188.     public DriverRegistroServiziDB getDriverRegistroServiziDB() {
  189.         return this.regservDB;
  190.     }

  191.     public DriverUsersDB getDriverUsersDB() {
  192.         return this.usersDB;
  193.     }

  194.     public DriverAudit getDriverAuditDB() {
  195.         return this.auditDB;
  196.     }

  197.     public DriverAuditDBAppender getDriverAuditDBAppender() {
  198.         return this.auditDBappender;
  199.     }
  200.    
  201.     public JDBCServiceManager getJdbcServiceManagerControlloTraffico() {
  202.         return this.jdbcServiceManagerControlloTraffico;
  203.     }
  204.    
  205.     public org.openspcoop2.core.plugins.dao.jdbc.JDBCServiceManager getJdbcServiceManagerPlugins() {
  206.         return this.jdbcServiceManagerPlugins;
  207.     }
  208.    
  209.     public org.openspcoop2.core.allarmi.dao.jdbc.JDBCServiceManager getJdbcServiceManagerAllarmi() {
  210.         return this.jdbcServiceManagerAllarmi;
  211.     }

  212.     public DriverControlStationDB(Connection connection, Properties context, String tipoDB) throws DriverControlStationException {
  213.         this.log = ControlStationLogger.getDriverDBPddConsoleLogger();

  214.         if (connection == null) {
  215.             this.create = false;
  216.             throw new DriverControlStationException("[DriverControlStationDB::DriverControlStation(Connection con, Properties context, String tipoDB) La connection non puo essere null.");
  217.         }

  218.         if (tipoDB == null) {
  219.             this.create = false;
  220.             throw new DriverControlStationException("[DriverControlStationDB::DriverControlStation(Connection con, Properties context, String tipoDB) Il tipoDatabase non puo essere null.");
  221.         }

  222.         // InitialContext initCtx = new InitialContext(context);
  223.         this.globalConnection = connection;
  224.         this.create = true;
  225.         this.atomica = false;
  226.         this.tipoDB = tipoDB;

  227.         try {
  228.             this.configDB = new DriverConfigurazioneDB(connection, this.tipoDB);
  229.             this.regservDB = new DriverRegistroServiziDB(connection, this.tipoDB);
  230.             boolean useSuperUser = false;
  231.             if(ControlStationCore.isAPIMode()==false) {
  232.                 useSuperUser = !ConsoleProperties.getInstance().isVisibilitaOggettiGlobale();
  233.             }
  234.             this.configDB.setUseSuperUser(useSuperUser);
  235.             this.regservDB.setUseSuperUser(useSuperUser);
  236.             this.usersDB = new DriverUsersDB(connection, this.tipoDB, this.log);
  237.             this.auditDB = new DriverAudit(connection, this.tipoDB);
  238.             this.auditDBappender = new DriverAuditDBAppender(connection, this.tipoDB);
  239.             ServiceManagerProperties properties = new ServiceManagerProperties();
  240.             properties.setDatabaseType(this.tipoDB);
  241.             properties.setShowSql(true);
  242.             this.jdbcServiceManagerControlloTraffico = new org.openspcoop2.core.controllo_traffico.dao.jdbc.JDBCServiceManager(connection, properties, this.log);
  243.             this.jdbcServiceManagerPlugins = new org.openspcoop2.core.plugins.dao.jdbc.JDBCServiceManager(connection, properties, this.log);
  244.             this.jdbcServiceManagerAllarmi = new org.openspcoop2.core.allarmi.dao.jdbc.JDBCServiceManager(connection, properties, this.log);
  245.             this.idAccordoFactory = IDAccordoFactory.getInstance();
  246.             this.idAccordoCooperazioneFactory = IDAccordoCooperazioneFactory.getInstance();
  247.         } catch (Exception e) {
  248.             throw new DriverControlStationException("[DriverControlStationDB::DriverControlStation(Connection con, Properties context, String tipoDB) Errore creando i driver ausiliari.");
  249.         }

  250.         // Setto il tipoDB anche in DriverControlStationDB_LIB
  251.         DriverControlStationDB_LIB.setTipoDB(tipoDB);

  252.         this.log.info("Creato DriverControlStationDB");
  253.     }

  254.    
  255.     private Connection getConnection(String nomeMetodo) throws DriverControlStationException {
  256.         Connection con = null;
  257.         if (this.atomica) {
  258.             try {
  259.                 con = this.datasource.getConnection();
  260.             } catch (SQLException e) {
  261.                 throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] SQLException accedendo al datasource :" + e.getMessage());
  262.             }

  263.         } else {
  264.             con = this.globalConnection;
  265.         }
  266.         return con;
  267.     }
  268.     private Connection getConnection(String nomeMetodo, BooleanNullable setAutoCommit) throws DriverControlStationException {
  269.         Connection con = getConnection(nomeMetodo);
  270.         if (this.atomica) {
  271.             if(setAutoCommit!=null && setAutoCommit.getValue()!=null) {
  272.                 try {
  273.                     con.setAutoCommit(setAutoCommit.getValue());
  274.                 } catch (SQLException e) {
  275.                     throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] SQLException accedendo al datasource :" + e.getMessage());
  276.                 }
  277.             }
  278.         }
  279.         return con;
  280.     }
  281.     private void releaseConnection(Connection con) {
  282.         try {
  283.             if (this.atomica) {
  284.                 this.logDebug("rilascio connessione al db...");
  285.                 JDBCUtilities.closeConnection(checkLogger, con, checkAutocommit, checkIsClosed);
  286.             }
  287.         } catch (Exception e) {
  288.             // ignore exception
  289.         }
  290.     }
  291.    
  292.    
  293.    
  294.     /* ***** PDD **** */
  295.    
  296.     public void createPdDControlStation(PdDControlStation pdd) throws DriverControlStationException {
  297.         String nomeMetodo = "createPdd";

  298.         Connection con = null;
  299.        
  300.         con = getConnection(nomeMetodo);

  301.         this.logDebug("operazione this.atomica = " + this.atomica);

  302.         try {

  303.             DriverControlStationDB_LIB.CRUDPdd(CostantiDB.CREATE, pdd, con);

  304.         } catch (Exception se) {
  305.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  306.         } finally {
  307.             releaseConnection(con);
  308.         }

  309.     }

  310.     public void deletePdDControlStation(PdDControlStation pdd) throws DriverControlStationException {
  311.         String nomeMetodo = "deletePdd";

  312.         Connection con = null;

  313.         con = getConnection(nomeMetodo);

  314.         this.logDebug("operazione this.atomica = " + this.atomica);

  315.         try {

  316.             DriverControlStationDB_LIB.CRUDPdd(CostantiDB.DELETE, pdd, con);

  317.         } catch (Exception se) {
  318.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  319.         } finally {

  320.             releaseConnection(con);
  321.         }

  322.     }

  323.     public void updatePdDControlStation(PdDControlStation pdd) throws DriverControlStationException {
  324.         String nomeMetodo = "updatePdd";

  325.         Connection con = null;

  326.         con = getConnection(nomeMetodo);

  327.         this.logDebug("operazione this.atomica = " + this.atomica);

  328.         try {

  329.             DriverControlStationDB_LIB.CRUDPdd(CostantiDB.UPDATE, pdd, con);

  330.         } catch (Exception se) {
  331.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  332.         } finally {
  333.             releaseConnection(con);
  334.         }

  335.     }
  336.    
  337.     public List<PdDControlStation> pddList(String superuser, ISearch ricerca) throws DriverControlStationException {
  338.         String nomeMetodo = "pddList";
  339.         int idLista = Liste.PDD;
  340.         int offset;
  341.         int limit;
  342.         String search;
  343.         String queryString;

  344.         limit = ricerca.getPageSize(idLista);
  345.         offset = ricerca.getIndexIniziale(idLista);
  346.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));
  347.         ricerca.getSearchString(idLista);

  348.         Connection con = null;
  349.         PreparedStatement stmt = null;
  350.         ResultSet risultato = null;

  351.         con = getConnection(nomeMetodo);

  352.         try {

  353.             if (!search.equals("")) {
  354.                 // query con search
  355.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  356.                 sqlQueryObject.addFromTable(CostantiDB.PDD);
  357.                 sqlQueryObject.addSelectCountField("*", "cont");
  358.                 if (superuser!=null && (!superuser.equals("")))
  359.                     sqlQueryObject.addWhereCondition("superuser = ?");
  360.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  361.                 sqlQueryObject.setANDLogicOperator(true);
  362.                 queryString = sqlQueryObject.createSQLQuery();
  363.             } else {
  364.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  365.                 sqlQueryObject.addFromTable(CostantiDB.PDD);
  366.                 sqlQueryObject.addSelectCountField("*", "cont");
  367.                 if (superuser!=null && (!superuser.equals("")))
  368.                     sqlQueryObject.addWhereCondition("superuser = ?");
  369.                 queryString = sqlQueryObject.createSQLQuery();
  370.             }
  371.             stmt = con.prepareStatement(queryString);
  372.             if (superuser!=null && (!superuser.equals("")))
  373.                 stmt.setString(1, superuser);
  374.             risultato = stmt.executeQuery();
  375.             if (risultato.next()) {
  376.                 ricerca.setNumEntries(idLista, risultato.getInt(1));
  377.             }
  378.             risultato.close();
  379.             stmt.close();

  380.             // ricavo le entries
  381.             if (limit == 0) {
  382.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  383.             }
  384.             if (!search.equals("")) {
  385.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  386.                 sqlQueryObject.addFromTable(CostantiDB.PDD);
  387.                 sqlQueryObject.addSelectField("id");
  388.                 sqlQueryObject.addSelectField("nome");
  389.                 if (superuser!=null && (!superuser.equals("")))
  390.                     sqlQueryObject.addWhereCondition("superuser = ?");
  391.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  392.                 sqlQueryObject.setANDLogicOperator(true);
  393.                 sqlQueryObject.addOrderBy("nome");
  394.                 sqlQueryObject.setSortType(true);
  395.                 sqlQueryObject.setLimit(limit);
  396.                 sqlQueryObject.setOffset(offset);
  397.                 queryString = sqlQueryObject.createSQLQuery();
  398.             } else {
  399.                 // senza search
  400.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  401.                 sqlQueryObject.addFromTable(CostantiDB.PDD);
  402.                 sqlQueryObject.addSelectField("id");
  403.                 sqlQueryObject.addSelectField("nome");
  404.                 if (superuser!=null && (!superuser.equals("")))
  405.                     sqlQueryObject.addWhereCondition("superuser = ?");
  406.                 sqlQueryObject.addOrderBy("nome");
  407.                 sqlQueryObject.setSortType(true);
  408.                 sqlQueryObject.setLimit(limit);
  409.                 sqlQueryObject.setOffset(offset);
  410.                 queryString = sqlQueryObject.createSQLQuery();
  411.             }
  412.             stmt = con.prepareStatement(queryString);
  413.             if (superuser!=null && (!superuser.equals("")))
  414.                 stmt.setString(1, superuser);
  415.             risultato = stmt.executeQuery();

  416.             ArrayList<PdDControlStation> lista = new ArrayList<PdDControlStation>();
  417.             PdDControlStation pdd = null;
  418.             while (risultato.next()) {
  419.                 long id = risultato.getLong("id");
  420.                 pdd = this.getPdDControlStation(id);
  421.                 lista.add(pdd);
  422.             }
  423.             risultato.close();
  424.             stmt.close();

  425.             return lista;

  426.         } catch (Exception se) {

  427.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  428.         } finally {

  429.             // Chiudo statement and resultset
  430.             try {
  431.                 if (risultato != null) {
  432.                     risultato.close();
  433.                 }
  434.             } catch (Exception e) {
  435.                 // ignore
  436.             }
  437.             try {
  438.                 if (stmt != null) {
  439.                     stmt.close();
  440.                 }
  441.             } catch (Exception e) {
  442.                 // ignore
  443.             }

  444.             releaseConnection(con);
  445.         }

  446.     }

  447.     /**
  448.      *
  449.      * @param idPdd
  450.      * @return Pdd
  451.      * @throws DriverControlStationException
  452.      */
  453.     public PdDControlStation getPdDControlStation(long idPdd) throws DriverControlStationException, DriverControlStationNotFound {
  454.         String nomeMetodo = "pddList(long idPdd)";

  455.         String queryString;

  456.         Connection con = null;
  457.         PreparedStatement stmt = null;
  458.         ResultSet risultato = null;

  459.         con = getConnection(nomeMetodo);

  460.         try {

  461.             PdDControlStation pdd = new PdDControlStation();

  462.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  463.             sqlQueryObject.addFromTable(CostantiDB.PDD);
  464.             sqlQueryObject.addSelectField("*");
  465.             sqlQueryObject.addWhereCondition("id = ?");
  466.             queryString = sqlQueryObject.createSQLQuery();
  467.             stmt = con.prepareStatement(queryString);
  468.             stmt.setLong(1, idPdd);
  469.             risultato = stmt.executeQuery();
  470.             if (risultato.next()) {
  471.                 pdd.setId(risultato.getLong("id"));
  472.                 pdd.setNome(risultato.getString("nome"));
  473.                 pdd.setDescrizione(risultato.getString("descrizione"));

  474.                 pdd.setIp(risultato.getString("ip"));
  475.                 pdd.setPorta(risultato.getInt("porta"));
  476.                 pdd.setIpGestione(risultato.getString("ip_gestione"));
  477.                 pdd.setPortaGestione(risultato.getInt("porta_gestione"));
  478.                 pdd.setProtocollo(risultato.getString("protocollo"));
  479.                 pdd.setProtocolloGestione(risultato.getString("protocollo_gestione"));

  480.                 pdd.setTipo(risultato.getString("tipo"));
  481.                 pdd.setImplementazione(risultato.getString("implementazione"));

  482.                 pdd.setPassword(risultato.getString("password"));
  483.                 pdd.setSubject(risultato.getString("subject"));
  484.                 pdd.setClientAuth(DriverRegistroServiziDB_LIB.getEnumStatoFunzionalita(risultato.getString("client_auth")));

  485.                 // Ora Registrazione
  486.                 if (risultato.getTimestamp("ora_registrazione") != null) {
  487.                     pdd.setOraRegistrazione(new Date(risultato.getTimestamp("ora_registrazione").getTime()));
  488.                 }

  489.                 pdd.setSuperUser(risultato.getString("superuser"));

  490.             } else {
  491.                 throw new DriverControlStationNotFound("Porta di dominio con id " + idPdd + " non trovata.");
  492.             }

  493.             risultato.close();
  494.             stmt.close();

  495.             return pdd;

  496.         } catch (DriverControlStationNotFound e) {
  497.             throw e;
  498.         } catch (Exception se) {

  499.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  500.         } finally {
  501.             // Chiudo statement and resultset
  502.             try {
  503.                 if (risultato != null) {
  504.                     risultato.close();
  505.                 }
  506.             } catch (Exception e) {
  507.                 // ignore
  508.             }
  509.             try {
  510.                 if (stmt != null) {
  511.                     stmt.close();
  512.                 }
  513.             } catch (Exception e) {
  514.                 // ignore
  515.             }
  516.             releaseConnection(con);
  517.         }

  518.     }

  519.     public List<org.openspcoop2.core.config.Soggetto> pddSoggettiList(long idPdd, ISearch ricerca) throws DriverControlStationException {
  520.         String nomeMetodo = "pddSoggettiList";
  521.         int idLista = Liste.PDD_SOGGETTI;
  522.         int offset;
  523.         int limit;
  524.         String search;
  525.         String queryString;

  526.         limit = ricerca.getPageSize(idLista);
  527.         offset = ricerca.getIndexIniziale(idLista);
  528.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));
  529.         ricerca.getSearchString(idLista);

  530.         Connection con = null;
  531.         PreparedStatement stmt = null;
  532.         ResultSet risultato = null;

  533.         con = getConnection(nomeMetodo);

  534.         ArrayList<org.openspcoop2.core.config.Soggetto> lista = null;

  535.         try {

  536.             // Prendo il nome del pdd
  537.             String nomePdd = "";
  538.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  539.             sqlQueryObject.addFromTable(CostantiDB.PDD);
  540.             sqlQueryObject.addSelectField("*");
  541.             sqlQueryObject.addWhereCondition("id = ?");
  542.             queryString = sqlQueryObject.createSQLQuery();
  543.             stmt = con.prepareStatement(queryString);
  544.             stmt.setLong(1, idPdd);
  545.             risultato = stmt.executeQuery();
  546.             if (risultato.next()) {
  547.                 nomePdd = risultato.getString("nome");
  548.             }
  549.             risultato.close();
  550.             stmt.close();

  551.             if (!search.equals("")) {
  552.                 // query con search
  553.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  554.                 sqlQueryObject.addFromTable(CostantiDB.SOGGETTI);
  555.                 sqlQueryObject.addSelectCountField("*", "cont");
  556.                 sqlQueryObject.addWhereCondition("server = ?");
  557.                 sqlQueryObject.addWhereCondition(false, sqlQueryObject.getWhereLikeCondition("nome_soggetto", search, true, true), sqlQueryObject.getWhereLikeCondition("tipo_soggetto", search, true, true));
  558.                 sqlQueryObject.setANDLogicOperator(true);
  559.                 queryString = sqlQueryObject.createSQLQuery();
  560.             } else {
  561.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  562.                 sqlQueryObject.addFromTable(CostantiDB.SOGGETTI);
  563.                 sqlQueryObject.addSelectCountField("*", "cont");
  564.                 sqlQueryObject.addWhereCondition("server = ?");
  565.                 queryString = sqlQueryObject.createSQLQuery();
  566.             }
  567.             stmt = con.prepareStatement(queryString);
  568.             stmt.setString(1, nomePdd);
  569.             risultato = stmt.executeQuery();
  570.             if (risultato.next()) {
  571.                 ricerca.setNumEntries(idLista, risultato.getInt(1));
  572.             }
  573.             risultato.close();
  574.             stmt.close();

  575.             // ricavo le entries
  576.             if (limit == 0) {
  577.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  578.             }
  579.             if (!search.equals("")) {
  580.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  581.                 sqlQueryObject.addFromTable(CostantiDB.SOGGETTI);
  582.                 sqlQueryObject.addSelectField("server");
  583.                 sqlQueryObject.addSelectField("nome_soggetto");
  584.                 sqlQueryObject.addSelectField("tipo_soggetto");
  585.                 sqlQueryObject.addSelectField("id");
  586.                 sqlQueryObject.addSelectField("descrizione");
  587.                 sqlQueryObject.addSelectField("identificativo_porta");
  588.                 sqlQueryObject.addWhereCondition("server = ?");
  589.                 sqlQueryObject.addWhereCondition(false, sqlQueryObject.getWhereLikeCondition("nome_soggetto", search, true, true), sqlQueryObject.getWhereLikeCondition("tipo_soggetto", search, true, true));
  590.                 sqlQueryObject.setANDLogicOperator(true);
  591.                 sqlQueryObject.addOrderBy("tipo_soggetto");
  592.                 sqlQueryObject.addOrderBy("nome_soggetto");
  593.                 sqlQueryObject.setSortType(true);
  594.                 sqlQueryObject.setLimit(limit);
  595.                 sqlQueryObject.setOffset(offset);
  596.                 queryString = sqlQueryObject.createSQLQuery();
  597.             } else {
  598.                 // senza search
  599.                 sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  600.                 sqlQueryObject.addFromTable(CostantiDB.SOGGETTI);
  601.                 sqlQueryObject.addSelectField("server");
  602.                 sqlQueryObject.addSelectField("nome_soggetto");
  603.                 sqlQueryObject.addSelectField("tipo_soggetto");
  604.                 sqlQueryObject.addSelectField("id");
  605.                 sqlQueryObject.addSelectField("descrizione");
  606.                 sqlQueryObject.addSelectField("identificativo_porta");
  607.                 sqlQueryObject.addWhereCondition("server = ?");
  608.                 sqlQueryObject.addOrderBy("tipo_soggetto");
  609.                 sqlQueryObject.addOrderBy("nome_soggetto");
  610.                 sqlQueryObject.setSortType(true);
  611.                 sqlQueryObject.setLimit(limit);
  612.                 sqlQueryObject.setOffset(offset);
  613.                 queryString = sqlQueryObject.createSQLQuery();
  614.             }
  615.             stmt = con.prepareStatement(queryString);
  616.             stmt.setString(1, nomePdd);
  617.             risultato = stmt.executeQuery();

  618.             lista = new ArrayList<org.openspcoop2.core.config.Soggetto>();
  619.             org.openspcoop2.core.config.Soggetto sog = null;
  620.             while (risultato.next()) {
  621.                 sog = new org.openspcoop2.core.config.Soggetto();

  622.                 sog.setId(risultato.getLong("id"));
  623.                 sog.setNome(risultato.getString("nome_soggetto"));
  624.                 sog.setTipo(risultato.getString("tipo_soggetto"));
  625.                 sog.setDescrizione(risultato.getString("descrizione"));
  626.                 sog.setIdentificativoPorta(risultato.getString("identificativo_porta"));

  627.                 lista.add(sog);
  628.             }

  629.             return lista;

  630.         } catch (Exception se) {

  631.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  632.         } finally {
  633.             // Chiudo statement and resultset
  634.             try {
  635.                 if (risultato != null) {
  636.                     risultato.close();
  637.                 }
  638.             } catch (Exception e) {
  639.                 // ignore
  640.             }
  641.             try {
  642.                 if (stmt != null) {
  643.                     stmt.close();
  644.                 }
  645.             } catch (Exception e) {
  646.                 // ignore
  647.             }
  648.             releaseConnection(con);
  649.         }

  650.     }


  651.     /**
  652.      * Ritorna una Porta di Dominio tramite il parametro passato
  653.      *
  654.      * @param nomePdd
  655.      * @return Pdd se esiste una Porta di Dominio con il nome passato, null
  656.      *         altrimenti
  657.      * @throws DriverControlStationException
  658.      */
  659.     public PdDControlStation getPdDControlStation(String nomePdd) throws DriverControlStationException, DriverControlStationNotFound {
  660.         String nomeMetodo = "pddList(String nomePdd)";

  661.         String queryString;

  662.         Connection con = null;
  663.         PreparedStatement stmt = null;
  664.         ResultSet risultato = null;

  665.         con = getConnection(nomeMetodo);

  666.         try {

  667.             PdDControlStation pdd = null;

  668.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  669.             sqlQueryObject.addFromTable(CostantiDB.PDD);
  670.             sqlQueryObject.addSelectField("*");
  671.             sqlQueryObject.addWhereCondition("nome = ?");
  672.             queryString = sqlQueryObject.createSQLQuery();
  673.             stmt = con.prepareStatement(queryString);
  674.             stmt.setString(1, nomePdd);
  675.             risultato = stmt.executeQuery();
  676.             if (risultato.next()) {
  677.                 long id = risultato.getLong("id");
  678.                 pdd = this.getPdDControlStation(id);
  679.             } else {
  680.                 throw new DriverControlStationNotFound("Porta di dominio con nome " + nomePdd + " non trovata.");
  681.             }

  682.             risultato.close();
  683.             stmt.close();

  684.             return pdd;

  685.         } catch (DriverControlStationNotFound e) {
  686.             throw e;
  687.         } catch (Exception se) {

  688.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  689.         } finally {
  690.             // Chiudo statement and resultset
  691.             try {
  692.                 if (risultato != null) {
  693.                     risultato.close();
  694.                 }
  695.             } catch (Exception e) {
  696.                 // ignore
  697.             }
  698.             try {
  699.                 if (stmt != null) {
  700.                     stmt.close();
  701.                 }
  702.             } catch (Exception e) {
  703.                 // ignore
  704.             }
  705.             releaseConnection(con);
  706.         }
  707.     }
  708.    
  709.     public List<SoggettoCtrlStat> soggettiWithServer(String nomePdD) throws DriverControlStationException {
  710.         Connection con = null;
  711.         PreparedStatement stmt = null;
  712.         ResultSet risultato = null;
  713.         String queryString = "";

  714.         String nomeMetodo = "soggettiWithServer";
  715.         con = getConnection(nomeMetodo);

  716.         this.logDebug("operazione this.atomica = " + this.atomica);

  717.         try {
  718.             SoggettoCtrlStat scs = null;
  719.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  720.             sqlQueryObject.addFromTable(CostantiDB.SOGGETTI);
  721.             sqlQueryObject.addSelectField("*");
  722.             sqlQueryObject.addWhereCondition("server=?");
  723.             queryString = sqlQueryObject.createSQLQuery();
  724.             stmt = con.prepareStatement(queryString);
  725.             stmt.setString(1, nomePdD);
  726.             List<SoggettoCtrlStat> scsList = new ArrayList<SoggettoCtrlStat>();
  727.             risultato = stmt.executeQuery();
  728.             while (risultato.next()) {
  729.                 org.openspcoop2.core.config.Soggetto soggConf = this.getDriverConfigurazioneDB().getSoggetto(risultato.getLong("id"));
  730.                 org.openspcoop2.core.registry.Soggetto soggReg = this.getDriverRegistroServiziDB().getSoggetto(risultato.getLong("id"));
  731.                 scs = new SoggettoCtrlStat(soggReg, soggConf);
  732.                 scsList.add(scs);
  733.             }
  734.             risultato.close();
  735.             stmt.close();

  736.             return scsList;

  737.         } catch (Exception se) {
  738.             throw new DriverControlStationException(se);
  739.         } finally {
  740.             // Chiudo statement and resultset
  741.             try {
  742.                 if (risultato != null) {
  743.                     risultato.close();
  744.                 }
  745.             } catch (Exception e) {
  746.                 // ignore
  747.             }
  748.             try {
  749.                 if (stmt != null) {
  750.                     stmt.close();
  751.                 }
  752.             } catch (Exception e) {
  753.                 // ignore
  754.             }
  755.             releaseConnection(con);
  756.         }
  757.     }

  758.    
  759.    
  760.    
  761.    
  762.    
  763.    
  764.    
  765.    
  766.     /* ***** MAPPING **** */
  767.    
  768.     public void createMappingFruizionePortaDelegata(MappingFruizionePortaDelegata mapping) throws DriverControlStationException {
  769.         String nomeMetodo = "createMappingFruizionePortaDelegata";

  770.         Connection con = null;

  771.         con = getConnection(nomeMetodo);

  772.         this.logDebug("operazione this.atomica = " + this.atomica);

  773.         try {

  774.             DBMappingUtils.createMappingFruizione(mapping.getNome(), mapping.getDescrizione(), mapping.isDefault(), mapping.getIdServizio(), mapping.getIdFruitore(), mapping.getIdPortaDelegata(), con, this.tipoDB);

  775.         } catch (Exception se) {
  776.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  777.         } finally {
  778.             releaseConnection(con);
  779.         }

  780.         mapping.setTableId(this.getTableIdMappingFruizionePortaDelegata(mapping));
  781.     }
  782.    
  783.     public void deleteMappingFruizionePortaDelegata(MappingFruizionePortaDelegata mapping) throws DriverControlStationException {
  784.         String nomeMetodo = "deleteMappingFruizionePortaDelegata";

  785.         Connection con = null;

  786.         con = getConnection(nomeMetodo);

  787.         this.logDebug("operazione this.atomica = " + this.atomica);

  788.         try {

  789.             DBMappingUtils.deleteMappingFruizione(mapping.getIdServizio(), mapping.getIdFruitore(), mapping.getIdPortaDelegata(), con, this.tipoDB);

  790.         } catch (Exception se) {
  791.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  792.         } finally {
  793.             releaseConnection(con);
  794.         }

  795.     }
  796.    
  797.     public IDPortaDelegata getIDPortaDelegataAssociataDefault(IDServizio idServizio,IDSoggetto idFruitore) throws DriverControlStationException {
  798.         String nomeMetodo = "getIDPortaDelegataAssociataDefault";

  799.         Connection con = null;

  800.         con = getConnection(nomeMetodo);

  801.         this.logDebug("operazione this.atomica = " + this.atomica);

  802.         try {

  803.             return DBMappingUtils.getIDPortaDelegataAssociataDefault(idServizio, idFruitore, con, this.tipoDB);

  804.         } catch (Exception se) {
  805.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  806.         } finally {
  807.             releaseConnection(con);
  808.         }

  809.     }
  810.    
  811.     public IDPortaDelegata getIDPortaDelegataAssociataAzione(IDServizio idServizio,IDSoggetto idFruitore) throws DriverControlStationException {
  812.         String nomeMetodo = "getIDPortaDelegataAssociataAzione";

  813.         Connection con = null;

  814.         con = getConnection(nomeMetodo);

  815.         this.logDebug("operazione this.atomica = " + this.atomica);

  816.         try {

  817.             return DBMappingUtils.getIDPortaDelegataAssociataAzione(idServizio, idFruitore, con, this.tipoDB);

  818.         } catch (Exception se) {
  819.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  820.         } finally {
  821.             releaseConnection(con);
  822.         }

  823.     }
  824.    
  825.     public List<IDPortaDelegata> getIDPorteDelegateAssociate(IDServizio idServizio,IDSoggetto idFruitore) throws DriverControlStationException {
  826.         String nomeMetodo = "getIDPorteDelegateAssociate";

  827.         Connection con = null;

  828.         con = getConnection(nomeMetodo);

  829.         this.logDebug("operazione this.atomica = " + this.atomica);

  830.         try {

  831.             return DBMappingUtils.getIDPorteDelegateAssociate(idServizio, idFruitore, con, this.tipoDB);

  832.         } catch (Exception se) {
  833.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  834.         } finally {
  835.             releaseConnection(con);
  836.         }

  837.     }
  838.    
  839.     public long getTableIdMappingFruizionePortaDelegata(MappingFruizionePortaDelegata mapping) throws DriverControlStationException {
  840.         String nomeMetodo = "getTableIdMappingFruizionePortaDelegata";

  841.         Connection con = null;

  842.         con = getConnection(nomeMetodo);

  843.         this.logDebug("operazione this.atomica = " + this.atomica);

  844.         try {

  845.             return DBMappingUtils.getTableIdMappingFruizione(mapping.getIdServizio(), mapping.getIdFruitore(), mapping.getIdPortaDelegata(), con, this.tipoDB);

  846.         } catch (Exception se) {
  847.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  848.         } finally {
  849.             releaseConnection(con);
  850.         }

  851.     }
  852.    
  853.     public boolean existsMappingFruizionePortaDelegata(MappingFruizionePortaDelegata mapping) throws DriverControlStationException {
  854.         String nomeMetodo = "existsMappingFruizionePortaDelegata";

  855.         Connection con = null;

  856.         con = getConnection(nomeMetodo);

  857.         this.logDebug("operazione this.atomica = " + this.atomica);

  858.         try {

  859.             return DBMappingUtils.existsMappingFruizione(mapping.getIdServizio(), mapping.getIdFruitore(), mapping.getIdPortaDelegata(), con, this.tipoDB);

  860.         } catch (Exception se) {
  861.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  862.         } finally {
  863.             releaseConnection(con);
  864.         }

  865.     }
  866.    
  867.    
  868.     public void createMappingErogazionePortaApplicativa(MappingErogazionePortaApplicativa mapping) throws DriverControlStationException {
  869.         String nomeMetodo = "createMappingErogazionePortaApplicativa";

  870.         Connection con = null;

  871.         con = getConnection(nomeMetodo);

  872.         this.logDebug("operazione this.atomica = " + this.atomica);

  873.         try {

  874.             DBMappingUtils.createMappingErogazione(mapping.getNome(), mapping.getDescrizione(), mapping.isDefault(), mapping.getIdServizio(), mapping.getIdPortaApplicativa(), con, this.tipoDB);

  875.         } catch (Exception se) {
  876.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  877.         } finally {
  878.             releaseConnection(con);
  879.         }

  880.         mapping.setTableId(mapping.getTableId());
  881.     }
  882.    
  883.    
  884.     public void deleteMappingErogazionePortaApplicativa(MappingErogazionePortaApplicativa mapping) throws DriverControlStationException {
  885.         String nomeMetodo = "deleteMappingErogazionePortaApplicativa";

  886.         Connection con = null;

  887.         con = getConnection(nomeMetodo);

  888.         this.logDebug("operazione this.atomica = " + this.atomica);

  889.         try {

  890.             DBMappingUtils.deleteMappingErogazione(mapping.getIdServizio(), mapping.getIdPortaApplicativa(), con, this.tipoDB);

  891.         } catch (Exception se) {
  892.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  893.         } finally {
  894.             releaseConnection(con);
  895.         }

  896.     }
  897.    
  898.     public IDPortaApplicativa getIDPortaApplicativaAssociataDefault(IDServizio idServizio) throws DriverControlStationException {
  899.         String nomeMetodo = "getIDPortaApplicativaAssociataDefault";

  900.         Connection con = null;

  901.         con = getConnection(nomeMetodo);

  902.         this.logDebug("operazione this.atomica = " + this.atomica);

  903.         try {

  904.             return DBMappingUtils.getIDPortaApplicativaAssociataDefault(idServizio, con, this.tipoDB);

  905.         } catch (Exception se) {
  906.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  907.         } finally {
  908.             releaseConnection(con);
  909.         }

  910.     }
  911.    
  912.     public IDPortaApplicativa getIDPortaApplicativaAssociataAzione(IDServizio idServizio) throws DriverControlStationException {
  913.         String nomeMetodo = "getIDPortaApplicativaAssociataAzione";

  914.         Connection con = null;

  915.         con = getConnection(nomeMetodo);

  916.         this.logDebug("operazione this.atomica = " + this.atomica);

  917.         try {

  918.             return DBMappingUtils.getIDPortaApplicativaAssociataAzione(idServizio, con, this.tipoDB);

  919.         } catch (Exception se) {
  920.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  921.         } finally {
  922.             releaseConnection(con);
  923.         }

  924.     }
  925.    
  926.     public List<IDPortaApplicativa> getIDPorteApplicativeAssociate(IDServizio idServizio) throws DriverControlStationException {
  927.         String nomeMetodo = "getIDPorteApplicativeAssociate";

  928.         Connection con = null;

  929.         con = getConnection(nomeMetodo);

  930.         this.logDebug("operazione this.atomica = " + this.atomica);

  931.         try {

  932.             return DBMappingUtils.getIDPorteApplicativeAssociate(idServizio, con, this.tipoDB);

  933.         } catch (Exception se) {
  934.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  935.         } finally {
  936.             releaseConnection(con);
  937.         }

  938.     }
  939.    
  940.     public long getTableIdMappingErogazionePortaApplicativa(MappingErogazionePortaApplicativa mapping) throws DriverControlStationException {
  941.         String nomeMetodo = "getTableIdMappingErogazionePortaApplicativa";

  942.         Connection con = null;

  943.         con = getConnection(nomeMetodo);

  944.         this.logDebug("operazione this.atomica = " + this.atomica);

  945.         try {

  946.             return DBMappingUtils.getTableIdMappingErogazione(mapping.getIdServizio(), mapping.getIdPortaApplicativa(), con, this.tipoDB);

  947.         } catch (Exception se) {
  948.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  949.         } finally {
  950.             releaseConnection(con);
  951.         }

  952.     }
  953.    
  954.     public boolean existsMappingErogazionePortaApplicativa(MappingErogazionePortaApplicativa mapping) throws DriverControlStationException {
  955.         String nomeMetodo = "existsMappingErogazionePortaApplicativa";

  956.         Connection con = null;

  957.         con = getConnection(nomeMetodo);

  958.         this.logDebug("operazione this.atomica = " + this.atomica);

  959.         try {

  960.             return DBMappingUtils.existsMappingErogazione(mapping.getIdServizio(), mapping.getIdPortaApplicativa(), con, this.tipoDB);

  961.         } catch (Exception se) {
  962.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  963.         } finally {
  964.             releaseConnection(con);
  965.         }

  966.     }
  967.    
  968.     private void initMappingErogazione_releaseConnectionGestioneErrore(boolean error, Connection con) {
  969.         try {
  970.             if (error && this.atomica) {
  971.                 this.logDebug("eseguo rollback a causa di errori e rilascio connessioni...");
  972.                 if(con!=null) {
  973.                     con.rollback();
  974.                     con.setAutoCommit(true);
  975.                     JDBCUtilities.closeConnection(checkLogger, con, checkAutocommit, checkIsClosed);
  976.                 }

  977.             } else if (!error && this.atomica) {
  978.                 this.logDebug("eseguo commit e rilascio connessioni...");
  979.                 if(con!=null) {
  980.                     con.commit();
  981.                     con.setAutoCommit(true);
  982.                     JDBCUtilities.closeConnection(checkLogger, con, checkAutocommit, checkIsClosed);
  983.                 }
  984.             }
  985.         } catch (Exception e) {
  986.             // ignore exception
  987.         }
  988.     }
  989.    
  990.     public void initMappingErogazione(Logger log) throws DriverControlStationException {
  991.         this._initMapping(true,false,log);
  992.     }  
  993.     public void initMappingErogazione(boolean forceMapping, Logger log) throws DriverControlStationException {
  994.         this._initMapping(true,forceMapping,log);
  995.     }
  996.     public void initMappingFruizione(Logger log) throws DriverControlStationException {
  997.         this._initMapping(false,false,log);
  998.     }  
  999.     public void initMappingFruizione(boolean forceMapping, Logger log) throws DriverControlStationException {
  1000.         this._initMapping(false,forceMapping,log);
  1001.     }  
  1002.     private void _initMapping(boolean erogazione, boolean forceMapping, Logger log) throws DriverControlStationException {
  1003.         String nomeMetodo = "initMappingErogazione";
  1004.         if(!erogazione){
  1005.             nomeMetodo = "initMappingFruizione";
  1006.         }

  1007.         Connection con = null;
  1008.         boolean error = false;

  1009.         con = getConnection(nomeMetodo, BooleanNullable.FALSE());

  1010.         log.debug("operazione this.atomica = " + this.atomica);

  1011.         try {

  1012.             int countMapping = -1;
  1013.             if(erogazione){
  1014.                 countMapping = DBMappingUtils.countMappingErogazione(con, this.tipoDB);
  1015.             }
  1016.             else{
  1017.                 countMapping = DBMappingUtils.countMappingFruizione(con, this.tipoDB);
  1018.             }
  1019.             log.debug("Count ["+nomeMetodo+"]: "+countMapping);
  1020.             if(countMapping<=0 || forceMapping){
  1021.                
  1022.                 log.debug("Controllo Consistenza Dati ["+nomeMetodo+"] ...");
  1023.                
  1024.                 DriverRegistroServiziDB driverRegistry = new DriverRegistroServiziDB(con, this.tipoDB);
  1025.                 DriverConfigurazioneDB driverConfig = new DriverConfigurazioneDB(con, this.tipoDB);
  1026.                
  1027.                 UtilitiesMappingFruizioneErogazione utilities = new UtilitiesMappingFruizioneErogazione(driverConfig, driverRegistry, log);
  1028.                 if(erogazione){
  1029.                     utilities.initMappingErogazione();
  1030.                 }else{
  1031.                     utilities.initMappingFruizione();
  1032.                 }
  1033.    
  1034.                 log.debug("Controllo Consistenza Dati ["+nomeMetodo+"] terminato");
  1035.             }          
  1036.            
  1037.         } catch (Throwable se) {
  1038.             log.error("Controllo Consistenza Dati ["+nomeMetodo+"] terminato con errore: "+se.getMessage(),se);
  1039.             error = true;
  1040.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1041.         } finally {
  1042.             initMappingErogazione_releaseConnectionGestioneErrore(error, con);
  1043.         }

  1044.     }
  1045.    
  1046.    
  1047.    
  1048.    
  1049.    
  1050.    
  1051.    
  1052.    
  1053.    
  1054.    
  1055.    
  1056.    
  1057.    
  1058.     /* *********** DB UTILS ****************** */
  1059.    
  1060.     public long getTableIdSoggetto(IDSoggetto idSoggetto) throws DriverControlStationException {
  1061.         String nomeMetodo = "getTableIdSoggetto";

  1062.         Connection con = null;

  1063.         con = getConnection(nomeMetodo);

  1064.         this.logDebug("operazione this.atomica = " + this.atomica);

  1065.         try {

  1066.             return DBUtils.getIdSoggetto(idSoggetto.getNome(), idSoggetto.getTipo(), con, this.tipoDB);

  1067.         } catch (Exception se) {
  1068.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1069.         } finally {
  1070.             releaseConnection(con);
  1071.         }

  1072.     }
  1073.    
  1074.     public long getTableIdAccordoServizioParteSpecifica(IDServizio idAccordoServizioParteSpecifica) throws DriverControlStationException {
  1075.         String nomeMetodo = "getTableIdAccordoServizioParteSpecifica";

  1076.         Connection con = null;

  1077.         con = getConnection(nomeMetodo);

  1078.         this.logDebug("operazione this.atomica = " + this.atomica);

  1079.         try {

  1080.             return DBUtils.getIdAccordoServizioParteSpecifica(idAccordoServizioParteSpecifica, con, this.tipoDB);

  1081.         } catch (Exception se) {
  1082.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1083.         } finally {
  1084.             releaseConnection(con);
  1085.         }

  1086.     }
  1087.    
  1088.     public long getTableIdPortaDelegata(IDPortaDelegata idPD) throws DriverControlStationException {
  1089.         String nomeMetodo = "getTableIdPortaDelegata";

  1090.         Connection con = null;

  1091.         con = getConnection(nomeMetodo);

  1092.         this.logDebug("operazione this.atomica = " + this.atomica);

  1093.         try {

  1094.             return DBUtils.getIdPortaDelegata(idPD.getNome(), con, this.tipoDB);

  1095.         } catch (Exception se) {
  1096.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1097.         } finally {
  1098.             releaseConnection(con);
  1099.         }
  1100.        
  1101.     }
  1102.    
  1103.     public long getTableIdPortaApplicativa(IDPortaApplicativa idPA) throws DriverControlStationException {
  1104.         String nomeMetodo = "getTableIdPortaApplicativa";

  1105.         Connection con = null;

  1106.         con = getConnection(nomeMetodo);

  1107.         this.logDebug("operazione this.atomica = " + this.atomica);

  1108.         try {

  1109.             return DBUtils.getIdPortaApplicativa(idPA.getNome(), con, this.tipoDB);

  1110.         } catch (Exception se) {
  1111.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1112.         } finally {
  1113.             releaseConnection(con);
  1114.         }

  1115.     }
  1116.    
  1117.    
  1118.    
  1119.    
  1120.    
  1121.    
  1122.    
  1123.    
  1124.    
  1125.    
  1126.    
  1127.    
  1128.    
  1129.    
  1130.    
  1131.    
  1132.    
  1133.    
  1134.    
  1135.    
  1136.    
  1137.     /* *********** METODI IS IN USO ****************** */

  1138.     public boolean isAccordoInUso(IDAccordo idAccordo, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  1139.         String nomeMetodo = "isAccordoInUso";

  1140.         Connection con = null;

  1141.         con = getConnection(nomeMetodo);

  1142.         try {
  1143.             return DBOggettiInUsoUtils.isAccordoServizioParteComuneInUso(con, this.tipoDB, idAccordo, whereIsInUso, normalizeObjectIds);

  1144.         } catch (Exception se) {
  1145.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1146.         } finally {
  1147.             releaseConnection(con);
  1148.         }
  1149.        
  1150.     }
  1151.    
  1152.     public boolean isAccordoInUso(AccordoServizioParteComune as, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  1153.         String nomeMetodo = "isAccordoInUso";

  1154.         Connection con = null;

  1155.         con = getConnection(nomeMetodo);

  1156.         try {
  1157.             return DBOggettiInUsoUtils.isAccordoServizioParteComuneInUso(con, this.tipoDB, this.idAccordoFactory.getIDAccordoFromAccordo(as), whereIsInUso, normalizeObjectIds);

  1158.         } catch (Exception se) {
  1159.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1160.         } finally {
  1161.             releaseConnection(con);
  1162.         }
  1163.        
  1164.     }
  1165.    
  1166.     public boolean isAccordoCooperazioneInUso(AccordoCooperazione as, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  1167.         String nomeMetodo = "isAccordoCooperazioneInUso";

  1168.         Connection con = null;

  1169.         con = getConnection(nomeMetodo);

  1170.         try {
  1171.             return DBOggettiInUsoUtils.isAccordoCooperazioneInUso(con, this.tipoDB, this.idAccordoCooperazioneFactory.getIDAccordoFromAccordo(as), whereIsInUso, normalizeObjectIds);

  1172.         } catch (Exception se) {
  1173.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1174.         } finally {
  1175.             releaseConnection(con);
  1176.         }
  1177.        
  1178.     }

  1179.     public boolean isPddInUso(PdDControlStation pdd, List<String> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  1180.         String nomeMetodo = "pddInUso";

  1181.         Connection con = null;
  1182.        
  1183.         con = getConnection(nomeMetodo);

  1184.         try {

  1185.             return DBOggettiInUsoUtils.isPddInUso(con, this.tipoDB, pdd.getNome(), whereIsInUso, normalizeObjectIds);

  1186.         } catch (Exception se) {
  1187.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1188.         } finally {
  1189.             releaseConnection(con);
  1190.         }
  1191.     }

  1192.     public boolean isSoggettoInUso(org.openspcoop2.core.config.Soggetto soggettoConfig, Map<ErrorsHandlerCostant, List<String>> whereIsInUso,
  1193.             boolean normalizeObjectIds, boolean verificaRuoli) throws DriverControlStationException {
  1194.         return isSoggettoInUso(soggettoConfig,null,whereIsInUso, normalizeObjectIds, verificaRuoli);
  1195.     }
  1196.     public boolean isSoggettoInUso(Soggetto soggettoRegistro, Map<ErrorsHandlerCostant, List<String>> whereIsInUso,
  1197.             boolean normalizeObjectIds, boolean verificaRuoli) throws DriverControlStationException {
  1198.         return isSoggettoInUso(null,soggettoRegistro,whereIsInUso, normalizeObjectIds, verificaRuoli);
  1199.     }
  1200.     private boolean isSoggettoInUso(org.openspcoop2.core.config.Soggetto soggettoConfig, Soggetto soggettoRegistro, Map<ErrorsHandlerCostant, List<String>> whereIsInUso,
  1201.             boolean normalizeObjectIds, boolean verificaRuoli) throws DriverControlStationException {
  1202.         String nomeMetodo = "isSoggettoInUso";

  1203.         Connection con = null;
  1204.         con = getConnection(nomeMetodo);

  1205.         this.logDebug("operazione this.atomica = " + this.atomica);

  1206.         try {

  1207.             String tipoSoggetto = null;
  1208.             String nomeSoggetto = null;
  1209.             if(soggettoRegistro!=null){
  1210.                 tipoSoggetto = soggettoRegistro.getTipo();
  1211.                 nomeSoggetto = soggettoRegistro.getNome();
  1212.             }else{
  1213.                 tipoSoggetto = soggettoConfig.getTipo();
  1214.                 nomeSoggetto = soggettoConfig.getNome();
  1215.             }
  1216.             IDSoggetto idSoggetto = new IDSoggetto(tipoSoggetto, nomeSoggetto);
  1217.            
  1218.             if(soggettoRegistro!=null){
  1219.                
  1220.                 return DBOggettiInUsoUtils.isSoggettoRegistryInUso(con, this.tipoDB, idSoggetto, true, whereIsInUso, normalizeObjectIds, verificaRuoli);
  1221.            
  1222.             }
  1223.             else{
  1224.                
  1225.                 return DBOggettiInUsoUtils.isSoggettoConfigInUso(con, this.tipoDB, idSoggetto, true, whereIsInUso, normalizeObjectIds, verificaRuoli);
  1226.                
  1227.             }

  1228.         } catch (Exception se) {
  1229.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1230.         } finally {
  1231.             releaseConnection(con);
  1232.         }
  1233.     }
  1234.    
  1235.     public boolean isRuoloInUso(IDRuolo idRuolo, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  1236.         String nomeMetodo = "isRuoloInUso";

  1237.         Connection con = null;
  1238.         con = getConnection(nomeMetodo);

  1239.         this.logDebug("operazione this.atomica = " + this.atomica);

  1240.         try {

  1241.             return DBOggettiInUsoUtils.isRuoloInUso(con, this.tipoDB, idRuolo, whereIsInUso, normalizeObjectIds);
  1242.            
  1243.         } catch (Exception se) {
  1244.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1245.         } finally {
  1246.             releaseConnection(con);
  1247.         }
  1248.     }
  1249.    
  1250.     public boolean isRuoloConfigInUso(IDRuolo idRuolo, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  1251.         String nomeMetodo = "isRuoloConfigInUso";

  1252.         Connection con = null;
  1253.         con = getConnection(nomeMetodo);

  1254.         this.logDebug("operazione this.atomica = " + this.atomica);

  1255.         try {

  1256.             return DBOggettiInUsoUtils.isRuoloConfigInUso(con, this.tipoDB, idRuolo, whereIsInUso, normalizeObjectIds);
  1257.            
  1258.         } catch (Exception se) {
  1259.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1260.         } finally {
  1261.             releaseConnection(con);
  1262.         }
  1263.     }

  1264.    
  1265.     public boolean isScopeInUso(IDScope idScope, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  1266.         String nomeMetodo = "isScopeInUso";

  1267.         Connection con = null;
  1268.         con = getConnection(nomeMetodo);

  1269.         this.logDebug("operazione this.atomica = " + this.atomica);

  1270.         try {

  1271.             return DBOggettiInUsoUtils.isScopeInUso(con, this.tipoDB, idScope, whereIsInUso, normalizeObjectIds);
  1272.            
  1273.         } catch (Exception se) {
  1274.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1275.         } finally {
  1276.             releaseConnection(con);
  1277.         }
  1278.     }
  1279.    
  1280.     public boolean isScopeConfigInUso(IDScope idScope, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  1281.         String nomeMetodo = "isScopeConfigInUso";

  1282.         Connection con = null;
  1283.         con = getConnection(nomeMetodo);

  1284.         this.logDebug("operazione this.atomica = " + this.atomica);

  1285.         try {

  1286.             return DBOggettiInUsoUtils.isScopeConfigInUso(con, this.tipoDB, idScope, whereIsInUso, normalizeObjectIds);
  1287.            
  1288.         } catch (Exception se) {
  1289.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1290.         } finally {
  1291.             releaseConnection(con);
  1292.         }
  1293.     }
  1294.    
  1295.    
  1296.    
  1297.    
  1298.    
  1299.    
  1300.    
  1301.    
  1302.    
  1303.    
  1304.    
  1305.    
  1306.     /* *********** METODI EXISTS ****************** */
  1307.    
  1308.     public long existServizio(String nomeServizio, String tipoServizio, int versioneServizio, long idSoggettoErogatore) throws DriverControlStationException {
  1309.         String nomeMetodo = "existServizio";
  1310.        
  1311.         Connection con = null;
  1312.         PreparedStatement stmt = null;
  1313.         ResultSet risultato = null;
  1314.         String queryString;
  1315.        
  1316.         con = getConnection(nomeMetodo);        
  1317.         try {
  1318.        
  1319.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  1320.             sqlQueryObject.addFromTable(CostantiDB.SERVIZI);
  1321.             sqlQueryObject.addSelectField("*");
  1322.             sqlQueryObject.addWhereCondition("id_soggetto = ?");
  1323.             sqlQueryObject.addWhereCondition("nome_servizio = ?");
  1324.             sqlQueryObject.addWhereCondition("tipo_servizio = ?");
  1325.             sqlQueryObject.addWhereCondition("versione_servizio = ?");
  1326.             sqlQueryObject.setANDLogicOperator(true);
  1327.             queryString = sqlQueryObject.createSQLQuery();
  1328.        
  1329.             stmt = con.prepareStatement(queryString);
  1330.             stmt.setLong(1, idSoggettoErogatore);
  1331.             stmt.setString(2, nomeServizio);
  1332.             stmt.setString(3, tipoServizio);
  1333.             stmt.setInt(4, versioneServizio);
  1334.        
  1335.             risultato = stmt.executeQuery();
  1336.             if (risultato.next()) {
  1337.                 return risultato.getLong("id");
  1338.             }
  1339.        
  1340.             return 0;
  1341.         } catch (Exception se) {
  1342.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1343.         } finally {
  1344.             // Chiudo statement and resultset
  1345.             try {
  1346.                 if (risultato != null) {
  1347.                     risultato.close();
  1348.                 }
  1349.             } catch (Exception e) {
  1350.                 // ignore
  1351.             }
  1352.             try {
  1353.                 if (stmt != null) {
  1354.                     stmt.close();
  1355.                 }
  1356.             } catch (Exception e) {
  1357.                 // ignore
  1358.             }
  1359.             releaseConnection(con);
  1360.         }
  1361.     }

  1362.    
  1363.     public long existPdd(String nomePdd) throws DriverControlStationException {
  1364.         String nomeMetodo = "existPdd";

  1365.         Connection con = null;
  1366.         PreparedStatement stmt = null;
  1367.         ResultSet risultato = null;
  1368.         String queryString = "";

  1369.         con = getConnection(nomeMetodo);

  1370.         try {

  1371.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.tipoDB);
  1372.             sqlQueryObject.addFromTable(CostantiDB.PDD);
  1373.             sqlQueryObject.addSelectField("*");
  1374.             sqlQueryObject.addWhereCondition("nome = ?");
  1375.             queryString = sqlQueryObject.createSQLQuery();

  1376.             stmt = con.prepareStatement(queryString);
  1377.             stmt.setString(1, nomePdd);
  1378.             risultato = stmt.executeQuery();
  1379.             if (risultato.next()) {
  1380.                 return risultato.getLong("id");
  1381.             }

  1382.             return 0;
  1383.         } catch (Exception se) {
  1384.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1385.         } finally {
  1386.             // Chiudo statement and resultset
  1387.             try {
  1388.                 if (risultato != null) {
  1389.                     risultato.close();
  1390.                 }
  1391.             } catch (Exception e) {
  1392.                 // ignore
  1393.             }
  1394.             try {
  1395.                 if (stmt != null) {
  1396.                     stmt.close();
  1397.                 }
  1398.             } catch (Exception e) {
  1399.                 // ignore
  1400.             }
  1401.             releaseConnection(con);
  1402.         }
  1403.     }
  1404.    

  1405.     // Controllo Traffico
  1406.        
  1407.     /**
  1408.      * Restituisce la configurazione generale
  1409.      *
  1410.      * @return Configurazione
  1411.      *
  1412.      */
  1413.     public ConfigurazioneGenerale getConfigurazioneControlloTraffico() throws DriverControlStationException,DriverControlStationNotFound {
  1414.         String nomeMetodo = "getConfigurazioneControlloTraffico";
  1415.         // ritorna la configurazione controllo del traffico della PdD
  1416.         Connection con = null;

  1417.         con = getConnection(nomeMetodo);

  1418.         this.logDebug("operazione this.atomica = " + this.atomica);
  1419.         ConfigurazioneGenerale config = null;
  1420.         try {
  1421.             config = ControlloTrafficoDriverUtils.getConfigurazioneControlloTraffico(con, this.log, this.tipoDB);
  1422.         }catch (Exception se) {
  1423.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1424.         } finally {
  1425.             releaseConnection(con);
  1426.         }

  1427.         return config;
  1428.     }

  1429.     /***
  1430.      * Aggiorna la configurazione del controllo del traffico
  1431.      *
  1432.      * @param configurazioneControlloTraffico
  1433.      * @throws DriverControlStationException
  1434.      */
  1435.     public void updateConfigurazioneControlloTraffico(ConfigurazioneGenerale configurazioneControlloTraffico) throws DriverControlStationException {
  1436.         String nomeMetodo = "updateConfigurazioneControlloTraffico";
  1437.         Connection con = null;
  1438.         con = getConnection(nomeMetodo);

  1439.         this.logDebug("operazione this.atomica = " + this.atomica);

  1440.         try {
  1441.             ControlloTrafficoDriverUtils.updateConfigurazioneControlloTraffico(configurazioneControlloTraffico, con, this.log, this.tipoDB);
  1442.         } catch (Exception se) {
  1443.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1444.         } finally {
  1445.             releaseConnection(con);
  1446.         }
  1447.     }
  1448.    
  1449.     public List<Proprieta> getProprietaRateLimiting() throws DriverControlStationException,DriverControlStationNotFound {
  1450.         String nomeMetodo = "getProprietaRateLimiting";
  1451.         // ritorna la configurazione controllo del traffico della PdD
  1452.         Connection con = null;

  1453.         con = getConnection(nomeMetodo);

  1454.         this.logDebug("operazione this.atomica = " + this.atomica);
  1455.         List<Proprieta> l = null;
  1456.         try {
  1457.             l = ControlloTrafficoDriverUtils.getProprietaRateLimiting(con, this.log, this.tipoDB);
  1458.         }catch (Exception se) {
  1459.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1460.         } finally {
  1461.             releaseConnection(con);
  1462.         }

  1463.         return l;
  1464.     }
  1465.    
  1466.     /**
  1467.      * Restituisce il numero di Configurazione Policy
  1468.      *
  1469.      * @return Configurazione
  1470.      *
  1471.      */
  1472.     public long countConfigurazioneControlloTrafficoConfigurazionePolicy(ISearch ricerca) throws DriverControlStationException {
  1473.         String nomeMetodo = "countConfigurazioneControlloTrafficoConfigurazionePolicy";
  1474.         Connection con = null;
  1475.        
  1476.         con = getConnection(nomeMetodo);

  1477.         this.logDebug("operazione this.atomica = " + this.atomica);
  1478.         long count = 0;
  1479.         try {
  1480.             count = ControlloTrafficoDriverUtils.countConfigurazioneControlloTrafficoConfigurazionePolicy(ricerca, con, this.log, this.tipoDB);
  1481.         }catch (Exception se) {
  1482.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1483.         } finally {
  1484.             releaseConnection(con);
  1485.         }

  1486.         return count;
  1487.     }
  1488.    
  1489.     /**
  1490.      * Restituisce il numero di Attivazione Policy
  1491.      *
  1492.      * @return Configurazione
  1493.      *
  1494.      */
  1495.     public long countConfigurazioneControlloTrafficoAttivazionePolicy(ISearch ricerca, RuoloPolicy ruoloPorta, String nomePorta) throws DriverControlStationException {
  1496.         String nomeMetodo = "countConfigurazioneControlloTrafficoAttivazionePolicy";
  1497.         // ritorna la configurazione controllo del traffico della PdD
  1498.         Connection con = null;
  1499.        
  1500.         con = getConnection(nomeMetodo);

  1501.         this.logDebug("operazione this.atomica = " + this.atomica);
  1502.         long count = 0;
  1503.         try {
  1504.             count = ControlloTrafficoDriverUtils.countConfigurazioneControlloTrafficoAttivazionePolicy(ricerca, ruoloPorta, nomePorta, con, this.log, this.tipoDB);
  1505.         }catch (Exception se) {
  1506.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1507.         } finally {
  1508.             releaseConnection(con);
  1509.         }

  1510.         return count;
  1511.     }

  1512.     public List<ConfigurazionePolicy> configurazioneControlloTrafficoConfigurazionePolicyList(ConsoleSearch ricerca) throws DriverControlStationException{
  1513.         String nomeMetodo = "configurazioneControlloTrafficoConfigurazionePolicyList";
  1514.         // ritorna la configurazione controllo del traffico della PdD
  1515.         Connection con = null;
  1516.        
  1517.         con = getConnection(nomeMetodo);

  1518.         this.logDebug("operazione this.atomica = " + this.atomica);
  1519.         List<ConfigurazionePolicy> listaPolicy = new ArrayList<ConfigurazionePolicy>();
  1520.        
  1521.         try {
  1522.             listaPolicy = ControlloTrafficoDriverUtils.configurazioneControlloTrafficoConfigurazionePolicyList(ricerca, con, this.log, this.tipoDB);                
  1523.         } catch (Exception qe) {
  1524.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1525.         } finally {
  1526.             releaseConnection(con);
  1527.         }
  1528.        
  1529.         return listaPolicy;
  1530.     }
  1531.    
  1532.     public List<ConfigurazionePolicy> configurazioneControlloTrafficoConfigurazionePolicyList_conApplicabilitaAllarme(String idAllarme) throws DriverControlStationException{
  1533.        
  1534.         String nomeMetodo = "configurazioneControlloTrafficoConfigurazionePolicyList_conApplicabilitaAllarme";
  1535.         // ritorna la configurazione controllo del traffico della PdD
  1536.         Connection con = null;
  1537.        
  1538.         con = getConnection(nomeMetodo);

  1539.         this.logDebug("operazione this.atomica = " + this.atomica);
  1540.         List<ConfigurazionePolicy> listaPolicy = new ArrayList<ConfigurazionePolicy>();
  1541.        
  1542.         try {
  1543.             listaPolicy = ControlloTrafficoDriverUtils.configurazioneControlloTrafficoConfigurazionePolicyList_conApplicabilitaAllarme(idAllarme, con, this.log, this.tipoDB);              
  1544.         } catch (Exception qe) {
  1545.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1546.         } finally {
  1547.             releaseConnection(con);
  1548.         }
  1549.        
  1550.         return listaPolicy;
  1551.     }

  1552.     public void updatePosizioneAttivazionePolicy(InfoPolicy infoPolicy, AttivazionePolicy policy,
  1553.             RuoloPolicy ruoloPorta, String nomePorta) throws DriverControlStationException{
  1554.         String nomeMetodo = "updatePosizioneAttivazionePolicy";
  1555.         // ritorna la configurazione controllo del traffico della PdD
  1556.         Connection con = null;
  1557.        
  1558.         con = getConnection(nomeMetodo);

  1559.         this.logDebug("operazione this.atomica = " + this.atomica);
  1560.        
  1561.         try {
  1562.             ControlloTrafficoDriverUtils.updatePosizioneAttivazionePolicy(infoPolicy, policy,
  1563.                     ruoloPorta, nomePorta,
  1564.                     con, this.log, this.tipoDB);    
  1565.         } catch (Exception qe) {
  1566.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1567.         } finally {
  1568.             releaseConnection(con);
  1569.         }
  1570.        
  1571.     }
  1572.    
  1573.     @SuppressWarnings("unchecked")
  1574.     public List<AttivazionePolicy> configurazioneControlloTrafficoAttivazionePolicyList(ConsoleSearch ricerca, RuoloPolicy ruoloPorta, String nomePorta) throws DriverControlStationException{
  1575.         return (List<AttivazionePolicy>) this._configurazioneControlloTrafficoAttivazionePolicyList(ricerca, ruoloPorta, nomePorta,
  1576.                 false, "configurazioneControlloTrafficoAttivazionePolicyList",
  1577.                 null, null, null,
  1578.                 null, null,
  1579.                 null, null);
  1580.     }
  1581.     @SuppressWarnings("unchecked")
  1582.     public List<AttivazionePolicy> configurazioneControlloTrafficoAttivazionePolicyListByFilter(ConsoleSearch ricerca, RuoloPolicy ruoloPorta, String nomePorta,
  1583.             IDSoggetto filtroSoggettoFruitore, IDServizioApplicativo filtroApplicativoFruitore,String filtroRuoloFruitore,
  1584.             IDSoggetto filtroSoggettoErogatore, String filtroRuoloErogatore,
  1585.             IDServizio filtroServizioAzione, String filtroRuolo) throws DriverControlStationException{
  1586.         return (List<AttivazionePolicy>) this._configurazioneControlloTrafficoAttivazionePolicyList(ricerca, ruoloPorta, nomePorta,
  1587.                 false, "configurazioneControlloTrafficoAttivazionePolicyListByFilter",
  1588.                 filtroSoggettoFruitore, filtroApplicativoFruitore, filtroRuoloFruitore,
  1589.                 filtroSoggettoErogatore, filtroRuoloErogatore,
  1590.                 filtroServizioAzione, filtroRuolo);
  1591.     }
  1592.     @SuppressWarnings("unchecked")
  1593.     public List<TipoRisorsaPolicyAttiva> configurazioneControlloTrafficoAttivazionePolicyTipoRisorsaList(ConsoleSearch ricerca, RuoloPolicy ruoloPorta, String nomePorta) throws DriverControlStationException{
  1594.         return (List<TipoRisorsaPolicyAttiva>) this._configurazioneControlloTrafficoAttivazionePolicyList(ricerca, ruoloPorta, nomePorta,
  1595.                 true, "configurazioneControlloTrafficoAttivazionePolicyTipoRisorsaList",
  1596.                 null, null, null,
  1597.                 null, null,
  1598.                 null, null);
  1599.     }
  1600.     @SuppressWarnings("unchecked")
  1601.     private Object _configurazioneControlloTrafficoAttivazionePolicyList(ConsoleSearch ricerca, RuoloPolicy ruoloPorta, String nomePorta, boolean tipoRisorsa, String nomeMetodo,
  1602.             IDSoggetto filtroSoggettoFruitore, IDServizioApplicativo filtroApplicativoFruitore,String filtroRuoloFruitore,
  1603.             IDSoggetto filtroSoggettoErogatore, String filtroRuoloErogatore,
  1604.             IDServizio filtroServizioAzione, String filtroRuolo) throws DriverControlStationException{
  1605.         // ritorna la configurazione controllo del traffico della PdD
  1606.         Connection con = null;
  1607.        
  1608.         con = getConnection(nomeMetodo);

  1609.         this.logDebug("operazione this.atomica = " + this.atomica);
  1610.         List<AttivazionePolicy> listaPolicy = null;
  1611.         List<TipoRisorsaPolicyAttiva> listaTipoRisorsa = null;
  1612.        
  1613.         try {
  1614.        
  1615.             Object o = ControlloTrafficoDriverUtils._configurazioneControlloTrafficoAttivazionePolicyList(ricerca, ruoloPorta, nomePorta,
  1616.                     con, this.log, this.tipoDB,
  1617.                     tipoRisorsa, nomeMetodo,
  1618.                     filtroSoggettoFruitore, filtroApplicativoFruitore, filtroRuoloFruitore,
  1619.                     filtroSoggettoErogatore, filtroRuoloErogatore,
  1620.                     filtroServizioAzione, filtroRuolo);
  1621.            
  1622.             if(tipoRisorsa) {
  1623.                 listaTipoRisorsa = (List<TipoRisorsaPolicyAttiva>) o;
  1624.             }
  1625.             else {
  1626.                 listaPolicy = (List<AttivazionePolicy>) o;
  1627.             }
  1628.                        
  1629.         } catch (Exception qe) {
  1630.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1631.         } finally {
  1632.             releaseConnection(con);
  1633.         }
  1634.        
  1635.         if(tipoRisorsa) {
  1636.             return listaTipoRisorsa;
  1637.         }
  1638.         else {
  1639.             return listaPolicy;
  1640.         }
  1641.     }
  1642.    
  1643.     public AttivazionePolicy getAttivazionePolicy(String alias, RuoloPolicy ruoloPorta, String nomePorta) throws DriverControlStationException, NotFoundException{
  1644.         String nomeMetodo = "configurazioneControlloTrafficoAttivazionePolicyList";
  1645.         // ritorna la configurazione controllo del traffico della PdD
  1646.         Connection con = null;

  1647.         con = getConnection(nomeMetodo);

  1648.         this.logDebug("operazione this.atomica = " + this.atomica);
  1649.         AttivazionePolicy policy = null;
  1650.        
  1651.         try {
  1652.             policy = ControlloTrafficoDriverUtils.getAttivazionePolicy(alias, ruoloPorta, nomePorta, con, this.log, this.tipoDB);          
  1653.         } catch(NotFoundException notFound) {
  1654.             throw notFound;
  1655.         }
  1656.         catch (Exception qe) {
  1657.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1658.         } finally {
  1659.             releaseConnection(con);
  1660.         }
  1661.        
  1662.         return policy;
  1663.     }
  1664.    
  1665.    
  1666.     public List<InfoPolicy> getInfoPolicyList(Boolean builtIn, String idPolicyParam) throws DriverControlStationException{
  1667.         String nomeMetodo = "getInfoPolicyList";
  1668.         // ritorna la configurazione controllo del traffico della PdD
  1669.         Connection con = null;
  1670.        
  1671.         con = getConnection(nomeMetodo);

  1672.         this.logDebug("operazione this.atomica = " + this.atomica);
  1673.         List<InfoPolicy> listaPolicy = new ArrayList<InfoPolicy>();
  1674.        
  1675.         try {
  1676.             listaPolicy = ControlloTrafficoDriverUtils.getInfoPolicyList(builtIn, idPolicyParam, con, this.log, this.tipoDB);          
  1677.         } catch (Exception qe) {
  1678.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1679.         } finally {
  1680.             releaseConnection(con);
  1681.         }
  1682.        
  1683.         return listaPolicy;
  1684.     }
  1685.    
  1686.     public List<AttivazionePolicy> findInUseAttivazioni(String idPolicy, boolean escludiDisabilitate) throws DriverControlStationException{
  1687.         String nomeMetodo = "findInUseAttivazioni";
  1688.         // ritorna la configurazione controllo del traffico della PdD
  1689.         Connection con = null;
  1690.        
  1691.         con = getConnection(nomeMetodo);

  1692.         this.logDebug("operazione this.atomica = " + this.atomica);
  1693.         List<AttivazionePolicy> listaPolicy = new ArrayList<AttivazionePolicy>();
  1694.        
  1695.         try {
  1696.             listaPolicy = ControlloTrafficoDriverUtils.findInUseAttivazioni(idPolicy, escludiDisabilitate, con, this.log, this.tipoDB);
  1697.         } catch (Exception qe) {
  1698.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1699.         } finally {
  1700.             releaseConnection(con);
  1701.         }
  1702.        
  1703.         return listaPolicy;
  1704.     }
  1705.    
  1706.     public long countInUseAttivazioni(String idPolicy, boolean escludiDisabilitate) throws DriverControlStationException{
  1707.         String nomeMetodo = "countInUseAttivazioni";
  1708.         // ritorna la configurazione controllo del traffico della PdD
  1709.         Connection con = null;

  1710.         con = getConnection(nomeMetodo);

  1711.         this.logDebug("operazione this.atomica = " + this.atomica);
  1712.         try {
  1713.             return ControlloTrafficoDriverUtils.countInUseAttivazioni(idPolicy, escludiDisabilitate, con, this.log, this.tipoDB);
  1714.         } catch (Exception qe) {
  1715.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1716.         } finally {
  1717.             releaseConnection(con);
  1718.         }
  1719.     }
  1720.    
  1721.     public ConfigurazionePolicy getConfigurazionePolicy(long id) throws DriverControlStationException,DriverControlStationNotFound{
  1722.         String nomeMetodo = "getConfigurazionePolicy";
  1723.         Connection con = null;
  1724.         con = getConnection(nomeMetodo);

  1725.         this.logDebug("operazione this.atomica = " + this.atomica);
  1726.         ConfigurazionePolicy policy = null;
  1727.        
  1728.         try {
  1729.             policy = ControlloTrafficoDriverUtils.getConfigurazionePolicy(id, con, this.log, this.tipoDB);
  1730.         }catch (NotFoundException e) {
  1731.             throw new DriverControlStationNotFound("[DriverControlStationDB::" + nomeMetodo + "] Configurazione Policy non presente.");
  1732.         } catch (Exception qe) {
  1733.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1734.         } finally {
  1735.             releaseConnection(con);
  1736.         }
  1737.        
  1738.         return policy;
  1739.     }
  1740.    
  1741.     public ConfigurazionePolicy getConfigurazionePolicy(String nomePolicy) throws DriverControlStationException,DriverControlStationNotFound{
  1742.         String nomeMetodo = "getConfigurazionePolicy";
  1743.         Connection con = null;
  1744.         con = getConnection(nomeMetodo);

  1745.         this.logDebug("operazione this.atomica = " + this.atomica);
  1746.         ConfigurazionePolicy policy = null;
  1747.        
  1748.         try {
  1749.             policy = ControlloTrafficoDriverUtils.getConfigurazionePolicy(nomePolicy, con, this.log, this.tipoDB);
  1750.         }catch (NotFoundException e) {
  1751.             throw new DriverControlStationNotFound("[DriverControlStationDB::" + nomeMetodo + "] Configurazione Policy non presente.");
  1752.         } catch (Exception qe) {
  1753.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1754.         } finally {
  1755.             releaseConnection(con);
  1756.         }
  1757.        
  1758.         return policy;
  1759.     }

  1760.     public void createConfigurazionePolicy(ConfigurazionePolicy policy) throws DriverControlStationException{
  1761.         String nomeMetodo = "createConfigurazionePolicy";
  1762.         Connection con = null;
  1763.         con = getConnection(nomeMetodo);

  1764.         this.logDebug("operazione this.atomica = " + this.atomica);
  1765.         try {
  1766.             ControlloTrafficoDriverUtils.createConfigurazionePolicy(policy, con, this.log, this.tipoDB);
  1767.         } catch (Exception qe) {
  1768.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1769.         } finally {
  1770.             releaseConnection(con);
  1771.         }  
  1772.     }

  1773.     public void createAttivazionePolicy(AttivazionePolicy policy) throws DriverControlStationException {
  1774.         String nomeMetodo = "createAttivazionePolicy";
  1775.         Connection con = null;
  1776.         con = getConnection(nomeMetodo);

  1777.         this.logDebug("operazione this.atomica = " + this.atomica);
  1778.         try {
  1779.             ControlloTrafficoDriverUtils.createAttivazionePolicy(policy, con, this.log, this.tipoDB);      
  1780.         } catch (Exception qe) {
  1781.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1782.         } finally {
  1783.             releaseConnection(con);
  1784.         }  
  1785.     }

  1786.     public void updateConfigurazionePolicy(ConfigurazionePolicy policy)throws DriverControlStationException,DriverControlStationNotFound{
  1787.         String nomeMetodo = "updateConfigurazionePolicy";
  1788.         Connection con = null;
  1789.         con = getConnection(nomeMetodo);

  1790.         this.logDebug("operazione this.atomica = " + this.atomica);
  1791.         try {
  1792.             ControlloTrafficoDriverUtils.updateConfigurazionePolicy(policy, con, this.log, this.tipoDB);
  1793.         }catch (NotFoundException e) {
  1794.             throw new DriverControlStationNotFound("[DriverControlStationDB::" + nomeMetodo + "] Configurazione Policy non presente.");
  1795.         } catch (Exception qe) {
  1796.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1797.         } finally {
  1798.             releaseConnection(con);
  1799.         }  
  1800.     }

  1801.     public void updateAttivazionePolicy(AttivazionePolicy policy) throws DriverControlStationException,DriverControlStationNotFound{
  1802.         String nomeMetodo = "updateAttivazionePolicy";
  1803.         Connection con = null;
  1804.         con = getConnection(nomeMetodo);

  1805.         this.logDebug("operazione this.atomica = " + this.atomica);
  1806.         try {
  1807.             ControlloTrafficoDriverUtils.updateAttivazionePolicy(policy, con, this.log, this.tipoDB);
  1808.         }catch (NotFoundException e) {
  1809.             throw new DriverControlStationNotFound("[DriverControlStationDB::" + nomeMetodo + "] Configurazione Policy non presente.");
  1810.         } catch (Exception qe) {
  1811.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1812.         } finally {
  1813.             releaseConnection(con);
  1814.         }  
  1815.     }

  1816.     public void deleteConfigurazionePolicy(ConfigurazionePolicy policy) throws DriverControlStationException {
  1817.         String nomeMetodo = "deleteConfigurazionePolicy";
  1818.         Connection con = null;
  1819.         con = getConnection(nomeMetodo);

  1820.         this.logDebug("operazione this.atomica = " + this.atomica);
  1821.         try {
  1822.             ControlloTrafficoDriverUtils.deleteConfigurazionePolicy(policy, con, this.log, this.tipoDB);            
  1823.         } catch (Exception qe) {
  1824.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1825.         } finally {
  1826.             releaseConnection(con);
  1827.         }
  1828.     }

  1829.     public void deleteAttivazionePolicy(AttivazionePolicy policy) throws DriverControlStationException,DriverControlStationNotFound{
  1830.         String nomeMetodo = "deleteAttivazionePolicy";
  1831.         Connection con = null;
  1832.         con = getConnection(nomeMetodo);

  1833.         this.logDebug("operazione this.atomica = " + this.atomica);
  1834.         try {
  1835.             ControlloTrafficoDriverUtils.deleteAttivazionePolicy(policy, con, this.log, this.tipoDB);
  1836.         } catch (Exception qe) {
  1837.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1838.         } finally {
  1839.             releaseConnection(con);
  1840.         }
  1841.     }
  1842.    
  1843.     public AttivazionePolicy getAttivazionePolicy(long id) throws DriverControlStationException,DriverControlStationNotFound{
  1844.         String nomeMetodo = "getAttivazionePolicy";
  1845.         Connection con = null;
  1846.         con = getConnection(nomeMetodo);

  1847.         this.logDebug("operazione this.atomica = " + this.atomica);
  1848.         AttivazionePolicy policy = null;
  1849.        
  1850.         try {
  1851.             policy = ControlloTrafficoDriverUtils.getAttivazionePolicy(id, con, this.log, this.tipoDB);
  1852.         }catch (NotFoundException e) {
  1853.             throw new DriverControlStationNotFound("[DriverControlStationDB::" + nomeMetodo + "] Configurazione Policy non presente.");
  1854.         } catch (Exception qe) {
  1855.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1856.         } finally {
  1857.             releaseConnection(con);
  1858.         }
  1859.        
  1860.         return policy;
  1861.     }
  1862.    
  1863.     public AttivazionePolicy getAttivazionePolicy(String nomePolicy) throws DriverControlStationException,DriverControlStationNotFound{
  1864.         String nomeMetodo = "getAttivazionePolicy";
  1865.         Connection con = null;
  1866.         con = getConnection(nomeMetodo);

  1867.         this.logDebug("operazione this.atomica = " + this.atomica);
  1868.         AttivazionePolicy policy = null;
  1869.        
  1870.         try {
  1871.             policy = ControlloTrafficoDriverUtils.getAttivazionePolicy(nomePolicy, con, this.log, this.tipoDB);
  1872.         }catch (NotFoundException e) {
  1873.             throw new DriverControlStationNotFound("[DriverControlStationDB::" + nomeMetodo + "] Configurazione Policy non presente.");
  1874.         } catch (Exception qe) {
  1875.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1876.         } finally {
  1877.             releaseConnection(con);
  1878.         }
  1879.        
  1880.         return policy;
  1881.     }
  1882.    
  1883.     public String getNextPolicyInstanceSerialId(String policyId) throws DriverControlStationException{
  1884.         String nomeMetodo = "getNextPolicyInstanceSerialId";
  1885.         Connection con = null;
  1886.         con = getConnection(nomeMetodo);

  1887.         this.logDebug("operazione this.atomica = " + this.atomica);
  1888.        
  1889.         try{
  1890.             return ControlloTrafficoDriverUtils.getNextPolicyInstanceSerialId(policyId, con, this.log, this.tipoDB);        
  1891.         } catch (Exception qe) {
  1892.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1893.         } finally {
  1894.             releaseConnection(con);
  1895.         }
  1896.     }
  1897.    
  1898.     public AttivazionePolicy getPolicy(String policyId, AttivazionePolicyFiltro filtroParam, AttivazionePolicyRaggruppamento groupBy,
  1899.             RuoloPolicy ruoloPorta, String nomePorta) throws DriverControlStationException,DriverControlStationNotFound{
  1900.         String nomeMetodo = "getPolicy";
  1901.         Connection con = null;
  1902.         con = getConnection(nomeMetodo);

  1903.         this.logDebug("operazione this.atomica = " + this.atomica);
  1904.         try{
  1905.             return ControlloTrafficoDriverUtils.getPolicy(policyId, filtroParam, groupBy,
  1906.                     ruoloPorta, nomePorta, con, this.log, this.tipoDB);
  1907.         }catch (NotFoundException e) {
  1908.             throw new DriverControlStationNotFound("[DriverControlStationDB::" + nomeMetodo + "] Attivazione Policy non presente.");    
  1909.         } catch (Exception qe) {
  1910.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1911.         } finally {
  1912.             releaseConnection(con);
  1913.         }
  1914.     }
  1915.    
  1916.     public AttivazionePolicy getPolicyByAlias(String alias,
  1917.             RuoloPolicy ruoloPorta, String nomePorta) throws DriverControlStationException,DriverControlStationNotFound{
  1918.         String nomeMetodo = "getPolicyByAlias";
  1919.         Connection con = null;
  1920.         con = getConnection(nomeMetodo);

  1921.         this.logDebug("operazione this.atomica = " + this.atomica);
  1922.         try{
  1923.             return ControlloTrafficoDriverUtils.getPolicyByAlias(alias,
  1924.                     ruoloPorta, nomePorta, con, this.log, this.tipoDB);
  1925.         }catch (NotFoundException e) {
  1926.             throw new DriverControlStationNotFound("[DriverControlStationDB::" + nomeMetodo + "] Attivazione Policy non presente.");
  1927.         } catch (Exception qe) {
  1928.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1929.         } finally {
  1930.             releaseConnection(con);
  1931.         }
  1932.     }
  1933.    
  1934.     public List<AttivazionePolicy> getPolicyByServizioApplicativo(IDServizioApplicativo idServizioApplicativo) throws DriverControlStationException,DriverControlStationNotFound{
  1935.         String nomeMetodo = "getPolicyByServizioApplicativo";
  1936.         Connection con = null;
  1937.         con = getConnection(nomeMetodo);

  1938.         this.logDebug("operazione this.atomica = " + this.atomica);
  1939.         try{
  1940.             return ControlloTrafficoDriverUtils.getPolicyByServizioApplicativo(idServizioApplicativo, con, this.log, this.tipoDB);
  1941.         }catch (NotFoundException e) {
  1942.             throw new DriverControlStationNotFound("[DriverControlStationDB::" + nomeMetodo + "] Attivazione Policy non presente.");
  1943.         } catch (Exception qe) {
  1944.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1945.         } finally {
  1946.             releaseConnection(con);
  1947.         }
  1948.     }
  1949.    
  1950.     public boolean usedInConfigurazioneControlloTrafficoAttivazionePolicy(RuoloPolicy ruoloPorta, String nomePorta, String azione) throws DriverControlStationException{
  1951.         String nomeMetodo = "usedInConfigurazioneControlloTrafficoAttivazionePolicy";
  1952.         // ritorna la configurazione controllo del traffico della PdD
  1953.         Connection con = null;
  1954.        
  1955.         con = getConnection(nomeMetodo);

  1956.         this.logDebug("operazione this.atomica = " + this.atomica);
  1957.        
  1958.         try {
  1959.             return ControlloTrafficoDriverUtils.usedInConfigurazioneControlloTrafficoAttivazionePolicy(ruoloPorta, nomePorta, azione, con, this.log, this.tipoDB);          
  1960.         } catch (Exception qe) {
  1961.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1962.         } finally {
  1963.             releaseConnection(con);
  1964.         }
  1965.        
  1966.     }
  1967.    
  1968.     public List<IDSoggetto> getSoggettiErogatori(String protocolloSelezionato,List<String> protocolliSupportati) throws DriverControlStationException{
  1969.         String nomeMetodo = "getSoggettiErogatori";
  1970.         Connection con = null;
  1971.         con = getConnection(nomeMetodo);

  1972.         this.logDebug("operazione this.atomica = " + this.atomica);
  1973.        
  1974.         try{
  1975.             org.openspcoop2.core.commons.search.dao.jdbc.JDBCServiceManager serviceManager = RegistroCore.getServiceManager(this.log, this.tipoDB, con);
  1976.            
  1977.             if(protocolloSelezionato!=null) {
  1978.                 return RegistroCore.getSoggettiErogatori(serviceManager, protocolloSelezionato);
  1979.             }
  1980.             else {
  1981.                 return RegistroCore.getSoggettiErogatori(serviceManager, protocolliSupportati);
  1982.             }
  1983.         }catch (Exception qe) {
  1984.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  1985.         } finally {
  1986.             releaseConnection(con);
  1987.         }
  1988.     }
  1989.     public List<IDServizio> getServizi(String protocolloSelezionato,List<String> protocolliSupportati,
  1990.             String tipoErogatore, String nomeErogatore, String tag) throws DriverControlStationException{
  1991.         String nomeMetodo = "getServizi";
  1992.         Connection con = null;
  1993.         con = getConnection(nomeMetodo);

  1994.         this.logDebug("operazione this.atomica = " + this.atomica);
  1995.         try{
  1996.             org.openspcoop2.core.commons.search.dao.jdbc.JDBCServiceManager serviceManager = RegistroCore.getServiceManager(this.log, this.tipoDB, con);
  1997.             if(protocolloSelezionato!=null) {
  1998.                 return RegistroCore.getServizi(serviceManager, protocolloSelezionato, tipoErogatore, nomeErogatore, tag);
  1999.             }
  2000.             else{
  2001.                 return RegistroCore.getServizi(serviceManager, protocolliSupportati, tipoErogatore, nomeErogatore, tag);
  2002.             }
  2003.         }catch (Exception qe) {
  2004.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  2005.         } finally {
  2006.             releaseConnection(con);
  2007.         }
  2008.     }
  2009.     public List<IDServizio> getServizi(String protocolloSelezionato,List<String> protocolliSupportati,
  2010.             String tipoServizio, String nomeServizio, Integer versioneServizio, String tag) throws DriverControlStationException{
  2011.         String nomeMetodo = "getServizi";
  2012.         Connection con = null;
  2013.         con = getConnection(nomeMetodo);

  2014.         this.logDebug("operazione this.atomica = " + this.atomica);
  2015.         try{
  2016.             org.openspcoop2.core.commons.search.dao.jdbc.JDBCServiceManager serviceManager = RegistroCore.getServiceManager(this.log, this.tipoDB, con);
  2017.             if(protocolloSelezionato!=null) {
  2018.                 return RegistroCore.getServizi(serviceManager, protocolloSelezionato, tipoServizio, nomeServizio, versioneServizio, tag);
  2019.             }
  2020.             else{
  2021.                 return RegistroCore.getServizi(serviceManager, protocolliSupportati, tipoServizio, nomeServizio, versioneServizio, tag);
  2022.             }
  2023.         }catch (Exception qe) {
  2024.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  2025.         } finally {
  2026.             releaseConnection(con);
  2027.         }
  2028.     }
  2029.     public List<String> getAzioni(String protocolloSelezionato,List<String> protocolliSupportati,
  2030.             String tipoErogatore, String nomeErogatore, String tipoServizio, String nomeServizio, Integer versioneServizio) throws DriverControlStationException{
  2031.         String nomeMetodo = "getAzioni";
  2032.         Connection con = null;
  2033.         con = getConnection(nomeMetodo);

  2034.         this.logDebug("operazione this.atomica = " + this.atomica);
  2035.         try{
  2036.             org.openspcoop2.core.commons.search.dao.jdbc.JDBCServiceManager serviceManager = RegistroCore.getServiceManager(this.log, this.tipoDB, con);
  2037.             if(protocolloSelezionato!=null) {
  2038.                 return RegistroCore.getAzioni(serviceManager, protocolloSelezionato,
  2039.                         tipoErogatore, nomeErogatore, tipoServizio, nomeServizio, versioneServizio);
  2040.             }
  2041.             else {
  2042.                 return RegistroCore.getAzioni(serviceManager, protocolliSupportati,
  2043.                         tipoErogatore, nomeErogatore, tipoServizio, nomeServizio, versioneServizio);
  2044.             }
  2045.         }catch (Exception qe) {
  2046.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  2047.         } finally {
  2048.             releaseConnection(con);
  2049.         }
  2050.     }
  2051.     public List<IDServizioApplicativo> getServiziApplicativiErogatori(String protocolloSelezionato,List<String> protocolliSupportati,
  2052.             String tipoErogatore, String nomeErogatore, String tipoServizio, String nomeServizio, Integer versioneServizio,
  2053.             String azione) throws DriverControlStationException {
  2054.         String nomeMetodo = "getServiziApplicativiErogatori";
  2055.         Connection con = null;
  2056.         con = getConnection(nomeMetodo);

  2057.         this.logDebug("operazione this.atomica = " + this.atomica);
  2058.         try{
  2059.             org.openspcoop2.core.commons.search.dao.jdbc.JDBCServiceManager serviceManager = RegistroCore.getServiceManager(this.log, this.tipoDB, con);
  2060.             if(protocolloSelezionato!=null) {
  2061.                 return RegistroCore.getServiziApplicativiErogatori(serviceManager, protocolloSelezionato,
  2062.                         tipoErogatore, nomeErogatore, tipoServizio, nomeServizio, versioneServizio,
  2063.                         azione);
  2064.             }
  2065.             else {
  2066.                 return RegistroCore.getServiziApplicativiErogatori(serviceManager, protocolliSupportati,
  2067.                         tipoErogatore, nomeErogatore, tipoServizio, nomeServizio, versioneServizio,
  2068.                         azione);
  2069.             }
  2070.         }catch (Exception qe) {
  2071.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  2072.         } finally {
  2073.             releaseConnection(con);
  2074.         }
  2075.     }
  2076.     public List<IDSoggetto> getSoggetti(String protocolloSelezionato,List<String> protocolliSupportati) throws DriverControlStationException{
  2077.         String nomeMetodo = "getSoggetti";
  2078.         Connection con = null;
  2079.         con = getConnection(nomeMetodo);

  2080.         this.logDebug("operazione this.atomica = " + this.atomica);
  2081.         try{
  2082.             org.openspcoop2.core.commons.search.dao.jdbc.JDBCServiceManager serviceManager = RegistroCore.getServiceManager(this.log, this.tipoDB, con);
  2083.             if(protocolloSelezionato!=null) {
  2084.                 return RegistroCore.getSoggetti(serviceManager, protocolloSelezionato);
  2085.             }
  2086.             else {
  2087.                 return RegistroCore.getSoggetti(serviceManager, protocolliSupportati);
  2088.             }
  2089.         }catch (Exception qe) {
  2090.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  2091.         } finally {
  2092.             releaseConnection(con);
  2093.         }
  2094.     }
  2095.     public List<IDSoggetto> getSoggettiFruitori(String protocolloSelezionato,List<String> protocolliSupportati,
  2096.             String tipoErogatore, String nomeErogatore, String tipoServizio, String nomeServizio, Integer versioneServizio) throws DriverControlStationException{
  2097.         String nomeMetodo = "getSoggettiFruitori";
  2098.         Connection con = null;
  2099.         con = getConnection(nomeMetodo);

  2100.         this.logDebug("operazione this.atomica = " + this.atomica);
  2101.         try{
  2102.             org.openspcoop2.core.commons.search.dao.jdbc.JDBCServiceManager serviceManager = RegistroCore.getServiceManager(this.log, this.tipoDB, con);
  2103.             if(protocolloSelezionato!=null) {
  2104.                 return RegistroCore.getSoggettiFruitori(serviceManager, protocolloSelezionato,
  2105.                         tipoErogatore, nomeErogatore, tipoServizio, nomeServizio, versioneServizio);
  2106.             }
  2107.             else {
  2108.                 return RegistroCore.getSoggettiFruitori(serviceManager, protocolliSupportati,
  2109.                         tipoErogatore, nomeErogatore, tipoServizio, nomeServizio, versioneServizio);
  2110.             }
  2111.         }catch (Exception qe) {
  2112.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  2113.         } finally {
  2114.             releaseConnection(con);
  2115.         }
  2116.     }
  2117.     public List<IDServizioApplicativo> getServiziApplicativiFruitore(String protocolloSelezionato,List<String> protocolliSupportati,
  2118.             String tipoFruitore, String nomeFruitore,  
  2119.             String tipoErogatore, String nomeErogatore, String tipoServizio, String nomeServizio, Integer versioneServizio,
  2120.             String azione) throws DriverControlStationException{
  2121.         String nomeMetodo = "getServiziApplicativiFruitore";
  2122.         Connection con = null;
  2123.         con = getConnection(nomeMetodo);

  2124.         this.logDebug("operazione this.atomica = " + this.atomica);
  2125.         try{
  2126.             org.openspcoop2.core.commons.search.dao.jdbc.JDBCServiceManager serviceManager = RegistroCore.getServiceManager(this.log, this.tipoDB, con);
  2127.             if(protocolloSelezionato!=null) {
  2128.                 return RegistroCore.getServiziApplicativiFruitore(serviceManager, protocolloSelezionato,
  2129.                         tipoFruitore, nomeFruitore,
  2130.                         tipoErogatore, nomeErogatore, tipoServizio, nomeServizio, versioneServizio,
  2131.                         azione);
  2132.             }
  2133.             else {
  2134.                 return RegistroCore.getServiziApplicativiFruitore(serviceManager, protocolliSupportati,
  2135.                         tipoFruitore, nomeFruitore,
  2136.                         tipoErogatore, nomeErogatore, tipoServizio, nomeServizio, versioneServizio,
  2137.                         azione);
  2138.             }
  2139.         }catch (Exception qe) {
  2140.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  2141.         } finally {
  2142.             releaseConnection(con);
  2143.         }
  2144.     }
  2145.     public List<IDServizioApplicativo> getServiziApplicativiFruitore(String protocolloSelezionato,List<String> protocolliSupportati,
  2146.             String tipoFruitore, String nomeFruitore) throws DriverControlStationException{
  2147.         String nomeMetodo = "getServiziApplicativiFruitore";
  2148.         Connection con = null;
  2149.         con = getConnection(nomeMetodo);

  2150.         this.logDebug("operazione this.atomica = " + this.atomica);
  2151.         try{
  2152.             org.openspcoop2.core.commons.search.dao.jdbc.JDBCServiceManager serviceManager = RegistroCore.getServiceManager(this.log, this.tipoDB, con);
  2153.             if(protocolloSelezionato!=null) {
  2154.                 return RegistroCore.getServiziApplicativiFruitore(serviceManager, protocolloSelezionato,
  2155.                         tipoFruitore, nomeFruitore);
  2156.             }
  2157.             else {
  2158.                 return RegistroCore.getServiziApplicativiFruitore(serviceManager, protocolliSupportati,
  2159.                         tipoFruitore, nomeFruitore);
  2160.             }
  2161.         }catch (Exception qe) {
  2162.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  2163.         } finally {
  2164.             releaseConnection(con);
  2165.         }
  2166.     }
  2167.     public List<IDServizioApplicativo> getServiziApplicativi(String protocolloSelezionato,List<String> protocolliSupportati,
  2168.             String tipoProprietario, String nomeProprietario) throws DriverControlStationException{
  2169.         String nomeMetodo = "getServiziApplicativi";
  2170.         Connection con = null;
  2171.         con = getConnection(nomeMetodo);

  2172.         this.logDebug("operazione this.atomica = " + this.atomica);
  2173.         try{
  2174.             org.openspcoop2.core.commons.search.dao.jdbc.JDBCServiceManager serviceManager = RegistroCore.getServiceManager(this.log, this.tipoDB, con);
  2175.             if(protocolloSelezionato!=null) {
  2176.                 return RegistroCore.getServiziApplicativi(serviceManager, protocolloSelezionato,
  2177.                         tipoProprietario, nomeProprietario);
  2178.             }
  2179.             else {
  2180.                 return RegistroCore.getServiziApplicativi(serviceManager, protocolliSupportati,
  2181.                         tipoProprietario, nomeProprietario);
  2182.             }
  2183.         }catch (Exception qe) {
  2184.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  2185.         } finally {
  2186.             releaseConnection(con);
  2187.         }
  2188.     }
  2189.    
  2190.     public List<IDServizio> getErogazioni(List<String> protocolli,
  2191.             String gruppo,
  2192.             String tipoSoggetto, String nomeSoggetto) throws Exception {
  2193.         return  getErogazioni(protocolli,
  2194.                 gruppo,
  2195.                 tipoSoggetto, nomeSoggetto,
  2196.                 null, null, null,
  2197.                 null);
  2198.     }
  2199.     public List<IDServizio> getErogazioni(List<String> protocolli,
  2200.             String gruppo,
  2201.             String tipoSoggetto, String nomeSoggetto,
  2202.             String tipoServizio, String nomeServizio, Integer versioneServizio,
  2203.             String nomeAzione) throws DriverControlStationException{
  2204.         String nomeMetodo = "getErogazioni";
  2205.         Connection con = null;
  2206.         con = getConnection(nomeMetodo);

  2207.         this.logDebug("operazione this.atomica = " + this.atomica);
  2208.         try{
  2209.             org.openspcoop2.core.commons.search.dao.jdbc.JDBCServiceManager serviceManager = RegistroCore.getServiceManager(this.log, this.tipoDB, con);
  2210.             return RegistroCore.getErogazioni(serviceManager, protocolli, gruppo, tipoSoggetto, nomeSoggetto, tipoServizio, nomeServizio, versioneServizio, nomeAzione);
  2211.         }catch (Exception qe) {
  2212.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  2213.         } finally {
  2214.             releaseConnection(con);
  2215.         }
  2216.     }
  2217.    
  2218.     public List<IDFruizione> getFruizioni(List<String> protocolli,
  2219.             String gruppo,
  2220.             String tipoSoggetto, String nomeSoggetto) throws Exception {
  2221.         return getFruizioni(protocolli,
  2222.                 gruppo,
  2223.                 tipoSoggetto, nomeSoggetto,
  2224.                 null, null,
  2225.                 null ,null, null,
  2226.                 null);
  2227.     }
  2228.     public List<IDFruizione> getFruizioni(List<String> protocolli,
  2229.             String gruppo,
  2230.             String tipoSoggetto, String nomeSoggetto,
  2231.             String tipoErogatore, String nomeErogatore,
  2232.             String tipoServizio ,String nomeServizio, Integer versioneServizio,
  2233.             String nomeAzione) throws DriverControlStationException{
  2234.         String nomeMetodo = "getFruizioni";
  2235.         Connection con = null;
  2236.         con = getConnection(nomeMetodo);

  2237.         this.logDebug("operazione this.atomica = " + this.atomica);
  2238.         try{
  2239.             org.openspcoop2.core.commons.search.dao.jdbc.JDBCServiceManager serviceManager = RegistroCore.getServiceManager(this.log, this.tipoDB, con);
  2240.             return RegistroCore.getFruizioni(serviceManager, protocolli, gruppo, tipoSoggetto, nomeSoggetto, tipoErogatore, nomeErogatore, tipoServizio, nomeServizio, versioneServizio, nomeAzione);
  2241.         }catch (Exception qe) {
  2242.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  2243.         } finally {
  2244.             releaseConnection(con);
  2245.         }
  2246.     }
  2247.    
  2248.     public boolean isGruppoInUso(IDGruppo idGruppo, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  2249.         String nomeMetodo = "isGruppoInUso";

  2250.         Connection con = null;
  2251.         con = getConnection(nomeMetodo);

  2252.         this.logDebug("operazione this.atomica = " + this.atomica);

  2253.         try {

  2254.             return DBOggettiInUsoUtils.isGruppoInUso(con, this.tipoDB, idGruppo, whereIsInUso, normalizeObjectIds);
  2255.            
  2256.         } catch (Exception se) {
  2257.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  2258.         } finally {
  2259.             releaseConnection(con);
  2260.         }
  2261.     }
  2262.    
  2263.     public boolean isGruppoConfigInUso(IDGruppo idRuolo, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  2264.         String nomeMetodo = "isGruppoConfigInUso";

  2265.         Connection con = null;
  2266.         con = getConnection(nomeMetodo);

  2267.         this.logDebug("operazione this.atomica = " + this.atomica);

  2268.         try {

  2269.             return DBOggettiInUsoUtils.isGruppoConfigInUso(con, this.tipoDB, idRuolo, whereIsInUso, normalizeObjectIds);
  2270.            
  2271.         } catch (Exception se) {
  2272.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  2273.         } finally {
  2274.             releaseConnection(con);
  2275.         }
  2276.     }
  2277.    
  2278.     public boolean isRisorsaInUso(IDResource idRisorsa, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  2279.         String nomeMetodo = "isRisorsaInUso";

  2280.         Connection con = null;
  2281.         con = getConnection(nomeMetodo);

  2282.         this.logDebug("operazione this.atomica = " + this.atomica);

  2283.         try {

  2284.             return DBOggettiInUsoUtils.isRisorsaInUso(con, this.tipoDB, idRisorsa, whereIsInUso, normalizeObjectIds);
  2285.            
  2286.         } catch (Exception se) {
  2287.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  2288.         } finally {
  2289.             releaseConnection(con);
  2290.         }
  2291.     }
  2292.    
  2293.     public boolean isPortTypeInUso(IDPortType idPT, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  2294.         String nomeMetodo = "isPortTypeInUso";

  2295.         Connection con = null;
  2296.         con = getConnection(nomeMetodo);

  2297.         this.logDebug("operazione this.atomica = " + this.atomica);

  2298.         try {

  2299.             return DBOggettiInUsoUtils.isPortTypeInUso(con, this.tipoDB, idPT, whereIsInUso, normalizeObjectIds);
  2300.            
  2301.         } catch (Exception se) {
  2302.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  2303.         } finally {
  2304.             releaseConnection(con);
  2305.         }
  2306.     }
  2307.    
  2308.     public boolean isOperazioneInUso(IDPortTypeAzione idOperazione, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  2309.         String nomeMetodo = "isOperazioneInUso";

  2310.         Connection con = null;
  2311.         con = getConnection(nomeMetodo);

  2312.         this.logDebug("operazione this.atomica = " + this.atomica);

  2313.         try {

  2314.             return DBOggettiInUsoUtils.isOperazioneInUso(con, this.tipoDB, idOperazione, whereIsInUso, normalizeObjectIds);
  2315.            
  2316.         } catch (Exception se) {
  2317.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  2318.         } finally {
  2319.             releaseConnection(con);
  2320.         }
  2321.     }


  2322.     public int numeroPluginsClassiList() throws DriverConfigurazioneException {
  2323.         String nomeMetodo = "numeroPluginsClassiList";
  2324.         Connection con = null;
  2325.        
  2326.         if (this.atomica) {
  2327.             try {
  2328.                 con = this.datasource.getConnection();
  2329.             } catch (Exception e) {
  2330.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2331.             }

  2332.         } else {
  2333.             con = this.globalConnection;
  2334.         }

  2335.         this.logDebug("operazione this.atomica = " + this.atomica);

  2336.         try {
  2337.             return PluginsDriverUtils.numeroPluginsClassiList(con, this.log, this.tipoDB);
  2338.         } catch (Exception qe) {
  2339.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2340.         } finally {
  2341.             releaseConnection(con);
  2342.         }
  2343.     }
  2344.    
  2345.     public List<Plugin> pluginsClassiList(ISearch ricerca) throws DriverConfigurazioneException {
  2346.         String nomeMetodo = "pluginsClassiList";
  2347.        
  2348.         Connection con = null;
  2349.        
  2350.         if (this.atomica) {
  2351.             try {
  2352.                 con = this.datasource.getConnection();
  2353.             } catch (Exception e) {
  2354.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2355.             }

  2356.         } else {
  2357.             con = this.globalConnection;
  2358.         }

  2359.         this.logDebug("operazione this.atomica = " + this.atomica);
  2360.        
  2361.         try {
  2362.             return PluginsDriverUtils.pluginsClassiList(ricerca, con, this.log, this.tipoDB);
  2363.         } catch (Exception qe) {
  2364.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2365.         } finally {
  2366.             releaseConnection(con);
  2367.         }
  2368.     }
  2369.    
  2370.     public void createPluginClassi(Plugin plugin) throws DriverConfigurazioneException {
  2371.         String nomeMetodo = "createPluginClassi";

  2372.         Connection con = null;

  2373.         if (this.atomica) {
  2374.             try {
  2375.                 con = this.datasource.getConnection();
  2376.             } catch (Exception e) {
  2377.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2378.             }

  2379.         } else {
  2380.             con = this.globalConnection;
  2381.         }

  2382.         this.logDebug("operazione this.atomica = " + this.atomica);

  2383.         try {
  2384.             PluginsDriverUtils.createPluginClassi(plugin, con, this.log, this.tipoDB);
  2385.         } catch (Exception qe) {
  2386.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2387.         } finally {
  2388.             releaseConnection(con);
  2389.         }
  2390.     }
  2391.    
  2392.     public void updatePluginClassi(Plugin plugin) throws DriverConfigurazioneException {
  2393.         String nomeMetodo = "updatePluginClassi";

  2394.         Connection con = null;

  2395.         if (this.atomica) {
  2396.             try {
  2397.                 con = this.datasource.getConnection();
  2398.             } catch (Exception e) {
  2399.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2400.             }

  2401.         } else {
  2402.             con = this.globalConnection;
  2403.         }

  2404.         this.logDebug("operazione this.atomica = " + this.atomica);

  2405.         try {
  2406.             PluginsDriverUtils.updatePluginClassi(plugin, con, this.log, this.tipoDB);      
  2407.         } catch (Exception qe) {
  2408.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2409.         } finally {
  2410.             releaseConnection(con);
  2411.         }
  2412.     }
  2413.    
  2414.     public void deletePluginClassi(Plugin plugin) throws DriverConfigurazioneException {
  2415.         String nomeMetodo = "deletePluginClassi";

  2416.         Connection con = null;

  2417.         if (this.atomica) {
  2418.             try {
  2419.                 con = this.datasource.getConnection();
  2420.             } catch (Exception e) {
  2421.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2422.             }

  2423.         } else {
  2424.             con = this.globalConnection;
  2425.         }

  2426.         this.logDebug("operazione this.atomica = " + this.atomica);

  2427.         try {
  2428.             PluginsDriverUtils.deletePluginClassi(plugin, con, this.log, this.tipoDB);      
  2429.         } catch (Exception qe) {
  2430.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2431.         } finally {
  2432.             releaseConnection(con);
  2433.         }
  2434.     }

  2435.     public boolean existsPlugin(TipoPlugin tipoPlugin, String tipo, String label, String className) throws DriverConfigurazioneException {
  2436.         String nomeMetodo = "existsPlugin";
  2437.         Connection con = null;

  2438.         if (this.atomica) {
  2439.             try {
  2440.                 con = this.datasource.getConnection();
  2441.             } catch (Exception e) {
  2442.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2443.             }

  2444.         } else {
  2445.             con = this.globalConnection;
  2446.         }

  2447.         this.logDebug("operazione this.atomica = " + this.atomica);

  2448.         try {
  2449.             return PluginsDriverUtils.existsPlugin(tipoPlugin, tipo, label, className, con, this.log, this.tipoDB);
  2450.         } catch (Exception qe) {
  2451.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2452.         } finally {
  2453.             releaseConnection(con);
  2454.         }
  2455.     }
  2456.    
  2457.     public boolean existsPluginConTipo(TipoPlugin tipoPlugin, String tipo) throws DriverConfigurazioneException {
  2458.         String nomeMetodo = "existsPluginConTipo";
  2459.         Connection con = null;

  2460.         if (this.atomica) {
  2461.             try {
  2462.                 con = this.datasource.getConnection();
  2463.             } catch (Exception e) {
  2464.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2465.             }

  2466.         } else {
  2467.             con = this.globalConnection;
  2468.         }

  2469.         this.logDebug("operazione this.atomica = " + this.atomica);

  2470.         try {
  2471.             return PluginsDriverUtils.existsPluginConTipo(tipoPlugin, tipo, con, this.log, this.tipoDB);
  2472.         } catch (Exception qe) {
  2473.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2474.         } finally {
  2475.             releaseConnection(con);
  2476.         }
  2477.     }
  2478.    
  2479.     public boolean existsPluginConLabel(TipoPlugin tipoPlugin,String label) throws DriverConfigurazioneException {
  2480.         String nomeMetodo = "existsPluginConLabel";
  2481.         Connection con = null;

  2482.         if (this.atomica) {
  2483.             try {
  2484.                 con = this.datasource.getConnection();
  2485.             } catch (Exception e) {
  2486.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2487.             }

  2488.         } else {
  2489.             con = this.globalConnection;
  2490.         }

  2491.         this.logDebug("operazione this.atomica = " + this.atomica);

  2492.         try {
  2493.             return PluginsDriverUtils.existsPluginConLabel(tipoPlugin, label, con, this.log, this.tipoDB);
  2494.         } catch (Exception qe) {
  2495.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2496.         } finally {
  2497.             releaseConnection(con);
  2498.         }
  2499.     }
  2500.    
  2501.     public boolean existsPluginConClassName(TipoPlugin tipoPlugin, String className) throws DriverConfigurazioneException {
  2502.         String nomeMetodo = "existsPluginConClassName";
  2503.         Connection con = null;

  2504.         if (this.atomica) {
  2505.             try {
  2506.                 con = this.datasource.getConnection();
  2507.             } catch (Exception e) {
  2508.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2509.             }

  2510.         } else {
  2511.             con = this.globalConnection;
  2512.         }

  2513.         this.logDebug("operazione this.atomica = " + this.atomica);

  2514.         try {
  2515.             return PluginsDriverUtils.existsPluginConClassName(tipoPlugin, className, con, this.log, this.tipoDB);
  2516.         } catch (Exception qe) {
  2517.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2518.         } finally {
  2519.             releaseConnection(con);
  2520.         }
  2521.     }

  2522.     public Plugin getPlugin(long idPlugin) throws DriverConfigurazioneException {
  2523.         String nomeMetodo = "getPlugin";
  2524.         Connection con = null;

  2525.         if (this.atomica) {
  2526.             try {
  2527.                 con = this.datasource.getConnection();
  2528.             } catch (Exception e) {
  2529.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2530.             }

  2531.         } else {
  2532.             con = this.globalConnection;
  2533.         }

  2534.         this.logDebug("operazione this.atomica = " + this.atomica);

  2535.         try {
  2536.             return PluginsDriverUtils.getPlugin(idPlugin, con, this.log, this.tipoDB);
  2537.         } catch (Exception qe) {
  2538.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2539.         } finally {
  2540.             releaseConnection(con);
  2541.         }
  2542.     }
  2543.    
  2544.     public Plugin getPlugin(TipoPlugin tipoPlugin, String tipo, boolean throwNotFound) throws DriverConfigurazioneException,DriverConfigurazioneNotFound {
  2545.         String nomeMetodo = "getPlugin";
  2546.         Connection con = null;

  2547.         if (this.atomica) {
  2548.             try {
  2549.                 con = this.datasource.getConnection();
  2550.             } catch (Exception e) {
  2551.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2552.             }

  2553.         } else {
  2554.             con = this.globalConnection;
  2555.         }

  2556.         this.logDebug("operazione this.atomica = " + this.atomica);

  2557.         try {
  2558.             return PluginsDriverUtils.getPlugin(tipoPlugin, tipo, throwNotFound, con, this.log, this.tipoDB);
  2559.         }
  2560.         catch(NotFoundException notFound) {
  2561.             throw new DriverConfigurazioneNotFound("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + notFound.getMessage(),notFound);
  2562.         }
  2563.         catch (Exception qe) {
  2564.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2565.         } finally {
  2566.             releaseConnection(con);
  2567.         }
  2568.     }
  2569.    
  2570.     public boolean isPluginInUso(String className, String label, String tipoPlugin, String tipo, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverControlStationException {
  2571.         String nomeMetodo = "isPluginInUso";

  2572.         Connection con = null;
  2573.         con = getConnection(nomeMetodo);

  2574.         this.logDebug("operazione this.atomica = " + this.atomica);

  2575.         try {
  2576.             return DBOggettiInUsoUtils.isPluginInUso(con, this.tipoDB, className, label, tipoPlugin, tipo, whereIsInUso, normalizeObjectIds);
  2577.         } catch (Exception se) {
  2578.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  2579.         } finally {
  2580.             releaseConnection(con);
  2581.         }
  2582.     }
  2583.    
  2584.     public List<ConfigurazioneAllarmeBean> allarmiList(ConsoleSearch ricerca, RuoloPorta ruoloPorta, String nomePorta) throws DriverConfigurazioneException {
  2585.         String nomeMetodo = "allarmiList";
  2586.        
  2587.         Connection con = null;
  2588.        
  2589.         if (this.atomica) {
  2590.             try {
  2591.                 con = this.datasource.getConnection();
  2592.             } catch (Exception e) {
  2593.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2594.             }

  2595.         } else {
  2596.             con = this.globalConnection;
  2597.         }

  2598.         this.logDebug("operazione this.atomica = " + this.atomica);
  2599.        
  2600.         try {
  2601.             return org.openspcoop2.monitor.engine.alarm.utils.AllarmiDriverUtils.allarmiList(ricerca, ruoloPorta, nomePorta, con, this.log, this.tipoDB);
  2602.         } catch (Exception qe) {
  2603.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2604.         } finally {
  2605.             releaseConnection(con);
  2606.         }
  2607.     }
  2608.    
  2609.     public List<Allarme> allarmiSenzaPluginList(ConsoleSearch ricerca, RuoloPorta ruoloPorta, String nomePorta) throws DriverConfigurazioneException {
  2610.         String nomeMetodo = "allarmiSenzaPluginList";
  2611.        
  2612.         Connection con = null;
  2613.        
  2614.         if (this.atomica) {
  2615.             try {
  2616.                 con = this.datasource.getConnection();
  2617.             } catch (Exception e) {
  2618.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2619.             }

  2620.         } else {
  2621.             con = this.globalConnection;
  2622.         }

  2623.         this.logDebug("operazione this.atomica = " + this.atomica);
  2624.        
  2625.         try {
  2626.             return org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils.allarmiList(ricerca, ruoloPorta, nomePorta, con, this.log, this.tipoDB);
  2627.         } catch (Exception qe) {
  2628.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2629.         } finally {
  2630.             releaseConnection(con);
  2631.         }
  2632.     }
  2633.    
  2634.     public boolean existsAllarmi(TipoAllarme tipoAllarme) throws DriverConfigurazioneException {
  2635.         String nomeMetodo = "existsAllarmi";
  2636.        
  2637.         Connection con = null;
  2638.        
  2639.         if (this.atomica) {
  2640.             try {
  2641.                 con = this.datasource.getConnection();
  2642.             } catch (Exception e) {
  2643.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2644.             }

  2645.         } else {
  2646.             con = this.globalConnection;
  2647.         }

  2648.         this.logDebug("operazione this.atomica = " + this.atomica);
  2649.        
  2650.         try {
  2651.             return org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils.existsAllarmi(tipoAllarme, con, this.log, this.tipoDB);
  2652.         } catch (Exception qe) {
  2653.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2654.         } finally {
  2655.             releaseConnection(con);
  2656.         }
  2657.     }
  2658.    
  2659.     public long countAllarmi(TipoAllarme tipoAllarme) throws DriverConfigurazioneException {
  2660.         String nomeMetodo = "countAllarmi";
  2661.        
  2662.         Connection con = null;
  2663.        
  2664.         if (this.atomica) {
  2665.             try {
  2666.                 con = this.datasource.getConnection();
  2667.             } catch (Exception e) {
  2668.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2669.             }

  2670.         } else {
  2671.             con = this.globalConnection;
  2672.         }

  2673.         this.logDebug("operazione this.atomica = " + this.atomica);
  2674.        
  2675.         try {
  2676.             return org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils.countAllarmi(tipoAllarme, con, this.log, this.tipoDB);
  2677.         } catch (Exception qe) {
  2678.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2679.         } finally {
  2680.             releaseConnection(con);
  2681.         }
  2682.     }
  2683.    
  2684.     public void createAllarme(Allarme allarme) throws DriverConfigurazioneException {
  2685.         String nomeMetodo = "createAllarme";

  2686.         Connection con = null;

  2687.         if (this.atomica) {
  2688.             try {
  2689.                 con = this.datasource.getConnection();
  2690.             } catch (Exception e) {
  2691.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2692.             }

  2693.         } else {
  2694.             con = this.globalConnection;
  2695.         }

  2696.         this.logDebug("operazione this.atomica = " + this.atomica);

  2697.         try {
  2698.             org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils.createAllarme(allarme, con, this.log, this.tipoDB);          
  2699.         } catch (Exception qe) {
  2700.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2701.         } finally {
  2702.             releaseConnection(con);
  2703.         }
  2704.     }
  2705.    
  2706.     public void updateAllarme(Allarme allarme) throws DriverConfigurazioneException {
  2707.         String nomeMetodo = "updateAllarme";

  2708.         Connection con = null;

  2709.         if (this.atomica) {
  2710.             try {
  2711.                 con = this.datasource.getConnection();
  2712.             } catch (Exception e) {
  2713.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2714.             }

  2715.         } else {
  2716.             con = this.globalConnection;
  2717.         }

  2718.         this.logDebug("operazione this.atomica = " + this.atomica);

  2719.         try {
  2720.             org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils.updateAllarme(allarme, con, this.log, this.tipoDB);
  2721.         } catch (Exception qe) {
  2722.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2723.         } finally {
  2724.             releaseConnection(con);
  2725.         }
  2726.     }
  2727.    
  2728.     public void deleteAllarme(Allarme allarme) throws DriverConfigurazioneException {
  2729.         String nomeMetodo = "deleteAllarme";

  2730.         Connection con = null;

  2731.         if (this.atomica) {
  2732.             try {
  2733.                 con = this.datasource.getConnection();
  2734.             } catch (Exception e) {
  2735.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2736.             }

  2737.         } else {
  2738.             con = this.globalConnection;
  2739.         }

  2740.         this.logDebug("operazione this.atomica = " + this.atomica);

  2741.         try {
  2742.             org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils.deleteAllarme(allarme, con,  this.log, this.tipoDB);
  2743.         } catch (Exception qe) {
  2744.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2745.         } finally {
  2746.             releaseConnection(con);
  2747.         }
  2748.     }

  2749.     public boolean existsAllarme(String nome) throws DriverConfigurazioneException {
  2750.         String nomeMetodo = "existsAllarme";
  2751.         Connection con = null;

  2752.         if (this.atomica) {
  2753.             try {
  2754.                 con = this.datasource.getConnection();
  2755.             } catch (Exception e) {
  2756.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2757.             }

  2758.         } else {
  2759.             con = this.globalConnection;
  2760.         }

  2761.         this.logDebug("operazione this.atomica = " + this.atomica);

  2762.         try {
  2763.             return org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils.existsAllarme(nome, con, this.log, this.tipoDB);
  2764.         } catch (Exception qe) {
  2765.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2766.         } finally {
  2767.             releaseConnection(con);
  2768.         }
  2769.     }
  2770.    
  2771.     public void createHistoryAllarme(AllarmeHistory allarme) throws DriverConfigurazioneException {
  2772.         String nomeMetodo = "createHistoryAllarme";

  2773.         Connection con = null;

  2774.         if (this.atomica) {
  2775.             try {
  2776.                 con = this.datasource.getConnection();
  2777.             } catch (Exception e) {
  2778.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2779.             }

  2780.         } else {
  2781.             con = this.globalConnection;
  2782.         }

  2783.         this.logDebug("operazione this.atomica = " + this.atomica);

  2784.         try {
  2785.             org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils.createHistoryAllarme(allarme, con, this.log, this.tipoDB);
  2786.         } catch (Exception qe) {
  2787.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2788.         } finally {
  2789.             releaseConnection(con);
  2790.         }
  2791.     }

  2792.    
  2793.     public Allarme getAllarmeSenzaPlugin(Long id) throws DriverConfigurazioneException {
  2794.         String nomeMetodo = "getAllarmeSenzaPlugin";
  2795.         Connection con = null;

  2796.         if (this.atomica) {
  2797.             try {
  2798.                 con = this.datasource.getConnection();
  2799.             } catch (Exception e) {
  2800.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2801.             }

  2802.         } else {
  2803.             con = this.globalConnection;
  2804.         }

  2805.         this.logDebug("operazione this.atomica = " + this.atomica);

  2806.         try {
  2807.             return org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils.getAllarme(id, con, this.log, this.tipoDB);
  2808.         } catch (Exception qe) {
  2809.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2810.         } finally {
  2811.             releaseConnection(con);
  2812.         }
  2813.     }
  2814.    
  2815.     public Allarme getAllarmeSenzaPlugin(String nome) throws DriverConfigurazioneException {
  2816.         String nomeMetodo = "getAllarmeSenzaPluginByNome";
  2817.         Connection con = null;

  2818.         if (this.atomica) {
  2819.             try {
  2820.                 con = this.datasource.getConnection();
  2821.             } catch (Exception e) {
  2822.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2823.             }

  2824.         } else {
  2825.             con = this.globalConnection;
  2826.         }

  2827.         this.logDebug("operazione this.atomica = " + this.atomica);

  2828.         try {
  2829.             return org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils.getAllarme(nome, con, this.log, this.tipoDB);
  2830.         } catch (Exception qe) {
  2831.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2832.         } finally {
  2833.             releaseConnection(con);
  2834.         }
  2835.     }
  2836.    
  2837.     public ConfigurazioneAllarmeBean getAllarme(Long id) throws DriverConfigurazioneException {
  2838.         String nomeMetodo = "getAllarme";
  2839.         Connection con = null;

  2840.         if (this.atomica) {
  2841.             try {
  2842.                 con = this.datasource.getConnection();
  2843.             } catch (Exception e) {
  2844.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2845.             }

  2846.         } else {
  2847.             con = this.globalConnection;
  2848.         }

  2849.         this.logDebug("operazione this.atomica = " + this.atomica);

  2850.         try {
  2851.             return org.openspcoop2.monitor.engine.alarm.utils.AllarmiDriverUtils.getAllarme(id, con, this.log, this.tipoDB);
  2852.         } catch (Exception qe) {
  2853.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2854.         } finally {
  2855.             releaseConnection(con);
  2856.         }
  2857.     }
  2858.    
  2859.     public ConfigurazioneAllarmeBean getAllarme(String nome) throws DriverConfigurazioneException {
  2860.         String nomeMetodo = "getAllarmeByNome";
  2861.         Connection con = null;

  2862.         if (this.atomica) {
  2863.             try {
  2864.                 con = this.datasource.getConnection();
  2865.             } catch (Exception e) {
  2866.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2867.             }

  2868.         } else {
  2869.             con = this.globalConnection;
  2870.         }

  2871.         this.logDebug("operazione this.atomica = " + this.atomica);

  2872.         try {
  2873.             return org.openspcoop2.monitor.engine.alarm.utils.AllarmiDriverUtils.getAllarme(nome, con, this.log, this.tipoDB);
  2874.         } catch (Exception qe) {
  2875.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2876.         } finally {
  2877.             releaseConnection(con);
  2878.         }
  2879.     }

  2880.     public ConfigurazioneAllarmeBean getAllarme(Allarme allarme) throws DriverConfigurazioneException {
  2881.         String nomeMetodo = "convertAllarme";
  2882.         Connection con = null;

  2883.         if (this.atomica) {
  2884.             try {
  2885.                 con = this.datasource.getConnection();
  2886.             } catch (Exception e) {
  2887.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2888.             }

  2889.         } else {
  2890.             con = this.globalConnection;
  2891.         }

  2892.         this.logDebug("operazione this.atomica = " + this.atomica);

  2893.         try {
  2894.             return org.openspcoop2.monitor.engine.alarm.utils.AllarmiDriverUtils.getAllarme(allarme, con, this.log, this.tipoDB);
  2895.         } catch (Exception qe) {
  2896.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2897.         } finally {
  2898.             releaseConnection(con);
  2899.         }
  2900.     }
  2901.    
  2902.     public Allarme getAllarmeByAlias(String alias,
  2903.             RuoloPorta ruoloPorta, String nomePorta) throws DriverControlStationNotFound, DriverConfigurazioneException {
  2904.         String nomeMetodo = "getAllarmeByAlias";
  2905.         Connection con = null;

  2906.         if (this.atomica) {
  2907.             try {
  2908.                 con = this.datasource.getConnection();
  2909.             } catch (Exception e) {
  2910.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2911.             }

  2912.         } else {
  2913.             con = this.globalConnection;
  2914.         }

  2915.         this.logDebug("operazione this.atomica = " + this.atomica);

  2916.         try {
  2917.             return AllarmiDriverUtils.getAllarmeByAlias(alias,
  2918.                     ruoloPorta, nomePorta, con, this.log, this.tipoDB);
  2919.         }catch (NotFoundException e) {
  2920.             throw new DriverControlStationNotFound("[DriverControlStationDB::" + nomeMetodo + "] Allarme non presente.");
  2921.         }  catch (Exception qe) {
  2922.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2923.         } finally {
  2924.             releaseConnection(con);
  2925.         }
  2926.     }
  2927.    
  2928.     public List<ConfigurazioneAllarmeHistoryBean> allarmiHistoryList(ConsoleSearch ricerca, Long idAllarme) throws DriverConfigurazioneException {
  2929.         String nomeMetodo = "allarmiHistoryList";
  2930.                
  2931.         Connection con = null;
  2932.        
  2933.         if (this.atomica) {
  2934.             try {
  2935.                 con = this.datasource.getConnection();
  2936.             } catch (Exception e) {
  2937.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2938.             }

  2939.         } else {
  2940.             con = this.globalConnection;
  2941.         }

  2942.         this.logDebug("operazione this.atomica = " + this.atomica);
  2943.        
  2944.         try {
  2945.             return org.openspcoop2.monitor.engine.alarm.utils.AllarmiDriverUtils.allarmiHistoryList(ricerca, idAllarme, con, this.log, this.tipoDB);

  2946.         } catch (Exception qe) {
  2947.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2948.         } finally {
  2949.             releaseConnection(con);
  2950.         }
  2951.     }
  2952.    
  2953.     public String getNextAlarmInstanceSerialId(String tipoPlugin) throws DriverControlStationException{
  2954.         String nomeMetodo = "getNextAlarmInstanceSerialId";
  2955.         Connection con = null;
  2956.         con = getConnection(nomeMetodo);

  2957.         this.logDebug("operazione this.atomica = " + this.atomica);
  2958.        
  2959.         try{
  2960.             return AllarmiDriverUtils.getNextAlarmInstanceSerialId(tipoPlugin, con, this.log, this.tipoDB);    
  2961.         } catch (Exception qe) {
  2962.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  2963.         } finally {
  2964.             releaseConnection(con);
  2965.         }
  2966.     }
  2967.    
  2968.     public List<ConfigurazioneAllarmeBean> configurazioneAllarmiList(ConsoleSearch ricerca, RuoloPorta ruoloPorta, String nomePorta) throws DriverControlStationException{
  2969.         return this._configurazioneAllarmiList(ricerca, ruoloPorta, nomePorta,
  2970.                 "configurazioneControlloTrafficoAttivazionePolicyList",
  2971.                 null, null, null,
  2972.                 null, null,
  2973.                 null, null);
  2974.     }
  2975.     public List<ConfigurazioneAllarmeBean> configurazioneAllarmiListByFilter(ConsoleSearch ricerca, RuoloPorta ruoloPorta, String nomePorta,
  2976.             IDSoggetto filtroSoggettoFruitore, IDServizioApplicativo filtroApplicativoFruitore,String filtroRuoloFruitore,
  2977.             IDSoggetto filtroSoggettoErogatore, String filtroRuoloErogatore,
  2978.             IDServizio filtroServizioAzione, String filtroRuolo) throws DriverControlStationException{
  2979.         return this._configurazioneAllarmiList(ricerca, ruoloPorta, nomePorta,
  2980.                 "configurazioneControlloTrafficoAttivazionePolicyListByFilter",
  2981.                 filtroSoggettoFruitore, filtroApplicativoFruitore, filtroRuoloFruitore,
  2982.                 filtroSoggettoErogatore, filtroRuoloErogatore,
  2983.                 filtroServizioAzione, filtroRuolo);
  2984.     }
  2985.     private List<ConfigurazioneAllarmeBean> _configurazioneAllarmiList(ConsoleSearch ricerca, RuoloPorta ruoloPorta, String nomePorta, String nomeMetodo,
  2986.             IDSoggetto filtroSoggettoFruitore, IDServizioApplicativo filtroApplicativoFruitore,String filtroRuoloFruitore,
  2987.             IDSoggetto filtroSoggettoErogatore, String filtroRuoloErogatore,
  2988.             IDServizio filtroServizioAzione, String filtroRuolo) throws DriverControlStationException{
  2989.         // ritorna la configurazione controllo del traffico della PdD
  2990.         Connection con = null;
  2991.        
  2992.         con = getConnection(nomeMetodo);

  2993.         this.logDebug("operazione this.atomica = " + this.atomica);
  2994.         List<ConfigurazioneAllarmeBean> listaAllarmi = null;
  2995.        
  2996.         try {
  2997.        
  2998.             listaAllarmi = org.openspcoop2.monitor.engine.alarm.utils.AllarmiDriverUtils.configurazioneAllarmiList(ricerca, ruoloPorta, nomePorta,
  2999.                     con, this.log, this.tipoDB,
  3000.                     nomeMetodo,
  3001.                     filtroSoggettoFruitore, filtroApplicativoFruitore, filtroRuoloFruitore,
  3002.                     filtroSoggettoErogatore, filtroRuoloErogatore,
  3003.                     filtroServizioAzione, filtroRuolo);
  3004.                        
  3005.         } catch (Exception qe) {
  3006.             throw new DriverControlStationException("[DriverControlStationDB::" + nomeMetodo +"] Errore : " + qe.getMessage(),qe);
  3007.         } finally {
  3008.             releaseConnection(con);
  3009.         }
  3010.        
  3011.         return listaAllarmi;
  3012.        
  3013.     }
  3014.    
  3015.     public List<Allarme> allarmiForPolicyRateLimiting(String activeIdPolicy, RuoloPorta ruoloPorta, String nomePorta) throws DriverConfigurazioneException {
  3016.         String nomeMetodo = "allarmiForPolicyRateLimiting";
  3017.        
  3018.         Connection con = null;
  3019.        
  3020.         if (this.atomica) {
  3021.             try {
  3022.                 con = this.datasource.getConnection();
  3023.             } catch (Exception e) {
  3024.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  3025.             }

  3026.         } else {
  3027.             con = this.globalConnection;
  3028.         }

  3029.         this.logDebug("operazione this.atomica = " + this.atomica);
  3030.        
  3031.         try {
  3032.             return org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils.allarmiForPolicyRateLimiting(activeIdPolicy, ruoloPorta, nomePorta, con, this.log, this.tipoDB);
  3033.         } catch (Exception qe) {
  3034.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  3035.         } finally {
  3036.             releaseConnection(con);
  3037.         }
  3038.     }

  3039.     public int numeroHandlersRichiestaList(String tipologia, TipoPdD ruoloPorta, Long idPorta) throws DriverConfigurazioneException {
  3040.         String nomeMetodo = "numeroHandlersRichiestaList";
  3041.         return numeroHandlersList(tipologia, ruoloPorta, idPorta, nomeMetodo, TipoPlugin.MESSAGE_HANDLER);
  3042.     }
  3043.    
  3044.     public int numeroHandlersRispostaList(String tipologia, TipoPdD ruoloPorta, Long idPorta) throws DriverConfigurazioneException {
  3045.         String nomeMetodo = "numeroHandlersRispostaList";
  3046.         return numeroHandlersList(tipologia, ruoloPorta, idPorta, nomeMetodo, TipoPlugin.MESSAGE_HANDLER);
  3047.     }
  3048.    
  3049.     public int numeroHandlersServizioList(String tipologia, TipoPdD ruoloPorta, Long idPorta) throws DriverConfigurazioneException {
  3050.         String nomeMetodo = "numeroHandlersServizioList";
  3051.         return numeroHandlersList(tipologia, ruoloPorta, idPorta, nomeMetodo, TipoPlugin.SERVICE_HANDLER);
  3052.     }
  3053.    
  3054.     private int numeroHandlersList(String tipologia, TipoPdD ruoloPorta, Long idPorta, String nomeMetodo, TipoPlugin tipoPlugin) throws DriverConfigurazioneException {
  3055.         Connection con = null;
  3056.        
  3057.         if (this.atomica) {
  3058.             try {
  3059.                 con = this.datasource.getConnection();
  3060.             } catch (Exception e) {
  3061.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  3062.             }

  3063.         } else {
  3064.             con = this.globalConnection;
  3065.         }

  3066.         this.logDebug("operazione this.atomica = " + this.atomica);

  3067.         try {
  3068.             return HandlersDriverUtils.numeroHandlerList(tipologia, ruoloPorta, idPorta, tipoPlugin, nomeMetodo, con, this.log, this.tipoDB);
  3069.         } catch (Exception qe) {
  3070.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  3071.         } finally {
  3072.             releaseConnection(con);
  3073.         }
  3074.     }
  3075.    
  3076.     public List<ConfigurazioneHandlerBean> handlersRichiestaList(ISearch ricerca, String tipologia, TipoPdD ruoloPorta, Long idPorta) throws DriverConfigurazioneException {
  3077.         String nomeMetodo = "handlersRichiestaList";
  3078.         int idLista = Liste.CONFIGURAZIONE_HANDLERS_RICHIESTA;
  3079.         return handlersList(ricerca, tipologia, ruoloPorta, idPorta, nomeMetodo, idLista, TipoPlugin.MESSAGE_HANDLER);
  3080.     }
  3081.    
  3082.     public List<ConfigurazioneHandlerBean> handlersRispostaList(ISearch ricerca, String tipologia, TipoPdD ruoloPorta, Long idPorta) throws DriverConfigurazioneException {
  3083.         String nomeMetodo = "handlersRispostaList";
  3084.         int idLista = Liste.CONFIGURAZIONE_HANDLERS_RISPOSTA;
  3085.         return handlersList(ricerca, tipologia, ruoloPorta, idPorta, nomeMetodo, idLista, TipoPlugin.MESSAGE_HANDLER);
  3086.     }
  3087.    
  3088.     public List<ConfigurazioneHandlerBean> handlersServizioList(ISearch ricerca, String tipologia, TipoPdD ruoloPorta, Long idPorta) throws DriverConfigurazioneException {
  3089.         String nomeMetodo = "handlersServizioList";
  3090.         int idLista = Liste.CONFIGURAZIONE_HANDLERS_SERVIZIO;
  3091.         return handlersList(ricerca, tipologia, ruoloPorta, idPorta, nomeMetodo, idLista, TipoPlugin.SERVICE_HANDLER);
  3092.     }
  3093.    
  3094.     private List<ConfigurazioneHandlerBean> handlersList(ISearch ricerca, String tipologia, TipoPdD ruoloPorta, Long idPorta, String nomeMetodo, int idLista, TipoPlugin tipoPlugin) throws DriverConfigurazioneException {
  3095.        
  3096.         Connection con = null;
  3097.        
  3098.         if (this.atomica) {
  3099.             try {
  3100.                 con = this.datasource.getConnection();
  3101.             } catch (Exception e) {
  3102.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  3103.             }

  3104.         } else {
  3105.             con = this.globalConnection;
  3106.         }

  3107.         this.logDebug("operazione this.atomica = " + this.atomica);
  3108.        
  3109.         try {
  3110.             return HandlersDriverUtils.handlerList(ricerca, tipologia, ruoloPorta, idPorta, nomeMetodo, idLista, tipoPlugin, con, this.log, this.tipoDB);
  3111.         } catch (Exception qe) {
  3112.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  3113.         } finally {
  3114.             releaseConnection(con);
  3115.         }
  3116.     }
  3117.    
  3118.     public int getMaxPosizioneHandlersRichiesta(String tipologia, TipoPdD ruoloPorta, Long idPorta) throws DriverConfigurazioneException {
  3119.         String nomeMetodo = "getMaxPosizioneHandlersRichiesta";
  3120.         return getMaxPosizioneHandlers(tipologia, ruoloPorta, idPorta, nomeMetodo, TipoPlugin.MESSAGE_HANDLER);
  3121.     }
  3122.    
  3123.     public int getMaxPosizioneHandlersRisposta(String tipologia, TipoPdD ruoloPorta, Long idPorta) throws DriverConfigurazioneException {
  3124.         String nomeMetodo = "getMaxPosizioneHandlersRisposta";
  3125.         return getMaxPosizioneHandlers(tipologia, ruoloPorta, idPorta, nomeMetodo, TipoPlugin.MESSAGE_HANDLER);
  3126.     }
  3127.    
  3128.     public int getMaxPosizioneHandlersServizio(String tipologia, TipoPdD ruoloPorta, Long idPorta) throws DriverConfigurazioneException {
  3129.         String nomeMetodo = "getMaxPosizioneHandlersServizio";
  3130.         return getMaxPosizioneHandlers(tipologia, ruoloPorta, idPorta, nomeMetodo, TipoPlugin.SERVICE_HANDLER);
  3131.     }
  3132.    
  3133.     private int getMaxPosizioneHandlers(String tipologia, TipoPdD ruoloPorta, Long idPorta, String nomeMetodo, TipoPlugin tipoPlugin) throws DriverConfigurazioneException {
  3134.        
  3135.         Connection con = null;
  3136.        
  3137.         if (this.atomica) {
  3138.             try {
  3139.                 con = this.datasource.getConnection();
  3140.             } catch (Exception e) {
  3141.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  3142.             }

  3143.         } else {
  3144.             con = this.globalConnection;
  3145.         }

  3146.         this.logDebug("operazione this.atomica = " + this.atomica);
  3147.        
  3148.         try {
  3149.             return HandlersDriverUtils.getMaxPosizioneHandlers(tipologia, ruoloPorta, idPorta, nomeMetodo, tipoPlugin, con, this.log, this.tipoDB);
  3150.         } catch (Exception qe) {
  3151.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  3152.         } finally {
  3153.             releaseConnection(con);
  3154.         }
  3155.     }
  3156.    
  3157.     public boolean existsHandlerRichiesta(String tipologia, TipoPdD ruoloPorta, Long idPorta, String tipo) throws DriverConfigurazioneException {
  3158.         String nomeMetodo = "existsHandlerRichiesta";
  3159.         return existsHandler(tipologia, ruoloPorta, idPorta, nomeMetodo, TipoPlugin.MESSAGE_HANDLER, tipo);
  3160.     }
  3161.    
  3162.     public boolean existsHandlerRisposta(String tipologia, TipoPdD ruoloPorta, Long idPorta, String tipo) throws DriverConfigurazioneException {
  3163.         String nomeMetodo = "existsHandlerRisposta";
  3164.         return existsHandler(tipologia, ruoloPorta, idPorta, nomeMetodo, TipoPlugin.MESSAGE_HANDLER, tipo);
  3165.     }
  3166.    
  3167.     public boolean existsHandlerServizio(String tipologia, TipoPdD ruoloPorta, Long idPorta, String tipo) throws DriverConfigurazioneException {
  3168.         String nomeMetodo = "existsHandlerServizio";
  3169.         return existsHandler(tipologia, ruoloPorta, idPorta, nomeMetodo, TipoPlugin.SERVICE_HANDLER, tipo);
  3170.     }
  3171.    
  3172.     private boolean existsHandler(String tipologia, TipoPdD ruoloPorta, Long idPorta, String nomeMetodo, TipoPlugin tipoPlugin, String tipo) throws DriverConfigurazioneException {
  3173.        
  3174.         Connection con = null;
  3175.        
  3176.         if (this.atomica) {
  3177.             try {
  3178.                 con = this.datasource.getConnection();
  3179.             } catch (Exception e) {
  3180.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  3181.             }

  3182.         } else {
  3183.             con = this.globalConnection;
  3184.         }

  3185.         this.logDebug("operazione this.atomica = " + this.atomica);
  3186.        
  3187.         try {
  3188.             return HandlersDriverUtils.existsHandler(tipologia, ruoloPorta, idPorta, nomeMetodo, tipoPlugin, tipo, con, this.log, this.tipoDB);
  3189.         } catch (Exception qe) {
  3190.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  3191.         } finally {
  3192.             releaseConnection(con);
  3193.         }
  3194.     }
  3195.    
  3196.     public ConfigurazioneHandlerBean getHandlerRichiesta(String tipologia, TipoPdD ruoloPorta, Long idPorta, Long idHandler) throws DriverConfigurazioneException {
  3197.         String nomeMetodo = "getHandlerRichiesta";
  3198.         return getHandler(tipologia, ruoloPorta, idPorta, idHandler, nomeMetodo, TipoPlugin.MESSAGE_HANDLER);
  3199.     }
  3200.    
  3201.     public ConfigurazioneHandlerBean getHandlerRisposta(String tipologia, TipoPdD ruoloPorta, Long idPorta, Long idHandler) throws DriverConfigurazioneException {
  3202.         String nomeMetodo = "getHandlerRisposta";
  3203.         return getHandler(tipologia, ruoloPorta, idPorta, idHandler, nomeMetodo, TipoPlugin.MESSAGE_HANDLER);
  3204.     }
  3205.    
  3206.     public ConfigurazioneHandlerBean getHandlerServizio(String tipologia, TipoPdD ruoloPorta, Long idPorta, Long idHandler) throws DriverConfigurazioneException {
  3207.         String nomeMetodo = "getHandlerServizio";
  3208.         return getHandler(tipologia, ruoloPorta, idPorta, idHandler, nomeMetodo, TipoPlugin.SERVICE_HANDLER);
  3209.     }
  3210.    
  3211.     private ConfigurazioneHandlerBean getHandler(String tipologia, TipoPdD ruoloPorta, Long idPorta, Long idHandler, String nomeMetodo, TipoPlugin tipoPlugin) throws DriverConfigurazioneException {
  3212.        
  3213.         Connection con = null;
  3214.        
  3215.         if (this.atomica) {
  3216.             try {
  3217.                 con = this.datasource.getConnection();
  3218.             } catch (Exception e) {
  3219.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  3220.             }

  3221.         } else {
  3222.             con = this.globalConnection;
  3223.         }

  3224.         this.logDebug("operazione this.atomica = " + this.atomica);
  3225.        
  3226.         try {
  3227.             return HandlersDriverUtils.getHandler(tipologia, ruoloPorta, idPorta, idHandler, nomeMetodo, tipoPlugin, con, this.log, this.tipoDB);
  3228.         } catch (Exception qe) {
  3229.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  3230.         } finally {
  3231.             releaseConnection(con);
  3232.         }
  3233.     }
  3234.    
  3235.     public void updateProprietaOggettoErogazione(IDServizio idServizio, String user, boolean throwException) throws DriverRegistroServiziException{
  3236.         Connection con = null;
  3237.         String nomeMetodo = "updateProprietaOggettoErogazione";
  3238.         DriverRegistroServiziDB driver = null;

  3239.         if (this.atomica) {
  3240.             try {
  3241.                 con = this.datasource.getConnection();
  3242.             } catch (Exception e) {
  3243.                 throw new DriverRegistroServiziException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  3244.             }

  3245.         } else {
  3246.             con = this.globalConnection;
  3247.         }
  3248.        
  3249.         try {

  3250.             this.logDebug("operazione this.atomica = " + this.atomica);
  3251.            
  3252.             // istanzio il driver
  3253.             driver = new DriverRegistroServiziDB(con, this.log, this.tipoDB);

  3254.             driver.updateProprietaOggettoErogazione(idServizio,user);
  3255.            
  3256.         } catch (Exception e) {
  3257.             String msgError = "[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + e.getMessage();
  3258.             ControlStationCore.logError(msgError, e);
  3259.             if(throwException) {
  3260.                 throw new DriverRegistroServiziException(msgError, e);
  3261.             }
  3262.         } finally {
  3263.             releaseConnection(con);
  3264.         }
  3265.     }
  3266.     public void updateProprietaOggettoErogazione(long idServizio, String user, boolean throwException) throws DriverRegistroServiziException{
  3267.         Connection con = null;
  3268.         String nomeMetodo = "updateProprietaOggettoErogazione";
  3269.         DriverRegistroServiziDB driver = null;

  3270.         if (this.atomica) {
  3271.             try {
  3272.                 con = this.datasource.getConnection();
  3273.             } catch (Exception e) {
  3274.                 throw new DriverRegistroServiziException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  3275.             }

  3276.         } else {
  3277.             con = this.globalConnection;
  3278.         }
  3279.        
  3280.         try {

  3281.             this.logDebug("operazione this.atomica = " + this.atomica);
  3282.            
  3283.             // istanzio il driver
  3284.             driver = new DriverRegistroServiziDB(con, this.log, this.tipoDB);

  3285.             driver.updateProprietaOggettoErogazione(idServizio,user);
  3286.            
  3287.         } catch (Exception e) {
  3288.             String msgError = "[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + e.getMessage();
  3289.             ControlStationCore.logError(msgError, e);
  3290.             if(throwException) {
  3291.                 throw new DriverRegistroServiziException(msgError, e);
  3292.             }
  3293.         } finally {
  3294.             releaseConnection(con);
  3295.         }
  3296.     }
  3297.     public void updateProprietaOggettoFruizione(IDServizio idServizio, IDSoggetto idFruitore, String user, boolean throwException) throws DriverRegistroServiziException{
  3298.         Connection con = null;
  3299.         String nomeMetodo = "updateProprietaOggettoFruizione";
  3300.         DriverRegistroServiziDB driver = null;

  3301.         if (this.atomica) {
  3302.             try {
  3303.                 con = this.datasource.getConnection();
  3304.             } catch (Exception e) {
  3305.                 throw new DriverRegistroServiziException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  3306.             }

  3307.         } else {
  3308.             con = this.globalConnection;
  3309.         }
  3310.        
  3311.         try {

  3312.             this.logDebug("operazione this.atomica = " + this.atomica);
  3313.            
  3314.             // istanzio il driver
  3315.             driver = new DriverRegistroServiziDB(con, this.log, this.tipoDB);

  3316.             driver.updateProprietaOggettoFruizione(idServizio,idFruitore,user);
  3317.            
  3318.         } catch (Exception e) {
  3319.             String msgError = "[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + e.getMessage();
  3320.             ControlStationCore.logError(msgError, e);
  3321.             if(throwException) {
  3322.                 throw new DriverRegistroServiziException(msgError, e);
  3323.             }
  3324.         } finally {
  3325.             releaseConnection(con);
  3326.         }
  3327.     }
  3328.     public void updateProprietaOggettoFruizione(long idFruizione, String user, boolean throwException) throws DriverRegistroServiziException{
  3329.         Connection con = null;
  3330.         String nomeMetodo = "updateProprietaOggettoFruizione";
  3331.         DriverRegistroServiziDB driver = null;

  3332.         if (this.atomica) {
  3333.             try {
  3334.                 con = this.datasource.getConnection();
  3335.             } catch (Exception e) {
  3336.                 throw new DriverRegistroServiziException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  3337.             }

  3338.         } else {
  3339.             con = this.globalConnection;
  3340.         }
  3341.        
  3342.         try {

  3343.             this.logDebug("operazione this.atomica = " + this.atomica);
  3344.            
  3345.             // istanzio il driver
  3346.             driver = new DriverRegistroServiziDB(con, this.log, this.tipoDB);

  3347.             driver.updateProprietaOggettoFruizione(idFruizione,user);
  3348.            
  3349.         } catch (Exception e) {
  3350.             String msgError = "[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + e.getMessage();
  3351.             ControlStationCore.logError(msgError, e);
  3352.             if(throwException) {
  3353.                 throw new DriverRegistroServiziException(msgError, e);
  3354.             }
  3355.         } finally {
  3356.             releaseConnection(con);
  3357.         }
  3358.     }
  3359. }