FSRecoveryEventi.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.monitor.engine.fs_recovery;

  21. import java.io.File;

  22. import org.slf4j.Logger;


  23. /**
  24.  * FSRecoveryEventi
  25.  *
  26.  * @author Poli Andrea (apoli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */
  30. public class FSRecoveryEventi {

  31.     private FSRecoveryEventiImpl impl;
  32.    
  33.    
  34.     public FSRecoveryEventi(
  35.             Logger log,
  36.             boolean debug,
  37.             org.openspcoop2.core.eventi.dao.IServiceManager pluginsEventiSM,
  38.             File directory, File directoryDLQ,
  39.             int tentativi, long msAttesaProcessingFile) {
  40.         this.impl = new FSRecoveryEventiImpl(log, debug, pluginsEventiSM, directory, directoryDLQ, tentativi, msAttesaProcessingFile);
  41.     }

  42.     public void process(){
  43.         // process file presenti nella directory.
  44.         // Per ogni file fare il marshall dell'oggetto 'it.link.pdd.core.plugins.eventi.utils.serializer.JaxbDeserializer'
  45.         // Usare poi il service this.pluginsEventiSM.getEventoService().create(obj); per salvare su database
  46.         // Se il salvataggio su database va a buon fine si puo eliminare il file.
  47.         // Se avviene un errore sul marshal o se avviene un errore durante l'inserimento effettuare un rename del file file.renameTo(file2)
  48.         // aggiungendo un suffisso sul numero del tentativo: es.
  49.         // File originale: Evento_2015-04-27_09\:37\:34.323_1.xml
  50.         // Dopo primo tentativo: Evento_2015-04-27_09\:37\:34.323_1.xml_1.error
  51.         // Dopo secondo tentativo: Evento_2015-04-27_09\:37\:34.323_1.xml_2.error
  52.         // ...
  53.         // In modo da riconoscere gli originali *.xml da quelli che sono andati in errore almeno una volta *.error
  54.         //
  55.         // Se per un file si raggiunge il massimo numero di tentativi, effettuare il rename del file file.renameTo(file2)
  56.         // Spostandolo nella directory DLQ.

  57.         // NOTA: prima di processare un file verificare che la sua data di ultima modifica sia piu' vecchia almeno di X minuti (mettere X minuti in una costante)
  58.         //       in modo da evitare di processare i file che sono creati nello stesso momento in cui gira la procedura

  59.         // NOTA: usare this.debug per emettere o meno informazioni in this.log

  60.         // NOTA: in DLQ estrapolare la data (solo anno mese e giorno) dal nome del file e usarla come nome della directory all'interno di DLQ.
  61.         this.impl.process(null);
  62.     }

  63. }