BeanUtilities.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.core.config.driver;

  21. import org.openspcoop2.core.config.AccessoConfigurazione;
  22. import org.openspcoop2.core.config.AccessoDatiAutorizzazione;
  23. import org.openspcoop2.core.config.AccessoRegistro;
  24. import org.openspcoop2.core.config.Configurazione;
  25. import org.openspcoop2.core.config.GestioneErrore;
  26. import org.openspcoop2.core.config.Openspcoop2;
  27. import org.openspcoop2.core.config.PortaApplicativa;
  28. import org.openspcoop2.core.config.PortaDelegata;
  29. import org.openspcoop2.core.config.RoutingTable;
  30. import org.openspcoop2.core.config.ServizioApplicativo;
  31. import org.openspcoop2.core.config.Soggetto;
  32. import org.openspcoop2.core.id.IDPortaApplicativa;
  33. import org.openspcoop2.core.id.IDPortaDelegata;
  34. import org.openspcoop2.core.id.IDServizioApplicativo;
  35. import org.openspcoop2.core.id.IDSoggetto;


  36. /**
  37.  * Utility sui bean del package
  38.  *  
  39.  * @author Poli Andrea (apoli@link.it)
  40.  * @author $Author$
  41.  * @version $Rev$, $Date$
  42.  */
  43. public abstract class BeanUtilities implements IDriverConfigurazioneGet {

  44.    
  45.     /**
  46.      * Controlla che il bean presente nel registro, sia uguale al bean passato come parametro
  47.      *
  48.      * @param idSoggetto
  49.      * @param soggetto
  50.      * @return true se il bean presente nel registro, sia uguale al bean passato come parametro
  51.      */
  52.     @Override
  53.     public boolean verificaSoggetto(IDSoggetto idSoggetto,Soggetto soggetto)throws DriverConfigurazioneException {
  54.         return verificaSoggetto(idSoggetto, soggetto,true);
  55.     }
  56.     @Override
  57.     public boolean verificaSoggetto(IDSoggetto idSoggetto,Soggetto soggetto,boolean checkID)throws DriverConfigurazioneException{
  58.         Soggetto beanRegistro = null;
  59.         try{
  60.             beanRegistro = this.getSoggetto(idSoggetto);
  61.         }catch(DriverConfigurazioneNotFound dNotFound){}
  62.         if(beanRegistro==null){
  63.             if(soggetto==null){
  64.                 return true;
  65.             }else{
  66.                 return false;
  67.             }
  68.         }else{
  69.             if(soggetto==null){
  70.                 return false;
  71.             }
  72.             else{
  73.                 return beanRegistro.equals(soggetto,checkID);
  74.             }
  75.         }
  76.     }
  77.    
  78.     /**
  79.      * Controlla che il bean presente nel registro, sia uguale al bean passato come parametro
  80.      *
  81.      * @param soggetto
  82.      * @return true se il bean presente nel registro, sia uguale al bean passato come parametro
  83.      */
  84.     @Override
  85.     public boolean verificaRouter(Soggetto soggetto)throws DriverConfigurazioneException {
  86.         return verificaRouter(soggetto,true);
  87.     }
  88.     @Override
  89.     public boolean verificaRouter(Soggetto soggetto,boolean checkID)throws DriverConfigurazioneException{
  90.         Soggetto beanRegistro = null;
  91.         try{
  92.             beanRegistro = this.getRouter();
  93.         }catch(DriverConfigurazioneNotFound dNotFound){}
  94.         if(beanRegistro==null){
  95.             if(soggetto==null)
  96.                 return true;
  97.             else
  98.                 return false;
  99.         }else{
  100.             if(soggetto==null)
  101.                 return false;
  102.             else
  103.                 return beanRegistro.equals(soggetto,checkID);
  104.         }
  105.     }
  106.    
  107.     /**
  108.      * Controlla che il bean presente nel registro, sia uguale al bean passato come parametro
  109.      *
  110.      * @param idPD
  111.      * @param pd
  112.      * @return true se il bean presente nel registro, sia uguale al bean passato come parametro
  113.      */
  114.     @Override
  115.     public boolean verificaPortaDelegata(IDPortaDelegata idPD,PortaDelegata pd)throws DriverConfigurazioneException {
  116.         return verificaPortaDelegata(idPD,pd,true);
  117.     }
  118.     @Override
  119.     public boolean verificaPortaDelegata(IDPortaDelegata idPD,PortaDelegata pd,boolean checkID)throws DriverConfigurazioneException{
  120.         PortaDelegata beanRegistro = null;
  121.         try{
  122.             beanRegistro = this.getPortaDelegata(idPD);
  123.         }catch(DriverConfigurazioneNotFound dNotFound){}
  124.         if(beanRegistro==null){
  125.             if(pd==null)
  126.                 return true;
  127.             else
  128.                 return false;
  129.         }else{
  130.             if(pd==null)
  131.                 return false;
  132.             else
  133.                 return beanRegistro.equals(pd,checkID);
  134.         }
  135.     }
  136.    
  137.     /**
  138.      * Controlla che il bean presente nel registro, sia uguale al bean passato come parametro
  139.      * Utilizza la porta applicativa identificata da <var>idPA</var>
  140.      * nel caso in cui e' specificata un'azione ma non viene trovato nessun risultato, viene ricercata
  141.      * una Porta Applicativa che non possegga l'azione
  142.      *
  143.      * @param idPA
  144.      * @param pa
  145.      * @return true se il bean presente nel registro, sia uguale al bean passato come parametro
  146.      */
  147.     @Override
  148.     public boolean verificaPortaApplicativa(IDPortaApplicativa idPA,PortaApplicativa pa)throws DriverConfigurazioneException {
  149.         return verificaPortaApplicativa(idPA,pa,true);
  150.     }
  151.     @Override
  152.     public boolean verificaPortaApplicativa(IDPortaApplicativa idPA,PortaApplicativa pa,boolean checkID)throws DriverConfigurazioneException{
  153.         PortaApplicativa beanRegistro = null;
  154.         try{
  155.             beanRegistro = this.getPortaApplicativa(idPA);
  156.         }catch(DriverConfigurazioneNotFound dNotFound){}
  157.         if(beanRegistro==null){
  158.             if(pa==null)
  159.                 return true;
  160.             else
  161.                 return false;
  162.         }else{
  163.             if(pa==null)
  164.                 return false;
  165.             else
  166.                 return beanRegistro.equals(pa,checkID);
  167.         }
  168.     }
  169.    
  170.    
  171.    
  172.     /**
  173.      * Controlla che il bean presente nel registro, sia uguale al bean passato come parametro
  174.      *
  175.      * @param idSA
  176.      * @param sa
  177.      * @return true se il bean presente nel registro, sia uguale al bean passato come parametro
  178.      */
  179.     @Override
  180.     public boolean verificaServizioApplicativo(IDServizioApplicativo idSA,ServizioApplicativo sa)throws DriverConfigurazioneException {
  181.         return verificaServizioApplicativo(idSA,sa,true);
  182.     }
  183.     @Override
  184.     public boolean verificaServizioApplicativo(IDServizioApplicativo idSA,ServizioApplicativo sa,boolean checkID)throws DriverConfigurazioneException{
  185.         ServizioApplicativo beanRegistro = null;
  186.         try{
  187.             beanRegistro = this.getServizioApplicativo(idSA);
  188.         }catch(DriverConfigurazioneNotFound dNotFound){}
  189.         if(beanRegistro==null){
  190.             if(sa==null)
  191.                 return true;
  192.             else
  193.                 return false;
  194.         }else{
  195.             if(sa==null)
  196.                 return false;
  197.             else
  198.                 return beanRegistro.equals(sa,checkID);
  199.         }
  200.     }
  201.    
  202.    
  203.     /**
  204.      * Controlla che il bean presente nel registro, sia uguale al bean passato come parametro
  205.      *
  206.      * @param rt
  207.      * @return true se il bean presente nel registro, sia uguale al bean passato come parametro
  208.      */
  209.     @Override
  210.     public boolean verificaRoutingTable(RoutingTable rt)throws DriverConfigurazioneException {
  211.         return verificaRoutingTable(rt,true);
  212.     }
  213.     @Override
  214.     public boolean verificaRoutingTable(RoutingTable rt,boolean checkID)throws DriverConfigurazioneException{
  215.         RoutingTable beanRegistro = this.getRoutingTable();
  216.         if(beanRegistro==null){
  217.             if(rt==null)
  218.                 return true;
  219.             else
  220.                 return false;
  221.         }else{
  222.             if(rt==null)
  223.                 return false;
  224.             else
  225.                 return beanRegistro.equals(rt,checkID);
  226.         }
  227.     }
  228.    
  229.    
  230.     /**
  231.      * Controlla che il bean presente nel registro, sia uguale al bean passato come parametro
  232.      *
  233.      * @param ar
  234.      * @return true se il bean presente nel registro, sia uguale al bean passato come parametro
  235.      */
  236.     @Override
  237.     public boolean verificaAccessoRegistro(AccessoRegistro ar)throws DriverConfigurazioneException {
  238.         return verificaAccessoRegistro(ar,true);
  239.     }
  240.     @Override
  241.     public boolean verificaAccessoRegistro(AccessoRegistro ar,boolean checkID)throws DriverConfigurazioneException{
  242.         AccessoRegistro beanRegistro = null;
  243.         try{
  244.             beanRegistro = this.getAccessoRegistro();
  245.         }catch(DriverConfigurazioneNotFound dNotFound){}
  246.         if(beanRegistro==null){
  247.             if(ar==null)
  248.                 return true;
  249.             else
  250.                 return false;
  251.         }else{
  252.             if(ar==null)
  253.                 return false;
  254.             else
  255.                 return beanRegistro.equals(ar,checkID);
  256.         }
  257.     }
  258.    
  259.     /**
  260.      * Controlla che il bean presente, sia uguale al bean passato come parametro
  261.      *
  262.      * @param ac
  263.      * @return true se il bean presente, sia uguale al bean passato come parametro
  264.      */
  265.     @Override
  266.     public boolean verificaAccessoConfigurazione(AccessoConfigurazione ac)throws DriverConfigurazioneException {
  267.         return verificaAccessoConfigurazione(ac,true);
  268.     }
  269.     @Override
  270.     public boolean verificaAccessoConfigurazione(AccessoConfigurazione ac,boolean checkID)throws DriverConfigurazioneException{
  271.         AccessoConfigurazione bean = null;
  272.         try{
  273.             bean = this.getAccessoConfigurazione();
  274.         }catch(DriverConfigurazioneNotFound dNotFound){}
  275.         if(bean==null){
  276.             if(ac==null)
  277.                 return true;
  278.             else
  279.                 return false;
  280.         }else{
  281.             if(ac==null)
  282.                 return false;
  283.             else
  284.                 return bean.equals(ac,checkID);
  285.         }
  286.     }
  287.    
  288.     /**
  289.      * Controlla che il bean presente, sia uguale al bean passato come parametro
  290.      *
  291.      * @param ad
  292.      * @return true se il bean presente, sia uguale al bean passato come parametro
  293.      */
  294.     @Override
  295.     public boolean verificaAccessoDatiAutorizzazione(AccessoDatiAutorizzazione ad)throws DriverConfigurazioneException {
  296.         return verificaAccessoDatiAutorizzazione(ad,true);
  297.     }
  298.     @Override
  299.     public boolean verificaAccessoDatiAutorizzazione(AccessoDatiAutorizzazione ad,boolean checkID)throws DriverConfigurazioneException{
  300.         AccessoDatiAutorizzazione bean = null;
  301.         try{
  302.             bean = this.getAccessoDatiAutorizzazione();
  303.         }catch(DriverConfigurazioneNotFound dNotFound){}
  304.         if(bean==null){
  305.             if(ad==null)
  306.                 return true;
  307.             else
  308.                 return false;
  309.         }else{
  310.             if(ad==null)
  311.                 return false;
  312.             else
  313.                 return bean.equals(ad,checkID);
  314.         }
  315.     }
  316.    
  317.     /**
  318.      * Controlla che il bean presente nel registro, sia uguale al bean passato come parametro
  319.      *
  320.      * @param gr
  321.      * @return true se il bean presente nel registro, sia uguale al bean passato come parametro
  322.      */
  323.     @Override
  324.     public boolean verificaGestioneErroreComponenteCooperazione(GestioneErrore gr)throws DriverConfigurazioneException {
  325.         return verificaGestioneErroreComponenteCooperazione(gr,true);
  326.     }
  327.     @Override
  328.     public boolean verificaGestioneErroreComponenteCooperazione(GestioneErrore gr,boolean checkID)throws DriverConfigurazioneException{
  329.         GestioneErrore beanRegistro = null;
  330.         try{
  331.             beanRegistro = this.getGestioneErroreComponenteCooperazione();
  332.         }catch(DriverConfigurazioneNotFound dNotFound){}
  333.         if(beanRegistro==null){
  334.             if(gr==null)
  335.                 return true;
  336.             else
  337.                 return false;
  338.         }else{
  339.             if(gr==null)
  340.                 return false;
  341.             else
  342.                 return beanRegistro.equals(gr,checkID);
  343.         }
  344.     }
  345.    
  346.     /**
  347.      * Controlla che il bean presente nel registro, sia uguale al bean passato come parametro
  348.      *
  349.      * @param gr
  350.      * @return true se il bean presente nel registro, sia uguale al bean passato come parametro
  351.      */
  352.     @Override
  353.     public boolean verificaGestioneErroreComponenteIntegrazione(GestioneErrore gr)throws DriverConfigurazioneException {
  354.         return verificaGestioneErroreComponenteIntegrazione(gr,true);
  355.     }
  356.     @Override
  357.     public boolean verificaGestioneErroreComponenteIntegrazione(GestioneErrore gr,boolean checkID)throws DriverConfigurazioneException{
  358.         GestioneErrore beanRegistro = null;
  359.         try{
  360.             beanRegistro = this.getGestioneErroreComponenteIntegrazione();
  361.         }catch(DriverConfigurazioneNotFound dNotFound){}
  362.         if(beanRegistro==null){
  363.             if(gr==null)
  364.                 return true;
  365.             else
  366.                 return false;
  367.         }else{
  368.             if(gr==null)
  369.                 return false;
  370.             else
  371.                 return beanRegistro.equals(gr,checkID);
  372.         }
  373.     }
  374.    
  375.     /**
  376.      * Controlla che il bean presente nel registro, sia uguale al bean passato come parametro
  377.      *
  378.      * @param configurazione
  379.      * @return true se il bean presente nel registro, sia uguale al bean passato come parametro
  380.      */
  381.     @Override
  382.     public boolean verificaConfigurazione(Configurazione configurazione)throws DriverConfigurazioneException {
  383.         return verificaConfigurazione(configurazione,true);
  384.     }
  385.     @Override
  386.     public boolean verificaConfigurazione(Configurazione configurazione,boolean checkID)throws DriverConfigurazioneException{
  387.         Configurazione beanRegistro = null;
  388.         try{
  389.             beanRegistro = this.getConfigurazioneGenerale();
  390.         }catch(DriverConfigurazioneNotFound dNotFound){}
  391.         if(beanRegistro==null){
  392.             if(configurazione==null)
  393.                 return true;
  394.             else
  395.                 return false;
  396.         }else{
  397.             if(configurazione==null)
  398.                 return false;
  399.             else
  400.                 return beanRegistro.equals(configurazione,checkID);
  401.         }
  402.     }
  403.    
  404.    
  405.    
  406.     public abstract Openspcoop2 getImmagineCompletaConfigurazionePdD() throws DriverConfigurazioneException;
  407. }