HttpBaseEntity.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.utils.rest.entity;

  21. import java.util.ArrayList;
  22. import java.util.HashMap;
  23. import java.util.List;
  24. import java.util.Map;

  25. import org.openspcoop2.utils.transport.TransportUtils;
  26. import org.openspcoop2.utils.transport.http.HttpRequestMethod;

  27. /**
  28.  * HttpBaseEntity
  29.  *
  30.  *
  31.  * @author Poli Andrea (apoli@link.it)
  32.  * @author $Author$
  33.  * @version $Rev$, $Date$
  34.  */
  35. public abstract class HttpBaseEntity<T> {

  36.     private String url;
  37.     private HttpRequestMethod method;
  38.     private String contentType;

  39.     /* ---- Coppie nome/valori di invocazione inserite nell'header del trasporto --- */
  40.     private Map<String, List<String>> headers = new HashMap<>();
  41.     /* ---- Coppie nome/valori di invocazione form ----- */
  42.     //Solo nella richiesta: private Map<String, List<String>> parameters = new HashMap<>();
  43.     /* ---- Cookies ----- */
  44.     private List<Cookie> cookies = new ArrayList<>();
  45.    
  46.     private T content;
  47.    
  48.     public T getContent() {
  49.         return this.content;
  50.     }
  51.     public void setContent(T content) {
  52.         this.content = content;
  53.     }

  54.     public String getUrl() {
  55.         return this.url;
  56.     }
  57.     public void setUrl(String url) {
  58.         this.url = url;
  59.     }
  60.     public HttpRequestMethod getMethod() {
  61.         return this.method;
  62.     }
  63.     public void setMethod(HttpRequestMethod method) {
  64.         this.method = method;
  65.     }
  66.     public String getContentType() {
  67.         return this.contentType;
  68.     }
  69.     public void setContentType(String contentType) {
  70.         this.contentType = contentType;
  71.     }
  72.    
  73.     /*
  74.      * Solo nella richiesta
  75.     @Deprecated
  76.     public Map<String, String> getParametersForm() {
  77.         return TransportUtils.convertToMapSingleValue(this.parameters);
  78.     }
  79.     public Map<String, List<String>> getParameters(){
  80.         return this.parameters;
  81.     }
  82.     @Deprecated
  83.     public void setParametersForm(Map<String, String> parametersForm) {
  84.         this.parameters = TransportUtils.convertToMapListValues(parametersForm);
  85.     }
  86.     public void setParameters(Map<String, List<String>> parametersFormBased) {
  87.         this.parameters = parametersFormBased;
  88.     }
  89.     */
  90.    
  91.     @Deprecated
  92.     public Map<String, String> getParametersTrasporto() {
  93.         return TransportUtils.convertToMapSingleValue(this.headers);
  94.     }
  95.     public Map<String, List<String>> getHeaders(){
  96.         return this.headers;
  97.     }
  98.    
  99.     @Deprecated
  100.     public void setParametersTrasporto(Map<String, String> parametersTrasporto) {
  101.         this.headers = TransportUtils.convertToMapListValues(parametersTrasporto);
  102.     }
  103.     public void setHeaders(Map<String, List<String>> parametersFormBased) {
  104.         this.headers = parametersFormBased;
  105.     }
  106.    
  107.     public List<Cookie> getCookies() {
  108.         return this.cookies;
  109.     }
  110.     public void setCookies(List<Cookie> cookies) {
  111.         this.cookies = cookies;
  112.     }
  113. }