AbstractGestoreIntegrazionePASoapWithResponseOutBC.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.pdd.core.integrazione.backward_compatibility;


  21. import javax.xml.soap.SOAPHeaderElement;

  22. import org.openspcoop2.message.OpenSPCoop2Message;
  23. import org.openspcoop2.message.OpenSPCoop2SoapMessage;
  24. import org.openspcoop2.message.constants.ServiceBinding;
  25. import org.openspcoop2.pdd.core.integrazione.HeaderIntegrazione;
  26. import org.openspcoop2.pdd.core.integrazione.HeaderIntegrazioneException;
  27. import org.openspcoop2.pdd.core.integrazione.OutResponsePAMessage;
  28. import org.openspcoop2.protocol.sdk.constants.TipoIntegrazione;


  29. /**
  30.  * Classe utilizzata per la spedizione di informazioni di integrazione
  31.  * dalla porta di dominio verso i servizi applicativi.
  32.  *
  33.  * @author Poli Andrea (apoli@link.it)
  34.  * @author $Author$
  35.  * @version $Rev$, $Date$
  36.  */
  37. public abstract class AbstractGestoreIntegrazionePASoapWithResponseOutBC extends AbstractGestoreIntegrazionePASoapBC{

  38.    
  39.     public AbstractGestoreIntegrazionePASoapWithResponseOutBC(boolean openspcoop2) {
  40.         super(openspcoop2);
  41.     }

  42.     @Override
  43.     public void setOutResponseHeader(HeaderIntegrazione integrazione,
  44.             OutResponsePAMessage outResponsePAMessage) throws HeaderIntegrazioneException{
  45.        
  46.         try{
  47.             OpenSPCoop2Message msg = outResponsePAMessage.getMessage();
  48.             if(ServiceBinding.SOAP.equals(msg.getServiceBinding())==false){
  49.                 throw new Exception("Non utilizzabile con un Service Binding Rest");
  50.             }
  51.             OpenSPCoop2SoapMessage soapMsg = msg.castAsSoap();
  52.            
  53.             String protocollo = this.getProtocolFactory()!=null ? this.getProtocolFactory().getProtocol() : null;
  54.            
  55.             SOAPHeaderElement header = this.utilitiesResponseBC.buildHeader(integrazione,
  56.                     this.openspcoop2 ?
  57.                             this.openspcoopProperties.getHeaderSoapNameIntegrazione_backwardCompatibility_openspcoop2() :
  58.                             this.openspcoopProperties.getHeaderSoapNameIntegrazione_backwardCompatibility_openspcoop1() ,  // header name
  59.                     this.openspcoop2 ?
  60.                             this.openspcoopProperties.getHeaderSoapPrefixIntegrazione_backwardCompatibility_openspcoop2() :
  61.                             this.openspcoopProperties.getHeaderSoapPrefixIntegrazione_backwardCompatibility_openspcoop1()   ,  // prefix
  62.                     this.openspcoop2 ?
  63.                             this.openspcoopProperties.getHeaderSoapActorIntegrazione_backwardCompatibility_openspcoop2() :
  64.                             this.openspcoopProperties.getHeaderSoapActorIntegrazione_backwardCompatibility_openspcoop1(),  // namespace
  65.                     this.openspcoop2 ?
  66.                             this.openspcoopProperties.getHeaderSoapActorIntegrazione_backwardCompatibility_openspcoop2() :
  67.                             this.openspcoopProperties.getHeaderSoapActorIntegrazione_backwardCompatibility_openspcoop1(),  // actor
  68.                     soapMsg,
  69.                     this.openspcoop2 ?
  70.                             this.openspcoopProperties.getHeaderSoapExtProtocolInfoNomeElementoIntegrazione_backwardCompatibility_openspcoop2() :
  71.                             this.openspcoopProperties.getHeaderSoapExtProtocolInfoNomeElementoIntegrazione_backwardCompatibility_openspcoop1()  , // nomeElemento ExtInfoProtocol
  72.                     this.openspcoop2 ?
  73.                             this.openspcoopProperties.getHeaderSoapExtProtocolInfoNomeAttributoIntegrazione_backwardCompatibility_openspcoop2() :
  74.                             this.openspcoopProperties.getHeaderSoapExtProtocolInfoNomeAttributoIntegrazione_backwardCompatibility_openspcoop1() , // nomeAttributo ExtInfoProtocol
  75.                     this.getProtocolFactory().createProtocolManager().buildIntegrationProperties(outResponsePAMessage.getBustaRichiesta(), false, TipoIntegrazione.SOAP),
  76.                     protocollo
  77.                 );
  78.            
  79.             if(soapMsg.getSOAPHeader() == null){
  80.                 soapMsg.getSOAPPart().getEnvelope().addHeader();
  81.             }
  82.             soapMsg.addHeaderElement(soapMsg.getSOAPHeader(), header);
  83.            
  84.         }catch(Exception e){
  85.             throw new HeaderIntegrazioneException("GestoreIntegrazionePASoap, "+e.getMessage(),e);
  86.         }
  87.        
  88.     }
  89. }