ValidazioneStatoPackageException.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.core.registry.driver;

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


  23. /**
  24.  * Contiene la definizione di una eccezione lanciata dal driver che gestisce il registro dei servizi
  25.  *
  26.  * @author Poli Andrea (apoli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */


  30. public class ValidazioneStatoPackageException extends Exception {
  31.    
  32.     private List<String> errori_validazione = new ArrayList<>();
  33.     private String tipoPackage = null;
  34.     private String stato = null;
  35.    
  36.      public ValidazioneStatoPackageException(String tipoPackage,String stato,String[] message, Throwable cause)
  37.     {
  38.         super(cause);
  39.        
  40.         if(message!=null){
  41.             for(int i=0; i<message.length; i++){
  42.                 this.errori_validazione.add(message[i]);
  43.             }
  44.         }
  45.         this.tipoPackage = tipoPackage;
  46.         this.stato = stato;

  47.         // TODO Auto-generated constructor stub
  48.     }
  49.     public ValidazioneStatoPackageException(Throwable cause)
  50.     {
  51.         super(cause);
  52.         // TODO Auto-generated constructor stub
  53.     }
  54.     /**
  55.      * serialVersionUID
  56.      */
  57.     private static final long serialVersionUID = 1L;
  58.    
  59.     public ValidazioneStatoPackageException() {
  60.         super();
  61.     }
  62.     public ValidazioneStatoPackageException(String tipoPackage,String stato,String[] msg) {
  63.         if(msg!=null){
  64.             for(int i=0; i<msg.length; i++){
  65.                 this.errori_validazione.add(msg[i]);
  66.             }
  67.         }
  68.         this.tipoPackage = tipoPackage;
  69.         this.stato = stato;
  70.     }
  71.    
  72.    
  73.     @Override
  74.     public String toString(){
  75.         return this.toString(" "," , ");
  76.     }
  77.     public String toString(String firstSeparator, String separator){
  78.         StringBuilder bf = new StringBuilder();
  79.         bf.append("Stato "+this.tipoPackage+" ["+this.stato+"] ");
  80.         bf.append("non utilizzabile");
  81.         bf.append(":");
  82.         bf.append(firstSeparator);
  83.         for(int i=0;i<this.errori_validazione.size();i++){
  84.             if(i>0)
  85.                 bf.append(separator);
  86.             bf.append(this.errori_validazione.get(i));
  87.         }
  88.         return bf.toString();
  89.     }
  90.    
  91.     @Override
  92.     public String getMessage() {
  93.         return this.toString();
  94.     }
  95.    
  96.     public void addErroreValidazione(String e){
  97.         this.errori_validazione.add(e);
  98.     }
  99.    
  100.     public int sizeErroriValidazione(){
  101.         return this.errori_validazione.size();
  102.     }
  103. }