Problem.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.service.beans;

  21. import javax.validation.constraints.*;

  22. import io.swagger.v3.oas.annotations.media.Schema;
  23. import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  24. import com.fasterxml.jackson.annotation.JsonProperty;

  25. @JsonIgnoreProperties(ignoreUnknown = true)
  26. public class Problem   {
  27.  
  28.   @Schema(example = "https://tools.ietf.org/html/rfc7231#section-6.6.4", description = "An absolute URI that identifies the problem type.  When dereferenced, it SHOULD provide human-readable documentation for the problem type (e.g., using HTML). ")
  29.  /**
  30.    * An absolute URI that identifies the problem type.  When dereferenced, it SHOULD provide human-readable documentation for the problem type (e.g., using HTML).  
  31.   **/
  32.   private String type = "about:blank";
  33.  
  34.   @Schema(description = "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable ")
  35.  /**
  36.    * A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable  
  37.   **/
  38.   private String title = null;
  39.  
  40.   @Schema(example = "503", description = "The HTTP status code generated by the origin server for this occurrence of the problem. ")
  41.  /**
  42.    * The HTTP status code generated by the origin server for this occurrence of the problem.  
  43.   **/
  44.   private Integer status = null;
  45.  
  46.   @Schema(example = "Request took too long to complete.", description = "A human readable explanation specific to this occurrence of the problem. You MUST NOT expose internal informations, personal data or implementation details through this field. ")
  47.  /**
  48.    * A human readable explanation specific to this occurrence of the problem. You MUST NOT expose internal informations, personal data or implementation details through this field.  
  49.   **/
  50.   private String detail = null;
  51.  
  52.   @Schema(description = "An absolute URI that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced. ")
  53.  /**
  54.    * An absolute URI that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.  
  55.   **/
  56.   private String instance = null;
  57.  /**
  58.    * An absolute URI that identifies the problem type.  When dereferenced, it SHOULD provide human-readable documentation for the problem type (e.g., using HTML).
  59.    * @return type
  60.   **/
  61.   @JsonProperty("type")
  62.   public String getType() {
  63.     return this.type;
  64.   }

  65.   public void setType(String type) {
  66.     this.type = type;
  67.   }

  68.   public Problem type(String type) {
  69.     this.type = type;
  70.     return this;
  71.   }

  72.  /**
  73.    * A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable
  74.    * @return title
  75.   **/
  76.   @JsonProperty("title")
  77.   public String getTitle() {
  78.     return this.title;
  79.   }

  80.   public void setTitle(String title) {
  81.     this.title = title;
  82.   }

  83.   public Problem title(String title) {
  84.     this.title = title;
  85.     return this;
  86.   }

  87.  /**
  88.    * The HTTP status code generated by the origin server for this occurrence of the problem.
  89.    * minimum: 100
  90.    * maximum: 600
  91.    * @return status
  92.   **/
  93.   @JsonProperty("status")
  94.  @Min(100) @Max(600)  public Integer getStatus() {
  95.     return this.status;
  96.   }

  97.   public void setStatus(Integer status) {
  98.     this.status = status;
  99.   }

  100.   public Problem status(Integer status) {
  101.     this.status = status;
  102.     return this;
  103.   }

  104.  /**
  105.    * A human readable explanation specific to this occurrence of the problem. You MUST NOT expose internal informations, personal data or implementation details through this field.
  106.    * @return detail
  107.   **/
  108.   @JsonProperty("detail")
  109.   public String getDetail() {
  110.     return this.detail;
  111.   }

  112.   public void setDetail(String detail) {
  113.     this.detail = detail;
  114.   }

  115.   public Problem detail(String detail) {
  116.     this.detail = detail;
  117.     return this;
  118.   }

  119.  /**
  120.    * An absolute URI that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.
  121.    * @return instance
  122.   **/
  123.   @JsonProperty("instance")
  124.   public String getInstance() {
  125.     return this.instance;
  126.   }

  127.   public void setInstance(String instance) {
  128.     this.instance = instance;
  129.   }

  130.   public Problem instance(String instance) {
  131.     this.instance = instance;
  132.     return this;
  133.   }


  134.   @Override
  135.   public String toString() {
  136.     StringBuilder sb = new StringBuilder();
  137.     sb.append("class Problem {\n");
  138.    
  139.     sb.append("    type: ").append(Problem.toIndentedString(this.type)).append("\n");
  140.     sb.append("    title: ").append(Problem.toIndentedString(this.title)).append("\n");
  141.     sb.append("    status: ").append(Problem.toIndentedString(this.status)).append("\n");
  142.     sb.append("    detail: ").append(Problem.toIndentedString(this.detail)).append("\n");
  143.     sb.append("    instance: ").append(Problem.toIndentedString(this.instance)).append("\n");
  144.     sb.append("}");
  145.     return sb.toString();
  146.   }

  147.   /**
  148.    * Convert the given object to string with each line indented by 4 spaces
  149.    * (except the first line).
  150.    */
  151.   private static String toIndentedString(java.lang.Object o) {
  152.     if (o == null) {
  153.       return "null";
  154.     }
  155.     return o.toString().replace("\n", "\n    ");
  156.   }
  157. }