AbstractArchiveEngine.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.protocol.engine.archive;

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

  25. import org.apache.commons.lang.StringUtils;
  26. import org.openspcoop2.core.allarmi.Allarme;
  27. import org.openspcoop2.core.allarmi.IdAllarme;
  28. import org.openspcoop2.core.allarmi.constants.RuoloPorta;
  29. import org.openspcoop2.core.allarmi.utils.AllarmiDriverUtils;
  30. import org.openspcoop2.core.commons.ErrorsHandlerCostant;
  31. import org.openspcoop2.core.config.Configurazione;
  32. import org.openspcoop2.core.config.ConfigurazioneGestioneErrore;
  33. import org.openspcoop2.core.config.ConfigurazioneUrlInvocazione;
  34. import org.openspcoop2.core.config.ConfigurazioneUrlInvocazioneRegola;
  35. import org.openspcoop2.core.config.GenericProperties;
  36. import org.openspcoop2.core.config.GestioneErrore;
  37. import org.openspcoop2.core.config.PortaApplicativa;
  38. import org.openspcoop2.core.config.PortaDelegata;
  39. import org.openspcoop2.core.config.RegistroPlugin;
  40. import org.openspcoop2.core.config.RegistroPluginArchivio;
  41. import org.openspcoop2.core.config.RegistroPlugins;
  42. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  43. import org.openspcoop2.core.config.driver.DriverConfigurazioneException;
  44. import org.openspcoop2.core.config.driver.DriverConfigurazioneNotFound;
  45. import org.openspcoop2.core.config.driver.FiltroRicercaPorteApplicative;
  46. import org.openspcoop2.core.config.driver.FiltroRicercaPorteDelegate;
  47. import org.openspcoop2.core.config.driver.FiltroRicercaServiziApplicativi;
  48. import org.openspcoop2.core.config.driver.FiltroRicercaSoggetti;
  49. import org.openspcoop2.core.config.driver.db.DriverConfigurazioneDB;
  50. import org.openspcoop2.core.config.utils.ConfigurazionePdDUtils;
  51. import org.openspcoop2.core.controllo_traffico.AttivazionePolicy;
  52. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  53. import org.openspcoop2.core.controllo_traffico.ConfigurazionePolicy;
  54. import org.openspcoop2.core.controllo_traffico.IdActivePolicy;
  55. import org.openspcoop2.core.controllo_traffico.IdPolicy;
  56. import org.openspcoop2.core.controllo_traffico.beans.InfoPolicy;
  57. import org.openspcoop2.core.controllo_traffico.constants.RuoloPolicy;
  58. import org.openspcoop2.core.controllo_traffico.utils.ControlloTrafficoDriverUtils;
  59. import org.openspcoop2.core.id.IDAccordo;
  60. import org.openspcoop2.core.id.IDAccordoCooperazione;
  61. import org.openspcoop2.core.id.IDGenericProperties;
  62. import org.openspcoop2.core.id.IDGruppo;
  63. import org.openspcoop2.core.id.IDPortaApplicativa;
  64. import org.openspcoop2.core.id.IDPortaDelegata;
  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.IdPlugin;
  74. import org.openspcoop2.core.plugins.Plugin;
  75. import org.openspcoop2.core.registry.AccordoCooperazione;
  76. import org.openspcoop2.core.registry.AccordoServizioParteComune;
  77. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  78. import org.openspcoop2.core.registry.Fruitore;
  79. import org.openspcoop2.core.registry.Gruppo;
  80. import org.openspcoop2.core.registry.PortaDominio;
  81. import org.openspcoop2.core.registry.Ruolo;
  82. import org.openspcoop2.core.registry.Scope;
  83. import org.openspcoop2.core.registry.driver.DriverRegistroServiziException;
  84. import org.openspcoop2.core.registry.driver.DriverRegistroServiziNotFound;
  85. import org.openspcoop2.core.registry.driver.FiltroRicerca;
  86. import org.openspcoop2.core.registry.driver.FiltroRicercaAccordi;
  87. import org.openspcoop2.core.registry.driver.FiltroRicercaGruppi;
  88. import org.openspcoop2.core.registry.driver.FiltroRicercaRuoli;
  89. import org.openspcoop2.core.registry.driver.FiltroRicercaScope;
  90. import org.openspcoop2.core.registry.driver.FiltroRicercaServizi;
  91. import org.openspcoop2.core.registry.driver.ValidazioneStatoPackageException;
  92. import org.openspcoop2.core.registry.driver.db.DriverRegistroServiziDB;
  93. import org.openspcoop2.generic_project.exception.NotFoundException;
  94. import org.openspcoop2.generic_project.expression.IExpression;
  95. import org.openspcoop2.generic_project.expression.IPaginatedExpression;
  96. import org.openspcoop2.protocol.engine.ConfigurazioneFiltroServiziApplicativi;
  97. import org.openspcoop2.protocol.engine.ProtocolFactoryManager;
  98. import org.openspcoop2.protocol.engine.utils.DBOggettiInUsoUtils;
  99. import org.openspcoop2.protocol.sdk.IProtocolFactory;
  100. import org.openspcoop2.protocol.sdk.archive.Archive;
  101. import org.openspcoop2.protocol.sdk.registry.RegistryException;
  102. import org.openspcoop2.utils.certificate.ArchiveLoader;
  103. import org.openspcoop2.utils.certificate.Certificate;
  104. import org.openspcoop2.utils.date.DateManager;
  105. import org.slf4j.Logger;

  106. /**
  107.  *  AbstractArchiveEngine
  108.  *
  109.  * @author Poli Andrea (apoli@link.it)
  110.  * @author $Author$
  111.  * @version $Rev$, $Date$
  112.  */
  113. public abstract class AbstractArchiveEngine {

  114.     private DriverRegistroServiziDB driverRegistroServizi;
  115.     public DriverRegistroServiziDB getDriverRegistroServizi() {
  116.         return this.driverRegistroServizi;
  117.     }

  118.     private DriverConfigurazioneDB driverConfigurazione;
  119.     public DriverConfigurazioneDB getDriverConfigurazione() {
  120.         return this.driverConfigurazione;
  121.     }

  122.     private org.openspcoop2.core.plugins.dao.jdbc.JDBCServiceManager serviceManagerPlugins;
  123.     public org.openspcoop2.core.plugins.dao.jdbc.JDBCServiceManager getServiceManagerPlugins() {
  124.         return this.serviceManagerPlugins;
  125.     }
  126.    
  127.     private org.openspcoop2.core.controllo_traffico.dao.jdbc.JDBCServiceManager serviceManagerControlloTraffico;
  128.     public org.openspcoop2.core.controllo_traffico.dao.jdbc.JDBCServiceManager getServiceManagerControlloTraffico() {
  129.         return this.serviceManagerControlloTraffico;
  130.     }
  131.    
  132.     private org.openspcoop2.core.allarmi.dao.jdbc.JDBCServiceManager serviceManagerAllarmi;
  133.     public org.openspcoop2.core.allarmi.dao.jdbc.JDBCServiceManager getServiceManagerAllarmi() {
  134.         return this.serviceManagerAllarmi;
  135.     }

  136.     public AbstractArchiveEngine(DriverRegistroServiziDB driverRegistroServizi,DriverConfigurazioneDB driverConfigurazione,
  137.             org.openspcoop2.core.plugins.dao.jdbc.JDBCServiceManager serviceManagerPlugins,
  138.             org.openspcoop2.core.controllo_traffico.dao.jdbc.JDBCServiceManager serviceManagerControlloTraffico,
  139.             org.openspcoop2.core.allarmi.dao.jdbc.JDBCServiceManager serviceManagerAllarmi){
  140.         this.driverRegistroServizi = driverRegistroServizi;
  141.         this.driverConfigurazione = driverConfigurazione;
  142.         this.serviceManagerPlugins = serviceManagerPlugins;
  143.         this.serviceManagerControlloTraffico = serviceManagerControlloTraffico;
  144.         this.serviceManagerAllarmi = serviceManagerAllarmi;
  145.     }
  146.    

  147.     public void finalizeImport(Archive archive) throws DriverConfigurazioneException{
  148.        
  149.     }
  150.     public void finalizeDelete(Archive archive) throws DriverConfigurazioneException{
  151.        
  152.     }
  153.    
  154.    
  155.     // --- Users ---
  156.    
  157.     public abstract boolean isVisioneOggettiGlobale(String userLogin);
  158.    
  159.    
  160.     // --- PDD ---
  161.    
  162.     public List<String> getAllIdPorteDominio(FiltroRicerca filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  163.         return this.driverRegistroServizi.getAllIdPorteDominio(filtroRicerca);
  164.     }
  165.    
  166.     public PortaDominio getPortaDominio(String nomePortaDominio) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  167.         return this.driverRegistroServizi.getPortaDominio(nomePortaDominio);
  168.     }
  169.    
  170.     public String getTipoPortaDominio(String nomePortaDominio) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  171.         return this.driverRegistroServizi.getTipoPortaDominio(nomePortaDominio);
  172.     }
  173.    
  174.     public boolean existsPortaDominio(String nomePortaDominio) throws DriverRegistroServiziException {
  175.         return this.driverRegistroServizi.existsPortaDominio(nomePortaDominio);
  176.     }
  177.    
  178.     public void createPortaDominio(PortaDominio pdd) throws DriverRegistroServiziException {
  179.         this.driverRegistroServizi.createPortaDominio(pdd);
  180.     }
  181.    
  182.     public void updatePortaDominio(PortaDominio pdd) throws DriverRegistroServiziException {
  183.         this.driverRegistroServizi.updatePortaDominio(pdd);
  184.     }
  185.    
  186.     public void deletePortaDominio(PortaDominio pdd) throws DriverRegistroServiziException {
  187.         this.driverRegistroServizi.deletePortaDominio(pdd);
  188.     }
  189.    
  190.     public boolean isPddInUso(String nomePortaDominio, List<String> whereIsInUso, boolean normalizeObjectIds) throws DriverRegistroServiziException {
  191.         Connection con = null;
  192.         try{
  193.             con = this.driverRegistroServizi.getConnection("archive.isPddInUso");
  194.             return DBOggettiInUsoUtils.isPddInUso(con, this.driverRegistroServizi.getTipoDB(), nomePortaDominio, whereIsInUso, normalizeObjectIds);
  195.         }
  196.         catch(Exception e){
  197.             throw new DriverRegistroServiziException(e.getMessage(),e);
  198.         }
  199.         finally{
  200.             try{
  201.                 this.driverRegistroServizi.releaseConnection(con);
  202.             }catch(Exception eClose){
  203.                 // close
  204.             }
  205.         }
  206.     }
  207.    
  208.    
  209.    
  210.    
  211.    
  212.    
  213.    
  214.    
  215.     // --- GRUPPI ---
  216.    
  217.     public List<IDGruppo> getAllIdGruppi(FiltroRicercaGruppi filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  218.         return this.driverRegistroServizi.getAllIdGruppi(filtroRicerca);
  219.     }
  220.    
  221.     public Gruppo getGruppo(IDGruppo idGruppo) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  222.         return this.driverRegistroServizi.getGruppo(idGruppo);
  223.     }
  224.    
  225.     public boolean existsGruppo(IDGruppo idGruppo) throws DriverRegistroServiziException {
  226.         return this.driverRegistroServizi.existsGruppo(idGruppo);
  227.     }
  228.    
  229.     public void createGruppo(Gruppo gruppo) throws DriverRegistroServiziException {
  230.         this.driverRegistroServizi.createGruppo(gruppo);
  231.     }
  232.    
  233.     public void updateGruppo(Gruppo gruppo) throws DriverRegistroServiziException {
  234.         this.driverRegistroServizi.updateGruppo(gruppo);
  235.     }
  236.    
  237.     public void deleteGruppo(Gruppo gruppo) throws DriverRegistroServiziException {
  238.         this.driverRegistroServizi.deleteGruppo(gruppo);
  239.     }
  240.    
  241.     public boolean isGruppoInUso(IDGruppo idGruppo, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverRegistroServiziException {
  242.         Connection con = null;
  243.         try{
  244.             con = this.driverRegistroServizi.getConnection("archive.isGruppoInUso");
  245.             return DBOggettiInUsoUtils.isGruppoInUso(con, this.driverRegistroServizi.getTipoDB(), idGruppo, whereIsInUso, normalizeObjectIds);
  246.         }
  247.         catch(Exception e){
  248.             throw new DriverRegistroServiziException(e.getMessage(),e);
  249.         }
  250.         finally{
  251.             try{
  252.                 this.driverRegistroServizi.releaseConnection(con);
  253.             }catch(Exception eClose){
  254.                 // close
  255.             }
  256.         }
  257.     }
  258.    
  259.    
  260.    
  261.    
  262.    
  263.    
  264.    
  265.    
  266.    
  267.     // --- RUOLI ---
  268.    
  269.     public List<IDRuolo> getAllIdRuoli(FiltroRicercaRuoli filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  270.         return this.driverRegistroServizi.getAllIdRuoli(filtroRicerca);
  271.     }
  272.    
  273.     public Ruolo getRuolo(IDRuolo idRuolo) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  274.         return this.driverRegistroServizi.getRuolo(idRuolo);
  275.     }
  276.    
  277.     public boolean existsRuolo(IDRuolo idRuolo) throws DriverRegistroServiziException {
  278.         return this.driverRegistroServizi.existsRuolo(idRuolo);
  279.     }
  280.    
  281.     public void createRuolo(Ruolo ruolo) throws DriverRegistroServiziException {
  282.         this.driverRegistroServizi.createRuolo(ruolo);
  283.     }
  284.    
  285.     public void updateRuolo(Ruolo ruolo) throws DriverRegistroServiziException {
  286.         this.driverRegistroServizi.updateRuolo(ruolo);
  287.     }
  288.    
  289.     public void deleteRuolo(Ruolo ruolo) throws DriverRegistroServiziException {
  290.         this.driverRegistroServizi.deleteRuolo(ruolo);
  291.     }
  292.    
  293.     public boolean isRuoloInUso(IDRuolo idRuolo, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverRegistroServiziException {
  294.         Connection con = null;
  295.         try{
  296.             con = this.driverRegistroServizi.getConnection("archive.isRuoloInUso");
  297.             return DBOggettiInUsoUtils.isRuoloInUso(con, this.driverRegistroServizi.getTipoDB(), idRuolo, whereIsInUso, normalizeObjectIds);
  298.         }
  299.         catch(Exception e){
  300.             throw new DriverRegistroServiziException(e.getMessage(),e);
  301.         }
  302.         finally{
  303.             try{
  304.                 this.driverRegistroServizi.releaseConnection(con);
  305.             }catch(Exception eClose){
  306.                 // close
  307.             }
  308.         }
  309.     }
  310.    
  311.    
  312.    
  313.    
  314.    
  315.    
  316.     // --- SCOPE ---
  317.    
  318.     public List<IDScope> getAllIdScope(FiltroRicercaScope filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  319.         return this.driverRegistroServizi.getAllIdScope(filtroRicerca);
  320.     }
  321.    
  322.     public Scope getScope(IDScope idScope) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  323.         return this.driverRegistroServizi.getScope(idScope);
  324.     }
  325.    
  326.     public boolean existsScope(IDScope idScope) throws DriverRegistroServiziException {
  327.         return this.driverRegistroServizi.existsScope(idScope);
  328.     }
  329.    
  330.     public void createScope(Scope scope) throws DriverRegistroServiziException {
  331.         this.driverRegistroServizi.createScope(scope);
  332.     }
  333.    
  334.     public void updateScope(Scope scope) throws DriverRegistroServiziException {
  335.         this.driverRegistroServizi.updateScope(scope);
  336.     }
  337.    
  338.     public void deleteScope(Scope scope) throws DriverRegistroServiziException {
  339.         this.driverRegistroServizi.deleteScope(scope);
  340.     }
  341.    
  342.     public boolean isScopeInUso(IDScope idScope, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverRegistroServiziException {
  343.         Connection con = null;
  344.         try{
  345.             con = this.driverRegistroServizi.getConnection("archive.isScopeInUso");
  346.             return DBOggettiInUsoUtils.isScopeInUso(con, this.driverRegistroServizi.getTipoDB(), idScope, whereIsInUso, normalizeObjectIds);
  347.         }
  348.         catch(Exception e){
  349.             throw new DriverRegistroServiziException(e.getMessage(),e);
  350.         }
  351.         finally{
  352.             try{
  353.                 this.driverRegistroServizi.releaseConnection(con);
  354.             }catch(Exception eClose){
  355.                 // close
  356.             }
  357.         }
  358.     }

  359.    
  360.        
  361.    
  362.    
  363.     // --- Soggetti Registro ---
  364.    
  365.     public List<IDSoggetto> getAllIdSoggettiRegistro(org.openspcoop2.core.registry.driver.FiltroRicercaSoggetti filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  366.         return this.driverRegistroServizi.getAllIdSoggetti(filtroRicerca);
  367.     }
  368.    
  369.     public org.openspcoop2.core.registry.Soggetto getSoggettoRegistro(IDSoggetto idSoggetto) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  370.         return this.driverRegistroServizi.getSoggetto(idSoggetto);
  371.     }
  372.    
  373.     public boolean existsSoggettoRegistro(IDSoggetto idSoggetto) throws DriverRegistroServiziException {
  374.         return this.driverRegistroServizi.existsSoggetto(idSoggetto);
  375.     }
  376.    
  377.     public void createSoggettoRegistro(org.openspcoop2.core.registry.Soggetto soggetto) throws DriverRegistroServiziException {
  378.         this.driverRegistroServizi.createSoggetto(soggetto);
  379.     }
  380.    
  381.     public void updateSoggettoRegistro(org.openspcoop2.core.registry.Soggetto soggetto) throws DriverRegistroServiziException {
  382.         this.driverRegistroServizi.updateSoggetto(soggetto);
  383.     }
  384.    
  385.     public void deleteSoggettoRegistro(org.openspcoop2.core.registry.Soggetto soggetto) throws DriverRegistroServiziException {
  386.         this.driverRegistroServizi.deleteSoggetto(soggetto);
  387.     }
  388.    
  389.     public boolean isSoggettoRegistroInUso(IDSoggetto idSoggetto, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds, boolean verificaRuoli) throws DriverRegistroServiziException {
  390.         Connection con = null;
  391.         try{
  392.             con = this.driverRegistroServizi.getConnection("archive.isSoggettoRegistroInUso");
  393.             return DBOggettiInUsoUtils.isSoggettoRegistryInUso(con, this.driverRegistroServizi.getTipoDB(), idSoggetto, true, whereIsInUso, normalizeObjectIds, verificaRuoli);
  394.         }
  395.         catch(Exception e){
  396.             throw new DriverRegistroServiziException(e.getMessage(),e);
  397.         }
  398.         finally{
  399.             try{
  400.                 this.driverRegistroServizi.releaseConnection(con);
  401.             }catch(Exception eClose){
  402.                 // close
  403.             }
  404.         }
  405.     }
  406.    
  407.     public IDSoggetto getSoggettoDefault(String protocollo) throws DriverRegistroServiziException{
  408.         try {
  409.             List<IDSoggetto> soggettiDefault = this.driverRegistroServizi.getSoggettiDefault();
  410.             if(soggettiDefault!=null && !soggettiDefault.isEmpty()) {
  411.                 ProtocolFactoryManager protocolFactoryManager = ProtocolFactoryManager.getInstance();
  412.                 for (IDSoggetto idSoggetto : soggettiDefault) {
  413.                     if(idSoggetto!=null && idSoggetto.getTipo()!=null) {
  414.                         String protCheck = protocolFactoryManager.getProtocolByOrganizationType(idSoggetto.getTipo());
  415.                         if(protCheck.equals(protocollo)) {
  416.                             return idSoggetto;
  417.                         }
  418.                     }
  419.                 }
  420.             }
  421.             return null;
  422.         }catch(Exception e) {
  423.             throw new DriverRegistroServiziException(e.getMessage(),e);
  424.         }
  425.     }
  426.    
  427.     public org.openspcoop2.core.registry.Soggetto getSoggettoRegistroCredenzialiBasic(String utente) throws DriverRegistroServiziException{
  428.         return this.driverRegistroServizi.soggettoWithCredenzialiBasic(utente, null, false);
  429.     }
  430.     public org.openspcoop2.core.registry.Soggetto getSoggettoRegistroCredenzialiApiKey(String utente, boolean appId) throws DriverRegistroServiziException{
  431.         return this.driverRegistroServizi.soggettoWithCredenzialiApiKey(utente, appId);
  432.     }
  433.     public org.openspcoop2.core.registry.Soggetto getSoggettoRegistroCredenzialiSsl(String subject, String issuer) throws DriverRegistroServiziException{
  434.         try {
  435.             return this.driverRegistroServizi.getSoggettoByCredenzialiSsl(subject, issuer);
  436.         }catch(DriverRegistroServiziNotFound notFound) {
  437.             return null;
  438.         }
  439.     }
  440.     public org.openspcoop2.core.registry.Soggetto getSoggettoRegistroCredenzialiSsl(byte[]archivio, boolean strictVerifier) throws DriverRegistroServiziException{
  441.         Certificate cSelezionato = null;
  442.         try {
  443.             cSelezionato = ArchiveLoader.load(archivio);
  444.         }catch(Exception e) {
  445.             throw new DriverRegistroServiziException(e.getMessage(),e);
  446.         }
  447.         try {
  448.             return this.driverRegistroServizi.getSoggettoByCredenzialiSsl(cSelezionato.getCertificate(), strictVerifier);
  449.         }catch(DriverRegistroServiziNotFound notFound) {
  450.             return null;
  451.         }
  452.     }
  453.     public org.openspcoop2.core.registry.Soggetto getSoggettoRegistroCredenzialiPrincipal(String principal) throws DriverRegistroServiziException{
  454.         try {
  455.             return this.driverRegistroServizi.getSoggettoByCredenzialiPrincipal(principal);
  456.         }catch(DriverRegistroServiziNotFound notFound) {
  457.             return null;
  458.         }
  459.     }
  460.    
  461.    
  462.    
  463.     // --- Soggetti Configurazione ---
  464.        
  465.     public List<IDSoggetto> getAllIdSoggettiConfigurazione(FiltroRicercaSoggetti filtroRicerca) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  466.         return this.driverConfigurazione.getAllIdSoggetti(filtroRicerca);
  467.     }
  468.    
  469.     public org.openspcoop2.core.config.Soggetto getSoggettoConfigurazione(IDSoggetto idSoggetto) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  470.         return this.driverConfigurazione.getSoggetto(idSoggetto);
  471.     }
  472.    
  473.     public boolean existsSoggettoConfigurazione(IDSoggetto idSoggetto) throws DriverConfigurazioneException {
  474.         return this.driverConfigurazione.existsSoggetto(idSoggetto);
  475.     }
  476.    
  477.     public void createSoggettoConfigurazione(org.openspcoop2.core.config.Soggetto soggetto) throws DriverConfigurazioneException {
  478.         this.driverConfigurazione.createSoggetto(soggetto);
  479.     }
  480.    
  481.     public void updateSoggettoConfigurazione(org.openspcoop2.core.config.Soggetto soggetto) throws DriverConfigurazioneException {
  482.         this.driverConfigurazione.updateSoggetto(soggetto);
  483.     }
  484.    
  485.     public void deleteSoggettoConfigurazione(org.openspcoop2.core.config.Soggetto soggetto) throws DriverConfigurazioneException {
  486.         this.driverConfigurazione.deleteSoggetto(soggetto);
  487.     }
  488.    
  489.     public boolean isSoggettoConfigurazioneInUso(IDSoggetto idSoggetto, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds, boolean verificaRuoli) throws DriverConfigurazioneException {
  490.         Connection con = null;
  491.         try{
  492.             con = this.driverConfigurazione.getConnection("archive.isSoggettoConfigurazioneInUso");
  493.             return DBOggettiInUsoUtils.isSoggettoConfigInUso(con, this.driverConfigurazione.getTipoDB(), idSoggetto, true, whereIsInUso, normalizeObjectIds, verificaRuoli);
  494.         }
  495.         catch(Exception e){
  496.             throw new DriverConfigurazioneException(e.getMessage(),e);
  497.         }
  498.         finally{
  499.             try{
  500.                 this.driverConfigurazione.releaseConnection(con);
  501.             }catch(Exception eClose){
  502.                 // close
  503.             }
  504.         }
  505.     }
  506.    
  507.    
  508.    
  509.     // --- Servizi Applicativi ---
  510.    
  511.     public List<IDServizioApplicativo> getAllIdServiziApplicativi(FiltroRicercaServiziApplicativi filtroRicerca) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  512.         return this.driverConfigurazione.getAllIdServiziApplicativi(filtroRicerca);
  513.     }
  514.    
  515.     public org.openspcoop2.core.config.ServizioApplicativo getServizioApplicativo(IDServizioApplicativo idServizioApplicativo) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  516.         return this.driverConfigurazione.getServizioApplicativo(idServizioApplicativo);
  517.     }
  518.    
  519.     public boolean existsServizioApplicativo(IDServizioApplicativo idServizioApplicativo) throws DriverConfigurazioneException {
  520.         return this.driverConfigurazione.existsServizioApplicativo(idServizioApplicativo);
  521.     }
  522.    
  523.     public void createServizioApplicativo(org.openspcoop2.core.config.ServizioApplicativo servizioApplicativo) throws DriverConfigurazioneException {
  524.         this.driverConfigurazione.createServizioApplicativo(servizioApplicativo);
  525.     }
  526.    
  527.     public void updateServizioApplicativo(org.openspcoop2.core.config.ServizioApplicativo servizioApplicativo) throws DriverConfigurazioneException {
  528.         this.driverConfigurazione.updateServizioApplicativo(servizioApplicativo);
  529.     }
  530.    
  531.     public void deleteServizioApplicativo(org.openspcoop2.core.config.ServizioApplicativo servizioApplicativo) throws DriverConfigurazioneException {
  532.         this.driverConfigurazione.deleteServizioApplicativo(servizioApplicativo);
  533.     }
  534.    
  535.     public boolean isServizioApplicativoInUso(IDServizioApplicativo idServizioApplicativo,
  536.             Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds, boolean verificaRuoli) throws DriverConfigurazioneException {
  537.         Connection con = null;
  538.         try{
  539.             con = this.driverConfigurazione.getConnection("archive.isServizioApplicativoInUso");
  540.             return DBOggettiInUsoUtils.isServizioApplicativoInUso(con, this.driverConfigurazione.getTipoDB(), idServizioApplicativo, whereIsInUso, true, normalizeObjectIds, verificaRuoli);
  541.         }
  542.         catch(Exception e){
  543.             throw new DriverConfigurazioneException(e.getMessage(),e);
  544.         }
  545.         finally{
  546.             try{
  547.                 this.driverConfigurazione.releaseConnection(con);
  548.             }catch(Exception eClose){
  549.                 // close
  550.             }
  551.         }
  552.     }
  553.    
  554.     public org.openspcoop2.core.config.ServizioApplicativo getServizioApplicativoCredenzialiBasic(String utente) throws DriverConfigurazioneException{
  555.         List<org.openspcoop2.core.config.ServizioApplicativo> l = this.driverConfigurazione.servizioApplicativoWithCredenzialiBasicList(utente, null, false);
  556.         if(l!=null && !l.isEmpty()) {
  557.             return l.get(0);
  558.         }
  559.         return null;
  560.     }
  561.     public org.openspcoop2.core.config.ServizioApplicativo getServizioApplicativoCredenzialiApiKey(String utente, boolean appId) throws DriverConfigurazioneException{
  562.         List<org.openspcoop2.core.config.ServizioApplicativo> l = this.driverConfigurazione.servizioApplicativoWithCredenzialiApiKeyList(utente, appId);
  563.         if(l!=null && !l.isEmpty()) {
  564.             return l.get(0);
  565.         }
  566.         return null;
  567.     }
  568.     public org.openspcoop2.core.config.ServizioApplicativo getServizioApplicativoCredenzialiSsl(String subject, String issuer,
  569.             ConfigurazioneFiltroServiziApplicativi filtro) throws DriverConfigurazioneException{
  570.         List<org.openspcoop2.core.config.ServizioApplicativo> l = this.driverConfigurazione.servizioApplicativoWithCredenzialiSslList(subject, issuer,
  571.                 filtro.getTipiSoggetti(),
  572.                 filtro.isIncludiApplicativiNonModI(), filtro.isIncludiApplicativiModIEsterni(), filtro.isIncludiApplicativiModIInterni());
  573.         if(l!=null && !l.isEmpty()) {
  574.             return l.get(0);
  575.         }
  576.         return null;
  577.     }
  578.     public org.openspcoop2.core.config.ServizioApplicativo getServizioApplicativoCredenzialiSsl(byte[]archivio, boolean strictVerifier,
  579.             ConfigurazioneFiltroServiziApplicativi filtro) throws DriverConfigurazioneException{
  580.         Certificate cSelezionato = null;
  581.         try {
  582.             cSelezionato = ArchiveLoader.load(archivio);
  583.         }catch(Exception e) {
  584.             throw new DriverConfigurazioneException(e.getMessage(),e);
  585.         }
  586.         List<org.openspcoop2.core.config.ServizioApplicativo> l = this.driverConfigurazione.servizioApplicativoWithCredenzialiSslList(cSelezionato.getCertificate(), strictVerifier,
  587.                 filtro.getTipiSoggetti(),
  588.                 filtro.isIncludiApplicativiNonModI(), filtro.isIncludiApplicativiModIEsterni(), filtro.isIncludiApplicativiModIInterni());
  589.         if(l!=null && !l.isEmpty()) {
  590.             return l.get(0);
  591.         }
  592.         return null;
  593.     }
  594.     public org.openspcoop2.core.config.ServizioApplicativo getServizioApplicativoCredenzialiPrincipal(String principal) throws DriverConfigurazioneException{
  595.         List<org.openspcoop2.core.config.ServizioApplicativo> l = this.driverConfigurazione.servizioApplicativoWithCredenzialiPrincipalList(principal);
  596.         if(l!=null && !l.isEmpty()) {
  597.             return l.get(0);
  598.         }
  599.         return null;
  600.     }
  601.     public org.openspcoop2.core.config.ServizioApplicativo getServizioApplicativoCredenzialiToken(String tokenPolicy, String tokenClientId) throws DriverConfigurazioneException{
  602.        
  603.         boolean tokenWithHttpsEnabled = false;
  604.         try {
  605.             // basta un protocollo che lo supporta per doverli cercare anche con la funzionalita' abilitata
  606.             for(IProtocolFactory<?> protocolFactory: ProtocolFactoryManager.getInstance().getProtocolFactories().values()) {
  607.                 if(protocolFactory.createProtocolConfiguration().isSupportatoAutenticazioneApplicativiHttpsConToken()) {
  608.                     tokenWithHttpsEnabled = true;
  609.                     break;
  610.                 }
  611.             }
  612.         }catch(Exception e) {
  613.             throw new DriverConfigurazioneException(e.getMessage(),e);
  614.         }
  615.        
  616.         List<org.openspcoop2.core.config.ServizioApplicativo> l = this.driverConfigurazione.servizioApplicativoWithCredenzialiTokenList(tokenPolicy, tokenClientId, tokenWithHttpsEnabled);
  617.         if(l!=null && !l.isEmpty()) {
  618.             return l.get(0);
  619.         }
  620.         return null;
  621.     }
  622.    
  623.    
  624.    
  625.     // --- Accordi di Cooperazione ---
  626.    
  627.     public List<IDAccordoCooperazione> getAllIdAccordiCooperazione(FiltroRicercaAccordi filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  628.         return this.driverRegistroServizi.getAllIdAccordiCooperazione(filtroRicerca);
  629.     }
  630.    
  631.     public AccordoCooperazione getAccordoCooperazione(IDAccordoCooperazione idAccordoCooperazione) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  632.         return this.driverRegistroServizi.getAccordoCooperazione(idAccordoCooperazione);
  633.     }
  634.    
  635.     public AccordoCooperazione getAccordoCooperazione(IDAccordoCooperazione idAccordoCooperazione, boolean readContenutoAllegati) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  636.         return this.driverRegistroServizi.getAccordoCooperazione(idAccordoCooperazione,readContenutoAllegati);
  637.     }
  638.    
  639.     public boolean existsAccordoCooperazione(IDAccordoCooperazione idAccordoCooperazione) throws DriverRegistroServiziException {
  640.         return this.driverRegistroServizi.existsAccordoCooperazione(idAccordoCooperazione);
  641.     }
  642.    
  643.     public void createAccordoCooperazione(AccordoCooperazione accordoCooperazione) throws DriverRegistroServiziException {
  644.         this.driverRegistroServizi.createAccordoCooperazione(accordoCooperazione);
  645.     }
  646.    
  647.     public void updateAccordoCooperazione(AccordoCooperazione accordoCooperazione) throws DriverRegistroServiziException {
  648.         this.driverRegistroServizi.updateAccordoCooperazione(accordoCooperazione);
  649.     }
  650.    
  651.     public void deleteAccordoCooperazione(AccordoCooperazione accordoCooperazione) throws DriverRegistroServiziException {
  652.         this.driverRegistroServizi.deleteAccordoCooperazione(accordoCooperazione);
  653.     }
  654.    
  655.     public void validaStatoAccordoCooperazione(AccordoCooperazione accordoCooperazione) throws ValidazioneStatoPackageException {
  656.         this.driverRegistroServizi.validaStatoAccordoCooperazione(accordoCooperazione);
  657.     }
  658.    
  659.     public boolean isAccordoCooperazioneInUso(IDAccordoCooperazione idAccordo,
  660.             Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverRegistroServiziException {
  661.         Connection con = null;
  662.         try{
  663.             con = this.driverRegistroServizi.getConnection("archive.isAccordoCooperazioneInUso");
  664.             return DBOggettiInUsoUtils.isAccordoCooperazioneInUso(con, this.driverRegistroServizi.getTipoDB(), idAccordo, whereIsInUso, normalizeObjectIds);
  665.         }
  666.         catch(Exception e){
  667.             throw new DriverRegistroServiziException(e.getMessage(),e);
  668.         }
  669.         finally{
  670.             try{
  671.                 this.driverRegistroServizi.releaseConnection(con);
  672.             }catch(Exception eClose){
  673.                 // close
  674.             }
  675.         }
  676.     }
  677.    
  678.    
  679.     // --- Accordi di Servizio Parte Comune ---
  680.    
  681.     public List<IDAccordo> getAllIdAccordiServizioParteComune(FiltroRicercaAccordi filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  682.         return this.driverRegistroServizi.getAllIdAccordiServizioParteComune(filtroRicerca);
  683.     }
  684.    
  685.     public AccordoServizioParteComune getAccordoServizioParteComune(IDAccordo idAccordoServizioParteComune) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  686.         return this.driverRegistroServizi.getAccordoServizioParteComune(idAccordoServizioParteComune);
  687.     }
  688.    
  689.     public AccordoServizioParteComune getAccordoServizioParteComune(IDAccordo idAccordoServizioParteComune, boolean readContenutoAllegati,boolean readDatiRegistro) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  690.         return this.driverRegistroServizi.getAccordoServizioParteComune(idAccordoServizioParteComune, readContenutoAllegati, readDatiRegistro);
  691.     }
  692.    
  693.     public boolean existsAccordoServizioParteComune(IDAccordo idAccordoServizioParteComune) throws DriverRegistroServiziException {
  694.         return this.driverRegistroServizi.existsAccordoServizioParteComune(idAccordoServizioParteComune);
  695.     }
  696.    
  697.     public void createAccordoServizioParteComune(AccordoServizioParteComune accordoServizioParteComune) throws DriverRegistroServiziException {
  698.         this.driverRegistroServizi.createAccordoServizioParteComune(accordoServizioParteComune);
  699.     }
  700.    
  701.     public void updateAccordoServizioParteComune(AccordoServizioParteComune accordoServizioParteComune) throws DriverRegistroServiziException {
  702.         this.driverRegistroServizi.updateAccordoServizioParteComune(accordoServizioParteComune);
  703.     }
  704.    
  705.     public void deleteAccordoServizioParteComune(AccordoServizioParteComune accordoServizioParteComune) throws DriverRegistroServiziException {
  706.         this.driverRegistroServizi.deleteAccordoServizioParteComune(accordoServizioParteComune);
  707.     }
  708.    
  709.     public void validaStatoAccordoServizioParteComune(AccordoServizioParteComune accordoServizioParteComune,boolean utilizzoAzioniDiretteInAccordoAbilitato) throws ValidazioneStatoPackageException {
  710.         this.driverRegistroServizi.validaStatoAccordoServizio(accordoServizioParteComune,utilizzoAzioniDiretteInAccordoAbilitato);
  711.     }
  712.    
  713.     public boolean isAccordoServizioParteComuneInUso(IDAccordo idAccordo,
  714.             Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverRegistroServiziException {
  715.         Connection con = null;
  716.         try{
  717.             con = this.driverRegistroServizi.getConnection("archive.isAccordoServizioParteComuneInUso");
  718.             return DBOggettiInUsoUtils.isAccordoServizioParteComuneInUso(con, this.driverRegistroServizi.getTipoDB(), idAccordo, whereIsInUso, normalizeObjectIds);
  719.         }
  720.         catch(Exception e){
  721.             throw new DriverRegistroServiziException(e.getMessage(),e);
  722.         }
  723.         finally{
  724.             try{
  725.                 this.driverRegistroServizi.releaseConnection(con);
  726.             }catch(Exception eClose){
  727.                 // close
  728.             }
  729.         }
  730.     }
  731.    
  732.    
  733.     // --- Accordi di Servizio Parte Specifica ---
  734.    
  735.     public List<IDServizio> getAllIdAccordiServizioParteSpecifica(FiltroRicercaServizi filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  736.         return this.driverRegistroServizi.getAllIdServizi(filtroRicerca);
  737.     }
  738.    
  739.     public AccordoServizioParteSpecifica getAccordoServizioParteSpecifica(IDServizio idServizio) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  740.         return this.driverRegistroServizi.getAccordoServizioParteSpecifica(idServizio);
  741.     }
  742.    
  743.     public AccordoServizioParteSpecifica getAccordoServizioParteSpecifica(IDServizio idServizio, boolean readContenutoAllegati) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  744.         return this.driverRegistroServizi.getAccordoServizioParteSpecifica(idServizio,readContenutoAllegati);
  745.     }
  746.    
  747.     public boolean existsAccordoServizioParteSpecifica(IDServizio idServizio) throws DriverRegistroServiziException {
  748.         return this.driverRegistroServizi.existsAccordoServizioParteSpecifica(idServizio);
  749.     }
  750.    
  751.     public boolean existsFruzioneAccordoServizioParteSpecifica(IDServizio idServizio, IDSoggetto fruitore) throws DriverRegistroServiziException {
  752.         if( this.driverRegistroServizi.existsAccordoServizioParteSpecifica(idServizio) ) {
  753.             try {
  754.                 AccordoServizioParteSpecifica asps = this.getAccordoServizioParteSpecifica(idServizio, false);
  755.                 if(asps.sizeFruitoreList()>0) {
  756.                     for (Fruitore fr : asps.getFruitoreList()) {
  757.                         if(fr.getTipo().equals(fruitore.getTipo()) && fr.getNome().equals(fruitore.getNome())) {
  758.                             return true;
  759.                         }
  760.                     }
  761.                 }
  762.             }catch(Exception e) {
  763.                 return false;
  764.             }          
  765.         }
  766.         return false;
  767.     }
  768.    
  769.     public void createAccordoServizioParteSpecifica(AccordoServizioParteSpecifica accordoServizioParteSpecifica) throws DriverRegistroServiziException {
  770.         this.driverRegistroServizi.createAccordoServizioParteSpecifica(accordoServizioParteSpecifica);
  771.     }
  772.    
  773.     public void updateAccordoServizioParteSpecifica(AccordoServizioParteSpecifica accordoServizioParteSpecifica) throws DriverRegistroServiziException {
  774.         this.driverRegistroServizi.updateAccordoServizioParteSpecifica(accordoServizioParteSpecifica);
  775.     }
  776.    
  777.     public void deleteAccordoServizioParteSpecifica(AccordoServizioParteSpecifica accordoServizioParteSpecifica) throws DriverRegistroServiziException {
  778.         this.driverRegistroServizi.deleteAccordoServizioParteSpecifica(accordoServizioParteSpecifica);
  779.     }
  780.    
  781.     public void validaStatoAccordoServizioParteSpecifica(AccordoServizioParteSpecifica accordoServizioParteSpecifica, boolean gestioneWsdlImplementativo, boolean checkConnettore) throws ValidazioneStatoPackageException {
  782.         this.driverRegistroServizi.validaStatoAccordoServizioParteSpecifica(accordoServizioParteSpecifica, gestioneWsdlImplementativo, checkConnettore);
  783.     }
  784.    
  785.     public void validaStatoFruitoreServizio(Fruitore fruitore, AccordoServizioParteSpecifica accordoServizioParteSpecifica) throws ValidazioneStatoPackageException {
  786.         this.driverRegistroServizi.validaStatoFruitoreServizio(fruitore, accordoServizioParteSpecifica);
  787.     }
  788.    
  789.     public void controlloUnicitaImplementazioneAccordoPerSoggetto(String portType,
  790.             IDSoggetto idSoggettoErogatore, long idSoggettoErogatoreLong,
  791.             IDAccordo idAccordoServizioParteComune, long idAccordoServizioParteComuneLong,
  792.             IDServizio idAccordoServizioParteSpecifica, long idAccordoServizioParteSpecificaLong,
  793.             boolean isUpdate,boolean isServizioCorrelato,
  794.             boolean isAbilitatoControlloUnicitaImplementazioneAccordoPerSoggetto,
  795.             boolean isAbilitatoControlloUnicitaImplementazionePortTypePerSoggetto) throws DriverRegistroServiziException{
  796.         this.driverRegistroServizi.controlloUnicitaImplementazioneAccordoPerSoggetto(portType, idSoggettoErogatore, idSoggettoErogatoreLong,
  797.                 idAccordoServizioParteComune, idAccordoServizioParteComuneLong,
  798.                 idAccordoServizioParteSpecifica, idAccordoServizioParteSpecificaLong,
  799.                 isUpdate, isServizioCorrelato,
  800.                 isAbilitatoControlloUnicitaImplementazioneAccordoPerSoggetto,
  801.                 isAbilitatoControlloUnicitaImplementazionePortTypePerSoggetto);
  802.     }
  803.    
  804.     public boolean isAccordoServizioParteSpecificaInUso(IDServizio idServizio,
  805.             Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverRegistroServiziException {
  806.         Connection con = null;
  807.         try{
  808.             con = this.driverRegistroServizi.getConnection("archive.isAccordoServizioParteSpecificaInUso");
  809.             return DBOggettiInUsoUtils.isAccordoServizioParteSpecificaInUso(con, this.driverRegistroServizi.getTipoDB(), idServizio, whereIsInUso, null, null, normalizeObjectIds);
  810.         }
  811.         catch(Exception e){
  812.             throw new DriverRegistroServiziException(e.getMessage(),e);
  813.         }
  814.         finally{
  815.             try{
  816.                 this.driverRegistroServizi.releaseConnection(con);
  817.             }catch(Exception eClose){
  818.                 // close
  819.             }
  820.         }
  821.     }
  822.    
  823.    
  824.    
  825.    
  826.     // --- Mapping Erogazione ---
  827.    
  828.     public void createMappingErogazione(String nome, String descrizione, boolean isDefault, IDServizio idServizio, IDPortaApplicativa idPortaApplicativaByNome) throws DriverRegistroServiziException {
  829.         Connection con = null;
  830.         try{
  831.             con = this.driverRegistroServizi.getConnection("createMappingErogazione");
  832.             DBMappingUtils.createMappingErogazione(nome, descrizione, isDefault, idServizio, idPortaApplicativaByNome, con, this.driverRegistroServizi.getTipoDB());
  833.         }
  834.         catch(Exception e){
  835.             throw new DriverRegistroServiziException(e.getMessage(),e);
  836.         }
  837.         finally{
  838.             try{
  839.                 this.driverRegistroServizi.releaseConnection(con);
  840.             }catch(Exception eClose){
  841.                 // close
  842.             }
  843.         }
  844.     }
  845.    
  846.     public IDPortaApplicativa getIDPortaApplicativaDefaultAssociataErogazione(IDServizio idServizio) throws DriverRegistroServiziException{
  847.         Connection con = null;
  848.         try{
  849.             con = this.driverRegistroServizi.getConnection("getIDPortaApplicativaDefaultAssociataErogazione");
  850.             return DBMappingUtils.getIDPortaApplicativaAssociataDefault(idServizio, con, this.driverRegistroServizi.getTipoDB());
  851.         }
  852.         catch(Exception e){
  853.             throw new DriverRegistroServiziException(e.getMessage(),e);
  854.         }
  855.         finally{
  856.             try{
  857.                 this.driverRegistroServizi.releaseConnection(con);
  858.             }catch(Exception eClose){
  859.                 // close
  860.             }
  861.         }
  862.     }
  863.    
  864.     public IDPortaApplicativa getIDPortaApplicativaPerAzioneAssociataErogazione(IDServizio idServizio) throws DriverRegistroServiziException{
  865.         Connection con = null;
  866.         try{
  867.             con = this.driverRegistroServizi.getConnection("getIDPortaApplicativaPerAzioneAssociataErogazione");
  868.             return DBMappingUtils.getIDPortaApplicativaAssociataAzione(idServizio, con, this.driverRegistroServizi.getTipoDB());
  869.         }
  870.         catch(Exception e){
  871.             throw new DriverRegistroServiziException(e.getMessage(),e);
  872.         }
  873.         finally{
  874.             try{
  875.                 this.driverRegistroServizi.releaseConnection(con);
  876.             }catch(Exception eClose){
  877.                 // close
  878.             }
  879.         }
  880.     }
  881.    
  882.     public List<IDPortaApplicativa> getIDPorteApplicativeAssociateErogazione(IDServizio idServizio) throws DriverRegistroServiziException{
  883.         Connection con = null;
  884.         try{
  885.             con = this.driverRegistroServizi.getConnection("getIDPorteApplicativeAssociateErogazione");
  886.             return DBMappingUtils.getIDPorteApplicativeAssociate(idServizio, con, this.driverRegistroServizi.getTipoDB());
  887.         }
  888.         catch(Exception e){
  889.             throw new DriverRegistroServiziException(e.getMessage(),e);
  890.         }
  891.         finally{
  892.             try{
  893.                 this.driverRegistroServizi.releaseConnection(con);
  894.             }catch(Exception eClose){
  895.                 // close
  896.             }
  897.         }
  898.     }
  899.    
  900.     public void deleteMappingErogazione(IDServizio idServizio, IDPortaApplicativa idPortaApplicativaByNome) throws DriverRegistroServiziException {
  901.         Connection con = null;
  902.         try{
  903.             con = this.driverRegistroServizi.getConnection("deleteMappingErogazione");
  904.             DBMappingUtils.deleteMappingErogazione(idServizio, idPortaApplicativaByNome, con, this.driverRegistroServizi.getTipoDB());
  905.         }
  906.         catch(Exception e){
  907.             throw new DriverRegistroServiziException(e.getMessage(),e);
  908.         }
  909.         finally{
  910.             try{
  911.                 this.driverRegistroServizi.releaseConnection(con);
  912.             }catch(Exception eClose){
  913.                 // close
  914.             }
  915.         }
  916.     }
  917.    
  918.     public void deleteMappingErogazione(IDServizio idServizio) throws DriverRegistroServiziException {
  919.         Connection con = null;
  920.         try{
  921.             con = this.driverRegistroServizi.getConnection("deleteMappingErogazione");
  922.             DBMappingUtils.deleteMappingErogazione(idServizio, null, con, this.driverRegistroServizi.getTipoDB());
  923.         }
  924.         catch(Exception e){
  925.             throw new DriverRegistroServiziException(e.getMessage(),e);
  926.         }
  927.         finally{
  928.             try{
  929.                 this.driverRegistroServizi.releaseConnection(con);
  930.             }catch(Exception eClose){
  931.                 // close
  932.             }
  933.         }
  934.     }
  935.    
  936.     public boolean existsIDPortaApplicativaDefaultAssociataErogazione(IDServizio idServizio) throws DriverRegistroServiziException {
  937.         Connection con = null;
  938.         try{
  939.             con = this.driverRegistroServizi.getConnection("existsIDPortaApplicativaDefaultAssociataErogazione");
  940.             return DBMappingUtils.existsIDPortaApplicativaAssociataDefault(idServizio, con, this.driverRegistroServizi.getTipoDB());
  941.         }
  942.         catch(Exception e){
  943.             throw new DriverRegistroServiziException(e.getMessage(),e);
  944.         }
  945.         finally{
  946.             try{
  947.                 this.driverRegistroServizi.releaseConnection(con);
  948.             }catch(Exception eClose){
  949.                 // close
  950.             }
  951.         }
  952.     }
  953.    
  954.     public boolean existsIDPortaApplicativaPerAzioneAssociataErogazione(IDServizio idServizio) throws DriverRegistroServiziException {
  955.         Connection con = null;
  956.         try{
  957.             con = this.driverRegistroServizi.getConnection("existsIDPortaApplicativaPerAzioneAssociataErogazione");
  958.             return DBMappingUtils.existsIDPortaApplicativaAssociataAzione(idServizio, con, this.driverRegistroServizi.getTipoDB());
  959.         }
  960.         catch(Exception e){
  961.             throw new DriverRegistroServiziException(e.getMessage(),e);
  962.         }
  963.         finally{
  964.             try{
  965.                 this.driverRegistroServizi.releaseConnection(con);
  966.             }catch(Exception eClose){
  967.                 // close
  968.             }
  969.         }
  970.     }
  971.    
  972.     public boolean existsIDPorteApplicativeAssociateErogazione(IDServizio idServizio) throws DriverRegistroServiziException {
  973.         Connection con = null;
  974.         try{
  975.             con = this.driverRegistroServizi.getConnection("existsIDPorteApplicativeAssociateErogazione");
  976.             return DBMappingUtils.existsIDPorteApplicativeAssociate(idServizio, con, this.driverRegistroServizi.getTipoDB());
  977.         }
  978.         catch(Exception e){
  979.             throw new DriverRegistroServiziException(e.getMessage(),e);
  980.         }
  981.         finally{
  982.             try{
  983.                 this.driverRegistroServizi.releaseConnection(con);
  984.             }catch(Exception eClose){
  985.                 // close
  986.             }
  987.         }
  988.     }
  989.    
  990.     public boolean existsMappingErogazione(IDServizio idServizio, IDPortaApplicativa idPortaApplicativa) throws DriverRegistroServiziException {
  991.         Connection con = null;
  992.         try{
  993.             con = this.driverRegistroServizi.getConnection("existsMappingErogazione");
  994.             return DBMappingUtils.existsMappingErogazione(idServizio, idPortaApplicativa, con, this.driverRegistroServizi.getTipoDB());
  995.         }
  996.         catch(Exception e){
  997.             throw new DriverRegistroServiziException(e.getMessage(),e);
  998.         }
  999.         finally{
  1000.             try{
  1001.                 this.driverRegistroServizi.releaseConnection(con);
  1002.             }catch(Exception eClose){
  1003.                 // close
  1004.             }
  1005.         }
  1006.     }
  1007.    
  1008.     public MappingErogazionePortaApplicativa getMappingErogazionePortaApplicativa(IDServizio idServizio, IDPortaApplicativa idPortaApplicativa) throws DriverRegistroServiziException {
  1009.         Connection con = null;
  1010.         try{
  1011.             con = this.driverRegistroServizi.getConnection("getMappingErogazionePortaApplicativa");
  1012.             return DBMappingUtils.getMappingErogazione(idServizio, idPortaApplicativa, con, this.driverRegistroServizi.getTipoDB());
  1013.         }
  1014.         catch(Exception e){
  1015.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1016.         }
  1017.         finally{
  1018.             try{
  1019.                 this.driverRegistroServizi.releaseConnection(con);
  1020.             }catch(Exception eClose){
  1021.                 // close
  1022.             }
  1023.         }
  1024.     }
  1025.    
  1026.     // Inefficiente
  1027.     @Deprecated
  1028.     public void initMappingErogazione(Logger log) throws DriverRegistroServiziException {
  1029.         try{
  1030.             UtilitiesMappingFruizioneErogazione utilities = new UtilitiesMappingFruizioneErogazione(this.driverConfigurazione, this.driverRegistroServizi, log);
  1031.             utilities.initMappingErogazione();
  1032.         }
  1033.         catch(Exception e){
  1034.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1035.         }
  1036.     }
  1037.     public void initMappingErogazioneById(Logger log, List<IDPortaApplicativa> listPA) throws DriverRegistroServiziException {
  1038.         try{
  1039.             UtilitiesMappingFruizioneErogazione utilities = new UtilitiesMappingFruizioneErogazione(this.driverConfigurazione, this.driverRegistroServizi, log);
  1040.             utilities.gestioneMappingErogazionePAbyId(listPA);
  1041.         }
  1042.         catch(Exception e){
  1043.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1044.         }
  1045.     }
  1046.     public void initMappingErogazione(Logger log, List<PortaApplicativa> listPA) throws DriverRegistroServiziException {
  1047.         try{
  1048.             UtilitiesMappingFruizioneErogazione utilities = new UtilitiesMappingFruizioneErogazione(this.driverConfigurazione, this.driverRegistroServizi, log);
  1049.             utilities.gestioneMappingErogazionePA(listPA);
  1050.         }
  1051.         catch(Exception e){
  1052.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1053.         }
  1054.     }
  1055.    
  1056.    
  1057.    
  1058.    
  1059.    
  1060.     // --- Mapping Fruizione ---
  1061.    
  1062.     public void createMappingFruizione(String nome, String descrizione, boolean isDefault, IDServizio idServizio, IDSoggetto idFruitore, IDPortaDelegata idPortaDelegata) throws DriverRegistroServiziException {
  1063.         Connection con = null;
  1064.         try{
  1065.             con = this.driverRegistroServizi.getConnection("createMappingFruizione");
  1066.             DBMappingUtils.createMappingFruizione(nome, descrizione, isDefault, idServizio, idFruitore, idPortaDelegata, con, this.driverRegistroServizi.getTipoDB());
  1067.         }
  1068.         catch(Exception e){
  1069.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1070.         }
  1071.         finally{
  1072.             try{
  1073.                 this.driverRegistroServizi.releaseConnection(con);
  1074.             }catch(Exception eClose){
  1075.                 // close
  1076.             }
  1077.         }
  1078.     }
  1079.    
  1080.     public IDPortaDelegata getIDPortaDelegataDefaultAssociataFruizione(IDServizio idServizio, IDSoggetto idFruitore) throws DriverRegistroServiziException{
  1081.         Connection con = null;
  1082.         try{
  1083.             con = this.driverRegistroServizi.getConnection("getIDPortaDelegataDefaultAssociataFruizione");
  1084.             return DBMappingUtils.getIDPortaDelegataAssociataDefault(idServizio, idFruitore, con, this.driverRegistroServizi.getTipoDB());
  1085.         }
  1086.         catch(Exception e){
  1087.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1088.         }
  1089.         finally{
  1090.             try{
  1091.                 this.driverRegistroServizi.releaseConnection(con);
  1092.             }catch(Exception eClose){
  1093.                 // close
  1094.             }
  1095.         }
  1096.     }
  1097.    
  1098.     public IDPortaDelegata getIDPortaDelegataPerAzioneAssociataFruizione(IDServizio idServizio, IDSoggetto idFruitore) throws DriverRegistroServiziException{
  1099.         Connection con = null;
  1100.         try{
  1101.             con = this.driverRegistroServizi.getConnection("getIDPortaDelegataPerAzioneAssociataFruizione");
  1102.             return DBMappingUtils.getIDPortaDelegataAssociataAzione(idServizio, idFruitore, con, this.driverRegistroServizi.getTipoDB());
  1103.         }
  1104.         catch(Exception e){
  1105.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1106.         }
  1107.         finally{
  1108.             try{
  1109.                 this.driverRegistroServizi.releaseConnection(con);
  1110.             }catch(Exception eClose){
  1111.                 // close
  1112.             }
  1113.         }
  1114.     }
  1115.    
  1116.     public List<IDPortaDelegata> getIDPorteDelegateAssociateFruizione(IDServizio idServizio, IDSoggetto idFruitore) throws DriverRegistroServiziException{
  1117.         Connection con = null;
  1118.         try{
  1119.             con = this.driverRegistroServizi.getConnection("getIDPorteDelegateAssociateFruizione");
  1120.             return DBMappingUtils.getIDPorteDelegateAssociate(idServizio, idFruitore, con, this.driverRegistroServizi.getTipoDB());
  1121.         }
  1122.         catch(Exception e){
  1123.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1124.         }
  1125.         finally{
  1126.             try{
  1127.                 this.driverRegistroServizi.releaseConnection(con);
  1128.             }catch(Exception eClose){
  1129.                 // close
  1130.             }
  1131.         }
  1132.     }
  1133.    
  1134.     public void deleteMappingFruizione(IDServizio idServizio, IDSoggetto idFruitore, IDPortaDelegata idPortaDelegata) throws DriverRegistroServiziException {
  1135.         Connection con = null;
  1136.         try{
  1137.             con = this.driverRegistroServizi.getConnection("deleteMappingFruizione");
  1138.             DBMappingUtils.deleteMappingFruizione(idServizio, idFruitore, idPortaDelegata, con, this.driverRegistroServizi.getTipoDB());
  1139.         }
  1140.         catch(Exception e){
  1141.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1142.         }
  1143.         finally{
  1144.             try{
  1145.                 this.driverRegistroServizi.releaseConnection(con);
  1146.             }catch(Exception eClose){
  1147.                 // close
  1148.             }
  1149.         }
  1150.     }
  1151.    
  1152.     public void deleteMappingFruizione(IDServizio idServizio, IDSoggetto idFruitore) throws DriverRegistroServiziException {
  1153.         Connection con = null;
  1154.         try{
  1155.             con = this.driverRegistroServizi.getConnection("deleteMappingFruizione");
  1156.             DBMappingUtils.deleteMappingFruizione(idServizio, idFruitore, null, con, this.driverRegistroServizi.getTipoDB());
  1157.         }
  1158.         catch(Exception e){
  1159.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1160.         }
  1161.         finally{
  1162.             try{
  1163.                 this.driverRegistroServizi.releaseConnection(con);
  1164.             }catch(Exception eClose){
  1165.                 // close
  1166.             }
  1167.         }
  1168.     }
  1169.    
  1170.     public boolean existsIDPortaDelegataDefaultAssociataFruizione(IDServizio idServizio, IDSoggetto idFruitore) throws DriverRegistroServiziException {
  1171.         Connection con = null;
  1172.         try{
  1173.             con = this.driverRegistroServizi.getConnection("existsIDPortaDelegataDefaultAssociataFruizione");
  1174.             return DBMappingUtils.existsIDPortaDelegataAssociataDefault(idServizio, idFruitore, con, this.driverRegistroServizi.getTipoDB());
  1175.         }
  1176.         catch(Exception e){
  1177.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1178.         }
  1179.         finally{
  1180.             try{
  1181.                 this.driverRegistroServizi.releaseConnection(con);
  1182.             }catch(Exception eClose){
  1183.                 // close
  1184.             }
  1185.         }
  1186.     }
  1187.    
  1188.     public boolean existsIDPortaDelegataPerAzioneAssociataFruizione(IDServizio idServizio, IDSoggetto idFruitore) throws DriverRegistroServiziException {
  1189.         Connection con = null;
  1190.         try{
  1191.             con = this.driverRegistroServizi.getConnection("existsIDPortaDelegataPerAzioneAssociataFruizione");
  1192.             return DBMappingUtils.existsIDPortaDelegataAssociataAzione(idServizio, idFruitore, con, this.driverRegistroServizi.getTipoDB());
  1193.         }
  1194.         catch(Exception e){
  1195.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1196.         }
  1197.         finally{
  1198.             try{
  1199.                 this.driverRegistroServizi.releaseConnection(con);
  1200.             }catch(Exception eClose){
  1201.                 // close
  1202.             }
  1203.         }
  1204.     }
  1205.    
  1206.     public boolean existsIDPorteDelegateAssociateFruizione(IDServizio idServizio, IDSoggetto idFruitore) throws DriverRegistroServiziException {
  1207.         Connection con = null;
  1208.         try{
  1209.             con = this.driverRegistroServizi.getConnection("existsIDPorteDelegateAssociateFruizione");
  1210.             return DBMappingUtils.existsIDPorteDelegateAssociate(idServizio, idFruitore, con, this.driverRegistroServizi.getTipoDB());
  1211.         }
  1212.         catch(Exception e){
  1213.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1214.         }
  1215.         finally{
  1216.             try{
  1217.                 this.driverRegistroServizi.releaseConnection(con);
  1218.             }catch(Exception eClose){
  1219.                 // close
  1220.             }
  1221.         }
  1222.     }
  1223.    
  1224.     public boolean existsMappingFruizione(IDServizio idServizio, IDSoggetto idFruitore, IDPortaDelegata idPortaDelegata) throws DriverRegistroServiziException {
  1225.         Connection con = null;
  1226.         try{
  1227.             con = this.driverRegistroServizi.getConnection("existsMappingFruizione");
  1228.             return DBMappingUtils.existsMappingFruizione(idServizio, idFruitore, idPortaDelegata, con, this.driverRegistroServizi.getTipoDB());
  1229.         }
  1230.         catch(Exception e){
  1231.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1232.         }
  1233.         finally{
  1234.             try{
  1235.                 this.driverRegistroServizi.releaseConnection(con);
  1236.             }catch(Exception eClose){
  1237.                 // close
  1238.             }
  1239.         }
  1240.     }
  1241.    
  1242.     public MappingFruizionePortaDelegata getMappingFruizionePortaDelegata(IDServizio idServizio, IDSoggetto idFruitore, IDPortaDelegata idPortaDelegata) throws DriverRegistroServiziException {
  1243.         Connection con = null;
  1244.         try{
  1245.             con = this.driverRegistroServizi.getConnection("getMappingFruizionePortaDelegata");
  1246.             return DBMappingUtils.getMappingFruizione(idServizio, idFruitore, idPortaDelegata, con, this.driverRegistroServizi.getTipoDB());
  1247.         }
  1248.         catch(Exception e){
  1249.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1250.         }
  1251.         finally{
  1252.             try{
  1253.                 this.driverRegistroServizi.releaseConnection(con);
  1254.             }catch(Exception eClose){
  1255.                 // close
  1256.             }
  1257.         }
  1258.     }
  1259.    
  1260.     // Inefficiente
  1261.     @Deprecated
  1262.     public void initMappingFruizione(Logger log) throws DriverRegistroServiziException {
  1263.         try{
  1264.             UtilitiesMappingFruizioneErogazione utilities = new UtilitiesMappingFruizioneErogazione(this.driverConfigurazione, this.driverRegistroServizi, log);
  1265.             utilities.initMappingFruizione();
  1266.         }
  1267.         catch(Exception e){
  1268.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1269.         }
  1270.     }
  1271.     public void initMappingFruizioneById(Logger log, List<IDPortaDelegata> listPD) throws DriverRegistroServiziException {
  1272.         try{
  1273.             UtilitiesMappingFruizioneErogazione utilities = new UtilitiesMappingFruizioneErogazione(this.driverConfigurazione, this.driverRegistroServizi, log);
  1274.             utilities.gestioneMappingFruizionePDbyId(listPD);
  1275.         }
  1276.         catch(Exception e){
  1277.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1278.         }
  1279.     }
  1280.     public void initMappingFruizione(Logger log, List<PortaDelegata> listPD) throws DriverRegistroServiziException {
  1281.         try{
  1282.             UtilitiesMappingFruizioneErogazione utilities = new UtilitiesMappingFruizioneErogazione(this.driverConfigurazione, this.driverRegistroServizi, log);
  1283.             utilities.gestioneMappingFruizionePD(listPD);
  1284.         }
  1285.         catch(Exception e){
  1286.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1287.         }
  1288.     }
  1289.        
  1290.    
  1291.    
  1292.     // --- Porte Delegate ---
  1293.    
  1294.     public List<IDPortaDelegata> getAllIdPorteDelegate(FiltroRicercaPorteDelegate filtroRicerca) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  1295.         return this.driverConfigurazione.getAllIdPorteDelegate(filtroRicerca);
  1296.     }
  1297.    
  1298.     public org.openspcoop2.core.config.PortaDelegata getPortaDelegata(IDPortaDelegata idPortaDelegata) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  1299.         return this.driverConfigurazione.getPortaDelegata(idPortaDelegata);
  1300.     }
  1301.    
  1302.     public boolean existsPortaDelegata(IDPortaDelegata idPortaDelegata) throws DriverConfigurazioneException {
  1303.         return this.driverConfigurazione.existsPortaDelegata(idPortaDelegata);
  1304.     }
  1305.    
  1306.     public void createPortaDelegata(org.openspcoop2.core.config.PortaDelegata portaDelegata) throws DriverConfigurazioneException {
  1307.         this.driverConfigurazione.createPortaDelegata(portaDelegata);
  1308.     }
  1309.    
  1310.     public void deletePortaDelegata(org.openspcoop2.core.config.PortaDelegata portaDelegata) throws DriverConfigurazioneException {
  1311.         this.driverConfigurazione.deletePortaDelegata(portaDelegata);
  1312.     }
  1313.    
  1314.     public void updatePortaDelegata(org.openspcoop2.core.config.PortaDelegata portaDelegata) throws DriverConfigurazioneException {
  1315.         this.driverConfigurazione.updatePortaDelegata(portaDelegata);
  1316.     }
  1317.    
  1318.    
  1319.    
  1320.    
  1321.     // --- Porte Applicative ---
  1322.    
  1323.     public List<IDPortaApplicativa> getAllIdPorteApplicative(FiltroRicercaPorteApplicative filtroRicerca) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  1324.         return this.driverConfigurazione.getAllIdPorteApplicative(filtroRicerca);
  1325.     }
  1326.    
  1327.     public org.openspcoop2.core.config.PortaApplicativa getPortaApplicativa(IDPortaApplicativa idPortaApplicativa) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  1328.         return this.driverConfigurazione.getPortaApplicativa(idPortaApplicativa);
  1329.     }
  1330.    
  1331.     public boolean existsPortaApplicativa(IDPortaApplicativa idPortaApplicativa) throws DriverConfigurazioneException {
  1332.         return this.driverConfigurazione.existsPortaApplicativa(idPortaApplicativa);
  1333.     }
  1334.    
  1335.     public void createPortaApplicativa(org.openspcoop2.core.config.PortaApplicativa portaApplicativa) throws DriverConfigurazioneException {
  1336.         this.driverConfigurazione.createPortaApplicativa(portaApplicativa);
  1337.     }
  1338.    
  1339.     public void deletePortaApplicativa(org.openspcoop2.core.config.PortaApplicativa portaApplicativa) throws DriverConfigurazioneException {
  1340.         this.driverConfigurazione.deletePortaApplicativa(portaApplicativa);
  1341.     }
  1342.    
  1343.     public void updatePortaApplicativa(org.openspcoop2.core.config.PortaApplicativa portaApplicativa) throws DriverConfigurazioneException {
  1344.         this.driverConfigurazione.updatePortaApplicativa(portaApplicativa);
  1345.     }
  1346.    
  1347.    
  1348.    
  1349.    
  1350.     // --- Controllo Traffico (Configurazione) ---
  1351.    
  1352.     public void updateControlloTraffico_configurazione(ConfigurazioneGenerale configurazione) throws DriverConfigurazioneException{
  1353.         try {
  1354.             this.serviceManagerControlloTraffico.getConfigurazioneGeneraleService().update(configurazione);
  1355.         }catch(Exception e) {
  1356.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1357.         }
  1358.     }
  1359.    
  1360.     public void deleteControlloTraffico_Configurazione(ConfigurazioneGenerale configurazione) throws DriverConfigurazioneException{
  1361.         try {
  1362.             this.serviceManagerControlloTraffico.getConfigurazioneGeneraleService().delete(configurazione);
  1363.         }catch(Exception e) {
  1364.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1365.         }
  1366.     }
  1367.    
  1368.     public ConfigurazioneGenerale getControlloTraffico_Configurazione() throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1369.         try {
  1370.             return this.serviceManagerControlloTraffico.getConfigurazioneGeneraleService().get();
  1371.         }catch(NotFoundException e) {
  1372.             throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  1373.         }catch(Exception e) {
  1374.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1375.         }
  1376.     }
  1377.    
  1378.    
  1379.     // --- Controllo Traffico (ConfigurazionePolicy) ---
  1380.    
  1381.     public List<IdPolicy> getAllIdControlloTraffico_configurationPolicies() throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1382.         try {
  1383.             IPaginatedExpression pagExpr = this.serviceManagerControlloTraffico.getConfigurazionePolicyServiceSearch().newPaginatedExpression();
  1384.             List<IdPolicy> l = this.serviceManagerControlloTraffico.getConfigurazionePolicyServiceSearch().findAllIds(pagExpr);
  1385.             if(l==null || l.size()<=0) {
  1386.                 throw new NotFoundException("Non esistono policy");
  1387.             }
  1388.             return l;
  1389.         }catch(NotFoundException e) {
  1390.             throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  1391.         }catch(Exception e) {
  1392.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1393.         }
  1394.     }
  1395.    
  1396.     public ConfigurazionePolicy getControlloTraffico_configurationPolicy(String idPolicy) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  1397.         IdPolicy idPolicyObject = new IdPolicy();
  1398.         idPolicyObject.setNome(idPolicy);
  1399.         return this.getControlloTraffico_configurationPolicy(idPolicyObject);
  1400.     }
  1401.     public ConfigurazionePolicy getControlloTraffico_configurationPolicy(IdPolicy idPolicy) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  1402.         try {
  1403.             return this.serviceManagerControlloTraffico.getConfigurazionePolicyServiceSearch().get(idPolicy);
  1404.         }catch(NotFoundException e) {
  1405.             throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  1406.         }catch(Exception e) {
  1407.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1408.         }
  1409.     }
  1410.    
  1411.     public boolean existsControlloTraffico_configurationPolicy(String idPolicy) throws DriverConfigurazioneException {
  1412.         IdPolicy idPolicyObject = new IdPolicy();
  1413.         idPolicyObject.setNome(idPolicy);
  1414.         return this.existsControlloTraffico_configurationPolicy(idPolicyObject);
  1415.     }
  1416.     public boolean existsControlloTraffico_configurationPolicy(IdPolicy idPolicy) throws DriverConfigurazioneException {
  1417.         try {
  1418.             return this.serviceManagerControlloTraffico.getConfigurazionePolicyServiceSearch().exists(idPolicy);
  1419.         }catch(Exception e) {
  1420.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1421.         }
  1422.     }
  1423.    
  1424.     public void createControlloTraffico_configurationPolicy(ConfigurazionePolicy policy) throws DriverConfigurazioneException {
  1425.         try {
  1426.             this.serviceManagerControlloTraffico.getConfigurazionePolicyService().create(policy);
  1427.         }catch(Exception e) {
  1428.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1429.         }
  1430.     }
  1431.    
  1432.     public void updateControlloTraffico_configurationPolicy(ConfigurazionePolicy policy) throws DriverConfigurazioneException {
  1433.         try {
  1434.             IdPolicy oldId = new IdPolicy();
  1435.             oldId.setNome(policy.getIdPolicy());
  1436.             if(policy.getOldIdPolicy()!=null && policy.getOldIdPolicy().getNome()!=null) {
  1437.                 oldId.setNome(policy.getOldIdPolicy().getNome());
  1438.             }
  1439.             this.serviceManagerControlloTraffico.getConfigurazionePolicyService().update(oldId, policy);
  1440.         }catch(Exception e) {
  1441.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1442.         }
  1443.     }
  1444.    
  1445.     public void deleteControlloTraffico_configurationPolicy(ConfigurazionePolicy policy) throws DriverConfigurazioneException {
  1446.         try {
  1447.             this.serviceManagerControlloTraffico.getConfigurazionePolicyService().delete(policy);
  1448.         }catch(Exception e) {
  1449.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1450.         }
  1451.     }
  1452.    
  1453.     public boolean isControlloTraffico_configurationPolicyInUso(String idPolicy, List<String> whereIsInUso) throws DriverConfigurazioneException {
  1454.         IdPolicy idPolicyObject = new IdPolicy();
  1455.         idPolicyObject.setNome(idPolicy);
  1456.         return this.isControlloTraffico_configurationPolicyInUso(idPolicyObject,whereIsInUso);
  1457.     }
  1458.     public boolean isControlloTraffico_configurationPolicyInUso(IdPolicy idPolicy, List<String> whereIsInUso) throws DriverConfigurazioneException {
  1459.         try {
  1460.             IPaginatedExpression pagExpr = this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().newPaginatedExpression();
  1461.             pagExpr.equals(AttivazionePolicy.model().ID_POLICY, idPolicy.getNome());
  1462.             List<IdActivePolicy> l = this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().findAllIds(pagExpr);
  1463.             if(l==null || l.size()<=0) {
  1464.                 return false;
  1465.             }
  1466.             else {
  1467.                 for (IdActivePolicy idActivePolicy : l) {
  1468.                     whereIsInUso.add(idActivePolicy.getNome());
  1469.                 }
  1470.                 return true;    
  1471.             }
  1472.         }catch(Exception e) {
  1473.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1474.         }
  1475.     }
  1476.    
  1477.    
  1478.     // --- Controllo Traffico (AttivazionePolicy) ---
  1479.    
  1480.     public List<IdActivePolicy> getAllIdControlloTraffico_activePolicies_globali(String tag) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1481.         return _getAllIdControlloTraffico_activePolicies(true, tag);
  1482.     }
  1483.     public List<IdActivePolicy> getAllIdControlloTraffico_activePolicies_erogazioniFruizioni(String tag) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1484.         return _getAllIdControlloTraffico_activePolicies(false, tag);
  1485.     }
  1486.     public List<IdActivePolicy> getAllIdControlloTraffico_activePolicies_all(String tag) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1487.         return _getAllIdControlloTraffico_activePolicies(null, tag);
  1488.     }
  1489.     private List<IdActivePolicy> _getAllIdControlloTraffico_activePolicies(Boolean globali, String tag) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1490.         try {
  1491.             IPaginatedExpression pagExpr = this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().newPaginatedExpression();
  1492.             pagExpr.and();
  1493.             if(globali!=null) {
  1494.                 if(globali) {
  1495.                     pagExpr.isNull(org.openspcoop2.core.controllo_traffico.AttivazionePolicy.model().FILTRO.NOME_PORTA);
  1496.                 }else {
  1497.                     pagExpr.isNotNull(org.openspcoop2.core.controllo_traffico.AttivazionePolicy.model().FILTRO.NOME_PORTA);
  1498.                 }
  1499.             }
  1500.             if(StringUtils.isNotEmpty(tag)) {
  1501.                 pagExpr.equals(org.openspcoop2.core.controllo_traffico.AttivazionePolicy.model().FILTRO.TAG, tag);
  1502.             }
  1503.             List<IdActivePolicy> l = this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().findAllIds(pagExpr);
  1504.             if(l==null || l.size()<=0) {
  1505.                 throw new NotFoundException("Non esistono policy");
  1506.             }
  1507.             return l;
  1508.         }catch(NotFoundException e) {
  1509.             throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  1510.         }catch(Exception e) {
  1511.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1512.         }
  1513.     }
  1514.    
  1515.     public List<IdActivePolicy> getAllIdControlloTraffico_activePolicies_fruizione(String nomePorta) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1516.         return _getAllIdControlloTraffico_activePolicies_porta(RuoloPolicy.DELEGATA, nomePorta);
  1517.     }
  1518.     public List<IdActivePolicy> getAllIdControlloTraffico_activePolicies_erogazione(String nomePorta) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{  
  1519.         return _getAllIdControlloTraffico_activePolicies_porta(RuoloPolicy.APPLICATIVA, nomePorta);
  1520.     }
  1521.     private List<IdActivePolicy> _getAllIdControlloTraffico_activePolicies_porta(RuoloPolicy ruoloPorta, String nomePorta) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1522.         try {
  1523.             IPaginatedExpression pagExpr = this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().newPaginatedExpression();
  1524.             pagExpr.equals(org.openspcoop2.core.controllo_traffico.AttivazionePolicy.model().FILTRO.RUOLO_PORTA,ruoloPorta.getValue());
  1525.             pagExpr.and();
  1526.             pagExpr.equals(org.openspcoop2.core.controllo_traffico.AttivazionePolicy.model().FILTRO.NOME_PORTA,nomePorta);
  1527.             List<IdActivePolicy> l = this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().findAllIds(pagExpr);
  1528.             if(l==null || l.size()<=0) {
  1529.                 throw new NotFoundException("Non esistono policy");
  1530.             }
  1531.             return l;
  1532.         }catch(NotFoundException e) {
  1533.             throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  1534.         }catch(Exception e) {
  1535.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1536.         }
  1537.     }
  1538.    
  1539.     // Pericoloso: l'id è dinamico e dipende dal sistema dove viene usato.
  1540. //  public AttivazionePolicy getControlloTraffico_activePolicy(String IdActivePolicy) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  1541. //      IdActivePolicy IdActivePolicyObject = new IdActivePolicy();
  1542. //      IdActivePolicyObject.setNome(IdActivePolicy);
  1543. //      return this.getControlloTraffico_activePolicy(IdActivePolicyObject);
  1544. //  }
  1545. //  public AttivazionePolicy getControlloTraffico_activePolicy(IdActivePolicy IdActivePolicy) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  1546. //      try {
  1547. //          return this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().get(IdActivePolicy);
  1548. //      }catch(NotFoundException e) {
  1549. //          throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  1550. //      }catch(Exception e) {
  1551. //          throw new DriverConfigurazioneException(e.getMessage(),e);
  1552. //      }
  1553. //  }
  1554.     public AttivazionePolicy getControlloTraffico_activePolicy(RuoloPolicy ruoloPorta, String nomePorta, String alias) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  1555.         try {
  1556.             IExpression expr = this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().newExpression();
  1557.            
  1558.             expr.and();
  1559.            
  1560.             if(ruoloPorta!=null && nomePorta!=null) {
  1561.                 expr.equals(AttivazionePolicy.model().FILTRO.RUOLO_PORTA, ruoloPorta);
  1562.                 expr.equals(AttivazionePolicy.model().FILTRO.NOME_PORTA, nomePorta);
  1563.             }
  1564.             else {
  1565.                 expr.isNull(AttivazionePolicy.model().FILTRO.NOME_PORTA);
  1566.             }
  1567.            
  1568.             expr.equals(AttivazionePolicy.model().ALIAS, alias);
  1569.            
  1570.             AttivazionePolicy att = this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().find(expr);
  1571.             return att;
  1572.         }
  1573.         catch(NotFoundException e) {
  1574.             throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  1575.         }
  1576.         catch(Exception e) {
  1577.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1578.         }
  1579.     }
  1580.    
  1581.     // Pericoloso: l'id è dinamico e dipende dal sistema dove viene usato.
  1582. //  public boolean existsControlloTraffico_activePolicy(String IdActivePolicy) throws DriverConfigurazioneException {
  1583. //      IdActivePolicy IdActivePolicyObject = new IdActivePolicy();
  1584. //      IdActivePolicyObject.setNome(IdActivePolicy);
  1585. //      return this.existsControlloTraffico_activePolicy(IdActivePolicyObject);
  1586. //  }
  1587. //  public boolean existsControlloTraffico_activePolicy(IdActivePolicy IdActivePolicy) throws DriverConfigurazioneException {
  1588. //      try {
  1589. //          return this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().exists(IdActivePolicy);
  1590. //      }catch(Exception e) {
  1591. //          throw new DriverConfigurazioneException(e.getMessage(),e);
  1592. //      }
  1593. //  }
  1594.     public boolean existsControlloTraffico_activePolicy(RuoloPolicy ruoloPorta, String nomePorta, String alias) throws DriverConfigurazioneException {
  1595.         try {
  1596.             IExpression expr = this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().newExpression();
  1597.            
  1598.             expr.and();
  1599.            
  1600.             if(ruoloPorta!=null && nomePorta!=null) {
  1601.                 expr.equals(AttivazionePolicy.model().FILTRO.RUOLO_PORTA, ruoloPorta);
  1602.                 expr.equals(AttivazionePolicy.model().FILTRO.NOME_PORTA, nomePorta);
  1603.             }
  1604.             else {
  1605.                 expr.isNull(AttivazionePolicy.model().FILTRO.NOME_PORTA);
  1606.             }
  1607.            
  1608.             expr.equals(AttivazionePolicy.model().ALIAS, alias);
  1609.            
  1610.             AttivazionePolicy att = this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().find(expr);
  1611.             return att!=null;
  1612.         }
  1613.         catch(NotFoundException notFound) {
  1614.             return false;
  1615.         }
  1616.         catch(Exception e) {
  1617.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1618.         }
  1619.     }
  1620.     public String getNextPolicyInstanceSerialId(String policyId, Logger log) throws RegistryException{
  1621.            
  1622.         Connection con = null;
  1623.         try {
  1624.             con = this.driverConfigurazione.getConnection("getNextPolicyInstanceSerialId");
  1625.            
  1626.             return ControlloTrafficoDriverUtils.getNextPolicyInstanceSerialId(policyId,
  1627.                     con, log, this.driverConfigurazione.getTipoDB());
  1628.            
  1629.         }
  1630.         catch(Exception e) {
  1631.             throw new RegistryException(e.getMessage(),e);
  1632.         }
  1633.         finally {
  1634.             try {
  1635.                 if(con!=null) {
  1636.                     this.driverConfigurazione.releaseConnection(con);
  1637.                 }
  1638.             }catch(Exception eClose) {
  1639.                 // close
  1640.             }
  1641.         }
  1642.        
  1643.     }
  1644.    
  1645.     protected void updatePosizioneBeforeCreate(AttivazionePolicy policy, Logger log) throws DriverConfigurazioneException{
  1646.         Connection con = null;
  1647.         try {
  1648.             con = this.driverConfigurazione.getConnection("updatePosizioneAttivazionePolicy");
  1649.            
  1650.             RuoloPolicy ruoloPorta=null;
  1651.             String nomePorta=null;
  1652.             if(policy.getFiltro()!=null) {
  1653.                 ruoloPorta = policy.getFiltro().getRuoloPorta();
  1654.                 nomePorta = policy.getFiltro().getNomePorta();
  1655.             }
  1656.        
  1657.             List<InfoPolicy> lst = ControlloTrafficoDriverUtils.getInfoPolicyList(null, policy.getIdPolicy(),
  1658.                     con, log, this.driverConfigurazione.getTipoDB());
  1659.             InfoPolicy infoPolicy = (lst != null && lst.size() > 0) ? lst.get(0) : null;
  1660.             if(infoPolicy==null) {
  1661.                 throw new Exception("Policy '"+policy.getIdPolicy()+"' non trovata");
  1662.             }
  1663.             ControlloTrafficoDriverUtils.updatePosizioneAttivazionePolicy(infoPolicy, policy,
  1664.                     ruoloPorta, nomePorta,
  1665.                     con, log, this.driverConfigurazione.getTipoDB());          
  1666.         }
  1667.         catch(Exception e) {
  1668.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1669.         }
  1670.         finally {
  1671.             try {
  1672.                 if(con!=null) {
  1673.                     this.driverConfigurazione.releaseConnection(con);
  1674.                 }
  1675.             }catch(Exception eClose) {
  1676.                 // close
  1677.             }
  1678.         }
  1679.     }
  1680.     public void createControlloTraffico_activePolicy(AttivazionePolicy policy, Logger log) throws DriverConfigurazioneException {
  1681.         updatePosizioneBeforeCreate(policy, log);      
  1682.         try {
  1683.             this.serviceManagerControlloTraffico.getAttivazionePolicyService().create(policy);
  1684.         }catch(Exception e) {
  1685.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1686.         }
  1687.     }
  1688.    
  1689.     public void updateControlloTraffico_activePolicy(AttivazionePolicy policy) throws DriverConfigurazioneException {
  1690.         try {
  1691.             IdActivePolicy oldId = new IdActivePolicy();
  1692.             oldId.setNome(policy.getIdActivePolicy());
  1693.             if(policy.getOldIdActivePolicy()!=null && policy.getOldIdActivePolicy().getNome()!=null) {
  1694.                 oldId.setNome(policy.getOldIdActivePolicy().getNome());
  1695.             }
  1696.             this.serviceManagerControlloTraffico.getAttivazionePolicyService().update(oldId, policy);
  1697.         }catch(Exception e) {
  1698.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1699.         }
  1700.     }
  1701.    
  1702.     public void deleteControlloTraffico_activePolicy(AttivazionePolicy policy) throws DriverConfigurazioneException {
  1703.         try {
  1704.             // Il file importato potrebbe avere un identificativo diverso da quello effettivamente salvato
  1705.             if(policy.getAlias()==null) {
  1706.                 this.serviceManagerControlloTraffico.getAttivazionePolicyService().delete(policy);
  1707.             }
  1708.             else {
  1709.                 IExpression expr = this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().newExpression();
  1710.                
  1711.                 expr.and();
  1712.                
  1713.                 if(policy.getFiltro()!=null && policy.getFiltro().getRuoloPorta()!=null && policy.getFiltro().getNomePorta()!=null) {
  1714.                     expr.equals(AttivazionePolicy.model().FILTRO.RUOLO_PORTA, policy.getFiltro().getRuoloPorta());
  1715.                     expr.equals(AttivazionePolicy.model().FILTRO.NOME_PORTA, policy.getFiltro().getNomePorta());
  1716.                 }
  1717.                 else {
  1718.                     expr.isNull(AttivazionePolicy.model().FILTRO.NOME_PORTA);
  1719.                 }
  1720.                
  1721.                 expr.equals(AttivazionePolicy.model().ALIAS, policy.getAlias());
  1722.                
  1723.                 try {
  1724.                     AttivazionePolicy att = this.serviceManagerControlloTraffico.getAttivazionePolicyServiceSearch().find(expr);
  1725.                     this.serviceManagerControlloTraffico.getAttivazionePolicyService().delete(att);
  1726.                 }catch(NotFoundException notFound) {}
  1727.             }
  1728.         }catch(Exception e) {
  1729.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1730.         }
  1731.     }
  1732.    
  1733.     public boolean isControlloTraffico_activePolicyInUso(RuoloPolicy ruoloPorta, String nomePorta, String alias, List<String> whereIsInUso) throws DriverRegistroServiziException {
  1734.         return false;
  1735.     }
  1736.    
  1737.    
  1738.    
  1739.    
  1740.    
  1741.    
  1742.    
  1743.     // --- Allarmi ---
  1744.    
  1745.     public List<IdAllarme> getAllIdAllarmi_globali(String tag) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1746.         return _getAllIdAllarmi(true, tag);
  1747.     }
  1748.     public List<IdAllarme> getAllIdAllarmi_erogazioniFruizioni(String tag) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1749.         return _getAllIdAllarmi(false, tag);
  1750.     }
  1751.     public List<IdAllarme> getAllIdAllarmi_all(String tag) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1752.         return _getAllIdAllarmi(null, tag);
  1753.     }
  1754.     private List<IdAllarme> _getAllIdAllarmi(Boolean globali, String tag) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1755.         try {
  1756.             IPaginatedExpression pagExpr = this.serviceManagerAllarmi.getAllarmeServiceSearch().newPaginatedExpression();
  1757.             pagExpr.and();
  1758.             if(globali!=null) {
  1759.                 if(globali) {
  1760.                     pagExpr.isNull(org.openspcoop2.core.allarmi.Allarme.model().FILTRO.NOME_PORTA);
  1761.                 }else {
  1762.                     pagExpr.isNotNull(org.openspcoop2.core.allarmi.Allarme.model().FILTRO.NOME_PORTA);
  1763.                 }
  1764.             }
  1765.             if(StringUtils.isNotEmpty(tag)) {
  1766.                 pagExpr.equals(org.openspcoop2.core.allarmi.Allarme.model().FILTRO.TAG, tag);
  1767.             }
  1768.             List<IdAllarme> l = this.serviceManagerAllarmi.getAllarmeServiceSearch().findAllIds(pagExpr);
  1769.             if(l==null || l.size()<=0) {
  1770.                 throw new NotFoundException("Non esistono allarmi");
  1771.             }
  1772.             return l;
  1773.         }catch(NotFoundException e) {
  1774.             throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  1775.         }catch(Exception e) {
  1776.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1777.         }
  1778.     }
  1779.    
  1780.     public List<IdAllarme> getAllIdAllarmi_fruizione(String nomePorta) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1781.         return _getAllIdAllarmi_porta(RuoloPorta.DELEGATA, nomePorta);
  1782.     }
  1783.     public List<IdAllarme> getAllIdAllarmi_erogazione(String nomePorta) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1784.         return _getAllIdAllarmi_porta(RuoloPorta.APPLICATIVA, nomePorta);
  1785.     }
  1786.     private List<IdAllarme> _getAllIdAllarmi_porta(RuoloPorta ruoloPorta, String nomePorta) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1787.         try {
  1788.             IPaginatedExpression pagExpr = this.serviceManagerAllarmi.getAllarmeServiceSearch().newPaginatedExpression();
  1789.             pagExpr.equals(org.openspcoop2.core.allarmi.Allarme.model().FILTRO.RUOLO_PORTA,ruoloPorta.getValue());
  1790.             pagExpr.and();
  1791.             pagExpr.equals(org.openspcoop2.core.allarmi.Allarme.model().FILTRO.NOME_PORTA,nomePorta);
  1792.             List<IdAllarme> l = this.serviceManagerAllarmi.getAllarmeServiceSearch().findAllIds(pagExpr);
  1793.             if(l==null || l.size()<=0) {
  1794.                 throw new NotFoundException("Non esistono allarmi");
  1795.             }
  1796.             return l;
  1797.         }catch(NotFoundException e) {
  1798.             throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  1799.         }catch(Exception e) {
  1800.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1801.         }
  1802.     }
  1803.    
  1804.     // Pericoloso: l'id è dinamico e dipende dal sistema dove viene usato.
  1805. //  public Allarme getAllarme(String IdAllarme) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  1806. //      IdAllarme IdAllarmeObject = new IdAllarme();
  1807. //      IdAllarmeObject.setNome(IdAllarme);
  1808. //      return this.getAllarme(IdAllarmeObject);
  1809. //  }
  1810. //  public Allarme getAllarme(IdAllarme IdAllarme) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  1811. //      try {
  1812. //          return this.serviceManagerAllarmi.getAllarmeServiceSearch().get(IdAllarme);
  1813. //      }catch(NotFoundException e) {
  1814. //          throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  1815. //      }catch(Exception e) {
  1816. //          throw new DriverConfigurazioneException(e.getMessage(),e);
  1817. //      }
  1818. //  }
  1819.     public Allarme getAllarme(RuoloPorta ruoloPorta, String nomePorta, String alias) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  1820.         try {
  1821.             IExpression expr = this.serviceManagerAllarmi.getAllarmeServiceSearch().newExpression();
  1822.            
  1823.             expr.and();
  1824.            
  1825.             if(ruoloPorta!=null && nomePorta!=null) {
  1826.                 expr.equals(Allarme.model().FILTRO.RUOLO_PORTA, ruoloPorta);
  1827.                 expr.equals(Allarme.model().FILTRO.NOME_PORTA, nomePorta);
  1828.             }
  1829.             else {
  1830.                 expr.isNull(Allarme.model().FILTRO.NOME_PORTA);
  1831.             }
  1832.            
  1833.             expr.equals(Allarme.model().ALIAS, alias);
  1834.            
  1835.             Allarme att = this.serviceManagerAllarmi.getAllarmeServiceSearch().find(expr);
  1836.             return att;
  1837.         }
  1838.         catch(NotFoundException e) {
  1839.             throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  1840.         }
  1841.         catch(Exception e) {
  1842.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1843.         }
  1844.     }
  1845.    
  1846.     // Pericoloso: l'id è dinamico e dipende dal sistema dove viene usato.
  1847. //  public boolean existsAllarme(String IdAllarme) throws DriverConfigurazioneException {
  1848. //      IdAllarme IdAllarmeObject = new IdAllarme();
  1849. //      IdAllarmeObject.setNome(IdAllarme);
  1850. //      return this.existsAllarme(IdAllarmeObject);
  1851. //  }
  1852. //  public boolean existsAllarme(IdAllarme IdAllarme) throws DriverConfigurazioneException {
  1853. //      try {
  1854. //          return this.serviceManagerAllarmi.getAllarmeServiceSearch().exists(IdAllarme);
  1855. //      }catch(Exception e) {
  1856. //          throw new DriverConfigurazioneException(e.getMessage(),e);
  1857. //      }
  1858. //  }
  1859.     public boolean existsAllarme(RuoloPorta ruoloPorta, String nomePorta, String alias) throws DriverConfigurazioneException {
  1860.         try {
  1861.             IExpression expr = this.serviceManagerAllarmi.getAllarmeServiceSearch().newExpression();
  1862.            
  1863.             expr.and();
  1864.            
  1865.             if(ruoloPorta!=null && nomePorta!=null) {
  1866.                 expr.equals(Allarme.model().FILTRO.RUOLO_PORTA, ruoloPorta);
  1867.                 expr.equals(Allarme.model().FILTRO.NOME_PORTA, nomePorta);
  1868.             }
  1869.             else {
  1870.                 expr.isNull(Allarme.model().FILTRO.NOME_PORTA);
  1871.             }
  1872.            
  1873.             expr.equals(Allarme.model().ALIAS, alias);
  1874.            
  1875.             Allarme att = this.serviceManagerAllarmi.getAllarmeServiceSearch().find(expr);
  1876.             return att!=null;
  1877.         }
  1878.         catch(NotFoundException notFound) {
  1879.             return false;
  1880.         }
  1881.         catch(Exception e) {
  1882.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1883.         }
  1884.     }
  1885.     public String getNextAlarmInstanceSerialId(String policyId, Logger log) throws RegistryException{
  1886.            
  1887.         Connection con = null;
  1888.         try {
  1889.             con = this.driverConfigurazione.getConnection("getNextAlarmInstanceSerialId");
  1890.            
  1891.             return AllarmiDriverUtils.getNextAlarmInstanceSerialId(policyId,
  1892.                     con, log, this.driverConfigurazione.getTipoDB());
  1893.            
  1894.         }
  1895.         catch(Exception e) {
  1896.             throw new RegistryException(e.getMessage(),e);
  1897.         }
  1898.         finally {
  1899.             try {
  1900.                 if(con!=null) {
  1901.                     this.driverConfigurazione.releaseConnection(con);
  1902.                 }
  1903.             }catch(Exception eClose) {
  1904.                 // close
  1905.             }
  1906.         }
  1907.        
  1908.     }
  1909.    
  1910.    
  1911.     public void createAllarme(Allarme allarme, Logger log) throws DriverConfigurazioneException {
  1912.         try {
  1913.             this.serviceManagerAllarmi.getAllarmeService().create(allarme);
  1914.         }catch(Exception e) {
  1915.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1916.         }
  1917.     }
  1918.    
  1919.     public void updateAllarme(Allarme allarme, Logger log) throws DriverConfigurazioneException {
  1920.         try {
  1921.             IdAllarme oldId = new IdAllarme();
  1922.             oldId.setNome(allarme.getNome());
  1923. //          if(allarme.get!=null && allarme.getOldIdAllarme().getNome()!=null) {
  1924. //              oldId.setNome(allarme.getOldIdAllarme().getNome());
  1925. //          }
  1926.             this.serviceManagerAllarmi.getAllarmeService().update(oldId, allarme);
  1927.         }catch(Exception e) {
  1928.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1929.         }
  1930.     }
  1931.    
  1932.     public void deleteAllarme(Allarme policy, Logger log) throws DriverConfigurazioneException {
  1933.         try {
  1934.             // Il file importato potrebbe avere un identificativo diverso da quello effettivamente salvato
  1935.             if(policy.getAlias()==null) {
  1936.                 this.serviceManagerAllarmi.getAllarmeService().delete(policy);
  1937.             }
  1938.             else {
  1939.                 IExpression expr = this.serviceManagerAllarmi.getAllarmeService().newExpression();
  1940.                
  1941.                 expr.and();
  1942.                
  1943.                 if(policy.getFiltro()!=null && policy.getFiltro().getRuoloPorta()!=null && policy.getFiltro().getNomePorta()!=null) {
  1944.                     expr.equals(AttivazionePolicy.model().FILTRO.RUOLO_PORTA, policy.getFiltro().getRuoloPorta());
  1945.                     expr.equals(AttivazionePolicy.model().FILTRO.NOME_PORTA, policy.getFiltro().getNomePorta());
  1946.                 }
  1947.                 else {
  1948.                     expr.isNull(AttivazionePolicy.model().FILTRO.NOME_PORTA);
  1949.                 }
  1950.                
  1951.                 expr.equals(AttivazionePolicy.model().ALIAS, policy.getAlias());
  1952.                
  1953.                 try {
  1954.                     Allarme all = this.serviceManagerAllarmi.getAllarmeService().find(expr);
  1955.                     this.serviceManagerAllarmi.getAllarmeService().delete(all);
  1956.                 }catch(NotFoundException notFound) {}
  1957.             }
  1958.         }catch(Exception e) {
  1959.             throw new DriverConfigurazioneException(e.getMessage(),e);
  1960.         }
  1961.     }
  1962.    
  1963.     public boolean isAllarmeInUso(RuoloPorta ruoloPorta, String nomePorta, String alias, List<String> whereIsInUso) throws DriverRegistroServiziException {
  1964.         return false;
  1965.     }
  1966.    
  1967.    
  1968.    
  1969.    
  1970.    
  1971.    
  1972.    
  1973.    
  1974.    
  1975.     // --- Token Policy ---
  1976.    
  1977.     public List<IDGenericProperties> getAllIdGenericProperties(String tipologia) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1978.         return _getAllIdGenericProperties(tipologia);
  1979.     }
  1980.     public List<IDGenericProperties> getAllIdGenericProperties_validation() throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1981.         return _getAllIdGenericProperties(CostantiConfigurazione.GENERIC_PROPERTIES_TOKEN_TIPOLOGIA_VALIDATION);
  1982.     }
  1983.     public List<IDGenericProperties> getAllIdGenericProperties_retrieve() throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1984.         return _getAllIdGenericProperties(CostantiConfigurazione.GENERIC_PROPERTIES_TOKEN_TIPOLOGIA_RETRIEVE);
  1985.     }
  1986.     public List<IDGenericProperties> getAllIdGenericProperties_attributeAuthorities() throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1987.         return _getAllIdGenericProperties(CostantiConfigurazione.GENERIC_PROPERTIES_ATTRIBUTE_AUTHORITY);
  1988.     }
  1989.     private List<IDGenericProperties> _getAllIdGenericProperties(String tipologia) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1990.         try {
  1991.             List<GenericProperties> l = this.driverConfigurazione.getGenericProperties(tipologia);
  1992.             if(l==null || l.isEmpty()) {
  1993.                 throw new DriverConfigurazioneNotFound();
  1994.             }
  1995.             List<IDGenericProperties> lNew = new ArrayList<IDGenericProperties>();
  1996.             for (GenericProperties genericProperties : l) {
  1997.                
  1998.                 if(!tipologia.equals(genericProperties.getTipologia())) {
  1999.                     continue;
  2000.                 }
  2001.                
  2002.                 IDGenericProperties id = new IDGenericProperties();
  2003.                 id.setNome(genericProperties.getNome());
  2004.                 id.setTipologia(tipologia);
  2005.                 lNew.add(id);
  2006.             }
  2007.             return lNew;
  2008.         }catch(DriverConfigurazioneNotFound e) {
  2009.             throw e;
  2010.         }catch(Exception e) {
  2011.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2012.         }
  2013.     }
  2014.    
  2015.     public GenericProperties getGenericProperties(String tipologia, String nome) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  2016.         return _getGenericProperties(tipologia, nome);
  2017.     }
  2018.     public GenericProperties getGenericProperties(IDGenericProperties idGP) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  2019.         return _getGenericProperties(idGP.getTipologia(), idGP.getNome());
  2020.     }
  2021.     public GenericProperties getGenericProperties_validation(String nome) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  2022.         return _getGenericProperties(CostantiConfigurazione.GENERIC_PROPERTIES_TOKEN_TIPOLOGIA_VALIDATION, nome);
  2023.     }
  2024.     public GenericProperties getGenericProperties_retrieve(String nome) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  2025.         return _getGenericProperties(CostantiConfigurazione.GENERIC_PROPERTIES_TOKEN_TIPOLOGIA_RETRIEVE, nome);
  2026.     }
  2027.     public GenericProperties getGenericProperties_attributeAuthority(String nome) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  2028.         return _getGenericProperties(CostantiConfigurazione.GENERIC_PROPERTIES_ATTRIBUTE_AUTHORITY, nome);
  2029.     }
  2030.     private GenericProperties _getGenericProperties(String tipologia, String nome) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  2031.         try {
  2032.             GenericProperties gp = this.driverConfigurazione.getGenericProperties(tipologia, nome);
  2033.             if(gp==null) {
  2034.                 throw new DriverConfigurazioneNotFound();
  2035.             }
  2036.             return gp;
  2037.         }catch(DriverConfigurazioneNotFound e) {
  2038.             throw e;
  2039.         }catch(Exception e) {
  2040.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2041.         }
  2042.     }
  2043.    
  2044.     public boolean existsGenericProperties(String tipologia, String nome) throws DriverConfigurazioneException {
  2045.         return _existsGenericProperties(tipologia, nome);
  2046.     }
  2047.     public boolean existsGenericProperties(IDGenericProperties idGP) throws DriverConfigurazioneException {
  2048.         return _existsGenericProperties(idGP.getTipologia(), idGP.getNome());
  2049.     }
  2050.     public boolean existsGenericProperties_validation(String nome) throws DriverConfigurazioneException{
  2051.         return _existsGenericProperties(CostantiConfigurazione.GENERIC_PROPERTIES_TOKEN_TIPOLOGIA_VALIDATION, nome);
  2052.     }
  2053.     public boolean existsGenericProperties_retrieve(String nome) throws DriverConfigurazioneException{
  2054.         return _existsGenericProperties(CostantiConfigurazione.GENERIC_PROPERTIES_TOKEN_TIPOLOGIA_RETRIEVE, nome);
  2055.     }
  2056.     public boolean existsGenericProperties_attributeAuthority(String nome) throws DriverConfigurazioneException{
  2057.         return _existsGenericProperties(CostantiConfigurazione.GENERIC_PROPERTIES_ATTRIBUTE_AUTHORITY, nome);
  2058.     }
  2059.     private boolean _existsGenericProperties(String tipologia, String nome) throws DriverConfigurazioneException{
  2060.         try {
  2061.             GenericProperties gp = this.driverConfigurazione.getGenericProperties(tipologia, nome);
  2062.             return gp!=null;
  2063.         }catch(DriverConfigurazioneNotFound e) {
  2064.             return false;
  2065.         }catch(Exception e) {
  2066.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2067.         }
  2068.     }

  2069.     public void createGenericProperties(GenericProperties gp) throws DriverConfigurazioneException{
  2070.         try {
  2071.             this.driverConfigurazione.createGenericProperties(gp);
  2072.         }catch(Exception e) {
  2073.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2074.         }
  2075.     }
  2076.     public void updateGenericProperties(GenericProperties gp) throws DriverConfigurazioneException{
  2077.         try {
  2078.             this.driverConfigurazione.updateGenericProperties(gp);
  2079.         }catch(Exception e) {
  2080.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2081.         }
  2082.     }
  2083.     public void deleteGenericProperties(GenericProperties gp) throws DriverConfigurazioneException{
  2084.         try {
  2085.             this.driverConfigurazione.deleteGenericProperties(gp);
  2086.         }catch(Exception e) {
  2087.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2088.         }
  2089.     }
  2090.    
  2091.     public boolean isGenericPropertiesInUso(String tipologia, String nome, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverRegistroServiziException {
  2092.         IDGenericProperties idGP = new IDGenericProperties();
  2093.         idGP.setTipologia(tipologia);
  2094.         idGP.setNome(nome);
  2095.         return this.isGenericPropertiesInUso(idGP,whereIsInUso, normalizeObjectIds);
  2096.     }
  2097.     public boolean isGenericPropertiesInUso(IDGenericProperties idGP, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverRegistroServiziException {
  2098.         Connection con = null;
  2099.         try{
  2100.             con = this.driverRegistroServizi.getConnection("archive.isGenericPropertiesInUso");
  2101.             return DBOggettiInUsoUtils.isGenericPropertiesInUso(con, this.driverRegistroServizi.getTipoDB(), idGP, whereIsInUso, normalizeObjectIds);
  2102.         }
  2103.         catch(Exception e){
  2104.             throw new DriverRegistroServiziException(e.getMessage(),e);
  2105.         }
  2106.         finally{
  2107.             try{
  2108.                 this.driverRegistroServizi.releaseConnection(con);
  2109.             }catch(Exception eClose){
  2110.                 // close
  2111.             }
  2112.         }
  2113.     }
  2114.    
  2115.    
  2116.    
  2117.    
  2118.    
  2119.    
  2120.     // Plugin Classe
  2121.    
  2122.     public List<IdPlugin> getAllIdPluginClasse() throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  2123.         return _getAllIdPluginClasse(null);
  2124.     }
  2125.     private List<IdPlugin> _getAllIdPluginClasse(String tipoPlugin) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  2126.         try {
  2127.             IPaginatedExpression pagExpr = this.serviceManagerPlugins.getPluginServiceSearch().newPaginatedExpression();
  2128.             if(tipoPlugin!=null) {
  2129.                 pagExpr.equals(org.openspcoop2.core.plugins.Plugin.model().TIPO_PLUGIN, tipoPlugin);
  2130.             }
  2131.             List<IdPlugin> l = this.serviceManagerPlugins.getPluginServiceSearch().findAllIds(pagExpr);
  2132.             if(l==null || l.size()<=0) {
  2133.                 throw new NotFoundException("Non esistono plugins");
  2134.             }
  2135.             return l;
  2136.         }catch(NotFoundException e) {
  2137.             throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  2138.         }catch(Exception e) {
  2139.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2140.         }
  2141.     }
  2142.    
  2143.     public Plugin getPluginClasse(String tipoPlugin, String tipo) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  2144.         IdPlugin idPluginObject = new IdPlugin();
  2145.         idPluginObject.setTipoPlugin(tipoPlugin);
  2146.         idPluginObject.setTipo(tipo);
  2147.         return this.getPluginClasse(idPluginObject);
  2148.     }
  2149.     public Plugin getPluginClasse(IdPlugin idPlugin) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  2150.         try {
  2151.             return this.serviceManagerPlugins.getPluginServiceSearch().get(idPlugin);
  2152.         }catch(NotFoundException e) {
  2153.             throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  2154.         }catch(Exception e) {
  2155.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2156.         }
  2157. //      try {
  2158. //          IExpression expr = this.serviceManagerPlugins.getPluginServiceSearch().newExpression();
  2159. //          expr.equals(org.openspcoop2.core.plugins.Plugin.model().TIPO_PLUGIN, idPlugin.getTipoPlugin());
  2160. //          expr.equals(org.openspcoop2.core.plugins.Plugin.model().TIPO, idPlugin.getTipo());
  2161. //          return this.serviceManagerPlugins.getPluginServiceSearch().find(expr);
  2162. //      }catch(NotFoundException e) {
  2163. //          throw new DriverConfigurazioneNotFound(e.getMessage(),e);
  2164. //      }catch(Exception e) {
  2165. //          throw new DriverConfigurazioneException(e.getMessage(),e);
  2166. //      }
  2167.     }
  2168.    
  2169.     public boolean existsPluginClasse(String tipoPlugin, String tipo) throws DriverConfigurazioneException {
  2170.         IdPlugin idPluginObject = new IdPlugin();
  2171.         idPluginObject.setTipoPlugin(tipoPlugin);
  2172.         idPluginObject.setTipo(tipo);
  2173.         return this.existsPluginClasse(idPluginObject);
  2174.     }
  2175.     public boolean existsPluginClasse(IdPlugin idPlugin) throws DriverConfigurazioneException {
  2176.         try {
  2177.             return this.serviceManagerPlugins.getPluginServiceSearch().exists(idPlugin);
  2178.         }catch(Exception e) {
  2179.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2180.         }
  2181. //      try {
  2182. //          IExpression expr = this.serviceManagerPlugins.getPluginServiceSearch().newExpression();
  2183. //          expr.equals(org.openspcoop2.core.plugins.Plugin.model().TIPO_PLUGIN, idPlugin.getTipoPlugin());
  2184. //          expr.equals(org.openspcoop2.core.plugins.Plugin.model().TIPO, idPlugin.getTipo());
  2185. //          NonNegativeNumber nn = this.serviceManagerPlugins.getPluginServiceSearch().count(expr);
  2186. //          if(nn!=null) {
  2187. //              if(nn.longValue()>1) {
  2188. //                  throw new MultipleResultException("Trovate "+nn.longValue()+" occorrenze");
  2189. //              }
  2190. //              else if(nn.longValue()==1) {
  2191. //                  return true;
  2192. //              }
  2193. //          }
  2194. //          return false;
  2195. //      }catch(Exception e) {
  2196. //          throw new DriverConfigurazioneException(e.getMessage(),e);
  2197. //      }
  2198.     }
  2199.    
  2200.    
  2201.     public void createPluginClasse(Plugin plugin) throws DriverConfigurazioneException {
  2202.         try {
  2203.             this.serviceManagerPlugins.getPluginService().create(plugin);
  2204.         }catch(Exception e) {
  2205.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2206.         }
  2207.     }
  2208.    
  2209.     public void updatePluginClasse(Plugin plugin) throws DriverConfigurazioneException {
  2210.         try {
  2211.             IdPlugin oldId = new IdPlugin();
  2212.             oldId.setTipoPlugin(plugin.getTipoPlugin());
  2213.             oldId.setTipo(plugin.getTipo());
  2214.             if(plugin.getOldIdPlugin()!=null && plugin.getOldIdPlugin().getTipoPlugin()!=null) {
  2215.                 oldId.setTipoPlugin(plugin.getOldIdPlugin().getTipoPlugin());
  2216.             }
  2217.             if(plugin.getOldIdPlugin()!=null && plugin.getOldIdPlugin().getTipo()!=null) {
  2218.                 oldId.setTipo(plugin.getOldIdPlugin().getTipo());
  2219.             }
  2220.             this.serviceManagerPlugins.getPluginService().update(oldId, plugin);
  2221.         }catch(Exception e) {
  2222.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2223.         }
  2224.     }
  2225.    
  2226.     public void deletePluginClasse(Plugin plugin) throws DriverConfigurazioneException {
  2227.         try {
  2228.             this.serviceManagerPlugins.getPluginService().delete(plugin);
  2229.         }catch(Exception e) {
  2230.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2231.         }
  2232.     }
  2233.    
  2234.     public boolean isPluginClasseInUso(IdPlugin idPlugin, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverConfigurazioneException {
  2235.         Connection con = null;
  2236.         try{
  2237.             con = this.driverConfigurazione.getConnection("archive.isPluginClasseInUso");
  2238.             return DBOggettiInUsoUtils.isPluginInUso(con, this.driverRegistroServizi.getTipoDB(),
  2239.                     idPlugin.getClassName(), idPlugin.getLabel(), idPlugin.getTipoPlugin(), idPlugin.getTipo(),
  2240.                     whereIsInUso, normalizeObjectIds);
  2241.         }
  2242.         catch(Exception e){
  2243.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2244.         }
  2245.         finally{
  2246.             try{
  2247.                 this.driverConfigurazione.releaseConnection(con);
  2248.             }catch(Exception eClose){
  2249.                 // close
  2250.             }
  2251.         }
  2252.     }
  2253.    
  2254.    
  2255.    
  2256.    
  2257.    
  2258.    
  2259.    
  2260.    
  2261.    
  2262.     // --- Plugin Archivio ---
  2263.    
  2264.     public List<String> getAllIdPluginArchivio() throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  2265.         try {
  2266.             RegistroPlugins registroPlugins = this.driverConfigurazione.getRegistroPlugins();
  2267.             List<String> l = new ArrayList<>();
  2268.             if(registroPlugins!=null && registroPlugins.sizePluginList()>0) {
  2269.                 for (RegistroPlugin registroPlugin : registroPlugins.getPluginList()) {
  2270.                     l.add(registroPlugin.getNome());
  2271.                 }
  2272.             }
  2273.             if(l==null || l.isEmpty()) {
  2274.                 throw new DriverConfigurazioneNotFound();
  2275.             }
  2276.             return l;
  2277.         }catch(DriverConfigurazioneNotFound e) {
  2278.             throw e;
  2279.         }catch(Exception e) {
  2280.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2281.         }
  2282.     }
  2283.    
  2284.     public RegistroPlugin getPluginArchivio(String nome) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  2285.         try {
  2286.             RegistroPlugins registroPlugins = this.driverConfigurazione.getRegistroPlugins();
  2287.             RegistroPlugin rp = null;
  2288.             if(registroPlugins!=null && registroPlugins.sizePluginList()>0) {
  2289.                 for (RegistroPlugin registroPlugin : registroPlugins.getPluginList()) {
  2290.                     if(nome.equals(registroPlugin.getNome())) {
  2291.                         rp = registroPlugin;
  2292.                         break;
  2293.                     }
  2294.                 }
  2295.             }
  2296.             if(rp==null) {
  2297.                 throw new DriverConfigurazioneNotFound();
  2298.             }
  2299.             return rp;
  2300.         }catch(DriverConfigurazioneNotFound e) {
  2301.             throw e;
  2302.         }catch(Exception e) {
  2303.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2304.         }
  2305.     }
  2306.    
  2307.     public boolean existsPluginArchivio(String nome) throws DriverConfigurazioneException {
  2308.         try {
  2309.             RegistroPlugin rp = getPluginArchivio(nome);
  2310.             return rp!=null;
  2311.         }catch(DriverConfigurazioneNotFound e) {
  2312.             return false;
  2313.         }catch(Exception e) {
  2314.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2315.         }
  2316.     }

  2317.     protected void updatePosizioneBeforeCreate(RegistroPlugin rp) throws DriverConfigurazioneException{
  2318.         try {
  2319.             // calcolo prossima posizione
  2320.             int posizione = this.driverConfigurazione.getMaxPosizioneRegistroPlugin() + 1;
  2321.             rp.setPosizione(posizione);
  2322.         }catch(Exception e) {
  2323.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2324.         }
  2325.     }
  2326.     protected void updateDate(RegistroPlugin rp) throws DriverConfigurazioneException{
  2327.         try {
  2328.             // aggiorno tutte le date
  2329.             rp.setData(DateManager.getDate());
  2330.             if(rp.sizeArchivioList()>0) {
  2331.                 for (RegistroPluginArchivio rpa : rp.getArchivioList()) {
  2332.                     rpa.setData(DateManager.getDate());
  2333.                 }
  2334.             }
  2335.         }catch(Exception e) {
  2336.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2337.         }
  2338.     }
  2339.     public void createPluginArchivio(RegistroPlugin rp) throws DriverConfigurazioneException{
  2340.         updatePosizioneBeforeCreate(rp);
  2341.         updateDate(rp);
  2342.         try {
  2343.             this.driverConfigurazione.createRegistroPlugin(rp);
  2344.         }catch(Exception e) {
  2345.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2346.         }
  2347.     }
  2348.     public void updatePluginArchivio(RegistroPlugin rp) throws DriverConfigurazioneException{
  2349.         updateDate(rp);
  2350.         try {
  2351.             this.driverConfigurazione.updateRegistroPlugin(rp);
  2352.         }catch(Exception e) {
  2353.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2354.         }
  2355.     }
  2356.     public void deletePluginArchivio(RegistroPlugin rp) throws DriverConfigurazioneException{
  2357.         try {
  2358.             this.driverConfigurazione.deleteRegistroPlugin(rp);
  2359.         }catch(Exception e) {
  2360.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2361.         }
  2362.     }
  2363.    
  2364.     public boolean isPluginArchivioInUso(String nome, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverRegistroServiziException {
  2365.         return false;
  2366.     }
  2367.    
  2368.    
  2369.    
  2370.    
  2371.    
  2372.    
  2373.     // --- Url Invocazione Regole ---
  2374.    
  2375.     public List<String> getAllIdUrlInvocazioneRegola() throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  2376.         try {
  2377.             ConfigurazioneUrlInvocazione configurazioneUrlInvocazione = this.driverConfigurazione.getConfigurazioneGenerale().getUrlInvocazione();
  2378.             List<String> l = new ArrayList<>();
  2379.             if(configurazioneUrlInvocazione!=null && configurazioneUrlInvocazione.sizeRegolaList()>0) {
  2380.                 for (ConfigurazioneUrlInvocazioneRegola regola : configurazioneUrlInvocazione.getRegolaList()) {
  2381.                     l.add(regola.getNome());
  2382.                 }
  2383.             }
  2384.             if(l==null || l.isEmpty()) {
  2385.                 throw new DriverConfigurazioneNotFound();
  2386.             }
  2387.             return l;
  2388.         }catch(DriverConfigurazioneNotFound e) {
  2389.             throw e;
  2390.         }catch(Exception e) {
  2391.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2392.         }
  2393.     }
  2394.    
  2395.     public ConfigurazioneUrlInvocazioneRegola getUrlInvocazioneRegola(String nome) throws DriverConfigurazioneException, DriverConfigurazioneNotFound {
  2396.         try {
  2397.             return this.driverConfigurazione.getUrlInvocazioneRegola(nome);
  2398.         }catch(DriverConfigurazioneNotFound e) {
  2399.             throw e;
  2400.         }catch(Exception e) {
  2401.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2402.         }
  2403.     }
  2404.    
  2405.     public boolean existsUrlInvocazioneRegola(String nome) throws DriverConfigurazioneException {
  2406.         try {
  2407.             return this.driverConfigurazione.existsUrlInvocazioneRegola(nome);
  2408.         }catch(DriverConfigurazioneNotFound e) {
  2409.             return false;
  2410.         }catch(Exception e) {
  2411.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2412.         }
  2413.     }

  2414.     protected void updatePosizioneBeforeCreate(ConfigurazioneUrlInvocazioneRegola regola) throws DriverConfigurazioneException{
  2415.         try {
  2416.             // calcolo prossima posizione
  2417.             int posizione = ConfigurazionePdDUtils.getProssimaPosizioneUrlInvocazioneRegola(this.driverConfigurazione.getConfigurazioneGenerale());
  2418.             regola.setPosizione(posizione);
  2419.         }catch(Exception e) {
  2420.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2421.         }
  2422.     }
  2423.     public void createUrlInvocazioneRegola(ConfigurazioneUrlInvocazioneRegola regola) throws DriverConfigurazioneException{
  2424.         updatePosizioneBeforeCreate(regola);
  2425.         try {
  2426.             this.driverConfigurazione.createUrlInvocazioneRegola(regola);
  2427.         }catch(Exception e) {
  2428.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2429.         }
  2430.     }
  2431.     public void updateUrlInvocazioneRegola(ConfigurazioneUrlInvocazioneRegola regola) throws DriverConfigurazioneException{
  2432.         try {
  2433.             this.driverConfigurazione.updateUrlInvocazioneRegola(regola);
  2434.         }catch(Exception e) {
  2435.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2436.         }
  2437.     }
  2438.     public void deleteUrlInvocazioneRegola(ConfigurazioneUrlInvocazioneRegola regola) throws DriverConfigurazioneException{
  2439.         try {
  2440.             this.driverConfigurazione.deleteUrlInvocazioneRegola(regola);
  2441.         }catch(Exception e) {
  2442.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2443.         }
  2444.     }
  2445.    
  2446.     public boolean isUrlInvocazioneRegolaInUso(String nome, Map<ErrorsHandlerCostant, List<String>> whereIsInUso, boolean normalizeObjectIds) throws DriverRegistroServiziException {
  2447.         return false;
  2448.     }
  2449.    
  2450.    
  2451.    
  2452.    
  2453.    
  2454.     // --- Configurazione (Url Invocazione) ---
  2455.    
  2456.     public void updateConfigurazione_UrlInvocazione(ConfigurazioneUrlInvocazione configurazione) throws DriverConfigurazioneException{
  2457.         try {
  2458.             Configurazione config = this.driverConfigurazione.getConfigurazioneGenerale();
  2459.             if(config.getUrlInvocazione()==null) {
  2460.                 config.setUrlInvocazione(configurazione);
  2461.             }
  2462.             else {
  2463.                 config.getUrlInvocazione().setBaseUrl(configurazione.getBaseUrl());
  2464.                 config.getUrlInvocazione().setBaseUrlFruizione(configurazione.getBaseUrlFruizione());
  2465.             }
  2466.             this.driverConfigurazione.updateConfigurazione(config);
  2467.         }catch(Exception e) {
  2468.             throw new DriverConfigurazioneException(e.getMessage(),e);
  2469.         }
  2470.     }
  2471.    
  2472.    
  2473.    
  2474.    
  2475.    
  2476.    
  2477.     // --- ConfigurazionePdD ---
  2478.    
  2479.     public void updateConfigurazione(Configurazione configurazione) throws DriverConfigurazioneException{
  2480.         if(configurazione.getRoutingTable()!=null){
  2481.             this.driverConfigurazione.updateRoutingTable(configurazione.getRoutingTable());
  2482.         }
  2483.         if(configurazione.getAccessoRegistro()!=null){
  2484.             this.driverConfigurazione.updateAccessoRegistro(configurazione.getAccessoRegistro());
  2485.         }
  2486.         if(configurazione.getGestioneErrore()!=null){
  2487.             if(configurazione.getGestioneErrore().getComponenteCooperazione()!=null){
  2488.                 this.driverConfigurazione.updateGestioneErroreComponenteCooperazione(configurazione.getGestioneErrore().getComponenteCooperazione());
  2489.             }
  2490.             if(configurazione.getGestioneErrore().getComponenteIntegrazione()!=null){
  2491.                 this.driverConfigurazione.updateGestioneErroreComponenteIntegrazione(configurazione.getGestioneErrore().getComponenteIntegrazione());
  2492.             }
  2493.         }
  2494.         if(configurazione.getStatoServiziPdd()!=null){
  2495.             this.driverConfigurazione.updateStatoServiziPdD(configurazione.getStatoServiziPdd());
  2496.         }
  2497.         if(configurazione.getSystemProperties()!=null){
  2498.             this.driverConfigurazione.updateSystemPropertiesPdD(configurazione.getSystemProperties());
  2499.         }
  2500.         this.driverConfigurazione.updateConfigurazione(configurazione);
  2501.     }
  2502.     public void deleteConfigurazione(Configurazione configurazione) throws DriverConfigurazioneException{
  2503.         this.driverConfigurazione.deleteConfigurazione(configurazione);
  2504.     }

  2505.     public Configurazione getConfigurazione() throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  2506.         Configurazione configurazione = this.driverConfigurazione.getConfigurazioneGenerale();
  2507.         configurazione.setRoutingTable(this.driverConfigurazione.getRoutingTable());
  2508.         configurazione.setAccessoRegistro(this.driverConfigurazione.getAccessoRegistro());
  2509.         try{
  2510.             configurazione.setAccessoConfigurazione(this.driverConfigurazione.getAccessoConfigurazione());
  2511.         }catch(DriverConfigurazioneNotFound notFound){}
  2512.         try{
  2513.             configurazione.setAccessoDatiAutorizzazione(this.driverConfigurazione.getAccessoDatiAutorizzazione());
  2514.         }catch(DriverConfigurazioneNotFound notFound){}
  2515.         GestioneErrore gestioneErroreCooperazione = null;
  2516.         GestioneErrore gestioneErroreIntegrazione = null;
  2517.         try{
  2518.             gestioneErroreCooperazione = this.driverConfigurazione.getGestioneErroreComponenteCooperazione();
  2519.         }catch(DriverConfigurazioneNotFound notFound){}
  2520.         try{
  2521.             gestioneErroreIntegrazione = this.driverConfigurazione.getGestioneErroreComponenteIntegrazione();
  2522.         }catch(DriverConfigurazioneNotFound notFound){}
  2523.         if(gestioneErroreCooperazione!=null || gestioneErroreIntegrazione!=null){
  2524.             if(configurazione.getGestioneErrore()==null){
  2525.                 configurazione.setGestioneErrore(new ConfigurazioneGestioneErrore());
  2526.             }
  2527.             if(gestioneErroreCooperazione!=null){
  2528.                 configurazione.getGestioneErrore().setComponenteCooperazione(gestioneErroreCooperazione);
  2529.             }
  2530.             if(gestioneErroreIntegrazione!=null){
  2531.                 configurazione.getGestioneErrore().setComponenteIntegrazione(gestioneErroreIntegrazione);
  2532.             }
  2533.         }
  2534.         try{
  2535.             configurazione.setStatoServiziPdd(this.driverConfigurazione.getStatoServiziPdD());
  2536.         }catch(DriverConfigurazioneNotFound notFound){}
  2537.         try{
  2538.             configurazione.setSystemProperties(this.driverConfigurazione.getSystemPropertiesPdD());
  2539.         }catch(DriverConfigurazioneNotFound notFound){}
  2540.         try{
  2541.             configurazione.setGenericPropertiesList(this.driverConfigurazione.getGenericProperties());
  2542.         }catch(DriverConfigurazioneNotFound notFound){}
  2543.        
  2544.         return configurazione;
  2545.     }
  2546. }