BasicManager.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.basic.config;

  21. import java.util.HashMap;
  22. import java.util.Map;

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

  39. /**
  40.  * BasicManager
  41.  *
  42.  * @author Poli Andrea (apoli@link.it)
  43.  * @author $Author$
  44.  * @version $Rev$, $Date$
  45.  */
  46. public abstract class BasicManager extends BasicComponentFactory implements IProtocolManager {

  47.     public BasicManager(IProtocolFactory<?> protocolFactory) throws ProtocolException{
  48.         super(protocolFactory);
  49.     }
  50.    

  51.    
  52.     /* *********** VALIDAZIONE/GENERAZIONE BUSTE ******************* */
  53.    
  54.     @Override
  55.     public boolean isBustaServizio(Busta busta){
  56.         return false;
  57.     }
  58.    
  59.     @Override
  60.     public String getKeywordTipoMittenteSconosciuto(){
  61.         return "Sconosciuto";
  62.     }
  63.    
  64.     @Override
  65.     public String getKeywordMittenteSconosciuto(){
  66.         return "Sconosciuto";
  67.     }
  68.    
  69.     @Override
  70.     public long getIntervalloScadenzaBuste(){
  71.         return 7200;
  72.     }
  73.    
  74.     @Override
  75.     public boolean isGenerazioneElementiNonValidabiliRispettoXSD(){
  76.         return false;
  77.     }
  78.    
  79.     @Override
  80.     public boolean isIgnoraEccezioniNonGravi(){
  81.         return false;
  82.     }
  83.    
  84.     @Override
  85.     public boolean isGenerazioneListaEccezioniErroreProcessamento(){
  86.         return false;
  87.     }
  88.    
  89.    
  90.    
  91.    
  92.     /* *********** SOAP Fault della Porta (Protocollo, Porta Applicativa) ******************* */

  93.     @Override
  94.     public boolean isGenerazioneDetailsFaultProtocollo_EccezioneValidazione(){
  95.         return false;
  96.     }
  97.    
  98.     @Override
  99.     public boolean isGenerazioneDetailsFaultProtocollo_EccezioneProcessamento(){
  100.         return true;
  101.     }
  102.        
  103.     @Override
  104.     public boolean isGenerazioneDetailsFaultProtocolloConStackTrace(){
  105.         return false;
  106.     }
  107.    
  108.     @Override
  109.     public boolean isGenerazioneDetailsFaultProtocolloConInformazioniGeneriche(){
  110.         return true;
  111.     }
  112.    
  113.    
  114.     /* *********** SOAP Fault della Porta (Integrazione, Porta Delegata) ******************* */
  115.    
  116.     @Override
  117.     public boolean isGenerazioneDetailsFaultIntegratione_erroreServer(){
  118.         return true;
  119.     }
  120.    
  121.     @Override
  122.     public boolean isGenerazioneDetailsFaultIntegratione_erroreClient(){
  123.         return false;
  124.     }
  125.    
  126.     @Override
  127.     public boolean isGenerazioneDetailsFaultIntegrationeConStackTrace(){
  128.         return false;
  129.     }
  130.    
  131.     @Override
  132.     public FaultIntegrationGenericInfoMode getModalitaGenerazioneInformazioniGeneriche_DetailsFaultIntegrazione(){
  133.         return FaultIntegrationGenericInfoMode.SERVIZIO_APPLICATIVO;
  134.     }
  135.    
  136.    
  137.     /* *********** SOAP Fault della Porta (Generati dagli attori esterni) ******************* */
  138.    
  139.     @Override
  140.     public BooleanNullable isAggiungiDetailErroreApplicativo_FaultApplicativo(){
  141.         return BooleanNullable.NULL(); // default in govway.properties
  142.     }
  143.    
  144.     @Override
  145.     public BooleanNullable isAggiungiDetailErroreApplicativo_FaultPdD(){
  146.         return BooleanNullable.NULL(); // default in govway.properties
  147.     }
  148.    
  149.    
  150.    
  151.    
  152.    
  153.     /* *********** INTEGRAZIONE ******************* */
  154.    
  155.     @Override
  156.     public Map<String, String> buildIntegrationProperties(Busta busta,
  157.             boolean isRichiesta, TipoIntegrazione tipoIntegrazione)
  158.             throws ProtocolException {
  159.         if(busta!=null && busta.sizeProperties()>0){
  160.             Map<String, String> map = new HashMap<>();
  161.             String[]names = busta.getPropertiesNames();
  162.             for (int i = 0; i < names.length; i++) {
  163.                 String nomeProprieta = names[i];
  164.                 String valoreProprieta = busta.getProperty(nomeProprieta);
  165.                 if(TipoIntegrazione.TRASPORTO.equals(tipoIntegrazione)){
  166.                     // X- e' deprecato
  167.                     //map.put("X-"+busta.getProtocollo().toUpperCase()+"-"+nomeProprieta, valoreProprieta);
  168.                     // Il prefisso viene deciso da files di properties
  169.                     //map.put("GovWay-"+busta.getProtocollo().toUpperCase()+"-"+nomeProprieta, valoreProprieta);
  170.                     map.put(busta.getProtocollo().toUpperCase()+"-"+nomeProprieta, valoreProprieta);
  171.                 }else if(TipoIntegrazione.URL.equals(tipoIntegrazione)){
  172.                     map.put(busta.getProtocollo().toUpperCase()+nomeProprieta, valoreProprieta);
  173.                 }else{
  174.                     map.put(nomeProprieta, valoreProprieta);
  175.                 }
  176.             }
  177.             return map;
  178.         }
  179.         else{
  180.             return null;
  181.         }
  182.        
  183.     }
  184.    
  185.     @Override
  186.     public OpenSPCoop2Message updateOpenSPCoop2MessageRequest(OpenSPCoop2Message msg, Busta busta,
  187.             IRegistryReader registryReader) throws ProtocolException{
  188.         return msg;
  189.     }
  190.    
  191.     @Override
  192.     public OpenSPCoop2Message updateOpenSPCoop2MessageResponse(OpenSPCoop2Message msg, Busta busta,
  193.             NotifierInputStreamParams notifierInputStreamParams,
  194.             TransportRequestContext transportRequestContext, TransportResponseContext transportResponseContext,
  195.             IRegistryReader registryReader,
  196.             boolean integration) throws ProtocolException{
  197.         return msg;
  198.     }
  199.    
  200.    
  201.    
  202.    
  203.    
  204.     /* *********** CONNETTORE ******************* */
  205.    
  206.     @Override
  207.     public boolean isStaticRoute()  throws ProtocolException{
  208.         return false;
  209.     }
  210.    
  211.     @Override
  212.     public org.openspcoop2.core.registry.Connettore getStaticRoute(IDSoggetto idSoggettoMittente, IDServizio idServizio,
  213.             IRegistryReader registryReader) throws ProtocolException{
  214.         return null;
  215.     }
  216.    
  217.     @Override
  218.     public boolean isSuccessfulHttpRedirectStatusCode(ServiceBinding serviceBinding) throws ProtocolException{
  219.         return ServiceBinding.REST.equals(serviceBinding);
  220.     }
  221.    
  222.    
  223.    
  224.    
  225.    
  226.    
  227.     /* *********** ALTRO ******************* */
  228.    
  229.     @Override
  230.     public boolean isHttpEmptyResponseOneWay(){
  231.         return true;
  232.     }
  233.    
  234.     @Override
  235.     public Integer getHttpReturnCodeEmptyResponseOneWay(){
  236.         return 200;
  237.     }
  238.    
  239.     @Override
  240.     public boolean isHttpOneWay_PD_HTTPEmptyResponse(){
  241.         return true;
  242.     }
  243.    
  244.     @Override
  245.     public boolean isBlockedTransaction_responseMessageWithTransportCodeError(){
  246.         return false;
  247.     }
  248.    
  249.    
  250. }