SPCoopProtocolManager.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.protocol.spcoop.config;

  21. import java.util.Map;

  22. import org.openspcoop2.core.id.IDServizio;
  23. import org.openspcoop2.core.id.IDSoggetto;
  24. import org.openspcoop2.message.OpenSPCoop2Message;
  25. import org.openspcoop2.message.constants.ServiceBinding;
  26. import org.openspcoop2.protocol.basic.BasicComponentFactory;
  27. import org.openspcoop2.protocol.sdk.Busta;
  28. import org.openspcoop2.protocol.sdk.IProtocolFactory;
  29. import org.openspcoop2.protocol.sdk.ProtocolException;
  30. import org.openspcoop2.protocol.sdk.config.IProtocolManager;
  31. import org.openspcoop2.protocol.sdk.constants.FaultIntegrationGenericInfoMode;
  32. import org.openspcoop2.protocol.sdk.constants.TipoIntegrazione;
  33. import org.openspcoop2.protocol.sdk.registry.IRegistryReader;
  34. import org.openspcoop2.utils.BooleanNullable;
  35. import org.openspcoop2.utils.io.notifier.NotifierInputStreamParams;
  36. import org.openspcoop2.utils.transport.TransportRequestContext;
  37. import org.openspcoop2.utils.transport.TransportResponseContext;

  38. /**
  39.  * Classe che implementa, in base al protocollo SPCoop, l'interfaccia {@link org.openspcoop2.protocol.sdk.config.IProtocolManager}
  40.  *
  41.  * @author Poli Andrea (apoli@link.it)
  42.  * @author Nardi Lorenzo (nardi@link.it)
  43.  * @author $Author$
  44.  * @version $Rev$, $Date$
  45.  */
  46. public class SPCoopProtocolManager extends BasicComponentFactory implements IProtocolManager {
  47.    
  48.     protected SPCoopProperties spcoopProperties = null;
  49.     public SPCoopProtocolManager(IProtocolFactory<?> protocolFactory) throws ProtocolException{
  50.         super(protocolFactory);
  51.         this.spcoopProperties = SPCoopProperties.getInstance(this.log);
  52.     }

  53.     @Override
  54.     public IProtocolFactory<?> getProtocolFactory() {
  55.         return this.protocolFactory;
  56.     }  
  57.    
  58.    
  59.    
  60.    
  61.    
  62.    
  63.     /* *********** VALIDAZIONE/GENERAZIONE BUSTE ******************* */
  64.    
  65.     /**
  66.      * Indicazione se la busta e' una busta di servizio
  67.      *  
  68.      * @return Indicazione se la busta e' una busta di servizio
  69.      */
  70.     @Override
  71.     public boolean isBustaServizio(Busta busta){
  72.         //  Una busta e' una busta di servizio, se:
  73.         // - non possiede un servizio (non e' quindi una richiesta)
  74.         // - non possiede un riferimentoMsg (non e' quindi una risposta)
  75.         return (busta.getServizio()==null && busta.getRiferimentoMessaggio()==null) ;
  76.     }
  77.    
  78.     @Override
  79.     public String getKeywordTipoMittenteSconosciuto(){
  80.         return this.spcoopProperties.getKeywordTipoMittenteSconosciuto();
  81.     }
  82.    
  83.     @Override
  84.     public String getKeywordMittenteSconosciuto(){
  85.         return this.spcoopProperties.getKeywordMittenteSconosciuto();
  86.     }
  87.    
  88.     @Override
  89.     public long getIntervalloScadenzaBuste(){
  90.         try{
  91.             return this.spcoopProperties.getIntervalloScadenzaBuste();
  92.         }catch(Exception e){
  93.             return -1;
  94.         }
  95.     }

  96.     @Override
  97.     public boolean isGenerazioneElementiNonValidabiliRispettoXSD(){
  98.         return this.spcoopProperties.isGenerazioneElementiNonValidabiliRispettoXSD();
  99.     }
  100.    
  101.     @Override
  102.     public boolean isIgnoraEccezioniNonGravi(){
  103.         return this.spcoopProperties.isIgnoraEccezioniNonGravi();
  104.     }
  105.    
  106.     @Override
  107.     public boolean isGenerazioneListaEccezioniErroreProcessamento(){
  108.         return this.spcoopProperties.isGenerazioneListaEccezioniErroreProcessamento();
  109.     }
  110.    
  111.    
  112.    
  113.    
  114.     /* *********** SOAP Fault della Porta (Protocollo, Porta Applicativa) ******************* */
  115.    
  116.     @Override
  117.     public boolean isGenerazioneDetailsFaultProtocollo_EccezioneValidazione(){
  118.         return this.spcoopProperties.isGenerazioneDetailsSOAPFaultProtocolValidazione();
  119.     }
  120.    
  121.     @Override
  122.     public boolean isGenerazioneDetailsFaultProtocollo_EccezioneProcessamento(){
  123.         return this.spcoopProperties.isGenerazioneDetailsSOAPFaultProtocolProcessamento();
  124.     }
  125.        
  126.     @Override
  127.     public boolean isGenerazioneDetailsFaultProtocolloConStackTrace(){
  128.         return this.spcoopProperties.isGenerazioneDetailsSOAPFaultProtocolWithStackTrace();
  129.     }
  130.    
  131.     @Override
  132.     public boolean isGenerazioneDetailsFaultProtocolloConInformazioniGeneriche(){
  133.         return this.spcoopProperties.isGenerazioneDetailsSOAPFaultProtocolConInformazioniGeneriche();
  134.     }
  135.    
  136.    
  137.    
  138.     /* *********** SOAP Fault della Porta (Integrazione, Porta Delegata) ******************* */
  139.    
  140.     @Override
  141.     public boolean isGenerazioneDetailsFaultIntegratione_erroreServer(){
  142.         return this.spcoopProperties.isGenerazioneDetailsSOAPFaultIntegrationServerError();
  143.     }
  144.    
  145.     @Override
  146.     public boolean isGenerazioneDetailsFaultIntegratione_erroreClient(){
  147.         return this.spcoopProperties.isGenerazioneDetailsSOAPFaultIntegrationClientError();
  148.     }
  149.    
  150.     @Override
  151.     public boolean isGenerazioneDetailsFaultIntegrationeConStackTrace(){
  152.         return this.spcoopProperties.isGenerazioneDetailsSOAPFaultIntegrationWithStackTrace();
  153.     }
  154.    
  155.     @Override
  156.     public FaultIntegrationGenericInfoMode getModalitaGenerazioneInformazioniGeneriche_DetailsFaultIntegrazione(){
  157.         Boolean value = this.spcoopProperties.isGenerazioneDetailsSOAPFaultIntegrazionConInformazioniGeneriche();
  158.         if(value==null){
  159.             return FaultIntegrationGenericInfoMode.SERVIZIO_APPLICATIVO;
  160.         }
  161.         else if(value){
  162.             return FaultIntegrationGenericInfoMode.ABILITATO;
  163.         }else{
  164.             return FaultIntegrationGenericInfoMode.DISABILITATO;
  165.         }
  166.     }
  167.    
  168.    
  169.    
  170.     /* *********** SOAP Fault della Porta (Generati dagli attori esterni) ******************* */
  171.    
  172.     @Override
  173.     public BooleanNullable isAggiungiDetailErroreApplicativo_FaultApplicativo() {
  174.         return this.spcoopProperties.isAggiungiDetailErroreApplicativo_SoapFaultApplicativo();
  175.     }

  176.     @Override
  177.     public BooleanNullable isAggiungiDetailErroreApplicativo_FaultPdD() {
  178.         return this.spcoopProperties.isAggiungiDetailErroreApplicativo_SoapFaultPdD();
  179.     }
  180.    
  181.    
  182.    
  183.    
  184.     /* *********** INTEGRAZIONE ******************* */
  185.    
  186.     @Override
  187.     public Map<String, String> buildIntegrationProperties(Busta busta,
  188.             boolean isRichiesta, TipoIntegrazione tipoIntegrazione)
  189.             throws ProtocolException {
  190.         // SPCoop non possiede informazioni aggiuntive di protocollo
  191.         return null;
  192.     }
  193.    
  194.     @Override
  195.     public OpenSPCoop2Message updateOpenSPCoop2MessageRequest(OpenSPCoop2Message msg, Busta busta,
  196.             IRegistryReader registryReader) throws ProtocolException{
  197.         return msg;
  198.     }
  199.    
  200.     @Override
  201.     public OpenSPCoop2Message updateOpenSPCoop2MessageResponse(OpenSPCoop2Message msg, Busta busta,
  202.             NotifierInputStreamParams notifierInputStreamParams,
  203.             TransportRequestContext transportRequestContext, TransportResponseContext transportResponseContext,
  204.             IRegistryReader registryReader,
  205.             boolean integration) throws ProtocolException{
  206.         return msg;
  207.     }
  208.    
  209.    
  210.    
  211.    
  212.    
  213.     /* *********** CONNETTORE ******************* */
  214.    
  215.     @Override
  216.     public boolean isStaticRoute()  throws ProtocolException{
  217.         return false;
  218.     }
  219.    
  220.     @Override
  221.     public org.openspcoop2.core.registry.Connettore getStaticRoute(IDSoggetto idSoggettoMittente, IDServizio idServizio,
  222.             IRegistryReader registryReader) throws ProtocolException{
  223.         return null;
  224.     }
  225.    
  226.     @Override
  227.     public boolean isSuccessfulHttpRedirectStatusCode(ServiceBinding serviceBinding) throws ProtocolException{
  228.         return false;
  229.     }
  230.    
  231.    
  232.    
  233.    
  234.     /* *********** ALTRO ******************* */
  235.    
  236.     @Override
  237.     public boolean isHttpEmptyResponseOneWay(){
  238.         return this.spcoopProperties.isHttpEmptyResponseOneWay();
  239.     }
  240.    
  241.     @Override
  242.     public Integer getHttpReturnCodeEmptyResponseOneWay(){
  243.         return this.spcoopProperties.getHttpReturnCodeEmptyResponseOneWay();
  244.     }
  245.    
  246.     @Override
  247.     public boolean isHttpOneWay_PD_HTTPEmptyResponse(){
  248.         return this.spcoopProperties.isHttpOneWay_PD_HTTPEmptyResponse();
  249.     }

  250.     @Override
  251.     public boolean isBlockedTransaction_responseMessageWithTransportCodeError(){
  252.         return this.spcoopProperties.isResponseMessageWithTransportCodeError_blockedTransaction();
  253.     }


  254. }