ProblemValidation.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.fault.jaxrs;

  21. import java.util.ArrayList;
  22. import java.util.List;
  23. /**
  24.  * ProblemValidation
  25.  *
  26.  * @author Poli Andrea (apoli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */
  30. public class ProblemValidation extends ProblemRFC7807 {
  31.    
  32.     public ProblemValidation() {}
  33.     public ProblemValidation(ProblemRFC7807 problem) {
  34.         super();
  35.         this.setDetail(problem.getDetail());
  36.         this.setInstance(problem.getInstance());
  37.         this.setStatus(problem.getStatus());
  38.         this.setType(problem.getType());
  39.         this.setTitle(problem.getTitle());
  40.         this.invalidParams = new ArrayList<ProblemValidation.InvalidParam>();
  41.     }
  42.    
  43.     public class InvalidParam {
  44.         private String name;
  45.         private String reason;
  46.         private String value;

  47.         public String getName() {
  48.             return this.name;
  49.         }
  50.         public void setName(String name) {
  51.             this.name = name;
  52.         }
  53.         public String getReason() {
  54.             return this.reason;
  55.         }
  56.         public void setReason(String reason) {
  57.             this.reason = reason;
  58.         }
  59.         public String getValue() {
  60.             return this.value;
  61.         }
  62.         public void setValue(String value) {
  63.             this.value = value;
  64.         }
  65.     }
  66.    
  67.     private List<InvalidParam> invalidParams;

  68.     public List<InvalidParam> getInvalidParams() {
  69.         return this.invalidParams;
  70.     }

  71.     public void setInvalidParams(List<InvalidParam> invalidParams) {
  72.         this.invalidParams = invalidParams;
  73.     }
  74.    
  75.     public void addInvalidParam(String name, String reason, Object value) {
  76.         InvalidParam ip = new InvalidParam();
  77.         ip.setName(name);
  78.         ip.setReason(reason);
  79.         ip.setValue(value != null ? value.toString() : null);
  80.         this.invalidParams.add(ip);
  81.     }
  82. }