Imbustamento.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.engine.builder;

  21. import org.openspcoop2.core.id.IDSoggetto;
  22. import org.openspcoop2.message.OpenSPCoop2Message;
  23. import org.openspcoop2.protocol.sdk.Busta;
  24. import org.openspcoop2.protocol.sdk.Context;
  25. import org.openspcoop2.protocol.sdk.Integrazione;
  26. import org.openspcoop2.protocol.sdk.ProtocolException;
  27. import org.openspcoop2.protocol.sdk.ProtocolMessage;
  28. import org.openspcoop2.protocol.sdk.Trasmissione;
  29. import org.openspcoop2.protocol.sdk.builder.ProprietaManifestAttachments;
  30. import org.openspcoop2.protocol.sdk.constants.FaseImbustamento;
  31. import org.openspcoop2.protocol.sdk.constants.RuoloMessaggio;
  32. import org.openspcoop2.protocol.sdk.state.IState;
  33. import org.openspcoop2.utils.LoggerWrapperFactory;
  34. import org.slf4j.Logger;


  35. /**
  36.  * Classe utilizzata per costruire una Busta, o parti di essa.
  37.  *
  38.  *
  39.  * @author Poli Andrea (apoli@link.it)
  40.  * @author Tronci Fabio (tronci@link.it)
  41.  * @author Lorenzo Nardi (nardi@link.it)
  42.  * @author $Author$
  43.  * @version $Rev$, $Date$
  44.  */

  45. public class Imbustamento  {

  46.     /* ********  F I E L D S  P R I V A T I  ******** */

  47.     /** Logger utilizzato per debug. */
  48.     @SuppressWarnings("unused")
  49.     private Logger log = null;
  50.     private org.openspcoop2.protocol.sdk.IProtocolFactory<?> protocolFactory;
  51.     private IState state;
  52.    
  53.     public Imbustamento(Logger aLog, org.openspcoop2.protocol.sdk.IProtocolFactory<?> protocolFactory, IState state) throws ProtocolException{
  54.         if(aLog!=null)
  55.             this.log = aLog;
  56.         else
  57.             this.log = LoggerWrapperFactory.getLogger(Imbustamento.class);
  58.         this.protocolFactory = protocolFactory;
  59.         this.state = state;
  60.     }

  61.     public org.openspcoop2.protocol.sdk.IProtocolFactory<?> getProtocolFactory(){
  62.         return this.protocolFactory;
  63.     }

  64.     /** LunghezzaPrefisso */
  65.     public static int prefixLenght = 0;

  66.    
  67.     /* ********  Metodi per la costruzione di parti della busta  ******** */

  68.     //public String buildID(IDSoggetto idSoggetto, String idTransazione, Boolean isRichiesta) throws ProtocolException{
  69.     //  return this.buildID(idSoggetto, idTransazione, Configurazione.getAttesaAttiva(), Configurazione.getCheckInterval(), isRichiesta);
  70.     //}

  71.     public String buildID(IDSoggetto idSoggetto, String idTransazione, long attesaAttiva,
  72.             int checkInterval, RuoloMessaggio ruoloMessaggio) throws ProtocolException {
  73.         try{
  74.             return this.protocolFactory.createBustaBuilder(this.state).newID(idSoggetto, idTransazione, ruoloMessaggio);    
  75.         }catch(Exception e){
  76.             throw new ProtocolException(e.getMessage(),e);
  77.         }
  78.     }
  79.    



  80.     /* ----------------  Metodi per la costruzione di una busta  -------------------- */

  81.     public ProtocolMessage imbustamentoRichiesta(OpenSPCoop2Message msg,Context context,
  82.             Busta busta,
  83.             Integrazione integrazione,boolean gestioneManifest,boolean scartaBody,
  84.             ProprietaManifestAttachments proprietaManifestAttachments,
  85.             FaseImbustamento faseImbustamento) throws ProtocolException{    
  86.         return this._imbustamento(msg, context,
  87.                 busta, null,
  88.                 integrazione, gestioneManifest, RuoloMessaggio.RICHIESTA, scartaBody,
  89.                 proprietaManifestAttachments, faseImbustamento);
  90.     }
  91.     public ProtocolMessage imbustamentoRisposta(OpenSPCoop2Message msg,Context context,
  92.             Busta busta, Busta bustaRichiesta,
  93.             Integrazione integrazione,boolean gestioneManifest,boolean scartaBody,
  94.             ProprietaManifestAttachments proprietaManifestAttachments,
  95.             FaseImbustamento faseImbustamento) throws ProtocolException{    
  96.         return this._imbustamento(msg, context,
  97.                 busta, bustaRichiesta,
  98.                 integrazione, gestioneManifest, RuoloMessaggio.RISPOSTA, scartaBody,
  99.                 proprietaManifestAttachments, faseImbustamento);
  100.     }
  101.     public ProtocolMessage imbustamentoRisposta(OpenSPCoop2Message msg,Context context,
  102.             Busta busta,Busta bustaRichiesta,
  103.             Integrazione integrazione,ProprietaManifestAttachments proprietaManifestAttachments,
  104.             FaseImbustamento faseImbustamento) throws ProtocolException{    
  105.         return this._imbustamento(msg, context,
  106.                 busta, bustaRichiesta,
  107.                 integrazione, false, RuoloMessaggio.RISPOSTA, false,
  108.                 proprietaManifestAttachments,
  109.                 faseImbustamento);
  110.     }

  111.     private ProtocolMessage _imbustamento(OpenSPCoop2Message msg,Context context,
  112.             Busta busta,Busta bustaRichiesta,
  113.             Integrazione integrazione,boolean gestioneManifest,RuoloMessaggio ruoloMessaggio,boolean scartaBody,
  114.             ProprietaManifestAttachments proprietaManifestAttachments,
  115.             FaseImbustamento faseImbustamento) throws ProtocolException{    
  116.         if(proprietaManifestAttachments==null){
  117.             proprietaManifestAttachments = new ProprietaManifestAttachments();
  118.         }
  119.         proprietaManifestAttachments.setGestioneManifest(gestioneManifest);
  120.         proprietaManifestAttachments.setScartaBody(scartaBody);
  121.         return this.protocolFactory.createBustaBuilder(this.state).imbustamento(msg, context,
  122.                 busta, bustaRichiesta,
  123.                 ruoloMessaggio, proprietaManifestAttachments, faseImbustamento);
  124.     }


  125.     /**
  126.      * Metodo che si occupa di costruire un elemento Trasmissione
  127.      *
  128.      * @param trasmissione Trasmissione
  129.      *
  130.      */

  131.     public ProtocolMessage addTrasmissione(OpenSPCoop2Message message,Trasmissione trasmissione,boolean readQualifiedAttribute, FaseImbustamento faseImbustamento) throws ProtocolException{
  132.         return this.protocolFactory.createBustaBuilder(this.state).addTrasmissione(message, trasmissione, faseImbustamento);
  133.     }


  134. }