AccordoServizioParteComuneRestCore.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.apc;

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

  23. import org.openspcoop2.core.commons.ISearch;
  24. import org.openspcoop2.core.id.IDResource;
  25. import org.openspcoop2.core.registry.constants.ParameterType;
  26. import org.openspcoop2.core.registry.driver.DriverRegistroServiziException;
  27. import org.openspcoop2.core.registry.driver.DriverRegistroServiziNotFound;
  28. import org.openspcoop2.core.registry.driver.FiltroRicercaResources;
  29. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  30. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationDB;
  31. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationException;
  32. import org.openspcoop2.web.ctrlstat.registro.GestoreRegistroServiziRemoto;

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

  41.     protected AccordoServizioParteComuneRestCore(ControlStationCore core) throws DriverControlStationException {
  42.         super(core);
  43.     }
  44.    
  45.     public List<org.openspcoop2.core.registry.Resource> accordiResourceList(long idAccordo, ISearch ricerca) throws DriverRegistroServiziException {
  46.         Connection con = null;
  47.         String nomeMetodo = "accordiResourceList";
  48.         DriverControlStationDB driver = null;

  49.         try {
  50.             // prendo una connessione
  51.             con = ControlStationCore.dbM.getConnection();
  52.             // istanzio il driver
  53.             driver = new DriverControlStationDB(con, null, this.tipoDB);

  54.             return driver.getDriverRegistroServiziDB().accordiResourceList(idAccordo, ricerca);

  55.         } catch (Exception e) {
  56.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  57.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e),e);
  58.         } finally {
  59.             ControlStationCore.dbM.releaseConnection(con);
  60.         }

  61.     }
  62.    
  63.     public List<org.openspcoop2.core.registry.ResourceResponse> accordiResourceResponseList(Long idRisorsa, ISearch ricerca) throws DriverRegistroServiziException {
  64.         Connection con = null;
  65.         String nomeMetodo = "accordiResourceResponseList";
  66.         DriverControlStationDB driver = null;

  67.         try {
  68.             // prendo una connessione
  69.             con = ControlStationCore.dbM.getConnection();
  70.             // istanzio il driver
  71.             driver = new DriverControlStationDB(con, null, this.tipoDB);

  72.             return driver.getDriverRegistroServiziDB().accordiResourceResponseList(idRisorsa, ricerca);

  73.         } catch (Exception e) {
  74.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  75.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e),e);
  76.         } finally {
  77.             ControlStationCore.dbM.releaseConnection(con);
  78.         }

  79.     }
  80.    
  81.     public List<org.openspcoop2.core.registry.ResourceRepresentation> accordiResourceRepresentationsList(Long idRisorsa, boolean isRequest, Long idRisposta, ISearch ricerca) throws DriverRegistroServiziException {
  82.         Connection con = null;
  83.         String nomeMetodo = "accordiResourceRepresentationList";
  84.         DriverControlStationDB driver = null;

  85.         try {
  86.             // prendo una connessione
  87.             con = ControlStationCore.dbM.getConnection();
  88.             // istanzio il driver
  89.             driver = new DriverControlStationDB(con, null, this.tipoDB);

  90.             return driver.getDriverRegistroServiziDB().accordiResourceRepresentationsList(idRisorsa, isRequest, idRisposta, ricerca);

  91.         } catch (Exception e) {
  92.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  93.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e),e);
  94.         } finally {
  95.             ControlStationCore.dbM.releaseConnection(con);
  96.         }

  97.     }
  98.    
  99.     public List<org.openspcoop2.core.registry.ResourceParameter> accordiResourceParametersList(Long idRisorsa, boolean isRequest, Long idRisposta, ISearch ricerca) throws DriverRegistroServiziException {
  100.         Connection con = null;
  101.         String nomeMetodo = "accordiResourceParametersList";
  102.         DriverControlStationDB driver = null;

  103.         try {
  104.             // prendo una connessione
  105.             con = ControlStationCore.dbM.getConnection();
  106.             // istanzio il driver
  107.             driver = new DriverControlStationDB(con, null, this.tipoDB);

  108.             return driver.getDriverRegistroServiziDB().accordiResourceParametersList(idRisorsa, isRequest, idRisposta, ricerca);

  109.         } catch (Exception e) {
  110.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  111.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e),e);
  112.         } finally {
  113.             ControlStationCore.dbM.releaseConnection(con);
  114.         }

  115.     }
  116.    
  117.     public boolean existsAccordoServizioResource(String nome, long idAccordo) throws DriverRegistroServiziException {
  118.         Connection con = null;
  119.         String nomeMetodo = "existsAccordoServizioResource";
  120.         DriverControlStationDB driver = null;

  121.         try {
  122.             // prendo una connessione
  123.             con = ControlStationCore.dbM.getConnection();
  124.             // istanzio il driver
  125.             driver = new DriverControlStationDB(con, null, this.tipoDB);
  126.             return driver.getDriverRegistroServiziDB().existsAccordoServizioParteComuneResource(nome, idAccordo);
  127.         } catch (Exception e) {
  128.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  129.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e),e);
  130.         } finally {
  131.             ControlStationCore.dbM.releaseConnection(con);
  132.         }
  133.     }
  134.    
  135.     public boolean existsAccordoServizioResource(String httpMethod, String path, long idAccordo, String excludeResourceWithName) throws DriverRegistroServiziException {
  136.         Connection con = null;
  137.         String nomeMetodo = "existsAccordoServizioResource";
  138.         DriverControlStationDB driver = null;

  139.         try {
  140.             // prendo una connessione
  141.             con = ControlStationCore.dbM.getConnection();
  142.             // istanzio il driver
  143.             driver = new DriverControlStationDB(con, null, this.tipoDB);
  144.             return driver.getDriverRegistroServiziDB().existsAccordoServizioParteComuneResource(httpMethod, path, idAccordo, excludeResourceWithName);
  145.         } catch (Exception e) {
  146.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  147.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e),e);
  148.         } finally {
  149.             ControlStationCore.dbM.releaseConnection(con);
  150.         }
  151.     }
  152.    
  153.     public boolean existsAccordoServizioResourceResponse(long idRisorsa, int httpStatus) throws DriverRegistroServiziException{
  154.         Connection con = null;
  155.         String nomeMetodo = "existsAccordoServizioResourceResponse";
  156.         DriverControlStationDB driver = null;

  157.         try {
  158.             // prendo una connessione
  159.             con = ControlStationCore.dbM.getConnection();
  160.             // istanzio il driver
  161.             driver = new DriverControlStationDB(con, null, this.tipoDB);
  162.             return driver.getDriverRegistroServiziDB().existsAccordoServizioResourceResponse(idRisorsa, httpStatus);
  163.         } catch (Exception e) {
  164.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  165.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e),e);
  166.         } finally {
  167.             ControlStationCore.dbM.releaseConnection(con);
  168.         }
  169.     }
  170.    
  171.     public boolean existsAccordoServizioResourceRepresentation(Long idRisorsa, boolean isRequest, Long idResponse, String mediaType) throws DriverRegistroServiziException{
  172.         Connection con = null;
  173.         String nomeMetodo = "existsAccordoServizioResourceRepresentation";
  174.         DriverControlStationDB driver = null;

  175.         try {
  176.             // prendo una connessione
  177.             con = ControlStationCore.dbM.getConnection();
  178.             // istanzio il driver
  179.             driver = new DriverControlStationDB(con, null, this.tipoDB);
  180.             return driver.getDriverRegistroServiziDB().existsAccordoServizioResourceRepresentation(idRisorsa, isRequest,idResponse,mediaType);
  181.         } catch (Exception e) {
  182.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  183.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e),e);
  184.         } finally {
  185.             ControlStationCore.dbM.releaseConnection(con);
  186.         }
  187.     }
  188.    
  189.     public boolean existsAccordoServizioResourceParameter(Long idRisorsa, boolean isRequest, Long idResponse, ParameterType tipoParametro, String nome) throws DriverRegistroServiziException{
  190.         Connection con = null;
  191.         String nomeMetodo = "existsAccordoServizioResourceParameter";
  192.         DriverControlStationDB driver = null;

  193.         try {
  194.             // prendo una connessione
  195.             con = ControlStationCore.dbM.getConnection();
  196.             // istanzio il driver
  197.             driver = new DriverControlStationDB(con, null, this.tipoDB);
  198.             return driver.getDriverRegistroServiziDB().existsAccordoServizioResourceParameter(idRisorsa, isRequest,idResponse,tipoParametro,nome);
  199.         } catch (Exception e) {
  200.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  201.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e),e);
  202.         } finally {
  203.             ControlStationCore.dbM.releaseConnection(con);
  204.         }
  205.     }
  206.    
  207.     public List<IDResource> getAllIdResource(FiltroRicercaResources filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound {
  208.         Connection con = null;
  209.         String nomeMetodo = "getAllIdResource";
  210.         DriverControlStationDB driver = null;

  211.         try {
  212.             if(this.isRegistroServiziLocale()){
  213.                 // prendo una connessione
  214.                 con = ControlStationCore.dbM.getConnection();
  215.                 // istanzio il driver
  216.                 driver = new DriverControlStationDB(con, null, this.tipoDB);

  217.                 return driver.getDriverRegistroServiziDB().getAllIdResource(filtroRicerca);
  218.             }
  219.             else{
  220.                 return GestoreRegistroServiziRemoto.getDriverRegistroServizi(ControlStationCore.log).getAllIdResource(filtroRicerca);
  221.             }

  222.         } catch (DriverRegistroServiziNotFound de) {
  223.             ControlStationCore.logDebug(getPrefixError(nomeMetodo,  de),de);
  224.             throw de;
  225.         } catch (Exception e) {
  226.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  227.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e),e);
  228.         } finally {
  229.             ControlStationCore.dbM.releaseConnection(con);
  230.         }
  231.     }
  232. }