GestoreIntegrazionePDWSAddressingWithRequestOut.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;

  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. /**
  26.  * Classe utilizzata per la ricezione di informazioni di integrazione
  27.  * dai servizi applicativi verso la porta di dominio.
  28.  *
  29.  * @author Poli Andrea (apoli@link.it)
  30.  * @author $Author$
  31.  * @version $Rev$, $Date$
  32.  */
  33. public class GestoreIntegrazionePDWSAddressingWithRequestOut extends GestoreIntegrazionePDWSAddressing{

  34.    
  35.    
  36.     @Override
  37.     public void setOutRequestHeader(HeaderIntegrazione integrazione,
  38.             OutRequestPDMessage outRequestPDMessage) throws HeaderIntegrazioneException{
  39.    
  40.         try{
  41.             OpenSPCoop2Message msg = outRequestPDMessage.getMessage();
  42.             if(ServiceBinding.SOAP.equals(msg.getServiceBinding())==false){
  43.                 throw new Exception("Non utilizzabile con un Service Binding Rest");
  44.             }
  45.             OpenSPCoop2SoapMessage soapMsg = msg.castAsSoap();
  46.            
  47.             if(soapMsg.getSOAPHeader() == null){
  48.                 soapMsg.getSOAPPart().getEnvelope().addHeader();
  49.             }
  50.            
  51.             if(integrazione.getBusta()!=null){
  52.                
  53.                 HeaderIntegrazioneBusta hBusta = integrazione.getBusta();
  54.                    
  55.                 if(hBusta.getDestinatario()!=null && hBusta.getServizio()!=null){
  56.                    
  57.                     // To
  58.                     SOAPHeaderElement wsaTO = UtilitiesIntegrazioneWSAddressing.buildWSATo(soapMsg,this.openspcoopProperties.getHeaderSoapActorIntegrazione()+"/wsa",
  59.                             hBusta.getTipoDestinatario(),hBusta.getDestinatario(),
  60.                             hBusta.getTipoServizio(), hBusta.getServizio(), hBusta.getVersioneServizio());
  61.                     soapMsg.addHeaderElement(soapMsg.getSOAPHeader(), wsaTO);
  62.                    
  63.                     // Action
  64.                     if(hBusta.getAzione()!=null){
  65.                         SOAPHeaderElement wsaAction = UtilitiesIntegrazioneWSAddressing.buildWSAAction(soapMsg,this.openspcoopProperties.getHeaderSoapActorIntegrazione()+"/wsa",
  66.                                 hBusta.getTipoDestinatario(),hBusta.getDestinatario(),
  67.                                 hBusta.getTipoServizio(), hBusta.getServizio(), hBusta.getVersioneServizio(), hBusta.getAzione());
  68.                         soapMsg.addHeaderElement(soapMsg.getSOAPHeader(), wsaAction);
  69.                     }
  70.                 }
  71.                
  72.                 if(hBusta.getMittente()!=null){
  73.                     SOAPHeaderElement wsaFROM = UtilitiesIntegrazioneWSAddressing.buildWSAFrom(soapMsg,this.openspcoopProperties.getHeaderSoapActorIntegrazione()+"/wsa",integrazione.getServizioApplicativo(),hBusta.getTipoMittente(),hBusta.getMittente());
  74.                     soapMsg.addHeaderElement(soapMsg.getSOAPHeader(), wsaFROM);
  75.                 }
  76.                    
  77.                 if(hBusta.getID()!=null){
  78.                     SOAPHeaderElement wsaID = UtilitiesIntegrazioneWSAddressing.buildWSAID(soapMsg,this.openspcoopProperties.getHeaderSoapActorIntegrazione()+"/wsa",hBusta.getID());
  79.                     soapMsg.addHeaderElement(soapMsg.getSOAPHeader(), wsaID);
  80.                 }
  81.                
  82.                 if(hBusta.getRiferimentoMessaggio()!=null || hBusta.getIdCollaborazione()!=null){
  83.                     String rif = hBusta.getRiferimentoMessaggio();
  84.                     if(rif==null){
  85.                         rif = hBusta.getIdCollaborazione();
  86.                     }
  87.                     SOAPHeaderElement wsaRelatesTo = UtilitiesIntegrazioneWSAddressing.buildWSARelatesTo(soapMsg,this.openspcoopProperties.getHeaderSoapActorIntegrazione()+"/wsa",rif);
  88.                     soapMsg.addHeaderElement(soapMsg.getSOAPHeader(), wsaRelatesTo);
  89.                 }
  90.             }
  91.            
  92.         }catch(Exception e){
  93.             throw new HeaderIntegrazioneException("GestoreIntegrazionePDWSAddressing, "+e.getMessage(),e);
  94.         }
  95.        
  96.     }


  97. }