DirectVMProtocolInfo.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.services;

  21. import org.openspcoop2.pdd.core.PdDContext;
  22. import org.openspcoop2.protocol.sdk.Busta;
  23. import org.openspcoop2.utils.Map;
  24. import org.openspcoop2.utils.MapKey;

  25. /**
  26.  * DirectVMProtocolInfo
  27.  *
  28.  * @author Andrea Poli (apoli@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */
  32. public class DirectVMProtocolInfo {

  33.     public static final MapKey<String> ID = Map.newMapKey("DirectVM-IDTransazione");
  34.     public static final MapKey<String> ID_MESSAGGIO_RICHIESTA = Map.newMapKey("DirectVM-IDMessaggioRichiesta");
  35.     public static final MapKey<String> ID_MESSAGGIO_RISPOSTA = Map.newMapKey("DirectVM-IDMessaggioRisposta");
  36.    
  37.     private String idTransazione;
  38.     private String idMessaggioRichiesta;
  39.     private String idMessaggioRisposta;
  40.    
  41.     public String getIdTransazione() {
  42.         return this.idTransazione;
  43.     }
  44.     public void setIdTransazione(String idTransazione) {
  45.         this.idTransazione = idTransazione;
  46.     }
  47.     public String getIdMessaggioRichiesta() {
  48.         return this.idMessaggioRichiesta;
  49.     }
  50.     public void setIdMessaggioRichiesta(String idMessaggioRichiesta) {
  51.         this.idMessaggioRichiesta = idMessaggioRichiesta;
  52.     }
  53.     public String getIdMessaggioRisposta() {
  54.         return this.idMessaggioRisposta;
  55.     }
  56.     public void setIdMessaggioRisposta(String idMessaggioRisposta) {
  57.         this.idMessaggioRisposta = idMessaggioRisposta;
  58.     }
  59.    
  60.    
  61.     public void setInfo(PdDContext pddContext){
  62.         if(this.idTransazione!=null){
  63.             pddContext.addObject(ID, this.idTransazione);
  64.         }
  65.         if(this.idMessaggioRichiesta!=null){
  66.             pddContext.addObject(ID_MESSAGGIO_RICHIESTA, this.idMessaggioRichiesta);
  67.         }
  68.         if(this.idMessaggioRisposta!=null){
  69.             pddContext.addObject(ID_MESSAGGIO_RISPOSTA, this.idMessaggioRisposta);
  70.         }
  71.     }
  72.    
  73.     public void setInfo(Busta busta){
  74.         if(this.idTransazione!=null){
  75.             busta.addProperty(ID.getValue(), this.idTransazione);
  76.         }
  77.         if(this.idMessaggioRichiesta!=null){
  78.             busta.addProperty(ID_MESSAGGIO_RICHIESTA.getValue(), this.idMessaggioRichiesta);
  79.         }
  80.         if(this.idMessaggioRisposta!=null){
  81.             busta.addProperty(ID_MESSAGGIO_RISPOSTA.getValue(), this.idMessaggioRisposta);
  82.         }
  83.     }
  84.    
  85.     public static void setInfoFromContext(PdDContext pddContext,Busta busta){
  86.        
  87.         Object oIdTransazione = pddContext.getObject(ID);
  88.         if(oIdTransazione!=null){
  89.             busta.addProperty(ID.getValue(), (String) oIdTransazione);
  90.         }
  91.        
  92.         Object oIdMessaggioRichiesta = pddContext.getObject(ID_MESSAGGIO_RICHIESTA);
  93.         if(oIdMessaggioRichiesta!=null){
  94.             busta.addProperty(ID_MESSAGGIO_RICHIESTA.getValue(), (String) oIdMessaggioRichiesta);
  95.         }
  96.        
  97.         Object oIdMessaggioRisposta = pddContext.getObject(ID_MESSAGGIO_RISPOSTA);
  98.         if(oIdMessaggioRisposta!=null){
  99.             busta.addProperty(ID_MESSAGGIO_RISPOSTA.getValue(), (String) oIdMessaggioRisposta);
  100.         }
  101.     }
  102. }