DynamicInfo.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.dynamic;

  21. import java.util.List;
  22. import java.util.Map;

  23. import org.openspcoop2.message.OpenSPCoop2Message;
  24. import org.openspcoop2.pdd.core.PdDContext;
  25. import org.openspcoop2.pdd.core.connettori.ConnettoreMsg;
  26. import org.openspcoop2.protocol.sdk.Busta;
  27. import org.openspcoop2.protocol.sdk.Context;
  28. import org.openspcoop2.utils.transport.TransportRequestContext;
  29. import org.openspcoop2.utils.transport.TransportUtils;

  30. /**
  31.  * DynamicInfo
  32.  *
  33.  * @author Andrea Poli (apoli@link.it)
  34.  * @author $Author$
  35.  * @version $Rev$, $Date$
  36.  */
  37. public class DynamicInfo {

  38.     private Context pddContext;
  39.     private Busta busta;
  40.     private Map<String, List<String>> trasporto;
  41.     private Map<String, List<String>> queryParameters;
  42.     private Map<String, List<String>> formParameters;
  43.    
  44.     // non disponibili nel connettore
  45.     private String url;
  46.     private MessageContent messageContent;
  47.     private OpenSPCoop2Message message;
  48.     private ErrorHandler errorHandler;
  49.    
  50.     public DynamicInfo() {
  51.        
  52.     }
  53.     public DynamicInfo(ConnettoreMsg connettoreMsg, PdDContext pddContext) {
  54.         if(connettoreMsg!=null && connettoreMsg.getBusta()!=null) {
  55.             this.busta = connettoreMsg.getBusta();
  56.         }
  57.        
  58.         TransportRequestContext trasportRequestContext = null;
  59.         if(connettoreMsg!=null) {
  60.             trasportRequestContext = connettoreMsg.getTransportRequestContext();
  61.         }

  62.         if(trasportRequestContext!=null) {
  63.             this.trasporto = trasportRequestContext.getHeaders();
  64.         }
  65.         if(connettoreMsg!=null &&
  66.                 connettoreMsg.getPropertiesTrasporto()!=null && !connettoreMsg.getPropertiesTrasporto().isEmpty()) {
  67.             if(this.trasporto==null || this.trasporto.isEmpty()) {
  68.                 this.trasporto =  connettoreMsg.getPropertiesTrasporto();
  69.             }
  70.             else {
  71.                 Map<String, List<String>> mapNew = connettoreMsg.getPropertiesTrasporto();
  72.                 for (String name : mapNew.keySet()) {
  73.                     TransportUtils.removeObject(this.trasporto, name);
  74.                     this.trasporto.put(name, mapNew.get(name));
  75.                 }          
  76.             }
  77.         }
  78.        
  79.         if(trasportRequestContext!=null) {
  80.             this.queryParameters = trasportRequestContext.getParameters();
  81.         }
  82.         if(connettoreMsg!=null &&
  83.                 connettoreMsg.getPropertiesUrlBased()!=null && !connettoreMsg.getPropertiesUrlBased().isEmpty()) {
  84.             if(this.queryParameters==null || this.queryParameters.isEmpty()) {
  85.                 this.queryParameters =  connettoreMsg.getPropertiesUrlBased();
  86.             }
  87.             else {
  88.                 Map<String, List<String>> mapNew = connettoreMsg.getPropertiesUrlBased();
  89.                 for (String name : mapNew.keySet()) {
  90.                     TransportUtils.removeObject(this.queryParameters, name);
  91.                     this.queryParameters.put(name, mapNew.get(name));
  92.                 }          
  93.             }
  94.         }
  95.        
  96.         this.pddContext = pddContext;
  97.        
  98.         if(connettoreMsg!=null) {
  99.             this.url = connettoreMsg.getUrlInvocazionePorta();
  100.         }
  101.     }
  102.    
  103.     public Busta getBusta() {
  104.         return this.busta;
  105.     }
  106.     public void setBusta(Busta busta) {
  107.         this.busta = busta;
  108.     }
  109.     public Context getPddContext() {
  110.         return this.pddContext;
  111.     }
  112.     public void setPddContext(Context pddContext) {
  113.         this.pddContext = pddContext;
  114.     }
  115.     public Map<String, List<String>> getHeaders() {
  116.         return this.trasporto;
  117.     }
  118.     public void setHeaders(Map<String, List<String>> trasporto) {
  119.         this.trasporto = trasporto;
  120.     }
  121.     public Map<String, List<String>> getParameters() {
  122.         return this.queryParameters;
  123.     }
  124.     public void setParameters(Map<String, List<String>> queryParameters) {
  125.         this.queryParameters = queryParameters;
  126.     }
  127.     public Map<String, List<String>> getFormParameters() {
  128.         return this.formParameters;
  129.     }
  130.     public void setFormParameters(Map<String, List<String>> formParameters) {
  131.         this.formParameters = formParameters;
  132.     }
  133.     public String getUrl() {
  134.         return this.url;
  135.     }
  136.     public void setUrl(String url) {
  137.         this.url = url;
  138.     }
  139.     public MessageContent getMessageContent() {
  140.         return this.messageContent;
  141.     }
  142.     public void setMessageContent(MessageContent messageContent) {
  143.         this.messageContent = messageContent;
  144.     }
  145.     public OpenSPCoop2Message getMessage() {
  146.         return this.message;
  147.     }
  148.     public void setMessage(OpenSPCoop2Message message) {
  149.         this.message = message;
  150.     }
  151.     public ErrorHandler getErrorHandler() {
  152.         return this.errorHandler;
  153.     }
  154.     public void setErrorHandler(ErrorHandler errorHandler) {
  155.         this.errorHandler = errorHandler;
  156.     }
  157.    
  158. }