FSRecoveryDumpImpl.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 java.sql.Connection;

  23. import org.openspcoop2.core.transazioni.DumpMessaggio;
  24. import org.openspcoop2.core.transazioni.utils.serializer.JaxbDeserializer;
  25. import org.openspcoop2.protocol.sdk.dump.IDumpProducer;
  26. import org.openspcoop2.utils.UtilsException;
  27. import org.openspcoop2.utils.UtilsMultiException;
  28. import org.slf4j.Logger;

  29. /**
  30.  * FSRecoveryDumpImpl
  31.  *
  32.  * @author Poli Andrea (apoli@link.it)
  33.  * @author $Author$
  34.  * @version $Rev$, $Date$
  35.  */
  36. public class FSRecoveryDumpImpl extends AbstractFSRecovery {
  37.     private IDumpProducer dumpAppender;
  38.     private boolean transazioniRegistrazioneDumpHeadersCompactEnabled = false;

  39.     public FSRecoveryDumpImpl(
  40.             Logger log,
  41.             boolean debug,
  42.             IDumpProducer dumpAppender,
  43.             File directory, File directoryDLQ,
  44.             int tentativi,
  45.             long msAttesaProcessingFile) {
  46.         super(log, debug, directory, directoryDLQ, tentativi, msAttesaProcessingFile);
  47.         this.dumpAppender = dumpAppender;
  48.     }

  49.     public void setTransazioniRegistrazioneDumpHeadersCompactEnabled(
  50.             boolean transazioniRegistrazioneDumpHeadersCompactEnabled) {
  51.         this.transazioniRegistrazioneDumpHeadersCompactEnabled = transazioniRegistrazioneDumpHeadersCompactEnabled;
  52.     }
  53.    
  54.     @Override
  55.     public void process(Connection connection) {
  56.         this.log.info("Recovery Dump ...");
  57.         super.process(connection);
  58.         this.log.info("Recovery Dump completato");
  59.     }

  60.     @Override
  61.     public void insertObject(File file, Connection connection) throws UtilsException, UtilsMultiException {
  62.         JaxbDeserializer deserializer = new JaxbDeserializer();
  63.         DumpMessaggio dumpMessaggio = null;
  64.         try {
  65.             dumpMessaggio = deserializer.readDumpMessaggio(file);
  66.         }catch(Exception e) {
  67.             throw new UtilsException(e.getMessage(),e);
  68.         }
  69.        
  70.         //FARE UN WRAPPER COSI COME ABBIAMO FATTO PER TRACCIA E DIAGNOSTICO
  71.        
  72.         org.openspcoop2.protocol.sdk.dump.Messaggio messaggioOp2 = new org.openspcoop2.protocol.sdk.dump.Messaggio(dumpMessaggio);
  73.         try {
  74.             this.dumpAppender.dump(connection, messaggioOp2, this.transazioniRegistrazioneDumpHeadersCompactEnabled);
  75.         }catch(Exception e) {
  76.             throw new UtilsException(e.getMessage(),e);
  77.         }
  78.        
  79.     }


  80. }