AuditingCore.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.audit;

  21. import java.sql.Connection;
  22. import java.util.List;

  23. import org.openspcoop2.core.commons.ISearch;
  24. import org.openspcoop2.core.commons.Liste;
  25. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  26. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationDB;
  27. import org.openspcoop2.web.lib.audit.AuditException;
  28. import org.openspcoop2.web.lib.audit.DriverAuditDBAppender;


  29. /**
  30.  * AuditingCore
  31.  *
  32.  * @author Poli Andrea (apoli@link.it)
  33.  * @author $Author$
  34.  * @version $Rev$, $Date$
  35.  */
  36. public class AuditingCore extends ControlStationCore {

  37.     public AuditingCore() throws Exception {
  38.         super();
  39.     }
  40.     public AuditingCore(ControlStationCore core) throws Exception {
  41.         super(core);
  42.     }

  43.    
  44.     public List<org.openspcoop2.web.lib.audit.log.Operation> auditOperationList(ISearch ricerca,
  45.             String datainizio, String datafine, String tipooperazione,
  46.             String tipooggetto, String id, String oldid, String utente,
  47.             String statooperazione, String contoggetto) throws AuditException {
  48.         Connection con = null;
  49.         String nomeMetodo = "auditOperationList";
  50.         DriverAuditDBAppender driver = null;

  51.         try {
  52.             // prendo una connessione
  53.             con = ControlStationCore.dbM.getConnection();
  54.             // istanzio il driver
  55.             driver = new DriverAuditDBAppender(con, this.tipoDB);
  56.             return driver.auditOperationList(ricerca, Liste.AUDIT_REPORT,
  57.                     datainizio, datafine, tipooperazione,
  58.                     tipooggetto, id, oldid, utente,
  59.                     statooperazione, contoggetto);
  60.         } catch (Exception e) {
  61.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  62.             throw new AuditException(getPrefixError(nomeMetodo,  e),e);
  63.         } finally {
  64.             ControlStationCore.dbM.releaseConnection(con);
  65.         }
  66.     }

  67.     public org.openspcoop2.web.lib.audit.log.Operation getAuditOperation(long idOp) throws AuditException {
  68.         Connection con = null;
  69.         String nomeMetodo = "getAuditOperation";
  70.         DriverAuditDBAppender driver = null;

  71.         try {
  72.             // prendo una connessione
  73.             con = ControlStationCore.dbM.getConnection();
  74.             // istanzio il driver
  75.             driver = new DriverAuditDBAppender(con, this.tipoDB);
  76.             return driver.getOperation(idOp);
  77.         } catch (Exception e) {
  78.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  79.             throw new AuditException(getPrefixError(nomeMetodo,  e),e);
  80.         } finally {
  81.             ControlStationCore.dbM.releaseConnection(con);
  82.         }
  83.     }
  84.    
  85.     public org.openspcoop2.web.lib.audit.dao.Configurazione getConfigurazioneAudit() throws AuditException {
  86.         Connection con = null;
  87.         String nomeMetodo = "getConfigurazioneAudit";
  88.         DriverControlStationDB driver = null;

  89.         try {
  90.             // prendo una connessione
  91.             con = ControlStationCore.dbM.getConnection();
  92.             // istanzio il driver
  93.             driver = new DriverControlStationDB(con, null, this.tipoDB);

  94.             return driver.getDriverAuditDB().getConfigurazione();

  95.         } catch (AuditException ae) {
  96.             ControlStationCore.logError(getPrefixError(nomeMetodo,  ae),ae);
  97.             throw ae;
  98.         } catch (Exception e) {
  99.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  100.             throw new AuditException(getPrefixError(nomeMetodo,  e),e);
  101.         } finally {
  102.             ControlStationCore.dbM.releaseConnection(con);
  103.         }

  104.     }
  105. }