AbstractGestoreIntegrazionePDSoapWithRequestOutBC.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.OutRequestPDMessage;
  28. import org.openspcoop2.protocol.sdk.constants.TipoIntegrazione;

  29. /**
  30.  * Classe utilizzata per la ricezione di informazioni di integrazione
  31.  * dai servizi applicativi verso la porta di dominio.
  32.  *
  33.  * @author Poli Andrea (apoli@link.it)
  34.  * @author Lorenzo Nardi (nardi@link.it)
  35.  * @author $Author$
  36.  * @version $Rev$, $Date$
  37.  */
  38. public class AbstractGestoreIntegrazionePDSoapWithRequestOutBC extends AbstractGestoreIntegrazionePDSoapBC{

  39.    
  40.    
  41.     public AbstractGestoreIntegrazionePDSoapWithRequestOutBC(boolean openspcoop2) {
  42.         super(openspcoop2);
  43.     }

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

  92. }