GestoreConsistenzaDati.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.gestori;

  21. import org.slf4j.Logger;
  22. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  23. import org.openspcoop2.web.ctrlstat.core.ControlStationLogger;

  24. /**
  25.  *
  26.  * GestoreConsistenzaDati
  27.  *
  28.  * @author Andrea Poli (apoli@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  *
  32.  */
  33. public class GestoreConsistenzaDati implements Runnable {

  34.     public static boolean gestoreConsistenzaDatiInEsecuzione = false;
  35.     public static boolean gestoreConsistenzaDatiEseguitoConErrore = false;
  36.    
  37.     private Logger log = null;

  38.     private boolean initForceMapping;
  39.    
  40.     private boolean stop = false;
  41.     public void setStop(boolean stop) {
  42.         this.stop = stop;
  43.     }

  44.     public GestoreConsistenzaDati(boolean initForceMapping) {
  45.         this.log = ControlStationLogger.getPddConsoleCoreLogger();
  46.         this.initForceMapping = initForceMapping;
  47.     }

  48.     @Override
  49.     public void run() {

  50.         if(gestoreConsistenzaDatiInEsecuzione){
  51.             this.log.info("Gestore Consistenza Dati risulta già avviato");
  52.             return;
  53.         }
  54.        
  55.         gestoreConsistenzaDatiInEsecuzione = true;
  56.        
  57.         String statoOperazione = "";
  58.         try{

  59.             // Controllo inizializzazione risorse
  60.             // L'inizializzazione del core attende anche che venga inizializzato il datasource
  61.             ControlStationCore core = null;
  62.             if(!this.stop){
  63.                 core = new ControlStationCore();
  64.             }

  65.             // Mapping Erogazione
  66.             if(!this.stop){
  67.                 statoOperazione = "[Inizializzazione Mapping Erogazione] ";
  68.                 this.log.debug("Controllo Consistenza Dati Mapping Erogazione-PA ....");
  69.                 core.initMappingErogazione(this.initForceMapping,this.log);
  70.                 this.log.debug("Controllo Consistenza Dati Mapping Erogazione-PA completato con successo");
  71.             }

  72.             // Mapping Fruizione
  73.             if(!this.stop){
  74.                 statoOperazione = "[Inizializzazione Mapping Fruizione] ";
  75.                 this.log.debug("Controllo Consistenza Dati Mapping Fruizione-PD ....");
  76.                 core.initMappingFruizione(this.initForceMapping,this.log);
  77.                 this.log.debug("Controllo Consistenza Dati Mapping Fruizione-PD completato con successo");
  78.             }
  79.            
  80.             this.log.info("Attività di Controllo Consistenza Dati completato con successo.");

  81.         }catch(Exception e){
  82.             gestoreConsistenzaDatiEseguitoConErrore = true;
  83.             this.log.error(statoOperazione+e.getMessage(),e);
  84.             throw new RuntimeException(e.getMessage(),e);
  85.         }finally{
  86.             gestoreConsistenzaDatiInEsecuzione = false;
  87.         }

  88.     }

  89. }