ApiResponse.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.api;

  21. import java.io.Serializable;
  22. import java.util.ArrayList;
  23. import java.util.List;

  24. import org.openspcoop2.utils.beans.BaseBean;

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

  34.     /**
  35.      *
  36.      */
  37.     private static final long serialVersionUID = 1L;
  38.    
  39.     private static final int defaultHttpReturnCode = -2;
  40.     public static final int getDefaultHttpReturnCode() {
  41.         return defaultHttpReturnCode;
  42.     }
  43.     public static final boolean isDefaultHttpReturnCode(int value) {
  44.         return defaultHttpReturnCode==value;
  45.     }
  46.    
  47.     private String description;
  48.     private int httpReturnCode;
  49.    
  50.     private List<ApiCookieParameter> cookieParameters = new ArrayList<>();
  51.     private List<ApiHeaderParameter> headerParameters = new ArrayList<>();
  52.    
  53.     private List<ApiBodyParameter> bodyParameters = new ArrayList<>();
  54.    
  55.     public String getDescription() {
  56.         return this.description;
  57.     }
  58.     public void setDescription(String description) {
  59.         this.description = description;
  60.     }
  61.     public boolean isDefaultHttpReturnCode() {
  62.         return isDefaultHttpReturnCode(this.httpReturnCode);
  63.     }
  64.     public int getHttpReturnCode() {
  65.         return this.httpReturnCode;
  66.     }
  67.     public void setDefaultHttpReturnCode() {
  68.         this.httpReturnCode = getDefaultHttpReturnCode();
  69.     }
  70.     public void setHttpReturnCode(int httpReturnCode) {
  71.         this.httpReturnCode = httpReturnCode;
  72.     }
  73.    
  74.     public void addCookieParameter(ApiCookieParameter parameter) {
  75.         this.cookieParameters.add(parameter);
  76.     }

  77.     public ApiCookieParameter getCookieParameter(int index) {
  78.         return this.cookieParameters.get( index );
  79.     }

  80.     public ApiCookieParameter removeCookieParameter(int index) {
  81.         return this.cookieParameters.remove( index );
  82.     }

  83.     public List<ApiCookieParameter> getCookieParameters() {
  84.         return this.cookieParameters;
  85.     }

  86.     public void setCookieParameters(List<ApiCookieParameter> parameters) {
  87.         this.cookieParameters=parameters;
  88.     }

  89.     public int sizeCookieParameters() {
  90.         return this.cookieParameters.size();
  91.     }
  92.    
  93.    
  94.     public void addHeaderParameter(ApiHeaderParameter parameter) {
  95.         this.headerParameters.add(parameter);
  96.     }

  97.     public ApiHeaderParameter getHeaderParameter(int index) {
  98.         return this.headerParameters.get( index );
  99.     }

  100.     public ApiHeaderParameter removeHeaderParameter(int index) {
  101.         return this.headerParameters.remove( index );
  102.     }

  103.     public List<ApiHeaderParameter> getHeaderParameters() {
  104.         return this.headerParameters;
  105.     }

  106.     public void setHeaderParameters(List<ApiHeaderParameter> parameters) {
  107.         this.headerParameters=parameters;
  108.     }

  109.     public int sizeHeaderParameters() {
  110.         return this.headerParameters.size();
  111.     }
  112.    
  113.    
  114.     public void addBodyParameter(ApiBodyParameter parameter) {
  115.         this.bodyParameters.add(parameter);
  116.     }

  117.     public ApiBodyParameter getBodyParameter(int index) {
  118.         return this.bodyParameters.get( index );
  119.     }

  120.     public ApiBodyParameter removeBodyParameter(int index) {
  121.         return this.bodyParameters.remove( index );
  122.     }

  123.     public List<ApiBodyParameter> getBodyParameters() {
  124.         return this.bodyParameters;
  125.     }

  126.     public void setBodyParameters(List<ApiBodyParameter> parameters) {
  127.         this.bodyParameters=parameters;
  128.     }

  129.     public int sizeBodyParameters() {
  130.         return this.bodyParameters.size();
  131.     }
  132. }