ArchiveEngine.java

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


  20. package org.openspcoop2.web.ctrlstat.servlet.archivi;

  21. import java.text.MessageFormat;
  22. import java.util.ArrayList;
  23. import java.util.List;

  24. import org.openspcoop2.core.allarmi.Allarme;
  25. import org.openspcoop2.core.allarmi.AllarmeHistory;
  26. import org.openspcoop2.core.config.Configurazione;
  27. import org.openspcoop2.core.config.ConfigurazioneUrlInvocazione;
  28. import org.openspcoop2.core.config.ConfigurazioneUrlInvocazioneRegola;
  29. import org.openspcoop2.core.config.GenericProperties;
  30. import org.openspcoop2.core.config.PortaApplicativa;
  31. import org.openspcoop2.core.config.PortaDelegata;
  32. import org.openspcoop2.core.config.RegistroPlugin;
  33. import org.openspcoop2.core.config.RegistroPluginArchivio;
  34. import org.openspcoop2.core.config.ServizioApplicativo;
  35. import org.openspcoop2.core.config.driver.DriverConfigurazioneException;
  36. import org.openspcoop2.core.config.driver.db.DriverConfigurazioneDB;
  37. import org.openspcoop2.core.controllo_traffico.AttivazionePolicy;
  38. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  39. import org.openspcoop2.core.controllo_traffico.ConfigurazionePolicy;
  40. import org.openspcoop2.core.id.IDPortaApplicativa;
  41. import org.openspcoop2.core.id.IDPortaDelegata;
  42. import org.openspcoop2.core.id.IDServizio;
  43. import org.openspcoop2.core.id.IDSoggetto;
  44. import org.openspcoop2.core.mapping.MappingErogazionePortaApplicativa;
  45. import org.openspcoop2.core.mapping.MappingFruizionePortaDelegata;
  46. import org.openspcoop2.core.plugins.Plugin;
  47. import org.openspcoop2.core.registry.AccordoCooperazione;
  48. import org.openspcoop2.core.registry.AccordoServizioParteComune;
  49. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  50. import org.openspcoop2.core.registry.Gruppo;
  51. import org.openspcoop2.core.registry.PortaDominio;
  52. import org.openspcoop2.core.registry.Ruolo;
  53. import org.openspcoop2.core.registry.Scope;
  54. import org.openspcoop2.core.registry.Soggetto;
  55. import org.openspcoop2.core.registry.driver.DriverRegistroServiziException;
  56. import org.openspcoop2.core.registry.driver.db.DriverRegistroServiziDB;
  57. import org.openspcoop2.monitor.engine.alarm.AlarmEngineConfig;
  58. import org.openspcoop2.monitor.engine.alarm.utils.AllarmiUtils;
  59. import org.openspcoop2.monitor.engine.alarm.wrapper.ConfigurazioneAllarmeBean;
  60. import org.openspcoop2.protocol.sdk.archive.Archive;
  61. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCore;
  62. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCostanti;
  63. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneUtilities;
  64. import org.slf4j.Logger;

  65. /**
  66.  * ArchiveEngine
  67.  *
  68.  * @author Poli Andrea (apoli@link.it)
  69.  * @author $Author$
  70.  * @version $Rev$, $Date$
  71.  */
  72. public class ArchiveEngine extends org.openspcoop2.protocol.engine.archive.AbstractArchiveEngine {

  73.     private ArchiviCore archiviCore;
  74.     private boolean smista;
  75.     private String userLogin;
  76.    
  77.     private AlarmEngineConfig alarmEngineConfig;
  78.     private ConfigurazioneCore allarmiConfigurazioneCore;
  79.    
  80.     public ArchiveEngine(DriverRegistroServiziDB driverRegistroServizi,
  81.             DriverConfigurazioneDB driverConfigurazione,
  82.             org.openspcoop2.core.plugins.dao.jdbc.JDBCServiceManager serviceManagerPlugins,
  83.             org.openspcoop2.core.controllo_traffico.dao.jdbc.JDBCServiceManager serviceManagerControlloTraffico,
  84.             org.openspcoop2.core.allarmi.dao.jdbc.JDBCServiceManager serviceManagerAllarmi,
  85.             ArchiviCore archiviCore,boolean smista,String userLogin) throws Exception {
  86.         super(driverRegistroServizi, driverConfigurazione,
  87.                 serviceManagerPlugins,
  88.                 serviceManagerControlloTraffico,
  89.                 serviceManagerAllarmi);
  90.         this.archiviCore = archiviCore;
  91.         this.smista = smista;
  92.         this.userLogin = userLogin;
  93.         if(this.archiviCore.isConfigurazioneAllarmiEnabled()) {
  94.             this.allarmiConfigurazioneCore = new ConfigurazioneCore(archiviCore);
  95.             this.alarmEngineConfig = this.allarmiConfigurazioneCore.getAllarmiConfig();
  96.         }
  97.     }
  98.    
  99.     // --- Users ---
  100.    
  101.     @Override
  102.     public boolean isVisioneOggettiGlobale(String userLogin) {
  103.         return this.archiviCore.isVisioneOggettiGlobale(userLogin);
  104.     }

  105.    
  106.     // --- PDD ---
  107.    
  108.     @Override
  109.     public void createPortaDominio(PortaDominio pdd)
  110.             throws DriverRegistroServiziException {
  111.         try{
  112.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, pdd);
  113.         }catch(Exception e){
  114.             throw new DriverRegistroServiziException(e.getMessage(),e);
  115.         }
  116.     }
  117.     @Override
  118.     public void updatePortaDominio(PortaDominio pdd)
  119.             throws DriverRegistroServiziException {
  120.         try{
  121.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, pdd);
  122.         }catch(Exception e){
  123.             throw new DriverRegistroServiziException(e.getMessage(),e);
  124.         }
  125.     }
  126.     @Override
  127.     public void deletePortaDominio(PortaDominio pdd)
  128.             throws DriverRegistroServiziException {
  129.         try{
  130.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, pdd);
  131.         }catch(Exception e){
  132.             throw new DriverRegistroServiziException(e.getMessage(),e);
  133.         }
  134.     }
  135.    
  136.    
  137.    
  138.     // --- GRUPPI ---
  139.    
  140.     @Override
  141.     public void createGruppo(Gruppo gruppo) throws DriverRegistroServiziException {
  142.         try{
  143.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, gruppo);
  144.         }catch(Exception e){
  145.             throw new DriverRegistroServiziException(e.getMessage(),e);
  146.         }
  147.     }
  148.    
  149.     @Override
  150.     public void updateGruppo(Gruppo gruppo) throws DriverRegistroServiziException {
  151.         try{
  152.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, gruppo);
  153.         }catch(Exception e){
  154.             throw new DriverRegistroServiziException(e.getMessage(),e);
  155.         }
  156.     }
  157.    
  158.     @Override
  159.     public void deleteGruppo(Gruppo gruppo) throws DriverRegistroServiziException {
  160.         try{
  161.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, gruppo);
  162.         }catch(Exception e){
  163.             throw new DriverRegistroServiziException(e.getMessage(),e);
  164.         }
  165.     }
  166.    
  167.    
  168.    
  169.    
  170.     // --- RUOLI ---
  171.    
  172.     @Override
  173.     public void createRuolo(Ruolo ruolo) throws DriverRegistroServiziException {
  174.         try{
  175.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, ruolo);
  176.         }catch(Exception e){
  177.             throw new DriverRegistroServiziException(e.getMessage(),e);
  178.         }
  179.     }
  180.    
  181.     @Override
  182.     public void updateRuolo(Ruolo ruolo) throws DriverRegistroServiziException {
  183.         try{
  184.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, ruolo);
  185.         }catch(Exception e){
  186.             throw new DriverRegistroServiziException(e.getMessage(),e);
  187.         }
  188.     }
  189.    
  190.     @Override
  191.     public void deleteRuolo(Ruolo ruolo) throws DriverRegistroServiziException {
  192.         try{
  193.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, ruolo);
  194.         }catch(Exception e){
  195.             throw new DriverRegistroServiziException(e.getMessage(),e);
  196.         }
  197.     }
  198.    
  199.    
  200.    
  201.     // --- SCOPE ---
  202.    
  203.     @Override
  204.     public void createScope(Scope scope) throws DriverRegistroServiziException {
  205.         try{
  206.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, scope);
  207.         }catch(Exception e){
  208.             throw new DriverRegistroServiziException(e.getMessage(),e);
  209.         }
  210.     }
  211.    
  212.     @Override
  213.     public void updateScope(Scope scope) throws DriverRegistroServiziException {
  214.         try{
  215.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, scope);
  216.         }catch(Exception e){
  217.             throw new DriverRegistroServiziException(e.getMessage(),e);
  218.         }
  219.     }
  220.    
  221.     @Override
  222.     public void deleteScope(Scope scope) throws DriverRegistroServiziException {
  223.         try{
  224.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, scope);
  225.         }catch(Exception e){
  226.             throw new DriverRegistroServiziException(e.getMessage(),e);
  227.         }
  228.     }
  229.    
  230.    
  231.     // --- Soggetti Registro ---
  232.    
  233.     @Override
  234.     public void createSoggettoRegistro(Soggetto soggetto)
  235.             throws DriverRegistroServiziException {
  236.         try{
  237.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, soggetto);
  238.         }catch(Exception e){
  239.             throw new DriverRegistroServiziException(e.getMessage(),e);
  240.         }
  241.     }
  242.     @Override
  243.     public void updateSoggettoRegistro(Soggetto soggetto)
  244.             throws DriverRegistroServiziException {
  245.         try{
  246.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, soggetto);
  247.         }catch(Exception e){
  248.             throw new DriverRegistroServiziException(e.getMessage(),e);
  249.         }
  250.     }
  251.     @Override
  252.     public void deleteSoggettoRegistro(Soggetto soggetto)
  253.             throws DriverRegistroServiziException {
  254.         try{
  255.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, soggetto);
  256.         }catch(Exception e){
  257.             throw new DriverRegistroServiziException(e.getMessage(),e);
  258.         }
  259.     }

  260.    
  261.     // --- Soggetti Configurazione ---
  262.    
  263.     @Override
  264.     public void createSoggettoConfigurazione(
  265.             org.openspcoop2.core.config.Soggetto soggetto)
  266.             throws DriverConfigurazioneException {
  267.         try{
  268.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, soggetto);
  269.         }catch(Exception e){
  270.             throw new DriverConfigurazioneException(e.getMessage(),e);
  271.         }
  272.     }
  273.     @Override
  274.     public void updateSoggettoConfigurazione(
  275.             org.openspcoop2.core.config.Soggetto soggetto)
  276.             throws DriverConfigurazioneException {
  277.         try{
  278.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, soggetto);
  279.         }catch(Exception e){
  280.             throw new DriverConfigurazioneException(e.getMessage(),e);
  281.         }
  282.     }
  283.     @Override
  284.     public void deleteSoggettoConfigurazione(
  285.             org.openspcoop2.core.config.Soggetto soggetto)
  286.             throws DriverConfigurazioneException {
  287.         try{
  288.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, soggetto);
  289.         }catch(Exception e){
  290.             throw new DriverConfigurazioneException(e.getMessage(),e);
  291.         }
  292.     }

  293.    
  294.     // --- Servizi Applicativi ---
  295.    
  296.     @Override
  297.     public void createServizioApplicativo(
  298.             ServizioApplicativo servizioApplicativo)
  299.             throws DriverConfigurazioneException {
  300.         try{
  301.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, servizioApplicativo);
  302.         }catch(Exception e){
  303.             throw new DriverConfigurazioneException(e.getMessage(),e);
  304.         }
  305.     }
  306.     @Override
  307.     public void updateServizioApplicativo(
  308.             ServizioApplicativo servizioApplicativo)
  309.             throws DriverConfigurazioneException {
  310.         try{
  311.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, servizioApplicativo);
  312.         }catch(Exception e){
  313.             throw new DriverConfigurazioneException(e.getMessage(),e);
  314.         }
  315.     }
  316.     @Override
  317.     public void deleteServizioApplicativo(
  318.             ServizioApplicativo servizioApplicativo)
  319.             throws DriverConfigurazioneException {
  320.         try{
  321.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, servizioApplicativo);
  322.         }catch(Exception e){
  323.             throw new DriverConfigurazioneException(e.getMessage(),e);
  324.         }
  325.     }

  326.    
  327.     // --- Accordi di Cooperazione ---

  328.     @Override
  329.     public void createAccordoCooperazione(
  330.             AccordoCooperazione accordoCooperazione)
  331.             throws DriverRegistroServiziException {
  332.         try{
  333.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, accordoCooperazione);
  334.         }catch(Exception e){
  335.             throw new DriverRegistroServiziException(e.getMessage(),e);
  336.         }
  337.     }
  338.     @Override
  339.     public void updateAccordoCooperazione(
  340.             AccordoCooperazione accordoCooperazione)
  341.             throws DriverRegistroServiziException {
  342.         try{
  343.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, accordoCooperazione);
  344.         }catch(Exception e){
  345.             throw new DriverRegistroServiziException(e.getMessage(),e);
  346.         }
  347.     }
  348.     @Override
  349.     public void deleteAccordoCooperazione(
  350.             AccordoCooperazione accordoCooperazione)
  351.             throws DriverRegistroServiziException {
  352.         try{
  353.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, accordoCooperazione);
  354.         }catch(Exception e){
  355.             throw new DriverRegistroServiziException(e.getMessage(),e);
  356.         }
  357.     }

  358.    
  359.     // --- Accordi di Servizio Parte Comune ---
  360.    
  361.     @Override
  362.     public void createAccordoServizioParteComune(
  363.             AccordoServizioParteComune accordoServizioParteComune)
  364.             throws DriverRegistroServiziException {
  365.         try{
  366.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, accordoServizioParteComune);
  367.         }catch(Exception e){
  368.             throw new DriverRegistroServiziException(e.getMessage(),e);
  369.         }
  370.     }
  371.     @Override
  372.     public void updateAccordoServizioParteComune(
  373.             AccordoServizioParteComune accordoServizioParteComune)
  374.             throws DriverRegistroServiziException {
  375.         try{
  376.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, accordoServizioParteComune);
  377.         }catch(Exception e){
  378.             throw new DriverRegistroServiziException(e.getMessage(),e);
  379.         }
  380.     }
  381.     @Override
  382.     public void deleteAccordoServizioParteComune(
  383.             AccordoServizioParteComune accordoServizioParteComune)
  384.             throws DriverRegistroServiziException {
  385.         try{
  386.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, accordoServizioParteComune);
  387.         }catch(Exception e){
  388.             throw new DriverRegistroServiziException(e.getMessage(),e);
  389.         }
  390.     }

  391.    
  392.     // --- Accordi di Servizio Parte Specifica ---
  393.    
  394.     @Override
  395.     public void createAccordoServizioParteSpecifica(
  396.             AccordoServizioParteSpecifica accordoServizioParteSpecifica)
  397.             throws DriverRegistroServiziException {
  398.         try{
  399.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, accordoServizioParteSpecifica);
  400.         }catch(Exception e){
  401.             throw new DriverRegistroServiziException(e.getMessage(),e);
  402.         }
  403.     }
  404.     @Override
  405.     public void updateAccordoServizioParteSpecifica(
  406.             AccordoServizioParteSpecifica accordoServizioParteSpecifica)
  407.             throws DriverRegistroServiziException {
  408.         try{
  409.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, accordoServizioParteSpecifica);
  410.         }catch(Exception e){
  411.             throw new DriverRegistroServiziException(e.getMessage(),e);
  412.         }
  413.     }
  414.     @Override
  415.     public void deleteAccordoServizioParteSpecifica(
  416.             AccordoServizioParteSpecifica accordoServizioParteSpecifica)
  417.             throws DriverRegistroServiziException {
  418.         try{
  419.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, accordoServizioParteSpecifica);
  420.         }catch(Exception e){
  421.             throw new DriverRegistroServiziException(e.getMessage(),e);
  422.         }
  423.     }
  424.    
  425.    
  426.    
  427.     // --- Mapping Erogazione ---
  428.    
  429.     @Override  
  430.     public void createMappingErogazione(String nome, String descrizione, boolean isDefault, IDServizio idServizio, IDPortaApplicativa idPortaApplicativa) throws DriverRegistroServiziException {
  431.         try{
  432.             MappingErogazionePortaApplicativa mapping = new MappingErogazionePortaApplicativa();
  433.             mapping.setIdServizio(idServizio);
  434.             mapping.setIdPortaApplicativa(idPortaApplicativa);
  435.             mapping.setNome(nome);
  436.             mapping.setDescrizione(descrizione);
  437.             mapping.setDefault(isDefault);
  438.            
  439.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, mapping);
  440.         }
  441.         catch(Exception e){
  442.             throw new DriverRegistroServiziException(e.getMessage(),e);
  443.         }
  444.     }
  445.    
  446.     @Override
  447.     public void deleteMappingErogazione(IDServizio idServizio, IDPortaApplicativa idPortaApplicativa) throws DriverRegistroServiziException {
  448.         try{
  449.             MappingErogazionePortaApplicativa mapping = new MappingErogazionePortaApplicativa();
  450.             mapping.setIdServizio(idServizio);
  451.             mapping.setIdPortaApplicativa(idPortaApplicativa);
  452.            
  453.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, mapping);
  454.         }
  455.         catch(Exception e){
  456.             throw new DriverRegistroServiziException(e.getMessage(),e);
  457.         }
  458.     }
  459.    
  460.    
  461.    
  462.    
  463.    
  464.     // --- Mapping Fruizione ---
  465.    
  466.     @Override
  467.     public void createMappingFruizione(String nome, String descrizione, boolean isDefault, IDServizio idServizio, IDSoggetto idFruitore, IDPortaDelegata idPortaDelegata) throws DriverRegistroServiziException {
  468.         try{
  469.             MappingFruizionePortaDelegata mapping = new MappingFruizionePortaDelegata();
  470.             mapping.setIdFruitore(idFruitore);
  471.             mapping.setIdServizio(idServizio);
  472.             mapping.setIdPortaDelegata(idPortaDelegata);
  473.             mapping.setNome(nome);
  474.             mapping.setDescrizione(descrizione);
  475.             mapping.setDefault(isDefault);
  476.            
  477.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, mapping);
  478.         }
  479.         catch(Exception e){
  480.             throw new DriverRegistroServiziException(e.getMessage(),e);
  481.         }
  482.     }
  483.    
  484.     @Override
  485.     public void deleteMappingFruizione(IDServizio idServizio, IDSoggetto idFruitore, IDPortaDelegata idPortaDelegata) throws DriverRegistroServiziException {
  486.         try{
  487.             MappingFruizionePortaDelegata mapping = new MappingFruizionePortaDelegata();
  488.             mapping.setIdFruitore(idFruitore);
  489.             mapping.setIdServizio(idServizio);
  490.             mapping.setIdPortaDelegata(idPortaDelegata);
  491.            
  492.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, mapping);
  493.         }
  494.         catch(Exception e){
  495.             throw new DriverRegistroServiziException(e.getMessage(),e);
  496.         }
  497.     }
  498.    
  499.    
  500.    


  501.    
  502.     // --- Porte Delegate ---
  503.    
  504.     @Override
  505.     public void createPortaDelegata(PortaDelegata portaDelegata)
  506.             throws DriverConfigurazioneException {
  507.         try{
  508.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, portaDelegata);
  509.         }catch(Exception e){
  510.             throw new DriverConfigurazioneException(e.getMessage(),e);
  511.         }
  512.     }
  513.     @Override
  514.     public void updatePortaDelegata(PortaDelegata portaDelegata)
  515.             throws DriverConfigurazioneException {
  516.         try{
  517.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, portaDelegata);
  518.         }catch(Exception e){
  519.             throw new DriverConfigurazioneException(e.getMessage(),e);
  520.         }
  521.     }
  522.     @Override
  523.     public void deletePortaDelegata(PortaDelegata portaDelegata)
  524.             throws DriverConfigurazioneException {
  525.         try{
  526.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, portaDelegata);
  527.         }catch(Exception e){
  528.             throw new DriverConfigurazioneException(e.getMessage(),e);
  529.         }
  530.     }

  531.    
  532.     // --- Porte Applicative ---
  533.    
  534.     @Override
  535.     public void createPortaApplicativa(PortaApplicativa portaApplicativa)
  536.             throws DriverConfigurazioneException {
  537.         try{
  538.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, portaApplicativa);
  539.         }catch(Exception e){
  540.             throw new DriverConfigurazioneException(e.getMessage(),e);
  541.         }
  542.     }

  543.     @Override
  544.     public void updatePortaApplicativa(PortaApplicativa portaApplicativa)
  545.             throws DriverConfigurazioneException {
  546.         try{
  547.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, portaApplicativa);
  548.         }catch(Exception e){
  549.             throw new DriverConfigurazioneException(e.getMessage(),e);
  550.         }
  551.     }
  552.     @Override
  553.     public void deletePortaApplicativa(PortaApplicativa portaApplicativa)
  554.             throws DriverConfigurazioneException {
  555.         try{
  556.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, portaApplicativa);
  557.         }catch(Exception e){
  558.             throw new DriverConfigurazioneException(e.getMessage(),e);
  559.         }
  560.     }


  561.     // --- Controllo Traffico (Configurazione) ---
  562.    
  563.     @Override
  564.     public void updateControlloTraffico_configurazione(ConfigurazioneGenerale configurazione) throws DriverConfigurazioneException{
  565.         try{
  566.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, configurazione);
  567.         }catch(Exception e){
  568.             throw new DriverConfigurazioneException(e.getMessage(),e);
  569.         }
  570.     }
  571.    
  572.     @Override
  573.     public void deleteControlloTraffico_Configurazione(ConfigurazioneGenerale configurazione) throws DriverConfigurazioneException{
  574.         try{
  575.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, configurazione);
  576.         }catch(Exception e){
  577.             throw new DriverConfigurazioneException(e.getMessage(),e);
  578.         }
  579.     }
  580.    
  581.    
  582.     // --- Controllo Traffico (ConfigurazionePolicy) ---
  583.    
  584.     @Override
  585.     public void createControlloTraffico_configurationPolicy(ConfigurazionePolicy policy) throws DriverConfigurazioneException {
  586.         try{
  587.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, policy);
  588.         }catch(Exception e){
  589.             throw new DriverConfigurazioneException(e.getMessage(),e);
  590.         }
  591.     }
  592.    
  593.     @Override
  594.     public void updateControlloTraffico_configurationPolicy(ConfigurazionePolicy policy) throws DriverConfigurazioneException {
  595.         try{
  596.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, policy);
  597.         }catch(Exception e){
  598.             throw new DriverConfigurazioneException(e.getMessage(),e);
  599.         }
  600.     }
  601.    
  602.     @Override
  603.     public void deleteControlloTraffico_configurationPolicy(ConfigurazionePolicy policy) throws DriverConfigurazioneException {
  604.         try{
  605.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, policy);
  606.         }catch(Exception e){
  607.             throw new DriverConfigurazioneException(e.getMessage(),e);
  608.         }
  609.     }
  610.    
  611.    
  612.     // --- Controllo Traffico (AttivazionePolicy) ---
  613.    
  614.     @Override
  615.     public void createControlloTraffico_activePolicy(AttivazionePolicy policy, Logger log) throws DriverConfigurazioneException {
  616.         updatePosizioneBeforeCreate(policy, log);      
  617.         try{
  618.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, policy);
  619.         }catch(Exception e){
  620.             throw new DriverConfigurazioneException(e.getMessage(),e);
  621.         }
  622.     }
  623.    
  624.     @Override
  625.     public void updateControlloTraffico_activePolicy(AttivazionePolicy policy) throws DriverConfigurazioneException {
  626.         try{
  627.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, policy);
  628.         }catch(Exception e){
  629.             throw new DriverConfigurazioneException(e.getMessage(),e);
  630.         }
  631.     }
  632.    
  633.     @Override
  634.     public void deleteControlloTraffico_activePolicy(AttivazionePolicy policy) throws DriverConfigurazioneException {
  635.         try{
  636.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, policy);
  637.         }catch(Exception e){
  638.             throw new DriverConfigurazioneException(e.getMessage(),e);
  639.         }
  640.     }
  641.    
  642.    
  643.    
  644.    
  645.     // --- Allarmi ---
  646.    
  647.     @Override
  648.     public void createAllarme(Allarme allarme, Logger log) throws DriverConfigurazioneException {
  649.         try{
  650.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, allarme);
  651.         }catch(Exception e){
  652.             throw new DriverConfigurazioneException(e.getMessage(),e);
  653.         }
  654.        
  655.         /* ******** GESTIONE AVVIO THREAD NEL CASO DI ATTIVO *************** */
  656.         try {
  657.             ConfigurazioneAllarmeBean allarmeWrap = this.allarmiConfigurazioneCore.getAllarme(allarme);
  658.             AllarmiUtils.notifyStateActiveThread(true, false, false, null, allarmeWrap, log, this.alarmEngineConfig);
  659.         } catch(Exception e) {
  660.             String errorMsg = MessageFormat.format(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_SALVATO_NOTIFICA_FALLITA, allarme.getAlias(),e.getMessage());
  661.             log.error(errorMsg, e);
  662.             throw new DriverConfigurazioneException(errorMsg, e);
  663.         }
  664.     }
  665.    
  666.     @Override
  667.     public void updateAllarme(Allarme allarme, Logger log) throws DriverConfigurazioneException {
  668.        
  669.         ConfigurazioneAllarmeBean allarmeWrap = null;
  670.         ConfigurazioneAllarmeBean oldAllarmeWrap = null;
  671.         try {
  672.             allarmeWrap = this.allarmiConfigurazioneCore.getAllarme(allarme);
  673.             oldAllarmeWrap = this.allarmiConfigurazioneCore.getAllarme(allarme.getId());
  674.         }catch(Exception e){
  675.             throw new DriverConfigurazioneException(e.getMessage(),e);
  676.         }
  677.        
  678.         try{
  679.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, allarme);
  680.         }catch(Exception e){
  681.             throw new DriverConfigurazioneException(e.getMessage(),e);
  682.         }
  683.        
  684.         boolean modificatoInformazioniHistory = false;
  685.         // se ho modificato l'abilitato devo registrare la modifica nella tabella history
  686.         if(allarme.getEnabled().intValue() != oldAllarmeWrap.getEnabled().intValue()) {
  687.             modificatoInformazioniHistory = true;
  688.         }
  689.         if(modificatoInformazioniHistory && this.alarmEngineConfig.isHistoryEnabled()) {
  690.             // registro la modifica
  691.             AllarmeHistory history = ConfigurazioneUtilities.createAllarmeHistory(allarme, this.userLogin);
  692.             try{
  693.                 this.allarmiConfigurazioneCore.performCreateOperation(this.userLogin, this.smista, history);
  694.             }catch(Throwable e) {
  695.                 String json = "";
  696.                 try {
  697.                     json = history.toJson();
  698.                 }catch(Throwable t) {}
  699.                 log.error("Registrazione stato allarme nell'hitstory non riuscita ["+json+"]: "+e.getMessage(),e);
  700.             }
  701.         }
  702.        
  703.         /* ******** GESTIONE AVVIO THREAD NEL CASO DI ATTIVO *************** */
  704.         try {
  705.             AllarmiUtils.notifyStateActiveThread(false, false, false, null, allarmeWrap, log, this.alarmEngineConfig);
  706.         } catch(Exception e) {
  707.             String errorMsg = MessageFormat.format(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_SALVATO_NOTIFICA_FALLITA, allarme.getAlias(),e.getMessage());
  708.             log.error(errorMsg, e);
  709.             throw new DriverConfigurazioneException(errorMsg, e);
  710.         }
  711.        
  712.     }
  713.    
  714.     @Override
  715.     public void deleteAllarme(Allarme allarme, Logger log) throws DriverConfigurazioneException {
  716.         try{
  717.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, allarme);
  718.         }catch(Exception e){
  719.             throw new DriverConfigurazioneException(e.getMessage(),e);
  720.         }
  721.        
  722.         /* ******** INVIO NOTIFICHE *************** */
  723.         try {
  724.             List<String> allarmeList = new ArrayList<>();
  725.             allarmeList.add(allarme.getNome());
  726.                
  727.             AllarmiUtils.stopActiveThreads(allarmeList, log, this.alarmEngineConfig);
  728.         } catch(Exception e) {
  729.             String errorMsg = MessageFormat.format(ConfigurazioneCostanti.MESSAGGIO_ERRORE_ALLARME_SINGOLO_ELIMINATO_NOTIFICA_FALLITA, allarme.getAlias(),e.getMessage());
  730.             log.error(errorMsg,e);
  731.             throw new DriverConfigurazioneException(errorMsg);
  732.         }
  733.     }
  734.    
  735.    
  736.    
  737.    
  738.     // --- Token Policy ---
  739.    
  740.     @Override
  741.     public void createGenericProperties(GenericProperties gp) throws DriverConfigurazioneException{
  742.         try {
  743.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, gp);
  744.         }catch(Exception e) {
  745.             throw new DriverConfigurazioneException(e.getMessage(),e);
  746.         }
  747.     }
  748.     @Override
  749.     public void updateGenericProperties(GenericProperties gp) throws DriverConfigurazioneException{
  750.         try {
  751.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, gp);
  752.         }catch(Exception e) {
  753.             throw new DriverConfigurazioneException(e.getMessage(),e);
  754.         }
  755.     }
  756.     @Override
  757.     public void deleteGenericProperties(GenericProperties gp) throws DriverConfigurazioneException{
  758.         try {
  759.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, gp);
  760.         }catch(Exception e) {
  761.             throw new DriverConfigurazioneException(e.getMessage(),e);
  762.         }
  763.     }
  764.    
  765.    
  766.    
  767.     // Plugin Classe
  768.    
  769.     @Override
  770.     public void createPluginClasse(Plugin plugin) throws DriverConfigurazioneException {
  771.         try {
  772.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, plugin);
  773.         }catch(Exception e) {
  774.             throw new DriverConfigurazioneException(e.getMessage(),e);
  775.         }
  776.     }
  777.     @Override
  778.     public void updatePluginClasse(Plugin plugin) throws DriverConfigurazioneException {
  779.         try {
  780.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, plugin);
  781.         }catch(Exception e) {
  782.             throw new DriverConfigurazioneException(e.getMessage(),e);
  783.         }
  784.     }
  785.     @Override
  786.     public void deletePluginClasse(Plugin plugin) throws DriverConfigurazioneException {
  787.         try {
  788.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, plugin);
  789.         }catch(Exception e) {
  790.             throw new DriverConfigurazioneException(e.getMessage(),e);
  791.         }
  792.     }
  793.    
  794.    
  795.    
  796.    
  797.     // --- Plugin Archivio ---
  798.    
  799.     private boolean archiviUpdated = false;
  800.    
  801.     @Override
  802.     public void createPluginArchivio(RegistroPlugin rp) throws DriverConfigurazioneException{
  803.         updatePosizioneBeforeCreate(rp);
  804.         updateDate(rp);
  805.         try {
  806.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, rp);
  807.             this.archiviUpdated = true;
  808.         }catch(Exception e) {
  809.             throw new DriverConfigurazioneException(e.getMessage(),e);
  810.         }
  811.     }
  812.     @Override
  813.     public void updatePluginArchivio(RegistroPlugin rp) throws DriverConfigurazioneException{
  814.         updateDate(rp);
  815.         try {
  816.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, rp); // aggiorna solo i dati principali
  817.             ConfigurazioneCore confCore = new ConfigurazioneCore(this.archiviCore);
  818.             if(rp.sizeArchivioList()>0) {
  819.                 for (RegistroPluginArchivio rpa : rp.getArchivioList()) {
  820.                     rpa.setNomePlugin(rp.getNome());
  821.                     if(confCore.existsRegistroPluginArchivio(rpa.getNomePlugin(), rpa.getNome())){
  822.                         this.archiviCore.performUpdateOperation(this.userLogin, this.smista, rpa);
  823.                     }
  824.                     else {
  825.                         this.archiviCore.performCreateOperation(this.userLogin, this.smista, rpa);
  826.                     }
  827.                 }
  828.             }
  829.             this.archiviUpdated = true;
  830.         }catch(Exception e) {
  831.             throw new DriverConfigurazioneException(e.getMessage(),e);
  832.         }
  833.     }
  834.     @Override
  835.     public void deletePluginArchivio(RegistroPlugin rp) throws DriverConfigurazioneException{
  836.         try {
  837.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, rp);
  838.             this.archiviUpdated = true;
  839.         }catch(Exception e) {
  840.             throw new DriverConfigurazioneException(e.getMessage(),e);
  841.         }
  842.     }
  843.    
  844.    
  845.    
  846.    
  847.     // --- Url Invocazione Regole ---
  848.    
  849.     @Override
  850.     public void createUrlInvocazioneRegola(ConfigurazioneUrlInvocazioneRegola regola) throws DriverConfigurazioneException{
  851.         updatePosizioneBeforeCreate(regola);
  852.         try {
  853.             this.archiviCore.performCreateOperation(this.userLogin, this.smista, regola);
  854.         }catch(Exception e) {
  855.             throw new DriverConfigurazioneException(e.getMessage(),e);
  856.         }
  857.     }
  858.     @Override
  859.     public void updateUrlInvocazioneRegola(ConfigurazioneUrlInvocazioneRegola regola) throws DriverConfigurazioneException{
  860.         try {
  861.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, regola);
  862.         }catch(Exception e) {
  863.             throw new DriverConfigurazioneException(e.getMessage(),e);
  864.         }
  865.     }
  866.     @Override
  867.     public void deleteUrlInvocazioneRegola(ConfigurazioneUrlInvocazioneRegola regola) throws DriverConfigurazioneException{
  868.         try {
  869.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, regola);
  870.         }catch(Exception e) {
  871.             throw new DriverConfigurazioneException(e.getMessage(),e);
  872.         }
  873.     }
  874.    
  875.    
  876.    
  877.    
  878.    
  879.     // --- Configurazione (Url Invocazione) ---
  880.    
  881.     @Override
  882.     public void updateConfigurazione_UrlInvocazione(ConfigurazioneUrlInvocazione configurazione) throws DriverConfigurazioneException{
  883.         try {
  884.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, configurazione);
  885.         }catch(Exception e) {
  886.             throw new DriverConfigurazioneException(e.getMessage(),e);
  887.         }
  888.     }
  889.    
  890.    
  891.    
  892.    
  893.    
  894.    
  895.    
  896.     // --- ConfigurazionePdD ---
  897.    
  898.     @Override
  899.     public void updateConfigurazione(Configurazione configurazione) throws DriverConfigurazioneException{
  900.         try{
  901.             this.archiviCore.performUpdateOperation(this.userLogin, this.smista, configurazione);
  902.         }catch(Exception e){
  903.             throw new DriverConfigurazioneException(e.getMessage(),e);
  904.         }
  905.     }
  906.    
  907.     @Override
  908.     public void deleteConfigurazione(Configurazione configurazione) throws DriverConfigurazioneException{
  909.         try{
  910.             this.archiviCore.performDeleteOperation(this.userLogin, this.smista, configurazione);
  911.         }catch(Exception e){
  912.             throw new DriverConfigurazioneException(e.getMessage(),e);
  913.         }
  914.     }
  915.    
  916.    
  917.    
  918.     // --- Finalize ---
  919.    
  920.     @Override
  921.     public void finalizeImport(Archive archive) throws DriverConfigurazioneException{
  922.         if(this.archiviUpdated) {
  923.             //  Aggiorno classLoader interno
  924.             try {
  925.                 this.archiviCore.updatePluginClassLoader();
  926.             }catch(Exception e) {
  927.                 throw new DriverConfigurazioneException(e.getMessage(),e);
  928.             }
  929.         }
  930.     }
  931.     @Override
  932.     public void finalizeDelete(Archive archive) throws DriverConfigurazioneException{
  933.         if(this.archiviUpdated) {
  934.             //  Aggiorno classLoader interno
  935.             try {
  936.                 this.archiviCore.updatePluginClassLoader();
  937.             }catch(Exception e) {
  938.                 throw new DriverConfigurazioneException(e.getMessage(),e);
  939.             }
  940.         }
  941.     }
  942. }