EsitiProperties.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.utils;

  21. import java.util.ArrayList;
  22. import java.util.Enumeration;
  23. import java.util.HashMap;
  24. import java.util.List;
  25. import java.util.Properties;

  26. import org.apache.commons.lang.StringUtils;
  27. import org.openspcoop2.core.constants.CostantiLabel;
  28. import org.openspcoop2.protocol.sdk.IProtocolFactory;
  29. import org.openspcoop2.protocol.sdk.ProtocolException;
  30. import org.openspcoop2.protocol.sdk.builder.EsitoTransazione;
  31. import org.openspcoop2.protocol.sdk.constants.CostantiProtocollo;
  32. import org.openspcoop2.protocol.sdk.constants.EsitoTransazioneName;
  33. import org.openspcoop2.utils.BooleanNullable;
  34. import org.openspcoop2.utils.LoggerWrapperFactory;
  35. import org.openspcoop2.utils.Map;
  36. import org.openspcoop2.utils.MapKey;
  37. import org.openspcoop2.utils.resources.Loader;
  38. import org.openspcoop2.utils.resources.MapReader;
  39. import org.slf4j.Logger;

  40. /**
  41.  * Classe che gestisce il file di properties 'esiti.properties'
  42.  *
  43.  * @author Poli Andrea (apoli@link.it)
  44.  * @author $Author$
  45.  * @version $Rev$, $Date$
  46.  */
  47. public class EsitiProperties {

  48.     /** Logger utilizzato per errori eventuali. */
  49.     private Logger log = null;


  50.     /** Copia Statica */
  51.     private static Map<EsitiProperties> esitiPropertiesMap = null;

  52.     /* ********  F I E L D S  P R I V A T I  ******** */

  53.     /** Reader delle proprieta' impostate nel file 'esiti.properties' */
  54.     private EsitiInstanceProperties reader;


  55.    


  56.     /* ********  C O S T R U T T O R E  ******** */

  57.     private boolean erroreProtocollo = false;
  58.     public boolean isErroreProtocollo() {
  59.         return this.erroreProtocollo;
  60.     }
  61.     private boolean envelopeErroreProtocollo = false;
  62.     public boolean isEnvelopeErroreProtocollo() {
  63.         return this.envelopeErroreProtocollo;
  64.     }
  65.     private String labelErroreProtocollo = null;
  66.     private boolean faultEsterno = false;
  67.     public boolean isFaultEsterno() {
  68.         return this.faultEsterno;
  69.     }
  70.     private String labelFaultEsterno = null;
  71.     @SuppressWarnings("unused")
  72.     private String protocollo = null;
  73.    
  74.     protected static final MapKey<String> NO_PROTOCOL_CONFIG = CostantiLabel.NO_PROTOCOL_MAP_KEY;
  75.    
  76.     /**
  77.      * Viene chiamato in causa per istanziare il properties reader
  78.      *
  79.      *
  80.      */
  81.     private EsitiProperties(String confDir,Logger log, IProtocolFactory<?> pf) throws ProtocolException{

  82.         if(log != null)
  83.             this.log = log;
  84.         else
  85.             this.log = LoggerWrapperFactory.getLogger(EsitiProperties.class);

  86.         /* ---- Lettura del cammino del file di configurazione ---- */

  87.         Properties propertiesReader = new Properties();
  88.         java.io.InputStream properties = null;
  89.         try{  
  90.             properties = EsitiProperties.class.getResourceAsStream("/org/openspcoop2/protocol/utils/esiti.properties");
  91.             if(properties==null){
  92.                 throw new Exception("File '/org/openspcoop2/protocol/utils/esiti.properties' not found");
  93.             }
  94.             propertiesReader.load(properties);
  95.         }catch(Exception e) {
  96.             this.log.error("Riscontrato errore durante la lettura del file 'org/openspcoop2/protocol/utils/esiti.properties': "+e.getMessage());
  97.             throw new ProtocolException("EsitiProperties initialize error: "+e.getMessage(),e);
  98.         }finally{
  99.             try{
  100.                 if(properties!=null)
  101.                     properties.close();
  102.             }catch(Throwable er){
  103.                 // close
  104.             }
  105.         }
  106.         try{
  107.             this.reader = new EsitiInstanceProperties(confDir, propertiesReader, this.log);
  108.         }catch(Exception e){
  109.             throw new ProtocolException(e.getMessage(),e);
  110.         }
  111.        
  112.         if(pf==null) {
  113.             // Serve per la configurazione
  114.             this.erroreProtocollo = true;
  115.             this.envelopeErroreProtocollo = true;
  116.             this.faultEsterno = true;
  117.         }
  118.         else if(pf.getInformazioniProtocol()!=null) {
  119.             this.erroreProtocollo = pf.getInformazioniProtocol().isErrorProtocol();
  120.             this.envelopeErroreProtocollo = pf.getInformazioniProtocol().isEnvelopeErrorProtocol();
  121.             this.labelErroreProtocollo = pf.getInformazioniProtocol().getLabelErrorProtocol();
  122.             this.faultEsterno = pf.getInformazioniProtocol().isExternalFault();
  123.             this.labelFaultEsterno = pf.getInformazioniProtocol().getLabelExternalFault();
  124.             this.protocollo = pf.getProtocol();
  125.         }

  126.     }

  127.     /**
  128.      * Il Metodo si occupa di inizializzare il propertiesReader
  129.      *
  130.      *
  131.      */
  132.     public static synchronized void initialize(String confDir,Logger log,Loader loader, MapReader<String, IProtocolFactory<?>> protocols) throws ProtocolException{

  133.         if(EsitiProperties.esitiPropertiesMap==null){
  134.            
  135.             EsitiProperties.esitiPropertiesMap = new Map<EsitiProperties>();
  136.            
  137.             // Aggiungo configurazione speciale usato dal metodo org.openspcoop2.protocol.utils.EsitiConfigUtils
  138.             // e usata anche per validare il file di properties esiti.properties
  139.             EsitiProperties esitiProperties = new EsitiProperties(confDir,log,null);
  140.             esitiProperties.validaConfigurazione(loader);
  141.             EsitiProperties.esitiPropertiesMap.put(CostantiLabel.NO_PROTOCOL_MAP_KEY, esitiProperties);
  142.            
  143.             if(protocols==null) {
  144.                 return;
  145.             }
  146.             Enumeration<String> enP = protocols.keys();
  147.             while (enP.hasMoreElements()) {
  148.                 String protocol = (String) enP.nextElement();
  149.                 IProtocolFactory<?> pf = protocols.get(protocol);
  150.                
  151.                 EsitiProperties esitiPropertiesByProtocol = new EsitiProperties(confDir,log,pf);
  152.                
  153.                 // init reader
  154.                
  155.                 esitiPropertiesByProtocol.initEsitiCodeSenzaFiltri();
  156.                 esitiPropertiesByProtocol.initEsitiCode();
  157.                 esitiPropertiesByProtocol.initEsitiCodeOk();
  158.                 esitiPropertiesByProtocol.initEsitiCodeOk_senzaFaultApplicativo();
  159.                 esitiPropertiesByProtocol.initEsitiCodeKo();
  160.                 esitiPropertiesByProtocol.initEsitiCodeKo_senzaFaultApplicativo();
  161.                 esitiPropertiesByProtocol.initEsitiCodeFaultApplicativo();
  162.                
  163.                 esitiPropertiesByProtocol.initEsitiCodeRichiestaScartate();
  164.                 esitiPropertiesByProtocol.initEsitiCodeErroriConsegna();
  165.                 esitiPropertiesByProtocol.initEsitiCodeAutorizzazioneNegata();
  166.                 esitiPropertiesByProtocol.initEsitiCodeControlloTrafficoPolicyViolate();
  167.                 esitiPropertiesByProtocol.initEsitiCodeServizioIntegrationManager();
  168.                 esitiPropertiesByProtocol.initEsitiCodeErroriProcessamentoRichiesta();
  169.                 esitiPropertiesByProtocol.initEsitiCodeErroriProcessamentoRisposta();
  170.                 esitiPropertiesByProtocol.initEsitiCodeErroriClientNonDisponibile();
  171.                 esitiPropertiesByProtocol.initEsitiCodeErroriGenerici();
  172.                 esitiPropertiesByProtocol.initEsitiCodeForSoapFaultIdentificationMode();
  173.                 esitiPropertiesByProtocol.initEsitiCodeForContextPropertyIdentificationMode();
  174.                 esitiPropertiesByProtocol.initEsitiCodeOrderLabel();
  175.                 esitiPropertiesByProtocol.initEsitiOrderLabel();
  176.                
  177.                 esitiPropertiesByProtocol.initEsitoName();
  178.                 esitiPropertiesByProtocol.initEsitoDescription();
  179.                 esitiPropertiesByProtocol.initEsitoLabel();
  180.                 esitiPropertiesByProtocol.initEsitoLabelSyntetic();
  181.                 esitiPropertiesByProtocol.initEsitoIdentificationMode();
  182.                 esitiPropertiesByProtocol.initEsitoIdentificationModeSoapFaultList();
  183.                 esitiPropertiesByProtocol.initEsitoIdentificationModeContextPropertyList();
  184.                
  185.                 EsitoTransazioneName[] esiti = EsitoTransazioneName.values();
  186.                 for (EsitoTransazioneName esitoTransazioneName : esiti) {
  187.                    
  188.                     if(EsitoTransazioneName.ERRORE_PROTOCOLLO.equals(esitoTransazioneName) && !esitiPropertiesByProtocol.erroreProtocollo){
  189.                         continue;
  190.                     }
  191.                     else if(EsitoTransazioneName.ERRORE_SERVER.equals(esitoTransazioneName) && !esitiPropertiesByProtocol.faultEsterno){
  192.                         continue;
  193.                     }
  194.                     else if(EsitoTransazioneName.CUSTOM.equals(esitoTransazioneName)) {
  195.                         continue;
  196.                     }
  197.                    
  198.                     int code = esitiPropertiesByProtocol.convertoToCode(esitoTransazioneName);
  199.                     esitiPropertiesByProtocol.initMapEsitoTransazione(esitoTransazioneName, code, CostantiProtocollo.ESITO_TRANSACTION_CONTEXT_STANDARD);  
  200.                 }
  201.                
  202.                 esitiPropertiesByProtocol.initEsitiTransactionContextCode();
  203.                 esitiPropertiesByProtocol.initEsitiTransactionContextCodeOrderLabel();
  204.                 esitiPropertiesByProtocol.initEsitiTransactionContextOrderLabel();
  205.                 esitiPropertiesByProtocol.initEsitoTransactionContextLabel();
  206.                 esitiPropertiesByProtocol.initEsitoTransactionContextDefault();
  207.                 esitiPropertiesByProtocol.initEsitoTransactionContextHeaderTrasportoName();
  208.                 esitiPropertiesByProtocol.initEsitoTransactionContextFormBasedPropertyName();
  209.                 esitiPropertiesByProtocol.initEsitoTransactionContextHeaderTrasportoDynamicIdentification();
  210.                 esitiPropertiesByProtocol.initEsitoTransactionContextHeaderFormBasedDynamicIdentification();
  211.                
  212.                 // init mappa delle protocol factory
  213.                 EsitiProperties.esitiPropertiesMap.put(ProtocolUtils.protocolToMapKey(protocol), esitiPropertiesByProtocol);
  214.             }
  215.                        
  216.         }

  217.     }

  218.     public static boolean isInitializedProtocol(MapKey<String> protocol) {
  219.         return EsitiProperties.esitiPropertiesMap!=null && EsitiProperties.esitiPropertiesMap.containsKey(protocol);
  220.     }
  221.    
  222.     /**
  223.      * Ritorna l'istanza di questa classe
  224.      *
  225.      * @return Istanza di OpenSPCoopProperties
  226.      * @throws Exception
  227.      *
  228.      */
  229.     public static EsitiProperties getInstanceFromProtocolName(Logger log,String protocol) throws ProtocolException{
  230.         return getInstance(log,ProtocolUtils.protocolToMapKey(protocol));
  231.     }
  232.     public static EsitiProperties getInstance(Logger log,IProtocolFactory<?> protocol) throws ProtocolException{
  233.         return getInstance(log,protocol.getProtocolMapKey());
  234.     }
  235.     public static EsitiProperties getInstance(Logger log,MapKey<String> protocol) throws ProtocolException{

  236.         if(EsitiProperties.esitiPropertiesMap==null)
  237.             throw new ProtocolException("EsitiProperties not initialized (use init method in factory)");

  238.         return EsitiProperties.esitiPropertiesMap.get(protocol);
  239.     }




  240.     public void validaConfigurazione(Loader loader) throws ProtocolException  {
  241.         try{  

  242.             List<Integer> codes = getEsitiCode();
  243.                        
  244.             getEsitiCodeOrderLabel();
  245.            
  246.             List<String> labelCheck = new ArrayList<>();
  247.             List<String> nameCheck = new ArrayList<>();
  248.            
  249.             for (Integer codeEsito : codes) {
  250.                
  251.                 String esitoName = getEsitoName(codeEsito);
  252.                 if(nameCheck.contains(esitoName)){
  253.                     throw new ProtocolException("Esito name ["+esitoName+"] already defined");
  254.                 }else{
  255.                     nameCheck.add(esitoName);
  256.                 }
  257.                
  258.                 getEsitoDescription(codeEsito);
  259.                
  260.                 String esitoLabel = getEsitoLabel(codeEsito);
  261.                 if(labelCheck.contains(esitoLabel)){
  262.                     throw new ProtocolException("Esito label ["+esitoLabel+"] already defined");
  263.                 }else{
  264.                     labelCheck.add(esitoLabel);
  265.                 }
  266.                
  267.                 EsitoIdentificationMode mode = getEsitoIdentificationMode(codeEsito);
  268.                 if(EsitoIdentificationMode.SOAP_FAULT.equals(mode)){
  269.                     getEsitoIdentificationModeSoapFaultList(codeEsito);
  270.                 }
  271.                 else if(EsitoIdentificationMode.CONTEXT_PROPERTY.equals(mode)){
  272.                     getEsitoIdentificationModeContextPropertyList(codeEsito);
  273.                 }
  274.             }
  275.                
  276.             List<Integer> codesOk = getEsitiCodeOk();
  277.             getEsitiCodeKo(); // ottenuto come diff tra esiti e esiti ok
  278.             for (Integer codeEsitoOk : codesOk) {
  279.                 boolean found = false;
  280.                 for (Integer codeEsito : codes) {
  281.                     if(codeEsitoOk.intValue() == codeEsito.intValue()){
  282.                         found = true;
  283.                         break;
  284.                     }
  285.                 }
  286.                 if(!found){
  287.                     throw new ProtocolException("Code 'ok' ["+codeEsitoOk+"] not defined in codes");
  288.                 }
  289.             }
  290.            
  291.             List<String> tipi = getEsitiTransactionContextCode();
  292.            
  293.             getEsitiTransactionContextCodeOrderLabel();
  294.            
  295.             labelCheck = new ArrayList<>();
  296.            
  297.             for (String tipo : tipi) {
  298.                 String tipoLabel = getEsitoTransactionContextLabel(tipo);
  299.                 if(labelCheck.contains(tipoLabel)){
  300.                     throw new ProtocolException("Transaction Context Label ["+tipoLabel+"] already defined");
  301.                 }else{
  302.                     labelCheck.add(tipoLabel);
  303.                 }
  304.             }
  305.            
  306.             // Validazione tipi e context built-in che esistano nel file esiti.properties
  307.             EsitoTransazioneName [] codeNames = EsitoTransazioneName.values();
  308.             for (int i = 0; i < codeNames.length; i++) {
  309.                 if(!EsitoTransazioneName.CUSTOM.equals(codeNames[i])){
  310.                     this.convertoToCode(codeNames[i]);
  311.                 }
  312.             }
  313.             if(this.getEsitiTransactionContextCode().contains(CostantiProtocollo.ESITO_TRANSACTION_CONTEXT_STANDARD)==false){
  314.                 throw new ProtocolException("Required TipoContext ["+CostantiProtocollo.ESITO_TRANSACTION_CONTEXT_STANDARD+"] undefined");
  315.             }
  316.            
  317.             // Altri init
  318.            
  319.             getEsitiOrderLabel();
  320.            
  321.             getEsitiTransactionContextOrderLabel();
  322.            
  323.             getEsitoTransactionContextDefault();
  324.            
  325.            
  326.         }catch(java.lang.Exception e) {
  327.             String msg = "Riscontrato errore durante la validazione della proprieta' degli esiti, "+e.getMessage();
  328.             this.log.error(msg,e);
  329.             throw new ProtocolException(msg,e);
  330.         }
  331.     }

  332.    
  333.    
  334.     /* **** CONVERTER **** */
  335.     public EsitoTransazioneName getEsitoTransazioneName(Integer cod) throws ProtocolException{
  336.         return EsitoTransazioneName.convertoTo(this.getEsitoName(cod));
  337.     }
  338.     public List<EsitoTransazione> getListEsitoTransazioneFromFilter(Integer codeParam, String tipoContextParam) throws ProtocolException{
  339.         List<EsitoTransazione> list = new ArrayList<EsitoTransazione>();
  340.        
  341.         if(codeParam==null){
  342.             // *
  343.             List<Integer> codes = this.getEsitiCode();
  344.             for (Integer codeEsito : codes) {
  345.                
  346.                 if(tipoContextParam==null){
  347.                     // **
  348.                     List<String> tipiContext = this.getEsitiTransactionContextCode();
  349.                     for (String tipo : tipiContext) {
  350.                         list.add(new EsitoTransazione(this.getEsitoTransazioneName(codeEsito),codeEsito,tipo));
  351.                     }
  352.                 }
  353.                 else{
  354.                     list.add(new EsitoTransazione(this.getEsitoTransazioneName(codeEsito),codeEsito,tipoContextParam));
  355.                 }
  356.                
  357.             }
  358.         }
  359.         else{
  360.             if(tipoContextParam==null){
  361.                 // **
  362.                 List<String> tipiContext = this.getEsitiTransactionContextCode();
  363.                 for (String tipo : tipiContext) {
  364.                     list.add(new EsitoTransazione(this.getEsitoTransazioneName(codeParam),codeParam,tipo));
  365.                 }
  366.             }
  367.             else{
  368.                 list.add(new EsitoTransazione(this.getEsitoTransazioneName(codeParam),codeParam,tipoContextParam));
  369.             }
  370.         }
  371.        
  372.         return list;
  373.     }
  374.    
  375.     public  EsitoTransazione convertToEsitoTransazione(Integer code, String tipoContext) throws ProtocolException{
  376.         if(code==null){
  377.             throw new ProtocolException("Code ["+code+"] undefined");
  378.         }
  379.         if(existsEsitoCode(code)==false){
  380.             throw new ProtocolException("Code ["+tipoContext+"] unsupported");
  381.         }
  382.         String name = this.getEsitoName(code);
  383.         if(name==null){
  384.             throw new ProtocolException("Name for esito code ["+code+"] undefined");
  385.         }
  386.         EsitoTransazioneName nameEnum = EsitoTransazioneName.convertoTo(name);
  387.         return convertToEsitoTransazione(nameEnum, code, tipoContext);
  388.     }
  389.     private Map<EsitoTransazione> mapEsitoTransazione = new Map<EsitoTransazione>();
  390.     private synchronized void initMapEsitoTransazione(EsitoTransazioneName esito,Integer code, String tipoContext) throws ProtocolException {
  391.         if(!this.mapEsitoTransazione.containsKey(esito.getMapKey())) {
  392.             EsitoTransazione et = _convertToEsitoTransazione(esito,code, tipoContext);
  393.             this.mapEsitoTransazione.put(esito.getMapKey(), et);
  394.         }
  395.     }
  396.     public  EsitoTransazione convertToEsitoTransazione(EsitoTransazioneName esito, String tipoContext) throws ProtocolException{
  397.         if( (!EsitoTransazioneName.CUSTOM.equals(esito))
  398.                 &&
  399.                 (this.isSingleTransactionContextCode() || CostantiProtocollo.ESITO_TRANSACTION_CONTEXT_STANDARD.equals(tipoContext))
  400.             ) {
  401.             if(!this.mapEsitoTransazione.containsKey(esito.getMapKey())) {
  402.                 initMapEsitoTransazione(esito, this.convertoToCode(esito), tipoContext);
  403.             }
  404.             return this.mapEsitoTransazione.get(esito.getMapKey());
  405.         }
  406.         else {
  407.             return _convertToEsitoTransazione(esito, tipoContext);
  408.         }
  409.     }
  410.     public  EsitoTransazione convertToEsitoTransazione(EsitoTransazioneName esito,Integer code, String tipoContext) throws ProtocolException{
  411.         if( (!EsitoTransazioneName.CUSTOM.equals(esito))
  412.                 &&
  413.                 (this.isSingleTransactionContextCode() || CostantiProtocollo.ESITO_TRANSACTION_CONTEXT_STANDARD.equals(tipoContext))
  414.             ) {
  415.             if(!this.mapEsitoTransazione.containsKey(esito.getMapKey())) {
  416.                 initMapEsitoTransazione(esito, code, tipoContext);
  417.             }
  418.             return this.mapEsitoTransazione.get(esito.getMapKey());
  419.         }
  420.         else {
  421.             return _convertToEsitoTransazione(esito, code, tipoContext);
  422.         }
  423.     }
  424.     private  EsitoTransazione _convertToEsitoTransazione(EsitoTransazioneName esito, String tipoContext) throws ProtocolException{
  425.         return convertToEsitoTransazione(esito, this.convertoToCode(esito), tipoContext);
  426.     }
  427.     private  EsitoTransazione _convertToEsitoTransazione(EsitoTransazioneName esito,Integer code, String tipoContext) throws ProtocolException{
  428.        
  429.         if(esito==null){
  430.             throw new ProtocolException("EsitoTransazioneName ["+code+"] undefined");
  431.         }
  432.        
  433.         if(code==null){
  434.             throw new ProtocolException("Code ["+code+"] undefined");
  435.         }
  436.         if(existsEsitoCode(code)==false){
  437.             throw new ProtocolException("Code ["+tipoContext+"] unsupported");
  438.         }
  439.        
  440.         if(tipoContext==null){
  441.             throw new ProtocolException("TipoContext ["+code+"] undefined");
  442.         }
  443.         if(this.getEsitiTransactionContextCode().contains(tipoContext)==false){
  444.             throw new ProtocolException("TipoContext ["+tipoContext+"] unsupported");
  445.         }
  446.        
  447.         return new EsitoTransazione(esito, code, tipoContext);
  448.     }
  449.    
  450.     public Integer convertoToCode(EsitoTransazioneName esito) throws ProtocolException{
  451.         Integer code = null;
  452.         List<Integer> codes = getEsitiCode();
  453.         for (Integer codeEsito : codes) {
  454.             String name = this.getEsitoName(codeEsito);
  455.             if(name.equals(esito.name())){
  456.                 code = codeEsito;
  457.                 break;
  458.             }
  459.         }
  460.         if(code==null){
  461.             throw new ProtocolException("Code ["+esito+"] undefined");
  462.         }
  463.         return code;
  464.     }
  465.    
  466.     public Integer convertLabelToCode(String label) throws ProtocolException{
  467.         List<Integer> codes = getEsitiCode();
  468.         for (Integer codeEsito : codes) {
  469.             String labelCheck = this.getEsitoLabel(codeEsito);
  470.             if(labelCheck.equals(label)){
  471.                 return codeEsito;
  472.             }
  473.         }
  474.         throw new ProtocolException("Not exists esito code with label ["+label+"]");
  475.     }
  476.    
  477.     public Integer convertNameToCode(String name) throws ProtocolException{
  478.         List<Integer> codes = getEsitiCodeSenzaFiltri();
  479.         for (Integer codeEsito : codes) {
  480.             String nameCheck = this.getEsitoName(codeEsito);
  481.             if(nameCheck.equals(name)){
  482.                 return codeEsito;
  483.             }
  484.         }
  485.         throw new ProtocolException("Not exists esito code with name ["+name+"]");
  486.     }
  487.    
  488.     public boolean existsEsitoCode(Integer code) throws ProtocolException{
  489.         if(code==null) {
  490.             return false;
  491.         }
  492.         List<Integer> codes = getEsitiCode();
  493.         for (Integer codeEsito : codes) {
  494.             if(codeEsito.intValue() == code.intValue()){
  495.                 return true;
  496.             }
  497.         }
  498.         return false;
  499.     }
  500.    
  501.     public String convertLabelToContextTypeCode(String label) throws ProtocolException{
  502.         List<String> codes = getEsitiTransactionContextCode();
  503.         for (String codeTransactionContext : codes) {
  504.             String labelCheck = this.getEsitoTransactionContextLabel(codeTransactionContext);
  505.             if(labelCheck.equals(label)){
  506.                 return codeTransactionContext;
  507.             }
  508.         }
  509.         throw new ProtocolException("Not exists context type with label ["+label+"]");
  510.     }
  511.    

  512.    
  513.    
  514.     /* **** LIBRERIA **** */

  515.     private List<Integer> filterByProtocol(List<Integer> esitiCode) throws ProtocolException {
  516.         List<Integer> esitiCodeNew = new ArrayList<>();
  517.         int codeErroreProtocollo = this.convertNameToCode(EsitoTransazioneName.ERRORE_PROTOCOLLO.name());
  518.         int codeFaultPdd = this.convertNameToCode(EsitoTransazioneName.ERRORE_SERVER.name());
  519.        
  520.         //System.out.println("["+this.protocollo+"] ["+this.erroreProtocollo+"]("+this.labelErroreProtocollo+") ["+this.faultEsterno+"]("+this.labelFaultEsterno+") listaOriginale["+esitiCode+"]");
  521.        
  522.         for (Integer esito : esitiCode) {
  523.             if(esito.intValue() == codeErroreProtocollo) {
  524.                 if(this.erroreProtocollo==false) {
  525.                     continue;
  526.                 }
  527.             }
  528.             if(esito.intValue() == codeFaultPdd) {
  529.                 if(this.faultEsterno==false) {
  530.                     continue;
  531.                 }
  532.             }
  533.             esitiCodeNew.add(esito);
  534.         }
  535.        
  536.         //System.out.println("["+this.protocollo+"] ["+this.erroreProtocollo+"]("+this.labelErroreProtocollo+") ["+this.faultEsterno+"]("+this.labelFaultEsterno+") listaFiltrata["+esitiCodeNew+"]");
  537.        
  538.         return esitiCodeNew;
  539.     }
  540.    
  541.     private String filterByProtocol(String label, int code) throws ProtocolException {
  542.         int codeErroreProtocollo = this.convertNameToCode(EsitoTransazioneName.ERRORE_PROTOCOLLO.name());
  543.         int codeFaultPdd = this.convertNameToCode(EsitoTransazioneName.ERRORE_SERVER.name());
  544.        
  545.         if(code == codeErroreProtocollo) {
  546.             if(this.erroreProtocollo && this.labelErroreProtocollo!=null) {
  547.                 return this.labelErroreProtocollo;
  548.             }
  549.         }
  550.         if(code == codeFaultPdd) {
  551.             if(this.faultEsterno && this.labelFaultEsterno!=null) {
  552.                 return this.labelFaultEsterno;
  553.             }
  554.         }

  555.         return label;
  556.     }
  557.    
  558.     private List<Integer> esitiCodeSenzaFiltri = null;
  559.     public List<Integer> getEsitiCodeSenzaFiltri() throws ProtocolException {
  560.         if(this.esitiCodeSenzaFiltri == null){
  561.             this.initEsitiCodeSenzaFiltri();
  562.         }

  563.         return this.esitiCodeSenzaFiltri;
  564.     }
  565.     private synchronized void initEsitiCodeSenzaFiltri() throws ProtocolException {
  566.         if(this.esitiCode == null){
  567.             this.esitiCodeSenzaFiltri = getListaInteger("esiti.codes");
  568.         }
  569.     }
  570.    
  571.     private List<Integer> esitiCode = null;
  572.     public List<Integer> getEsitiCode() throws ProtocolException {
  573.         if(this.esitiCode == null){
  574.             this.initEsitiCode();
  575.         }

  576.         return this.esitiCode;
  577.     }
  578.     private synchronized void initEsitiCode() throws ProtocolException {
  579.         if(this.esitiCode == null){
  580.             this.esitiCode = filterByProtocol(getListaInteger("esiti.codes"));
  581.         }
  582.     }
  583.    
  584.     private List<Integer> esitiCodeOk = null;
  585.     public List<Integer> getEsitiCodeOk() throws ProtocolException {
  586.         if(this.esitiCodeOk == null){
  587.             this.initEsitiCodeOk();
  588.         }

  589.         return this.esitiCodeOk;
  590.     }
  591.     private synchronized void initEsitiCodeOk() throws ProtocolException {
  592.         if(this.esitiCodeOk == null){
  593.             this.esitiCodeOk = filterByProtocol(getListaInteger("esiti.codes.ok"));        
  594.         }
  595.     }
  596.    
  597.     private List<Integer> esitiCodeOk_senzaFaultApplicativo = null;
  598.     public List<Integer> getEsitiCodeOk_senzaFaultApplicativo() throws ProtocolException {
  599.         if(this.esitiCodeOk_senzaFaultApplicativo == null){
  600.                 this.initEsitiCodeOk_senzaFaultApplicativo();  
  601.         }

  602.         return this.esitiCodeOk_senzaFaultApplicativo;
  603.     }
  604.     private synchronized void initEsitiCodeOk_senzaFaultApplicativo() throws ProtocolException {
  605.         if(this.esitiCodeOk_senzaFaultApplicativo == null){
  606.             List<Integer> tmp = this.getEsitiCodeOk();
  607.             int codeFaultApplicativo = this.convertNameToCode(EsitoTransazioneName.ERRORE_APPLICATIVO.name());
  608.             List<Integer> esitiOk = new ArrayList<Integer>();
  609.             for (Integer e : tmp) {
  610.                 if(e!=codeFaultApplicativo){
  611.                     esitiOk.add(e);
  612.                 }
  613.             }
  614.             this.esitiCodeOk_senzaFaultApplicativo = filterByProtocol(esitiOk);        
  615.         }
  616.     }
  617.    
  618.     private List<Integer> esitiCodeKo = null;
  619.     public List<Integer> getEsitiCodeKo() throws ProtocolException {
  620.         if(this.esitiCodeKo == null){
  621.             this.initEsitiCodeKo();
  622.         }

  623.         return this.esitiCodeKo;
  624.     }
  625.     private synchronized void initEsitiCodeKo() throws ProtocolException {
  626.         if(this.esitiCodeKo == null){
  627.             List<Integer> esitiCodeKo = new ArrayList<Integer>();
  628.             List<Integer> esiti = this.getEsitiCodeOrderLabel();
  629.             for (Integer esito : esiti) {
  630.                 boolean found = false;
  631.                 List<Integer> oks = this.getEsitiCodeOk();
  632.                 for (Integer ok : oks) {
  633.                     if(ok.intValue() == esito.intValue()){
  634.                         found = true;
  635.                         break;
  636.                     }
  637.                 }
  638.                 if(!found){
  639.                     esitiCodeKo.add(esito);
  640.                 }
  641.             }
  642.             this.esitiCodeKo = filterByProtocol(esitiCodeKo);
  643.         }
  644.     }
  645.    
  646.     private List<Integer> esitiCodeKo_senzaFaultApplicativo = null;
  647.     public List<Integer> getEsitiCodeKo_senzaFaultApplicativo() throws ProtocolException { // serve ad essere sicuri che anche se si è registrato un faultApplicativo tra gli errori, cmq non viene ritornato
  648.         if(this.esitiCodeKo_senzaFaultApplicativo == null){
  649.             this.initEsitiCodeKo_senzaFaultApplicativo();  
  650.         }

  651.         return this.esitiCodeKo_senzaFaultApplicativo;
  652.     }
  653.     private synchronized void initEsitiCodeKo_senzaFaultApplicativo() throws ProtocolException {
  654.         if(this.esitiCodeKo_senzaFaultApplicativo == null){
  655.             List<Integer> tmp = this.getEsitiCodeKo();
  656.             int codeFaultApplicativo = this.convertNameToCode(EsitoTransazioneName.ERRORE_APPLICATIVO.name());
  657.             List<Integer> esitiKo = new ArrayList<Integer>();
  658.             for (Integer e : tmp) {
  659.                 if(e!=codeFaultApplicativo){
  660.                     esitiKo.add(e);
  661.                 }
  662.             }
  663.             this.esitiCodeKo_senzaFaultApplicativo = filterByProtocol(esitiKo);        
  664.         }
  665.     }
  666.    
  667.     private List<Integer> esitiCodeFaultApplicativo = null;
  668.     public List<Integer> getEsitiCodeFaultApplicativo() throws ProtocolException {
  669.         if(this.esitiCodeFaultApplicativo == null){
  670.             this.initEsitiCodeFaultApplicativo();
  671.         }

  672.         return this.esitiCodeFaultApplicativo;
  673.     }
  674.     private synchronized void initEsitiCodeFaultApplicativo() throws ProtocolException {
  675.         if(this.esitiCodeFaultApplicativo == null){
  676.             int codeFaultApplicativo = this.convertNameToCode(EsitoTransazioneName.ERRORE_APPLICATIVO.name());
  677.             List<Integer> esitiCodeFaultApplicativo = new ArrayList<Integer>();
  678.             esitiCodeFaultApplicativo.add(codeFaultApplicativo);
  679.             this.esitiCodeFaultApplicativo = esitiCodeFaultApplicativo;
  680.         }
  681.     }
  682.    
  683.     private List<Integer> esitiCodeRichiestaScartate = null;
  684.     public List<Integer> getEsitiCodeRichiestaScartate() throws ProtocolException {
  685.         if(this.esitiCodeRichiestaScartate == null){
  686.             this.initEsitiCodeRichiestaScartate();
  687.         }

  688.         return this.esitiCodeRichiestaScartate;
  689.     }
  690.     private synchronized void initEsitiCodeRichiestaScartate() throws ProtocolException {
  691.         if(this.esitiCodeRichiestaScartate == null){
  692.             this.esitiCodeRichiestaScartate = filterByProtocol(getListaInteger("esiti.codes.richiestaScartate"));      
  693.         }
  694.     }
  695.    
  696.     private List<Integer> esitiCodeErroriConsegna = null;
  697.     public List<Integer> getEsitiCodeErroriConsegna() throws ProtocolException {
  698.         if(this.esitiCodeErroriConsegna == null){
  699.             this.initEsitiCodeErroriConsegna();
  700.         }

  701.         return this.esitiCodeErroriConsegna;
  702.     }
  703.     private synchronized void initEsitiCodeErroriConsegna() throws ProtocolException {
  704.         if(this.esitiCodeErroriConsegna == null){
  705.             this.esitiCodeErroriConsegna = filterByProtocol(getListaInteger("esiti.codes.erroriConsegna"));        
  706.         }
  707.     }
  708.    
  709.     private List<Integer> esitiCodeAutorizzazioneNegata = null;
  710.     public List<Integer> getEsitiCodeAutorizzazioneNegata() throws ProtocolException {
  711.         if(this.esitiCodeAutorizzazioneNegata == null){
  712.             this.initEsitiCodeAutorizzazioneNegata();
  713.         }

  714.         return this.esitiCodeAutorizzazioneNegata;
  715.     }
  716.     private synchronized void initEsitiCodeAutorizzazioneNegata() throws ProtocolException {
  717.         if(this.esitiCodeAutorizzazioneNegata == null){
  718.             this.esitiCodeAutorizzazioneNegata = filterByProtocol(getListaInteger("esiti.codes.autorizzazioneNegata"));        
  719.         }
  720.     }
  721.    
  722.     private List<Integer> esitiCodeControlloTrafficoPolicyViolate = null;
  723.     public List<Integer> getEsitiCodeControlloTrafficoPolicyViolate() throws ProtocolException {
  724.         if(this.esitiCodeControlloTrafficoPolicyViolate == null){
  725.             this.initEsitiCodeControlloTrafficoPolicyViolate();
  726.         }

  727.         return this.esitiCodeControlloTrafficoPolicyViolate;
  728.     }
  729.     private synchronized void initEsitiCodeControlloTrafficoPolicyViolate() throws ProtocolException {
  730.         if(this.esitiCodeControlloTrafficoPolicyViolate == null){
  731.             this.esitiCodeControlloTrafficoPolicyViolate = filterByProtocol(getListaInteger("esiti.codes.controlloTrafficoPolicyViolate"));        
  732.         }
  733.     }
  734.    
  735.     private List<Integer> esitiCodeServizioIntegrationManager = null;
  736.     public List<Integer> getEsitiCodeServizioIntegrationManager() throws ProtocolException {
  737.         if(this.esitiCodeServizioIntegrationManager == null){
  738.             this.initEsitiCodeServizioIntegrationManager();
  739.         }

  740.         return this.esitiCodeServizioIntegrationManager;
  741.     }
  742.     private synchronized void initEsitiCodeServizioIntegrationManager() throws ProtocolException {
  743.         if(this.esitiCodeServizioIntegrationManager == null){
  744.             this.esitiCodeServizioIntegrationManager = filterByProtocol(getListaInteger("esiti.codes.servizioIntegrationManager"));        
  745.         }
  746.     }
  747.    
  748.     private List<Integer> esitiCodeErroriProcessamentoRichiesta = null;
  749.     public List<Integer> getEsitiCodeErroriProcessamentoRichiesta() throws ProtocolException {
  750.         if(this.esitiCodeErroriProcessamentoRichiesta == null){
  751.             this.initEsitiCodeErroriProcessamentoRichiesta();
  752.         }

  753.         return this.esitiCodeErroriProcessamentoRichiesta;
  754.     }
  755.     private synchronized void initEsitiCodeErroriProcessamentoRichiesta() throws ProtocolException {
  756.         if(this.esitiCodeErroriProcessamentoRichiesta == null){
  757.             this.esitiCodeErroriProcessamentoRichiesta = filterByProtocol(getListaInteger("esiti.codes.erroriProcessamentoRichiesta"));        
  758.         }
  759.     }
  760.    
  761.     private List<Integer> esitiCodeErroriProcessamentoRisposta = null;
  762.     public List<Integer> getEsitiCodeErroriProcessamentoRisposta() throws ProtocolException {
  763.         if(this.esitiCodeErroriProcessamentoRisposta == null){
  764.             this.initEsitiCodeErroriProcessamentoRisposta();
  765.         }

  766.         return this.esitiCodeErroriProcessamentoRisposta;
  767.     }
  768.     private synchronized void initEsitiCodeErroriProcessamentoRisposta() throws ProtocolException {
  769.         if(this.esitiCodeErroriProcessamentoRisposta == null){
  770.             this.esitiCodeErroriProcessamentoRisposta = filterByProtocol(getListaInteger("esiti.codes.erroriProcessamentoRisposta"));      
  771.         }
  772.     }
  773.    
  774.     private List<Integer> esitiCodeErroriClientNonDisponibile = null;
  775.     public List<Integer> getEsitiCodeErroriClientNonDisponibile() throws ProtocolException {
  776.         if(this.esitiCodeErroriClientNonDisponibile == null){
  777.             this.initEsitiCodeErroriClientNonDisponibile();
  778.         }

  779.         return this.esitiCodeErroriClientNonDisponibile;
  780.     }
  781.     private synchronized void initEsitiCodeErroriClientNonDisponibile() throws ProtocolException {
  782.         if(this.esitiCodeErroriClientNonDisponibile == null){
  783.             this.esitiCodeErroriClientNonDisponibile = filterByProtocol(getListaInteger("esiti.codes.erroriClientIndisponibile"));    
  784.         }
  785.     }
  786.    
  787.     private List<Integer> esitiCodeErroriGenerici = null;
  788.     public List<Integer> getEsitiCodeErroriGenerici() throws ProtocolException {
  789.         if(this.esitiCodeErroriGenerici == null){
  790.             this.initEsitiCodeErroriGenerici();
  791.         }

  792.         return this.esitiCodeErroriGenerici;
  793.     }
  794.     private synchronized void initEsitiCodeErroriGenerici() throws ProtocolException {
  795.         if(this.esitiCodeErroriGenerici == null){
  796.             this.esitiCodeErroriGenerici = filterByProtocol(getListaInteger("esiti.codes.erroriGenerici"));        
  797.         }
  798.     }
  799.    
  800.    
  801.     private List<Integer> esitiCodeForSoapFaultIdentificationMode = null;
  802.     public List<Integer> getEsitiCodeForSoapFaultIdentificationMode() throws ProtocolException {
  803.         if(this.esitiCodeForSoapFaultIdentificationMode == null){
  804.             this.initEsitiCodeForSoapFaultIdentificationMode();
  805.         }

  806.         return this.esitiCodeForSoapFaultIdentificationMode;
  807.     }
  808.     private synchronized void initEsitiCodeForSoapFaultIdentificationMode() throws ProtocolException {
  809.         if(this.esitiCodeForSoapFaultIdentificationMode == null){
  810.             List<Integer> esitiCodeForSoapFaultIdentificationMode = new ArrayList<Integer>();
  811.             List<Integer> codes = getEsitiCode();  
  812.             for (Integer codeEsito : codes) {
  813.                 if(EsitoIdentificationMode.SOAP_FAULT.equals(this.getEsitoIdentificationMode(codeEsito))){
  814.                     esitiCodeForSoapFaultIdentificationMode.add(codeEsito);
  815.                 }
  816.             }
  817.             this.esitiCodeForSoapFaultIdentificationMode = filterByProtocol(esitiCodeForSoapFaultIdentificationMode);
  818.         }
  819.     }
  820.    
  821.     private List<Integer> esitiCodeForContextPropertyIdentificationMode = null;
  822.     public List<Integer> getEsitiCodeForContextPropertyIdentificationMode() throws ProtocolException {
  823.         if(this.esitiCodeForContextPropertyIdentificationMode == null){
  824.             this.initEsitiCodeForContextPropertyIdentificationMode();
  825.         }

  826.         return this.esitiCodeForContextPropertyIdentificationMode;
  827.     }
  828.     private synchronized void initEsitiCodeForContextPropertyIdentificationMode() throws ProtocolException {
  829.         if(this.esitiCodeForContextPropertyIdentificationMode == null){
  830.             List<Integer> esitiCodeForContextPropertyIdentificationMode = new ArrayList<Integer>();
  831.             List<Integer> codes = getEsitiCode();  
  832.             for (Integer codeEsito : codes) {
  833.                 if(EsitoIdentificationMode.CONTEXT_PROPERTY.equals(this.getEsitoIdentificationMode(codeEsito))){
  834.                     esitiCodeForContextPropertyIdentificationMode.add(codeEsito);
  835.                 }
  836.             }
  837.             this.esitiCodeForContextPropertyIdentificationMode = filterByProtocol(esitiCodeForContextPropertyIdentificationMode);
  838.         }
  839.     }

  840.     private List<Integer> esitiCodeOrderLabel = null;
  841.     public List<Integer> getEsitiCodeOrderLabel() throws ProtocolException {
  842.         if(this.esitiCodeOrderLabel == null){
  843.             this.initEsitiCodeOrderLabel();
  844.         }

  845.         return this.esitiCodeOrderLabel;
  846.     }
  847.     private synchronized void initEsitiCodeOrderLabel() throws ProtocolException {
  848.         if(this.esitiCodeOrderLabel == null){
  849.             this.esitiCodeOrderLabel = filterByProtocol(getListaInteger("esiti.codes.labelOrder"));        
  850.         }
  851.     }
  852.    
  853.     private List<String> esitiOrderLabel = null;
  854.     public List<String> getEsitiOrderLabel() throws ProtocolException {
  855.         if(this.esitiOrderLabel == null){
  856.             this.initEsitiOrderLabel();
  857.         }

  858.         return this.esitiOrderLabel;
  859.     }
  860.     private synchronized void initEsitiOrderLabel() throws ProtocolException {
  861.         if(this.esitiOrderLabel == null){
  862.             List<Integer> codes = getEsitiCode();
  863.             List<String> esitiOrderLabel = new ArrayList<>();
  864.             for (Integer codeEsito : codes) {
  865.                 esitiOrderLabel.add(this.getEsitoLabel(codeEsito));
  866.             }
  867.             this.esitiOrderLabel = esitiOrderLabel;
  868.         }
  869.     }
  870.    
  871.     private java.util.Map<String,String> esitoName= null;
  872.     public String getEsitoName(Integer codeEsito) throws ProtocolException {
  873.         if(this.esitoName == null){
  874.             this.initEsitoName();
  875.         }
  876.         if(this.esitoName.containsKey(codeEsito+"")==false){
  877.             throw new ProtocolException("EsitoName for code ["+codeEsito+"] not found");
  878.         }
  879.         return this.esitoName.get(codeEsito+"");
  880.     }
  881.     private synchronized void initEsitoName() throws ProtocolException {
  882.         if(this.esitoName == null){
  883.             java.util.Map<String,String> esitoName = new HashMap<>();
  884.             List<Integer> codes = getEsitiCodeSenzaFiltri();
  885.             for (Integer code : codes) {
  886.                 esitoName.put(code+"", getProperty("esito."+code+".name"));
  887.             }
  888.             this.esitoName = esitoName;
  889.         }
  890.     }
  891.    
  892.     private java.util.Map<String,String> esitoDescription= null;
  893.     public String getEsitoDescription(Integer codeEsito) throws ProtocolException {
  894.         if(this.esitoDescription == null){
  895.             this.initEsitoDescription();
  896.         }
  897.         if(this.esitoDescription.containsKey(codeEsito+"")==false){
  898.             throw new ProtocolException("EsitoDescription for code ["+codeEsito+"] not found");
  899.         }
  900.         return this.esitoDescription.get(codeEsito+"");
  901.     }
  902.     private synchronized void initEsitoDescription() throws ProtocolException {
  903.         if(this.esitoDescription == null){
  904.             java.util.Map<String, String> esitoDescription = new HashMap<>();
  905.             List<Integer> codes = getEsitiCode();
  906.             for (Integer code : codes) {
  907.                 esitoDescription.put(code+"", getProperty("esito."+code+".description"));
  908.             }
  909.             this.esitoDescription = esitoDescription;
  910.         }
  911.     }
  912.    
  913.     private java.util.Map<String,String> esitoLabel= null;
  914.     public String getEsitoLabel(Integer codeEsito) throws ProtocolException {
  915.         if(this.esitoLabel == null){
  916.             this.initEsitoLabel();
  917.         }
  918.         if(this.esitoLabel.containsKey(codeEsito+"")==false){
  919.             throw new ProtocolException("EsitoLabel for code ["+codeEsito+"] not found");
  920.         }
  921.         return this.esitoLabel.get(codeEsito+"");
  922.     }
  923.     private synchronized void initEsitoLabel() throws ProtocolException {
  924.         if(this.esitoLabel == null){
  925.             java.util.Map<String, String> esitoLabel = new HashMap<>();
  926.             List<Integer> codes = getEsitiCode();
  927.             for (Integer code : codes) {
  928.                 String label = getProperty("esito."+code+".label");
  929.                 label = filterByProtocol(label, code);
  930.                 esitoLabel.put(code+"", label);
  931.             }  
  932.             this.esitoLabel = esitoLabel;
  933.         }
  934.     }
  935.    
  936.     private java.util.Map<String,String> esitoLabelSyntetic= null;
  937.     public String getEsitoLabelSyntetic(Integer codeEsito) throws ProtocolException {
  938.         if(this.esitoLabelSyntetic == null){
  939.             this.initEsitoLabelSyntetic();
  940.         }
  941.         if(this.esitoLabelSyntetic.containsKey(codeEsito+"")==false){
  942.             throw new ProtocolException("EsitoLabelSyntetic for code ["+codeEsito+"] not found");
  943.         }
  944.         return this.esitoLabelSyntetic.get(codeEsito+"");
  945.     }
  946.     private synchronized void initEsitoLabelSyntetic() throws ProtocolException {
  947.         if(this.esitoLabelSyntetic == null){
  948.             java.util.Map<String, String> esitoLabelSyntetic = new HashMap<>();
  949.             List<Integer> codes = getEsitiCode();
  950.             for (Integer code : codes) {
  951.                 String label = getProperty("esito."+code+".label.syntetic");
  952.                 label = filterByProtocol(label, code);
  953.                 esitoLabelSyntetic.put(code+"", label);
  954.             }
  955.             this.esitoLabelSyntetic = esitoLabelSyntetic;
  956.         }
  957.     }
  958.    
  959.     private java.util.Map<String,EsitoIdentificationMode> esitoIdentificationMode= null;
  960.     public EsitoIdentificationMode getEsitoIdentificationMode(Integer codeEsito) throws ProtocolException {
  961.         if(this.esitoIdentificationMode == null){
  962.             this.initEsitoIdentificationMode();  
  963.         }
  964.         if(this.esitoIdentificationMode.containsKey(codeEsito+"")==false){
  965.             throw new ProtocolException("EsitoIdentificationMode for code ["+codeEsito+"] not found");
  966.         }
  967.         return this.esitoIdentificationMode.get(codeEsito+"");
  968.     }
  969.     private synchronized void initEsitoIdentificationMode() throws ProtocolException {
  970.         if(this.esitoIdentificationMode == null){
  971.             java.util.Map<String, EsitoIdentificationMode> esitoIdentificationMode = new HashMap<String, EsitoIdentificationMode>();
  972.             List<Integer> codes = getEsitiCode();
  973.             for (Integer code : codes) {
  974.                 String prop = "esito."+code+".mode";
  975.                 String tmp = getProperty(prop);
  976.                 try{
  977.                     EsitoIdentificationMode e = EsitoIdentificationMode.toEnumConstant(tmp);
  978.                     if(e==null){
  979.                         throw new Exception("proprieta con valore non supportato");
  980.                     }
  981.                     esitoIdentificationMode.put(code+"", e);
  982.                 }catch(java.lang.Exception e) {
  983.                     String msg = "Riscontrato errore durante la lettura della proprieta' '"+prop+"': "+e.getMessage();
  984.                     this.log.error(msg,e);
  985.                     throw new ProtocolException(msg,e);
  986.                 }    
  987.             }
  988.             this.esitoIdentificationMode = esitoIdentificationMode;
  989.         }
  990.     }
  991.    
  992.     private java.util.Map<String,List<EsitoIdentificationModeSoapFault>> esitoIdentificationModeSoapFaultList= null;
  993.     public List<EsitoIdentificationModeSoapFault> getEsitoIdentificationModeSoapFaultList(Integer codeEsito) throws ProtocolException {
  994.         if(this.esitoIdentificationModeSoapFaultList==null){
  995.             this.initEsitoIdentificationModeSoapFaultList();
  996.         }
  997.         return this.esitoIdentificationModeSoapFaultList.get(codeEsito+"");
  998.     }
  999.     private synchronized void initEsitoIdentificationModeSoapFaultList() throws ProtocolException {
  1000.         if(this.esitoIdentificationModeSoapFaultList==null){
  1001.             java.util.Map<String, List<EsitoIdentificationModeSoapFault>> esitoIdentificationModeSoapFaultList = new HashMap<String, List<EsitoIdentificationModeSoapFault>>();
  1002.             List<Integer> codes = getEsitiCode();
  1003.             for (Integer code : codes) {
  1004.                 try{
  1005.                     EsitoIdentificationMode mode = this.getEsitoIdentificationMode(code);
  1006.                     if(EsitoIdentificationMode.SOAP_FAULT.equals(mode)){
  1007.                         esitoIdentificationModeSoapFaultList.put(code+"", this._getEsitoIdentificationModeSoapFaultList(code));
  1008.                     }
  1009.                 }catch(Exception e){
  1010.                     throw new ProtocolException("Errore durante la gestione del codice ["+code+"]: "+e.getMessage(),e);
  1011.                 }
  1012.             }
  1013.             this.esitoIdentificationModeSoapFaultList= esitoIdentificationModeSoapFaultList;
  1014.         }
  1015.     }
  1016.     private List<EsitoIdentificationModeSoapFault> _getEsitoIdentificationModeSoapFaultList(Integer codeEsito) throws ProtocolException {
  1017.            
  1018.         List<EsitoIdentificationModeSoapFault>  l = null;
  1019.        
  1020.         String prefix = "esito."+codeEsito+".mode.soapFault.";
  1021.        
  1022.         int index = 0;
  1023.         while(index<1000){
  1024.            
  1025.             EsitoIdentificationModeSoapFault esito = new EsitoIdentificationModeSoapFault();
  1026.            
  1027.             esito.setFaultCode(this.getOptionalProperty(prefix+index+".code"));
  1028.             esito.setFaultNamespaceCode(this.getOptionalProperty(prefix+index+".namespaceCode"));
  1029.            
  1030.             esito.setFaultReason(this.getOptionalProperty(prefix+index+".reason"));
  1031.             BooleanNullable bn = this.getOptionalBooleanProperty(prefix+index+".reason.contains");
  1032.             if(bn!=null && bn.getValue()!=null) {
  1033.                 esito.setFaultReasonContains(bn.getValue());
  1034.             }
  1035.             else {
  1036.                 esito.setFaultReasonContains(null);
  1037.             }
  1038.            
  1039.             esito.setFaultActor(this.getOptionalProperty(prefix+index+".actor"));
  1040.             bn = this.getOptionalBooleanProperty(prefix+index+".actorNotDefined");
  1041.             if(bn!=null && bn.getValue()!=null) {
  1042.                 esito.setFaultActorNotDefined(bn.getValue());
  1043.             }
  1044.             else {
  1045.                 esito.setFaultActorNotDefined(null);
  1046.             }
  1047.            
  1048.             // check consistenza
  1049.             if(esito.getFaultReasonContains()!=null && esito.getFaultReason()==null){
  1050.                 throw new ProtocolException("Per il codice ["+codeEsito+"] esiste un mapping rispetto alla modalità soapFault in cui è stato definita la proprietà '*.reason.contains' senza la proprietà '*.reason'");
  1051.             }
  1052.             if(esito.getFaultActor()!=null && esito.getFaultActorNotDefined()!=null){
  1053.                 throw new ProtocolException("Per il codice ["+codeEsito+"] esiste un mapping rispetto alla modalità soapFault in cui sono state definite entrambe le modalità di indenficazione dell'actor");
  1054.             }
  1055.            
  1056.             if(esito.getFaultActor()==null && esito.getFaultActorNotDefined()==null &&
  1057.                     esito.getFaultCode()==null && esito.getFaultNamespaceCode()==null &&
  1058.                     esito.getFaultReason()==null){
  1059.                 if(index==0){
  1060.                     // almeno una opzione è obbligatoria in modalità soapFault
  1061.                     throw new ProtocolException("Per il codice ["+codeEsito+"] non esiste alcun mapping rispetto alla modalità soapFault");
  1062.                 }
  1063.                 break;
  1064.             }
  1065.        
  1066.             if(l==null){
  1067.                 l = new ArrayList<EsitoIdentificationModeSoapFault>();
  1068.             }
  1069.             l.add(esito);
  1070.            
  1071.             index++;
  1072.         }
  1073.            
  1074.         return l;
  1075.     }
  1076.    
  1077.    
  1078.    
  1079.    
  1080.     private java.util.Map<String,List<EsitoIdentificationModeContextProperty>> esitoIdentificationModeContextPropertyList= null;
  1081.     public List<EsitoIdentificationModeContextProperty> getEsitoIdentificationModeContextPropertyList(Integer codeEsito) throws ProtocolException {
  1082.         if(this.esitoIdentificationModeContextPropertyList==null){
  1083.             this.initEsitoIdentificationModeContextPropertyList();
  1084.         }
  1085.         return this.esitoIdentificationModeContextPropertyList.get(codeEsito+"");
  1086.     }
  1087.     private synchronized void initEsitoIdentificationModeContextPropertyList() throws ProtocolException {
  1088.         if(this.esitoIdentificationModeContextPropertyList==null){
  1089.             java.util.Map<String, List<EsitoIdentificationModeContextProperty>> esitoIdentificationModeContextPropertyList = new HashMap<String, List<EsitoIdentificationModeContextProperty>>();
  1090.             List<Integer> codes = getEsitiCode();
  1091.             for (Integer code : codes) {
  1092.                 try{
  1093.                     EsitoIdentificationMode mode = this.getEsitoIdentificationMode(code);
  1094.                     if(EsitoIdentificationMode.CONTEXT_PROPERTY.equals(mode)){
  1095.                         esitoIdentificationModeContextPropertyList.put(code+"", this._getEsitoIdentificationModeContextPropertyList(code));
  1096.                     }
  1097.                 }catch(Exception e){
  1098.                     throw new ProtocolException("Errore durante la gestione del codice ["+code+"]: "+e.getMessage(),e);
  1099.                 }
  1100.             }
  1101.             this.esitoIdentificationModeContextPropertyList=esitoIdentificationModeContextPropertyList;
  1102.         }
  1103.     }
  1104.     private List<EsitoIdentificationModeContextProperty> _getEsitoIdentificationModeContextPropertyList(Integer codeEsito) throws ProtocolException {
  1105.            
  1106.         List<EsitoIdentificationModeContextProperty>  l = null;
  1107.        
  1108.         String prefix = "esito."+codeEsito+".mode.contextProperty.";
  1109.        
  1110.         int index = 0;
  1111.         while(index<1000){
  1112.            
  1113.             EsitoIdentificationModeContextProperty esito = new EsitoIdentificationModeContextProperty();
  1114.            
  1115.             EsitoTransazioneName esitoTransazioneName = null;
  1116.             try {
  1117.                 esitoTransazioneName = getEsitoTransazioneName(codeEsito);
  1118.                 esito.setEsito(esitoTransazioneName);
  1119.             }catch(Throwable t) {
  1120.                 // ignore
  1121.             }
  1122.            
  1123.             esito.setName(this.getOptionalProperty(prefix+index+".name"));
  1124.             if(esito.getName()!=null) {
  1125.                 esito.setMapKey(Map.newMapKey(esito.getName()));
  1126.             }
  1127.            
  1128.             esito.setValue(this.getOptionalProperty(prefix+index+".value"));

  1129.             if(esito.getName()==null && esito.getValue()==null){
  1130.                 if(index==0){
  1131.                     // almeno una opzione è obbligatoria in modalità soapFault
  1132.                     throw new ProtocolException("Per il codice ["+codeEsito+"] non esiste alcun mapping rispetto alla modalità contextProperty");
  1133.                 }
  1134.                 break;
  1135.             }
  1136.            
  1137.             if(esito.getName()==null){
  1138.                 throw new ProtocolException("Per il codice ["+codeEsito+"] non esiste il mapping rispetto al nome, obbligtorio per la modalità contextProperty");
  1139.             }
  1140.            
  1141.             if(l==null){
  1142.                 l = new ArrayList<EsitoIdentificationModeContextProperty>();
  1143.             }
  1144.             l.add(esito);
  1145.            
  1146.             index++;
  1147.         }
  1148.            
  1149.         return l;
  1150.     }
  1151.    
  1152.    
  1153.    
  1154.     private List<String> esitiTransactionContextCode = null;
  1155.     private Boolean isSingleTransactionContextCode = null;
  1156.     public List<String> getEsitiTransactionContextCode() throws ProtocolException {
  1157.         if(this.esitiTransactionContextCode == null){
  1158.             this.initEsitiTransactionContextCode();
  1159.         }

  1160.         return this.esitiTransactionContextCode;
  1161.     }
  1162.     public boolean isSingleTransactionContextCode() throws ProtocolException {
  1163.         if(this.isSingleTransactionContextCode == null){
  1164.             this.initEsitiTransactionContextCode();
  1165.         }

  1166.         return this.isSingleTransactionContextCode;
  1167.     }
  1168.     private synchronized void initEsitiTransactionContextCode() throws ProtocolException {
  1169.         if(this.esitiTransactionContextCode == null){
  1170.             this.esitiTransactionContextCode = getLista("esiti.transactionContext");
  1171.             for (String context : this.esitiTransactionContextCode) {
  1172.                 if(context.length()>255){
  1173.                     throw new ProtocolException("Context id ["+context+"] length must be less then 255 characters");
  1174.                 }
  1175.             }
  1176.             this.isSingleTransactionContextCode = this.esitiTransactionContextCode.size()<=1;
  1177.         }
  1178.     }
  1179.    
  1180.     private List<String> esitiTransactionContextCodeOrderLabel = null;
  1181.     public List<String> getEsitiTransactionContextCodeOrderLabel() throws ProtocolException {
  1182.         if(this.esitiTransactionContextCodeOrderLabel == null){
  1183.             this.initEsitiTransactionContextCodeOrderLabel();
  1184.         }

  1185.         return this.esitiTransactionContextCodeOrderLabel;
  1186.     }
  1187.     private synchronized void initEsitiTransactionContextCodeOrderLabel() throws ProtocolException {
  1188.         if(this.esitiTransactionContextCodeOrderLabel == null){
  1189.             this.esitiTransactionContextCodeOrderLabel = getLista("esiti.transactionContext.labelOrder");      
  1190.         }
  1191.     }
  1192.    
  1193.     private List<String> esitiTransactionContextOrderLabel = null;
  1194.     public List<String> getEsitiTransactionContextOrderLabel() throws ProtocolException {
  1195.         if(this.esitiTransactionContextOrderLabel == null){
  1196.             this.initEsitiTransactionContextOrderLabel();
  1197.         }

  1198.         return this.esitiTransactionContextOrderLabel;
  1199.     }
  1200.     private synchronized void initEsitiTransactionContextOrderLabel() throws ProtocolException {
  1201.         if(this.esitiTransactionContextOrderLabel == null){
  1202.             List<String> codes = getEsitiTransactionContextCode();
  1203.             List<String> esitiTransactionContextOrderLabel = new ArrayList<>();
  1204.             for (String codeTransactionContext : codes) {
  1205.                 esitiTransactionContextOrderLabel.add(this.getEsitoTransactionContextLabel(codeTransactionContext));
  1206.             }
  1207.             this.esitiTransactionContextOrderLabel = esitiTransactionContextOrderLabel;
  1208.         }
  1209.     }

  1210.     private java.util.Map<String,String> esitoTransactionContextLabel= null;
  1211.     public String getEsitoTransactionContextLabel(String tipo) throws ProtocolException {
  1212.         if(this.esitoTransactionContextLabel == null){
  1213.             this.initEsitoTransactionContextLabel();
  1214.         }
  1215.         if(this.esitoTransactionContextLabel.containsKey(tipo)==false){
  1216.             throw new ProtocolException("EsitoTransactionContextLabel for code ["+tipo+"] not found");
  1217.         }
  1218.         return this.esitoTransactionContextLabel.get(tipo);
  1219.     }
  1220.     private synchronized void initEsitoTransactionContextLabel() throws ProtocolException {
  1221.         if(this.esitoTransactionContextLabel == null){
  1222.             java.util.Map<String, String> esitoTransactionContextLabel = new HashMap<>();
  1223.             List<String> codes = getEsitiTransactionContextCode();
  1224.             for (String code : codes) {
  1225.                 esitoTransactionContextLabel.put(code, getProperty("esiti.transactionContext."+code+".label"));
  1226.             }
  1227.             this.esitoTransactionContextLabel = esitoTransactionContextLabel;
  1228.         }
  1229.     }
  1230.    
  1231.     private String esitoTransactionContextDefault= null;
  1232.     private Boolean esitoTransactionContextDefault_read= null;
  1233.     public String getEsitoTransactionContextDefault() throws ProtocolException {
  1234.         if(this.esitoTransactionContextDefault_read == null){
  1235.             this.initEsitoTransactionContextDefault();
  1236.         }
  1237.         return this.esitoTransactionContextDefault;
  1238.     }
  1239.     private synchronized void initEsitoTransactionContextDefault() throws ProtocolException {
  1240.         if(this.esitoTransactionContextDefault_read == null){
  1241.             this.esitoTransactionContextDefault = getOptionalProperty("esiti.transactionContext.default");
  1242.             this.esitoTransactionContextDefault_read = true;
  1243.             if(this.esitoTransactionContextDefault!=null){
  1244.                 if(this.getEsitiTransactionContextCode().contains(this.esitoTransactionContextDefault)==false){
  1245.                     throw new ProtocolException("Indicato nella proprietà 'esiti.transactionContext.default' un codice di contesto non registrato");
  1246.                 }
  1247.             }
  1248.         }
  1249.     }
  1250.    
  1251.     private String esitoTransactionContextHeaderTrasportoName= null;
  1252.     public String getEsitoTransactionContextHeaderTrasportoName() throws ProtocolException {
  1253.         if(this.esitoTransactionContextHeaderTrasportoName == null){
  1254.             this.initEsitoTransactionContextHeaderTrasportoName();
  1255.         }
  1256.         return this.esitoTransactionContextHeaderTrasportoName;
  1257.     }
  1258.     private synchronized void initEsitoTransactionContextHeaderTrasportoName() throws ProtocolException {
  1259.         if(this.esitoTransactionContextHeaderTrasportoName == null){
  1260.             this.esitoTransactionContextHeaderTrasportoName = getProperty("esiti.transactionContext.trasporto.headerName");    
  1261.         }
  1262.     }
  1263.    
  1264.     private String esitoTransactionContextFormBasedPropertyName= null;
  1265.     public String getEsitoTransactionContextFormBasedPropertyName() throws ProtocolException {
  1266.         if(this.esitoTransactionContextFormBasedPropertyName == null){
  1267.             this.initEsitoTransactionContextFormBasedPropertyName();
  1268.         }
  1269.         return this.esitoTransactionContextFormBasedPropertyName;
  1270.     }
  1271.     private synchronized void initEsitoTransactionContextFormBasedPropertyName() throws ProtocolException {
  1272.         if(this.esitoTransactionContextFormBasedPropertyName == null){
  1273.             this.esitoTransactionContextFormBasedPropertyName = getProperty("esiti.transactionContext.urlFormBased.propertyName");    
  1274.         }
  1275.     }
  1276.    
  1277.     private List<EsitoTransportContextIdentification> esitoTransactionContextHeaderTrasportoDynamicIdentification = null;
  1278.     public  List<EsitoTransportContextIdentification> getEsitoTransactionContextHeaderTrasportoDynamicIdentification() throws ProtocolException {
  1279.         if(this.esitoTransactionContextHeaderTrasportoDynamicIdentification == null){
  1280.             this.initEsitoTransactionContextHeaderTrasportoDynamicIdentification();
  1281.         }
  1282.         return this.esitoTransactionContextHeaderTrasportoDynamicIdentification;
  1283.     }
  1284.     private synchronized void initEsitoTransactionContextHeaderTrasportoDynamicIdentification() throws ProtocolException {
  1285.         if(this.esitoTransactionContextHeaderTrasportoDynamicIdentification == null){
  1286.             this.esitoTransactionContextHeaderTrasportoDynamicIdentification = this.readEsitoTransportContextIdentification("esiti.transactionContext.trasporto.dynamic.");        
  1287.         }
  1288.     }
  1289.    
  1290.     private List<EsitoTransportContextIdentification> esitoTransactionContextHeaderFormBasedDynamicIdentification = null;
  1291.     public  List<EsitoTransportContextIdentification> getEsitoTransactionContextHeaderFormBasedDynamicIdentification() throws ProtocolException {
  1292.         if(this.esitoTransactionContextHeaderFormBasedDynamicIdentification == null){
  1293.             this.initEsitoTransactionContextHeaderFormBasedDynamicIdentification();
  1294.         }
  1295.         return this.esitoTransactionContextHeaderFormBasedDynamicIdentification;
  1296.     }
  1297.     private synchronized void initEsitoTransactionContextHeaderFormBasedDynamicIdentification() throws ProtocolException {
  1298.         if(this.esitoTransactionContextHeaderFormBasedDynamicIdentification == null){
  1299.             this.esitoTransactionContextHeaderFormBasedDynamicIdentification = this.readEsitoTransportContextIdentification("esiti.transactionContext.urlFormBased.dynamic.");          
  1300.         }
  1301.     }
  1302.    
  1303.     private List<EsitoTransportContextIdentification> readEsitoTransportContextIdentification(String pName) throws ProtocolException{
  1304.         try{
  1305.             List<EsitoTransportContextIdentification> l = new ArrayList<EsitoTransportContextIdentification>();
  1306.             Properties p = this.reader.readPropertiesConvertEnvProperties(pName);
  1307.             if(p.size()>0){
  1308.                 List<String> keys = new ArrayList<>();
  1309.                 Enumeration<?> enKeys = p.keys();
  1310.                 while (enKeys.hasMoreElements()) {
  1311.                     String key = (String) enKeys.nextElement();
  1312.                     if(key.endsWith(".headerName")){
  1313.                         keys.add(key.substring(0, (key.length()-".headerName".length())));
  1314.                     }
  1315.                 }
  1316.                 for (String key : keys) {
  1317.                     EsitoTransportContextIdentification etci = new EsitoTransportContextIdentification();
  1318.                     etci.setName(p.getProperty(key+".headerName"));
  1319.                     etci.setValue(p.getProperty(key+".value"));
  1320.                     String mode = p.getProperty(key+".mode");
  1321.                     etci.setMode(EsitoTransportContextIdentificationMode.toEnumConstant(mode));
  1322.                     if(etci.getMode()==null){
  1323.                         throw new ProtocolException("Modalità indicata ["+mode+"] per chiave ["+key+"] sconosciuta");
  1324.                     }
  1325.                     etci.setRegularExpr(p.getProperty(key+".regularExpr"));
  1326.                     if(EsitoTransportContextIdentificationMode.MATCH.equals(etci.getMode())){
  1327.                         if(etci.getRegularExpr()==null){
  1328.                             throw new ProtocolException("Modalità indicata ["+mode+"] per la chiave ["+key+"] richiede obbligatoriamente la definizione di una espressione regolare");
  1329.                         }
  1330.                     }
  1331.                     else if(EsitoTransportContextIdentificationMode.EQUALS.equals(etci.getMode()) || EsitoTransportContextIdentificationMode.CONTAINS.equals(etci.getMode())){
  1332.                         if(etci.getValue()==null){
  1333.                             throw new ProtocolException("Modalità indicata ["+mode+"] per la chiave ["+key+"] richiede obbligatoriamente la definizione di un valore su cui basare il confronto");
  1334.                         }
  1335.                     }
  1336.                     etci.setType(p.getProperty(key+".type"));
  1337.                     if(getEsitiTransactionContextCode().contains(etci.getType())==false){
  1338.                         throw new ProtocolException("Tipo di contesto indicato ["+etci.getType()+"] per la chiave ["+key+"] non risulta tra le tipologie di contesto supportate: "+getEsitiTransactionContextCode());
  1339.                     }
  1340.                     l.add(etci);
  1341.                 }
  1342.             }
  1343.             return l;
  1344.         }catch(Exception e){
  1345.             throw new ProtocolException(e.getMessage(),e);
  1346.         }
  1347.     }

  1348.    
  1349.    
  1350.     /* ******* UTILITIES ********* */
  1351.    
  1352.     public String getProperty(String property) throws ProtocolException {
  1353.         try{
  1354.             String name = null;
  1355.             name = this.reader.getValueConvertEnvProperties(property);
  1356.             if(name==null)
  1357.                 throw new Exception("proprieta non definita");
  1358.             return name.trim();
  1359.         }catch(java.lang.Exception e) {
  1360.             String msg = "Riscontrato errore durante la lettura della proprieta' '"+property+"': "+e.getMessage();
  1361.             this.log.error(msg,e);
  1362.             throw new ProtocolException(msg,e);
  1363.         }      
  1364.     }
  1365.    
  1366.     public String getOptionalProperty(String property) throws ProtocolException {
  1367.         try{
  1368.             String name = null;
  1369.             name = this.reader.getValueConvertEnvProperties(property);
  1370.             if(name==null)
  1371.                 return null;
  1372.             return name.trim();
  1373.         }catch(java.lang.Exception e) {
  1374.             String msg = "Riscontrato errore durante la lettura della proprieta' '"+property+"': "+e.getMessage();
  1375.             this.log.error(msg,e);
  1376.             throw new ProtocolException(msg,e);
  1377.         }      
  1378.     }
  1379.    
  1380.     public BooleanNullable getOptionalBooleanProperty(String property) throws ProtocolException {
  1381.         String p = this.getOptionalProperty(property);
  1382.         if(p!=null){
  1383.             try{
  1384.                 return Boolean.parseBoolean(p) ? BooleanNullable.TRUE() : BooleanNullable.FALSE();
  1385.             }catch(java.lang.Exception e) {
  1386.                 String msg = "Riscontrato errore durante la lettura della proprieta' '"+property+"': "+e.getMessage();
  1387.                 this.log.error(msg,e);
  1388.                 throw new ProtocolException(msg,e);
  1389.             }  
  1390.         }
  1391.         return BooleanNullable.NULL();
  1392.     }
  1393.    
  1394.     private List<String> getLista(String property) throws ProtocolException {
  1395.         List<String> lista = null;
  1396.         String name = null;
  1397.         try{
  1398.             name = this.reader.getValueConvertEnvProperties(property);
  1399.             if(name==null)
  1400.                 throw new Exception("proprieta non definita");
  1401.             else
  1402.                 name = name.trim();
  1403.             lista  = new ArrayList<>();
  1404.             String [] split = name.split(",");
  1405.             if(split==null || split.length<=0){
  1406.                 throw new Exception("proprieta non definita (dopo split?)");
  1407.             }
  1408.             for (int i = 0; i < split.length; i++) {
  1409.                 String p = split[i];
  1410.                 if(p==null){
  1411.                     throw new Exception("valore alla posizione "+(i+1)+" della proprieta non definita");
  1412.                 }
  1413.                 p = p .trim();
  1414.                 if(p.equals("")){
  1415.                     throw new Exception("valore alla posizione "+(i+1)+" della proprieta è vuoto");
  1416.                 }
  1417.                 if(lista.contains(p)){
  1418.                     throw new Exception("valore '"+p+"' alla posizione "+(i+1)+" della proprieta è definito più di una volta");
  1419.                 }
  1420.                 lista.add(p);
  1421.             }
  1422.         }catch(java.lang.Exception e) {
  1423.             String listaDebug = "";
  1424.             if(StringUtils.isNotEmpty(name)) {
  1425.                 listaDebug = " (lista: "+name+")";
  1426.             }
  1427.             String msg = "Riscontrato errore durante la lettura della proprieta' '"+property+"'"+listaDebug+": "+e.getMessage();
  1428.             this.log.error(msg,e);
  1429.             throw new ProtocolException(msg,e);
  1430.         }      
  1431.        
  1432.         return lista;
  1433.     }
  1434.    
  1435.     private List<Integer> getListaInteger(String property) throws ProtocolException {
  1436.         List<String> lista = this.getLista(property);
  1437.         List<Integer> listaInteger = null;
  1438.         if(lista!=null && lista.size()>0){
  1439.             listaInteger = new ArrayList<Integer>();
  1440.             for (String s : lista) {
  1441.                 try{
  1442.                     listaInteger.add(Integer.parseInt(s));
  1443.                 }catch(Exception e){
  1444.                     throw new ProtocolException("Property ["+property+"] with wrong value (not integer) ["+s+"]");
  1445.                 }  
  1446.             }
  1447.         }
  1448.         return listaInteger;
  1449.     }
  1450. }