EsitoTransazioneName.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.protocol.sdk.constants;

  21. import java.io.Serializable;

  22. import org.openspcoop2.utils.Map;
  23. import org.openspcoop2.utils.MapKey;


  24. /**
  25.  * Contiene i possibili esiti
  26.  *
  27.  * @author apoli@link.it
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */

  31. public enum EsitoTransazioneName implements Serializable{

  32.     OK,
  33.     OK_PRESENZA_ANOMALIE,
  34.     MESSAGGI_NON_PRESENTI,
  35.     CONTROLLO_TRAFFICO_POLICY_VIOLATA_WARNING_ONLY,
  36.     CONTROLLO_TRAFFICO_MAX_THREADS_WARNING_ONLY,
  37.     HTTP_3xx,
  38.     CONSEGNA_MULTIPLA,
  39.     CONSEGNA_MULTIPLA_IN_CORSO,
  40.     CONSEGNA_MULTIPLA_COMPLETATA,
  41.    
  42.     ERRORE_APPLICATIVO,
  43.    
  44.     ERRORE_PROTOCOLLO,
  45.     ERRORE_CONNESSIONE_CLIENT_NON_DISPONIBILE,
  46.     ERRORE_PROCESSAMENTO_PDD_4XX,
  47.     ERRORE_PROCESSAMENTO_PDD_5XX,
  48.     AUTENTICAZIONE_FALLITA,
  49.     AUTORIZZAZIONE_FALLITA,
  50.     MESSAGGIO_NON_TROVATO,
  51.     ERRORE_INVOCAZIONE,
  52.     ERRORE_SERVER,
  53.     CONTENUTO_RICHIESTA_NON_RICONOSCIUTO,
  54.     CONTENUTO_RISPOSTA_NON_RICONOSCIUTO,
  55.     TOKEN_NON_PRESENTE,
  56.     ERRORE_AUTENTICAZIONE_TOKEN,
  57.     ERRORE_TOKEN,
  58.     ERRORE_AUTENTICAZIONE,
  59.     ERRORE_AUTORIZZAZIONE,
  60.     CONTROLLO_TRAFFICO_POLICY_VIOLATA,
  61.     CONTROLLO_TRAFFICO_MAX_THREADS,
  62.     ERRORE_SICUREZZA_MESSAGGIO_RICHIESTA,
  63.     ERRORE_SICUREZZA_MESSAGGIO_RISPOSTA,
  64.     ERRORE_ALLEGATI_MESSAGGIO_RICHIESTA,
  65.     ERRORE_ALLEGATI_MESSAGGIO_RISPOSTA,
  66.     ERRORE_CORRELAZIONE_APPLICATIVA_RICHIESTA,
  67.     ERRORE_CORRELAZIONE_APPLICATIVA_RISPOSTA,
  68.     HTTP_4xx,
  69.     HTTP_5xx,
  70.     ERRORE_VALIDAZIONE_RICHIESTA,
  71.     ERRORE_VALIDAZIONE_RISPOSTA,
  72.     ERRORE_SOSPENSIONE,
  73.     CORS_PREFLIGHT_REQUEST_VIA_GATEWAY,
  74.     CORS_PREFLIGHT_REQUEST_TRASPARENTE,
  75.     ERRORE_TRASFORMAZIONE_RICHIESTA,
  76.     ERRORE_TRASFORMAZIONE_RISPOSTA,
  77.     CONSEGNA_MULTIPLA_FALLITA,
  78.     API_NON_INDIVIDUATA,
  79.     OPERAZIONE_NON_INDIVIDUATA,
  80.     RICHIESTA_DUPLICATA,
  81.     RISPOSTA_DUPLICATA,
  82.     MESSAGE_BOX,
  83.     ERRORE_RESPONSE_TIMEOUT,
  84.     ERRORE_REQUEST_TIMEOUT,
  85.     ERRORE_CONNECTION_TIMEOUT,
  86.     ERRORE_NEGOZIAZIONE_TOKEN,
  87.     ERRORE_TRACCIAMENTO,
  88.    
  89.     CUSTOM;

  90.     private MapKey<String> mapKey;
  91.    
  92.     EsitoTransazioneName()
  93.     {
  94.         this.mapKey = Map.newMapKey("EsitoTransazioneName."+this.name());
  95.     }
  96.    
  97.     public MapKey<String> getMapKey() {
  98.         return this.mapKey;
  99.     }
  100.    
  101.     public static boolean isPddSpecific(EsitoTransazioneName esitoTransactionName){
  102.         if(!EsitoTransazioneName.OK.equals(esitoTransactionName)
  103.                 &&
  104.                 !isIntegrationManagerSpecific(esitoTransactionName)
  105.                 ){
  106.             return true;
  107.         }
  108.         return false;
  109.     }
  110.     public static  boolean isIntegrationManagerSpecific(EsitoTransazioneName esitoTransactionName){
  111.         if(EsitoTransazioneName.MESSAGGI_NON_PRESENTI.equals(esitoTransactionName) ||
  112.                 EsitoTransazioneName.MESSAGGIO_NON_TROVATO.equals(esitoTransactionName) ||
  113.                 EsitoTransazioneName.AUTENTICAZIONE_FALLITA.equals(esitoTransactionName) ||
  114.                 EsitoTransazioneName.AUTORIZZAZIONE_FALLITA.equals(esitoTransactionName)
  115.                 ){
  116.             return true;
  117.         }
  118.         return false;
  119.     }
  120.     public static  boolean isStatiConsegnaMultipla(EsitoTransazioneName esitoTransactionName){
  121.         // Stati successivi al primo stato
  122.         if(EsitoTransazioneName.CONSEGNA_MULTIPLA_IN_CORSO.equals(esitoTransactionName) ||
  123.                 EsitoTransazioneName.CONSEGNA_MULTIPLA_COMPLETATA.equals(esitoTransactionName) ||
  124.                 EsitoTransazioneName.CONSEGNA_MULTIPLA_FALLITA.equals(esitoTransactionName)
  125.                 ){
  126.             return true;
  127.         }
  128.         return false;
  129.     }
  130.     public static boolean isConsegnaMultipla(EsitoTransazioneName esitoTransactionName){
  131.         if(EsitoTransazioneName.CONSEGNA_MULTIPLA.equals(esitoTransactionName) ||
  132.                 EsitoTransazioneName.CONSEGNA_MULTIPLA_IN_CORSO.equals(esitoTransactionName) ||
  133.                 EsitoTransazioneName.CONSEGNA_MULTIPLA_COMPLETATA.equals(esitoTransactionName) ||
  134.                 EsitoTransazioneName.CONSEGNA_MULTIPLA_FALLITA.equals(esitoTransactionName)
  135.                 ){
  136.             return true;
  137.         }
  138.         return false;
  139.     }
  140.    
  141.     public static boolean isErroreRisposta(EsitoTransazioneName esitoTransactionName){
  142.         // Vedi anche gruppo in esiti.properties
  143.         if(EsitoTransazioneName.CONTENUTO_RISPOSTA_NON_RICONOSCIUTO.equals(esitoTransactionName) ||
  144.                 EsitoTransazioneName.ERRORE_ALLEGATI_MESSAGGIO_RISPOSTA.equals(esitoTransactionName) ||
  145.                 EsitoTransazioneName.ERRORE_CORRELAZIONE_APPLICATIVA_RISPOSTA.equals(esitoTransactionName) ||
  146.                 EsitoTransazioneName.ERRORE_SICUREZZA_MESSAGGIO_RISPOSTA.equals(esitoTransactionName) ||
  147.                 EsitoTransazioneName.ERRORE_VALIDAZIONE_RISPOSTA.equals(esitoTransactionName) ||
  148.                 EsitoTransazioneName.ERRORE_TRASFORMAZIONE_RISPOSTA.equals(esitoTransactionName) ||
  149.                 EsitoTransazioneName.RISPOSTA_DUPLICATA.equals(esitoTransactionName)
  150.                 ){
  151.             return true;
  152.         }
  153.         return false;
  154.     }
  155.    
  156.     public static boolean isSavedInMessageBox(EsitoTransazioneName esitoTransactionName){
  157.         if(EsitoTransazioneName.MESSAGE_BOX.equals(esitoTransactionName)){
  158.             return true;
  159.         }
  160.         return false;
  161.     }

  162.     public static EsitoTransazioneName convertoTo(String name){
  163.         EsitoTransazioneName esitoTransactionName = null;
  164.         try{
  165.             esitoTransactionName = EsitoTransazioneName.valueOf(name);
  166.         }catch(Exception e){
  167.             // ignore
  168.         }
  169.         if(esitoTransactionName==null){
  170.             esitoTransactionName = EsitoTransazioneName.CUSTOM;
  171.         }
  172.         return esitoTransactionName;
  173.     }
  174.    
  175.     public static String[] toEnumNameArray(){
  176.         String[] res = new String[EsitoTransazioneName.values().length];
  177.         int i=0;
  178.         for (EsitoTransazioneName tmp : EsitoTransazioneName.values()) {
  179.             res[i]=tmp.name();
  180.             i++;
  181.         }
  182.         return res;
  183.     }

  184.    
  185.     @Override
  186.     public String toString(){
  187.         return this.name();
  188.     }


  189. }