RemoteStoresCore.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.remote_stores;

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

  23. import org.openspcoop2.core.config.driver.DriverConfigurazioneException;
  24. import org.openspcoop2.core.config.driver.db.DriverConfigurazioneDB;
  25. import org.openspcoop2.pdd.core.keystore.KeystoreException;
  26. import org.openspcoop2.pdd.core.keystore.KeystoreNotFoundException;
  27. import org.openspcoop2.pdd.core.keystore.RemoteStore;
  28. import org.openspcoop2.pdd.core.keystore.RemoteStoreKeyEntry;
  29. import org.openspcoop2.pdd.core.keystore.RemoteStoreProviderDriverUtils;
  30. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  31. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  32. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationException;

  33. /**
  34.  * RemoteStoresCore
  35.  *
  36.  * @author Pintori Giuliano (pintori@link.it)
  37.  * @author Poli Andrea (apoli@link.it)
  38.  * @author $Author$
  39.  * @version $Rev$, $Date$
  40.  */
  41. public class RemoteStoresCore extends ControlStationCore {

  42.     public RemoteStoresCore() throws DriverControlStationException {
  43.         super();
  44.     }
  45.     public RemoteStoresCore(ControlStationCore core) throws DriverControlStationException {
  46.         super(core);
  47.     }
  48.     public List<RemoteStoreKeyEntry> remoteStoreKeysList(ConsoleSearch ricerca, long idRemoteStore) throws DriverControlStationException {
  49.         Connection con = null;
  50.         String nomeMetodo = "remoteStoreKeysList";
  51.         DriverConfigurazioneDB driver = null;

  52.         try {
  53.             // prendo una connessione
  54.             con = ControlStationCore.dbM.getConnection();
  55.             // istanzio il driver
  56.             driver = new DriverConfigurazioneDB(con, null, this.tipoDB);
  57.             return RemoteStoreProviderDriverUtils.getRemoteStoreKeyEntries(log, driver, ricerca, idRemoteStore);
  58.         } catch (DriverConfigurazioneException | KeystoreException e) {
  59.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  60.             throw new DriverControlStationException(getPrefixError(nomeMetodo,  e),e);
  61.         } finally {
  62.             ControlStationCore.dbM.releaseConnection(con);
  63.         }
  64.     }

  65.     public List<RemoteStore> remoteStoresList() throws DriverControlStationException {
  66.         Connection con = null;
  67.         String nomeMetodo = "remoteStoresList";
  68.         DriverConfigurazioneDB driver = null;

  69.         try {
  70.             // prendo una connessione
  71.             con = ControlStationCore.dbM.getConnection();
  72.             // istanzio il driver
  73.             driver = new DriverConfigurazioneDB(con, null, this.tipoDB);
  74.             return RemoteStoreProviderDriverUtils.getRemoteStores(driver);
  75.         } catch (DriverConfigurazioneException | KeystoreException e) {
  76.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  77.             throw new DriverControlStationException(getPrefixError(nomeMetodo,  e),e);
  78.         } finally {
  79.             ControlStationCore.dbM.releaseConnection(con);
  80.         }
  81.     }
  82.     public RemoteStoreKeyEntry getRemoteStoreKeyEntry(long idRemoteStoreKey) throws DriverControlStationException {
  83.         Connection con = null;
  84.         String nomeMetodo = "getRemoteStoreKeyEntry";
  85.         DriverConfigurazioneDB driver = null;

  86.         try {
  87.             // prendo una connessione
  88.             con = ControlStationCore.dbM.getConnection();
  89.             // istanzio il driver
  90.             driver = new DriverConfigurazioneDB(con, null, this.tipoDB);
  91.             return RemoteStoreProviderDriverUtils.getRemoteStoreKeyEntry(log,driver, idRemoteStoreKey);
  92.         } catch (DriverConfigurazioneException | KeystoreException | KeystoreNotFoundException e) {
  93.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  94.             throw new DriverControlStationException(getPrefixError(nomeMetodo,  e),e);
  95.         } finally {
  96.             ControlStationCore.dbM.releaseConnection(con);
  97.         }
  98.     }
  99. }